Class PermissionProviderImpl
- java.lang.Object
-
- org.apache.jackrabbit.oak.security.authorization.permission.PermissionProviderImpl
-
- All Implemented Interfaces:
AccessControlConstants,AggregatedPermissionProvider,PermissionConstants,PermissionProvider
- Direct Known Subclasses:
MountPermissionProvider
public class PermissionProviderImpl extends Object implements PermissionProvider, AccessControlConstants, PermissionConstants, AggregatedPermissionProvider
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants
AC_NODETYPE_NAMES, ACE_PROPERTY_NAMES, MIX_REP_ACCESS_CONTROLLABLE, MIX_REP_REPO_ACCESS_CONTROLLABLE, NT_REP_ACE, NT_REP_ACL, NT_REP_DENY_ACE, NT_REP_GRANT_ACE, NT_REP_POLICY, NT_REP_RESTRICTIONS, PARAM_RESTRICTION_PROVIDER, POLICY_NODE_NAMES, REP_CURRENT, REP_GLOB, REP_GLOBS, REP_ITEM_NAMES, REP_NODE_PATH, REP_NT_NAMES, REP_POLICY, REP_PREFIXES, REP_PRINCIPAL_NAME, REP_PRIVILEGES, REP_REPO_POLICY, REP_RESTRICTIONS, REP_SUBTREES
-
Fields inherited from interface org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionConstants
DEFAULT_READ_PATHS, NT_REP_PERMISSION_STORE, NT_REP_PERMISSIONS, PARAM_ADMINISTRATIVE_PRINCIPALS, PARAM_PERMISSIONS_JR2, PARAM_READ_PATHS, PERMISSION_NODE_NAMES, PERMISSION_NODETYPE_NAMES, PERMISSION_PROPERTY_NAMES, PERMISSIONS_STORE_PATH, REP_ACCESS_CONTROLLED_PATH, REP_IS_ALLOW, REP_NUM_PERMISSIONS, REP_PERMISSION_STORE, REP_PRIVILEGE_BITS, VALUE_PERMISSIONS_JR2
-
-
Constructor Summary
Constructors Constructor Description PermissionProviderImpl(@NotNull Root root, @NotNull String workspaceName, @NotNull Set<Principal> principals, @NotNull RestrictionProvider restrictionProvider, @NotNull ConfigurationParameters options, @NotNull Context ctx, @NotNull ProviderCtx providerCtx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected @NotNull org.apache.jackrabbit.oak.security.authorization.permission.PermissionStoregetPermissionStore(@NotNull Root root, @NotNull String workspaceName, @NotNull RestrictionProvider restrictionProvider)@NotNull Set<String>getPrivileges(@Nullable Tree tree)Returns the set of privilege names which are granted to the set ofPrincipals associated with this provider instance for the specifiedTree.@NotNull RepositoryPermissiongetRepositoryPermission()Return theRepositoryPermissionfor the set ofPrincipals associated with this provider instance.@NotNull TreePermissiongetTreePermission(@NotNull Tree tree, @NotNull TreeType type, @NotNull TreePermission parentPermission)Return theTreePermissionfor the set ofPrincipals associated with this provider at the specifiedtreewith the giventype.@NotNull TreePermissiongetTreePermission(@NotNull Tree tree, @NotNull TreePermission parentPermission)Return theTreePermissionfor the set ofPrincipals associated with this provider at the specifiedtree.booleanhasPrivileges(@Nullable Tree tree, @NotNull String... privilegeNames)Returns whether the principal set associated with thisPrivilegeManageris granted the privileges identified by the specified privilege names for the giventree.booleanisGranted(@NotNull String oakPath, @NotNull String jcrActions)Tests if the the specified actions are granted at the given path for the set ofPrincipals associated with this provider instance.booleanisGranted(@NotNull Tree tree, @Nullable PropertyState property, long permissions)Test if the specified permissions are granted for the set ofPrincipals associated with this provider instance for the item identified by the given tree and optionally property.booleanisGranted(@NotNull TreeLocation location, long permissions)Test if the specified permissions are granted for the set ofPrincipals associated with this provider instance for the item identified by the givenlocationand optionally property.voidrefresh()Refresh thisPermissionProvider.longsupportedPermissions(@NotNull TreeLocation location, long permissions)Allows to determined the set or subset of permissions evaluated by the implementing permission provider for the specified location.longsupportedPermissions(@NotNull TreePermission treePermission, @Nullable PropertyState property, long permissions)Allows to determined the set or subset of permissions evaluated by the implementing permission provider for the specified tree permission (plus optionallyproperty).longsupportedPermissions(@Nullable Tree tree, @Nullable PropertyState property, long permissions)Allows to determined the set or subset of permissions evaluated by the implementing permission provider for the specified item (identified bytreeand optionallyproperty) or at the repository level in case the specifiedtreeisnull.@NotNull PrivilegeBitssupportedPrivileges(@Nullable Tree tree, @Nullable PrivilegeBits privilegeBits)Allows to determined the set or subset of privileges evaluated by the implementing permission provider for the specified tree or at the repository level in case the specifiedtreeisnull.
-
-
-
Constructor Detail
-
PermissionProviderImpl
public PermissionProviderImpl(@NotNull @NotNull Root root, @NotNull @NotNull String workspaceName, @NotNull @NotNull Set<Principal> principals, @NotNull @NotNull RestrictionProvider restrictionProvider, @NotNull @NotNull ConfigurationParameters options, @NotNull @NotNull Context ctx, @NotNull @NotNull ProviderCtx providerCtx)
-
-
Method Detail
-
refresh
public void refresh()
Description copied from interface:PermissionProviderRefresh thisPermissionProvider. The implementation is expected to subsequently return permission evaluation results that reflect the most recent revision of the repository.- Specified by:
refreshin interfacePermissionProvider
-
getPrivileges
@NotNull public @NotNull Set<String> getPrivileges(@Nullable @Nullable Tree tree)
Description copied from interface:PermissionProviderReturns the set of privilege names which are granted to the set ofPrincipals associated with this provider instance for the specifiedTree.- Specified by:
getPrivilegesin interfacePermissionProvider- Parameters:
tree- Thetreefor which the privileges should be retrieved.- Returns:
- set of privilege names
-
hasPrivileges
public boolean hasPrivileges(@Nullable @Nullable Tree tree, @NotNull @NotNull String... privilegeNames)Description copied from interface:PermissionProviderReturns whether the principal set associated with thisPrivilegeManageris granted the privileges identified by the specified privilege names for the giventree. In order to test for privileges being granted on a repository level rather than on a particular tree anulltree should be passed to this method.Testing a name identifying an aggregate privilege is equivalent to testing each non aggregate privilege name.
- Specified by:
hasPrivilegesin interfacePermissionProvider- Parameters:
tree- The tree to test for privileges being granted.privilegeNames- The name of the privileges.- Returns:
trueif all privileges are granted;falseotherwise.
-
getRepositoryPermission
@NotNull public @NotNull RepositoryPermission getRepositoryPermission()
Description copied from interface:PermissionProviderReturn theRepositoryPermissionfor the set ofPrincipals associated with this provider instance.- Specified by:
getRepositoryPermissionin interfacePermissionProvider- Returns:
- The
RepositoryPermissionfor the set ofPrincipals this provider instance has been created for.
-
getTreePermission
@NotNull public @NotNull TreePermission getTreePermission(@NotNull @NotNull Tree tree, @NotNull @NotNull TreePermission parentPermission)
Description copied from interface:PermissionProviderReturn theTreePermissionfor the set ofPrincipals associated with this provider at the specifiedtree.- Specified by:
getTreePermissionin interfacePermissionProvider- Parameters:
tree- The tree for which theTreePermissionobject should be built.parentPermission- TheTreePermissionobject that has been obtained before for the parent tree.- Returns:
- The
TreePermissionobject for the specifiedtree.
-
isGranted
public boolean isGranted(@NotNull @NotNull Tree tree, @Nullable @Nullable PropertyState property, long permissions)Description copied from interface:PermissionProviderTest if the specified permissions are granted for the set ofPrincipals associated with this provider instance for the item identified by the given tree and optionally property. This method will only returntrueif all permissions are granted.- Specified by:
isGrantedin interfacePermissionProvider- Parameters:
tree- TheTreeto test the permissions for.property- APropertyStateif the item to test is a property ornullif the item is aTree.permissions- The permissions to be tested.- Returns:
trueif the specified permissions are granted for the item identified by the given tree and optionally property state.
-
isGranted
public boolean isGranted(@NotNull @NotNull String oakPath, @NotNull @NotNull String jcrActions)Description copied from interface:PermissionProviderTests if the the specified actions are granted at the given path for the set ofPrincipals associated with this provider instance.The
jcrActionsparameter is a comma separated list of action strings such as defined bySessionand passed toSession.hasPermission(String, String). When more than one action is specified in thejcrActionsparameter, this method will only returntrueif all of them are granted on the specified path.- Specified by:
isGrantedin interfacePermissionProvider- Parameters:
oakPath- A valid oak path.jcrActions- The JCR actions that should be tested separated by ','- Returns:
trueif all actions are granted at the specified path;falseotherwise.
-
supportedPrivileges
@NotNull public @NotNull PrivilegeBits supportedPrivileges(@Nullable @Nullable Tree tree, @Nullable @Nullable PrivilegeBits privilegeBits)
Description copied from interface:AggregatedPermissionProviderAllows to determined the set or subset of privileges evaluated by the implementing permission provider for the specified tree or at the repository level in case the specifiedtreeisnull. If the givenprivilegeBitsisnullan implementation returns the complete set that is covered by the provider; otherwise the supported subset of the specifiedprivilegeBitsis returned. ReturningPrivilegeBits.EMPTYindicates that this implementation is not in charge of evaluating the specified privileges and thus will be ignored while computing the composite result ofPermissionProvider.getPrivileges(org.apache.jackrabbit.oak.api.Tree)orPermissionProvider.hasPrivileges(org.apache.jackrabbit.oak.api.Tree, String...).- Specified by:
supportedPrivilegesin interfaceAggregatedPermissionProvider- Parameters:
tree- The tree for which the privileges will be evaluated ornullfor repository level privileges.privilegeBits- The privilege(s) to be tested ornull- Returns:
- The set of privileges or the subset of the given
privilegeBitsthat are supported and evaluated by the implementation at the giventreerepresented asPrivilegeBits.
-
supportedPermissions
public long supportedPermissions(@Nullable @Nullable Tree tree, @Nullable @Nullable PropertyState property, long permissions)Description copied from interface:AggregatedPermissionProviderAllows to determined the set or subset of permissions evaluated by the implementing permission provider for the specified item (identified bytreeand optionallyproperty) or at the repository level in case the specifiedtreeisnull. ReturningPermissions.NO_PERMISSIONindicates that this implementation is not in charge of evaluating the specified permissions for the specified item and thus will be ignored while computing the composite result ofPermissionProvider.isGranted(Tree, PropertyState, long).- Specified by:
supportedPermissionsin interfaceAggregatedPermissionProvider- Parameters:
tree- The tree for which the permissions will be evaluated ornullfor repository level privileges.property- The target property ornull.permissions- The permissions to be tested- Returns:
- The subset of the given
permissionsthat are supported and evaluated by the implementation for the given item.
-
supportedPermissions
public long supportedPermissions(@NotNull @NotNull TreeLocation location, long permissions)Description copied from interface:AggregatedPermissionProviderAllows to determined the set or subset of permissions evaluated by the implementing permission provider for the specified location. ReturningPermissions.NO_PERMISSIONindicates that this implementation is not in charge of evaluating the specified permissions for the specified location and thus will be ignored while computing the composite result ofPermissionProvider.isGranted(String, String)andAggregatedPermissionProvider.isGranted(TreeLocation, long).- Specified by:
supportedPermissionsin interfaceAggregatedPermissionProvider- Parameters:
location- The tree location for which the permissions will be evaluated.permissions- The permissions to be tested- Returns:
- The subset of the given
permissionsthat are supported and evaluated by the implementation for the given location.
-
supportedPermissions
public long supportedPermissions(@NotNull @NotNull TreePermission treePermission, @Nullable @Nullable PropertyState property, long permissions)Description copied from interface:AggregatedPermissionProviderAllows to determined the set or subset of permissions evaluated by the implementing permission provider for the specified tree permission (plus optionallyproperty). ReturningPermissions.NO_PERMISSIONindicates that this implementation is not in charge of evaluating the specified permissions for the specified tree permission and thus will be ignored while computing the composite result ofTreePermission.isGranted(long, PropertyState)andTreePermission.isGranted(long).- Specified by:
supportedPermissionsin interfaceAggregatedPermissionProvider- Parameters:
treePermission- The target tree permission.property- The target property ornull.permissions- The permissions to be tested- Returns:
- The subset of the given
permissionsthat are supported and evaluated by the implementation for the given tree permissions.
-
isGranted
public boolean isGranted(@NotNull @NotNull TreeLocation location, long permissions)Description copied from interface:AggregatedPermissionProviderTest if the specified permissions are granted for the set ofPrincipals associated with this provider instance for the item identified by the givenlocationand optionally property. This method will only returntrueif all permissions are granted.- Specified by:
isGrantedin interfaceAggregatedPermissionProvider- Parameters:
location- TheTreeLocationto test the permissions for.permissions- The permissions to be tested.- Returns:
trueif the specified permissions are granted for the existing or non-existing item identified by the given location.
-
getTreePermission
@NotNull public @NotNull TreePermission getTreePermission(@NotNull @NotNull Tree tree, @NotNull @NotNull TreeType type, @NotNull @NotNull TreePermission parentPermission)
Description copied from interface:AggregatedPermissionProviderReturn theTreePermissionfor the set ofPrincipals associated with this provider at the specifiedtreewith the giventype.- Specified by:
getTreePermissionin interfaceAggregatedPermissionProvider- Parameters:
tree- The tree for which theTreePermissionobject should be built.type- The type of this tree.parentPermission- TheTreePermissionobject that has been obtained before for the parent tree.- Returns:
- The
TreePermissionobject for the specifiedtree.
-
getPermissionStore
@NotNull protected @NotNull org.apache.jackrabbit.oak.security.authorization.permission.PermissionStore getPermissionStore(@NotNull @NotNull Root root, @NotNull @NotNull String workspaceName, @NotNull @NotNull RestrictionProvider restrictionProvider)
-
-