org.apache.jackrabbit.core.security.authorization
Class PrivilegeRegistry

java.lang.Object
  extended by org.apache.jackrabbit.core.security.authorization.PrivilegeRegistry

public final class PrivilegeRegistry
extends Object

The PrivilegeRegistry defines the set of Privileges known to the repository.


Field Summary
static int NO_PRIVILEGE
           
static String REP_WRITE
          Jackrabbit specific write privilege that combines Privilege.JCR_WRITE and Privilege.JCR_NODE_TYPE_MANAGEMENT.
 
Constructor Summary
PrivilegeRegistry(NameResolver resolver)
          Create a new PrivilegeRegistry instance.
 
Method Summary
static int calculatePermissions(int privs, int parentPrivs, boolean isAllow, boolean protectsPolicy)
          Build the permissions granted by evaluating the given privileges.
static int getBits(Privilege[] privileges)
           
 Privilege getPrivilege(String privilegeName)
          Returns the privilege with the specified privilegeName.
 Privilege[] getPrivileges(int bits)
          Returns an array of registered Privileges.
 Privilege[] getRegisteredPrivileges()
          Returns all registered privileges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REP_WRITE

public static final String REP_WRITE
Jackrabbit specific write privilege that combines Privilege.JCR_WRITE and Privilege.JCR_NODE_TYPE_MANAGEMENT.

See Also:
Constant Field Values

NO_PRIVILEGE

public static final int NO_PRIVILEGE
See Also:
Constant Field Values
Constructor Detail

PrivilegeRegistry

public PrivilegeRegistry(NameResolver resolver)
Create a new PrivilegeRegistry instance.

Parameters:
resolver - NameResolver used to calculate the JCR name of the privileges.
Method Detail

getRegisteredPrivileges

public Privilege[] getRegisteredPrivileges()
Returns all registered privileges.

Returns:
all registered privileges.

getPrivilege

public Privilege getPrivilege(String privilegeName)
                       throws AccessControlException,
                              RepositoryException
Returns the privilege with the specified privilegeName.

Parameters:
privilegeName - Name of the principal.
Returns:
the privilege with the specified privilegeName.
Throws:
AccessControlException - If no privilege with the given name exists.
RepositoryException - If another error occurs.

getPrivileges

public Privilege[] getPrivileges(int bits)
Returns an array of registered Privileges. If the specified bits represent a registered privilege the returned array contains a single element. Otherwise the returned array contains the individual registered privileges that are combined in the givent bits. If bits is 0 or does not match to any registered privilege an empty array will be returned.

Parameters:
bits - Privilege bits as obtained from getBits(Privilege[]).
Returns:
Array of Privileges that are presented by the given it or an empty array if bits is lower than READ or cannot be resolved to registered Privileges.
See Also:
getBits(Privilege[])

getBits

public static int getBits(Privilege[] privileges)
                   throws AccessControlException
Parameters:
privileges - An array of privileges.
Returns:
The privilege bits.
Throws:
AccessControlException - If the specified array is null or if it contains an unregistered privilege.
See Also:
getPrivileges(int)

calculatePermissions

public static int calculatePermissions(int privs,
                                       int parentPrivs,
                                       boolean isAllow,
                                       boolean protectsPolicy)
Build the permissions granted by evaluating the given privileges.

Parameters:
privs - The privileges granted on the Node itself (for properties the ACL of the direct ancestor).
parentPrivs - The privileges granted on the parent of the Node. Not relevant for properties since it only is used to determine permissions on a Node (add_child_nodes, remove_child_nodes).
isAllow - true if the privileges are granted; false otherwise.
protectsPolicy - If true the affected item itself defines access control related information.
Returns:
the permissions granted evaluating the given privileges.


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.