001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id: PermissionProvider.java 28325 2007-12-24 08:29:26Z sfermigier $
020 */
021
022package org.nuxeo.ecm.core.api.security;
023
024import java.util.List;
025
026
027/**
028 * Provider for existing permission and permission groups.
029 *
030 * @author Bogdan Stefanescu
031 * @author Olivier Grisel
032 */
033public interface PermissionProvider {
034
035    /**
036     * @return an array of a all registered permission names
037     */
038    String[] getPermissions();
039
040    /**
041     * @param perm the name of a registered permissions that belongs to permission groups (aka compound permissions)
042     * @return an array of a all compound permissions 'perm' is a sub-permission of, directly or not ; returns null if
043     *         'perm' is not registered or if 'perm' does not belong to any compound permission
044     */
045    String[] getPermissionGroups(String perm);
046
047    /**
048     * @return get the sorted list of UserVisiblePermission objects to be used in the permission management screen of
049     *         the UI (be it web based, a rich client or any-thing else)
050     */
051    List<UserVisiblePermission> getUserVisiblePermissionDescriptors();
052
053    /**
054     * @param typeName the name of a Core type of the document whose ACP is to be edited by the user
055     * @return get the sorted list of UserVisiblePermission objects to be used in the permission management screen of
056     *         the UI (be it web based, a rich client or any-thing else) ; if no specific permissions are registered for
057     *         typeName, the default list is returned
058     */
059    List<UserVisiblePermission> getUserVisiblePermissionDescriptors(String typeName);
060
061    /**
062     * @param perm the name of a registered compound permission
063     * @return the list of permission names of sub-permissions of 'perm'
064     */
065    String[] getSubPermissions(String perm);
066
067    /**
068     * @param perm the name of a registered permission
069     * @return the list of alias permissions to 'perm'
070     */
071    String[] getAliasPermissions(String perm);
072
073}