Package org.xwiki.security.authorization
Class DefaultAuthorizationManager
- java.lang.Object
-
- org.xwiki.security.authorization.DefaultAuthorizationManager
-
- All Implemented Interfaces:
AuthorizationManager
@Component @Singleton public class DefaultAuthorizationManager extends Object implements AuthorizationManager
Default implementation of theAuthorizationManager.- Since:
- 4.0M2
- Version:
- $Id: 5366e2597113ad7d7473d35248f2fddd572fb2a9 $
-
-
Field Summary
-
Fields inherited from interface org.xwiki.security.authorization.AuthorizationManager
SUPERADMIN_USER
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthorizationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckAccess(Right right, DocumentReference userReference, EntityReference entityReference)Check if the user identified byuserReferencehas the access identified byrighton the entity identified byentityReference.booleanhasAccess(Right right, DocumentReference userReference, EntityReference entityReference)Verifies if the user identified byuserReferencehas the access identified byrighton the entity identified byentityReference.protected voidlogDeny(DocumentReference user, EntityReference entity, Right right, String info)Log denied access conclusion.Rightregister(RightDescription rightDescription)Register a new customRight.Rightregister(RightDescription rightDescription, Set<Right> impliedByRights)Register a new customRightand add it as an implied right to the given set of rights.voidunregister(Right right)Unregister the given customRight.
-
-
-
Method Detail
-
checkAccess
public void checkAccess(Right right, DocumentReference userReference, EntityReference entityReference) throws AccessDeniedException
Description copied from interface:AuthorizationManagerCheck if the user identified byuserReferencehas the access identified byrighton the entity identified byentityReference. Note that some rights may be checked higher in hierarchy of the provided entity if such right is not enabled at lowest hierarchy level provided. This function should be used at security checkpoint.- Specified by:
checkAccessin interfaceAuthorizationManager- Parameters:
right- the right needed for execution of the actionuserReference- the user to check the right forentityReference- the entity on which to check the right- Throws:
AccessDeniedException- if the action should be denied, which may also happen when an error occurs
-
hasAccess
public boolean hasAccess(Right right, DocumentReference userReference, EntityReference entityReference)
Description copied from interface:AuthorizationManagerVerifies if the user identified byuserReferencehas the access identified byrighton the entity identified byentityReference. Note that some rights may be checked higher in hierarchy of the provided entity if such right is not enabled at lowest hierarchy level provided. This function should be used for interface matters, useAuthorizationManager.checkAccess(org.xwiki.security.authorization.Right, org.xwiki.model.reference.DocumentReference, org.xwiki.model.reference.EntityReference)at security checkpoints.- Specified by:
hasAccessin interfaceAuthorizationManager- Parameters:
right- the right to check .userReference- the user to check the right forentityReference- the entity on which to check the right- Returns:
trueif the user has the specified right on the entity,falseotherwise
-
register
public Right register(RightDescription rightDescription) throws UnableToRegisterRightException
Description copied from interface:AuthorizationManagerRegister a new customRight.- Specified by:
registerin interfaceAuthorizationManager- Parameters:
rightDescription- the full description of the newRight- Returns:
- the created
Right - Throws:
UnableToRegisterRightException- if an error prevent creation of the new right. Registering exactly the same right does not cause an exception and return the existing right.
-
register
public Right register(RightDescription rightDescription, Set<Right> impliedByRights) throws UnableToRegisterRightException
Description copied from interface:AuthorizationManagerRegister a new customRightand add it as an implied right to the given set of rights.- Specified by:
registerin interfaceAuthorizationManager- Parameters:
rightDescription- the full description of the newRightimpliedByRights- the rights that should imply the new right.- Returns:
- the created
Right - Throws:
UnableToRegisterRightException- if an error prevent creation of the new right. Registering exactly the same right does not cause an exception and return the existing right.
-
unregister
public void unregister(Right right) throws AuthorizationException
Description copied from interface:AuthorizationManagerUnregister the given customRight.- Specified by:
unregisterin interfaceAuthorizationManager- Parameters:
right- the custom right to unregister.- Throws:
AuthorizationException- if the right is not custom.
-
logDeny
protected void logDeny(DocumentReference user, EntityReference entity, Right right, String info)
Log denied access conclusion. All denied access conclusion made during a security checkpoint use this method.- Parameters:
user- The user name that was checked.entity- The page that was checked.right- The action that was requested.info- Additional information.
-
-