001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Nuxeo - initial API and implementation
011 *
012 * $Id: PermissionProvider.java 28325 2007-12-24 08:29:26Z sfermigier $
013 */
014
015package org.nuxeo.ecm.core.api.security;
016
017import java.util.List;
018
019
020/**
021 * Provider for existing permission and permission groups.
022 *
023 * @author Bogdan Stefanescu
024 * @author Olivier Grisel
025 */
026public interface PermissionProvider {
027
028    /**
029     * @return an array of a all registered permission names
030     */
031    String[] getPermissions();
032
033    /**
034     * @param perm the name of a registered permissions that belongs to permission groups (aka compound permissions)
035     * @return an array of a all compound permissions 'perm' is a sub-permission of, directly or not ; returns null if
036     *         'perm' is not registered or if 'perm' does not belong to any compound permission
037     */
038    String[] getPermissionGroups(String perm);
039
040    /**
041     * @return get the sorted list of UserVisiblePermission objects to be used in the permission management screen of
042     *         the UI (be it web based, a rich client or any-thing else)
043     */
044    List<UserVisiblePermission> getUserVisiblePermissionDescriptors();
045
046    /**
047     * @param typeName the name of a Core type of the document whose ACP is to be edited by the user
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) ; if no specific permissions are registered for
050     *         typeName, the default list is returned
051     */
052    List<UserVisiblePermission> getUserVisiblePermissionDescriptors(String typeName);
053
054    /**
055     * @param perm the name of a registered compound permission
056     * @return the list of permission names of sub-permissions of 'perm'
057     */
058    String[] getSubPermissions(String perm);
059
060    /**
061     * @param perm the name of a registered permission
062     * @return the list of alias permissions to 'perm'
063     */
064    String[] getAliasPermissions(String perm);
065
066}