Package org.ametys.core.right
Interface AccessController
- All Known Implementing Classes:
AbstractHierarchicalAccessController
,AbstractHierarchicalWithPermissionContextAccessController
,AbstractODFRoleAccessController
,AbstractProfileStorageBasedAccessController
,AbstractRightBasedAccessController
,AdminAccessController
,ApplicationAccessController
,BackOfficeAccessController
,CartAccessController
,CartAuthorAccessController
,CatalogNewsAccessController
,ContentAccessController
,ContentsCreatorAccessController
,ContentTypeAccessController
,EditionFOAccessController
,ExtractionAccessController
,ExtractionAuthorAccessController
,FormAccessController
,FormAuthorAccessController
,LinkDirectoryAccessController
,ModuleAccessController
,ModuleResourceAccessController
,ODFContentHierarchicalAccessController
,ODFContributorAccessController
,ODFManagerAccessController
,ODFMCCManagerAccessController
,ODFOrphanContentAccessController
,OdfRefTableDataSynchronizationAccessController
,PageAccessController
,ProjectAccessController
,QueryAccessController
,QueryAuthorAccessController
,ReferenceTableAccessController
,RemoteCDMFrSCCAccessController
,ReportsPageAccessController
,ResourceAccessController
,SiteWorkspaceAccessController
,StringHierarchicalAccessController
,SurveyAccessController
,SynchronizedContentAccessController
,ThematicAccessController
,ThesaurusAccessController
,UGCCreatorContentAccessController
,UGCCreatorPageAccessController
,UserDirectoryContentAccessController
,WebContentAccessController
,WebContentTypeAccessController
,WebWorkspaceAccessController
,WorkspaceAccessController
,WorkspaceAccessController
,WorkspaceSwitchedAccessController
public interface AccessController
This interface is for computing the rights a user has.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The access result when looking for a rightstatic final record
A object with an associated label, category and order.static final record
A permission given by an AccessController -
Method Summary
Modifier and TypeMethodDescriptionexplainAllPermissions
(UserIdentity identity, Set<GroupIdentity> groups) GetAccessExplanation
for each permission given to the user by this access controller.default AccessExplanation
explainPermission
(UserIdentity user, Set<GroupIdentity> groups, String rightId, Object object) Explain the permission for a user on the given object.default AccessExplanation
explainPermissionForAnonymous
(String rightId, Object object) Explain the permission for anonymous on the given object.default AccessExplanation
explainPermissionForAnyConnectedUser
(String rightId, Object object) Explain the permission for any connected user on the given object.default AccessExplanation
explainReadAccessPermission
(UserIdentity user, Set<GroupIdentity> groups, Object object) Explain the read access permission for a user on the given object.default AccessExplanation
Explain the read access permission for anonymous on the given object.default AccessExplanation
Explain the read access permission for any connected user on the given object.static AccessExplanation
getDefaultAccessExplanation
(String controllerId, AccessController.AccessResult result) Build a default explanation for an access result provided by a controller.getExplanationObject
(Object object) Get the explanation object representing the objectgetId()
Get the id of this controllergetObjectCategory
(Object object) Get a label classifying the object handled by this access controllergetObjectLabel
(Object object) Get a label describing the object handled by this access controllerdefault int
getObjectPriority
(Object object) Get the priority of the object to order it in its categorygetPermission
(UserIdentity user, Set<GroupIdentity> userGroups, String rightId, Object object) Gets the kind of access a user has on an object for a given rightgetPermissionByGroup
(String rightId, Object object) Gets the permission by group only on an object for the given right.getPermissionByRight
(UserIdentity user, Set<GroupIdentity> userGroups, Object object) Gets the kind of access a user has on an object for all rightsgetPermissionByUser
(String rightId, Object object) Gets the permission by user only on an object for the given right.getPermissionForAnonymous
(String rightId, Object object) Gets the permission for Anonymous only on an object for a given rightgetPermissionForAnyConnectedUser
(String rightId, Object object) Gets the permission for any connected user only on an object for a given rightgetReadAccessPermission
(UserIdentity user, Set<GroupIdentity> userGroups, Object object) Gets the kind of access a user has on an object for thye read accessgetReadAccessPermissionByGroup
(Object object) Gets the read access permission by group only on an object.getReadAccessPermissionByUser
(Object object) Gets the read access permission by user only on an object.Gets the read access permission for Anonymous only on an objectGets the read access permission for any connected user only on an objectdefault AccessExplanation
getStandardAccessExplanation
(AccessController.AccessResult accessResult, Object object) Get a standard explanation based on the access resultboolean
hasAnonymousAnyPermissionOnWorkspace
(Set<Object> workspacesContexts, String rightId) Returns true if anonymous has a permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.boolean
hasAnonymousAnyReadAccessPermissionOnWorkspace
(Set<Object> workspacesContexts) Returns true if anonymous has a read access permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.boolean
hasAnyConnectedUserAnyPermissionOnWorkspace
(Set<Object> workspacesContexts, String rightId) Returns true if any connected user has a permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.boolean
hasAnyConnectedUserAnyReadAccessPermissionOnWorkspace
(Set<Object> workspacesContexts) Returns true if any connected user has a read access permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.boolean
hasUserAnyPermissionOnWorkspace
(Set<Object> workspacesContexts, UserIdentity user, Set<GroupIdentity> userGroups, String rightId) Returns true if the user has a permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.boolean
hasUserAnyReadAccessPermissionOnWorkspace
(Set<Object> workspacesContexts, UserIdentity user, Set<GroupIdentity> userGroups) Returns true if the user has a read access permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.boolean
isSupported
(Object object) Returns true if this access controller supports the given object
-
Method Details
-
getId
Get the id of this controller- Returns:
- the id of this controller
-
getPermission
AccessController.AccessResult getPermission(UserIdentity user, Set<GroupIdentity> userGroups, String rightId, Object object) Gets the kind of access a user has on an object for a given right- Parameters:
user
- The user. Cannot be null.userGroups
- The groups the user belongs torightId
- The id of the right of the userobject
- The context object to check the access- Returns:
- the kind of access a user has on an object for a right
-
getReadAccessPermission
AccessController.AccessResult getReadAccessPermission(UserIdentity user, Set<GroupIdentity> userGroups, Object object) Gets the kind of access a user has on an object for thye read access- Parameters:
user
- The user. Cannot be null.userGroups
- The groups the user belongs toobject
- The context object to check the access- Returns:
- the kind of access a user has on an object for the read access
-
getPermissionByRight
Map<String,AccessController.AccessResult> getPermissionByRight(UserIdentity user, Set<GroupIdentity> userGroups, Object object) Gets the kind of access a user has on an object for all rights- Parameters:
user
- The user. Cannot be null.userGroups
- The groups the user belongs toobject
- The context object to check the access- Returns:
- the kind of access a user has on an object for all rights
-
getPermissionForAnonymous
Gets the permission for Anonymous only on an object for a given right- Parameters:
rightId
- The id of the right to checkobject
- The object- Returns:
- the permission for Anonymous only on an object for a given right
-
getReadAccessPermissionForAnonymous
Gets the read access permission for Anonymous only on an object- Parameters:
object
- The object- Returns:
- the read access permission for Anonymous only on an object
-
getPermissionForAnyConnectedUser
Gets the permission for any connected user only on an object for a given right- Parameters:
rightId
- The id of the right to checkobject
- The object- Returns:
- the permission for any connected user only on an object for a given right
-
getReadAccessPermissionForAnyConnectedUser
Gets the read access permission for any connected user only on an object- Parameters:
object
- The object- Returns:
- the read access permission for any connected user only on an object
-
getPermissionByUser
Gets the permission by user only on an object for the given right. It does not take account of the groups of the user, etc.- Parameters:
rightId
- The id of the right to checkobject
- The object- Returns:
- the permission by user only on an object for the given right
-
getReadAccessPermissionByUser
Gets the read access permission by user only on an object. It does not take account of the groups of the user, etc.- Parameters:
object
- The object- Returns:
- the read access permission by user only on an object
-
getPermissionByGroup
Map<GroupIdentity,AccessController.AccessResult> getPermissionByGroup(String rightId, Object object) Gets the permission by group only on an object for the given right.- Parameters:
rightId
- The id of the right to checkobject
- The object- Returns:
- the permission by group only on an object for the given right
-
getReadAccessPermissionByGroup
Gets the read access permission by group only on an object.- Parameters:
object
- The object- Returns:
- the read access permission by group only on an object
-
hasUserAnyPermissionOnWorkspace
boolean hasUserAnyPermissionOnWorkspace(Set<Object> workspacesContexts, UserIdentity user, Set<GroupIdentity> userGroups, String rightId) Returns true if the user has a permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.- Parameters:
workspacesContexts
- The contexts to tests such as {"/${WorkspaceName}", "/repository", "/admin"}user
- The useruserGroups
- The groupsrightId
- The id of the right to check- Returns:
- true if the user has a permission on at least one object, directly or though groups, for a given right
-
hasUserAnyReadAccessPermissionOnWorkspace
boolean hasUserAnyReadAccessPermissionOnWorkspace(Set<Object> workspacesContexts, UserIdentity user, Set<GroupIdentity> userGroups) Returns true if the user has a read access permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.- Parameters:
workspacesContexts
- The contexts to tests such as {"/${WorkspaceName}", "/repository", "/admin"}user
- The useruserGroups
- The groups- Returns:
- true if the user has a permission on at least one object, directly or though groups, for a given right
-
hasAnonymousAnyPermissionOnWorkspace
Returns true if anonymous has a permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.- Parameters:
workspacesContexts
- The contexts to tests such as {"/${WorkspaceName}", "/repository", "/admin"}rightId
- The id of the right to check- Returns:
- true if anonymous has a permission on at least one object, directly or though groups, for a given right
-
hasAnonymousAnyReadAccessPermissionOnWorkspace
Returns true if anonymous has a read access permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.- Parameters:
workspacesContexts
- The contexts to tests such as {"/${WorkspaceName}", "/repository", "/admin"}- Returns:
- true if anonymous has a permission on at least one object, directly or though groups, for a given right
-
hasAnyConnectedUserAnyPermissionOnWorkspace
Returns true if any connected user has a permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.- Parameters:
workspacesContexts
- The contexts to tests such as {"/${WorkspaceName}", "/repository", "/admin"}rightId
- The id of the right to check- Returns:
- true if any connected user has a permission on at least one object, directly or though groups, for a given right
-
hasAnyConnectedUserAnyReadAccessPermissionOnWorkspace
Returns true if any connected user has a read access permission on at least one object, directly or though groups, for a given rights and if the object is attached to the given context that is /${WorkspaceName} and its conversions.- Parameters:
workspacesContexts
- The contexts to tests such as {"/${WorkspaceName}", "/repository", "/admin"}- Returns:
- true if any connected user has a permission on at least one object, directly or though groups, for a given right
-
isSupported
Returns true if this access controller supports the given object- Parameters:
object
- The object to test- Returns:
- true if this access controller supports the given object
-
explainReadAccessPermissionForAnonymous
Explain the read access permission for anonymous on the given object. The access result in the explanation MUST be the same value as the one returned bygetReadAccessPermissionForAnonymous(Object)
. And the explanation should described the actual object that granted the right to allow final user to see if any context conversion happened- Parameters:
object
- the object to test- Returns:
- an explanation of the access
-
explainPermissionForAnonymous
Explain the permission for anonymous on the given object. The access result in the explanation MUST be the same value as the one returned bygetPermissionForAnonymous(String, Object)
. And the explanation should described the actual object that granted the right to allow final user to see if any context conversion happened- Parameters:
rightId
- the right to testobject
- the object to test- Returns:
- an explanation of the access
-
explainReadAccessPermissionForAnyConnectedUser
Explain the read access permission for any connected user on the given object. The access result in the explanation MUST be the same value as the one returned bygetReadAccessPermissionForAnyConnectedUser(Object)
. And the explanation should described the actual object that granted the right to allow final user to see if any context conversion happened- Parameters:
object
- the object to test- Returns:
- an explanation of the access
-
explainPermissionForAnyConnectedUser
Explain the permission for any connected user on the given object. The access result in the explanation MUST be the same value as the one returned bygetPermissionForAnyConnectedUser(String, Object)
. And the explanation should described the actual object that granted the right to allow final user to see if any context conversion happened- Parameters:
rightId
- the right to testobject
- the object to test- Returns:
- an explanation of the access
-
explainReadAccessPermission
default AccessExplanation explainReadAccessPermission(UserIdentity user, Set<GroupIdentity> groups, Object object) Explain the read access permission for a user on the given object. The access result in the explanation MUST be the same value as the one returned bygetReadAccessPermission(UserIdentity, Set, Object)
. And the explanation should described the actual object that granted the right to allow final user to see if any context conversion happened- Parameters:
user
- the user to testgroups
- the groups of the userobject
- the object to test- Returns:
- an explanation of the access
-
explainPermission
default AccessExplanation explainPermission(UserIdentity user, Set<GroupIdentity> groups, String rightId, Object object) Explain the permission for a user on the given object. The access result in the explanation MUST be the same value as the one returned bygetPermission(UserIdentity, Set, String, Object)
. And the explanation should described the actual object that granted the right to allow final user to see if any context conversion happened- Parameters:
user
- the user to testgroups
- the groups of the userrightId
- the right to testobject
- the object to test- Returns:
- an explanation of the access
-
getStandardAccessExplanation
default AccessExplanation getStandardAccessExplanation(AccessController.AccessResult accessResult, Object object) Get a standard explanation based on the access result- Parameters:
accessResult
- the access resultobject
- the inspected context- Returns:
- the explanation
-
getDefaultAccessExplanation
static AccessExplanation getDefaultAccessExplanation(String controllerId, AccessController.AccessResult result) Build a default explanation for an access result provided by a controller. This method should be used as a fallback. AccessController should provide their own explanation with more details- Parameters:
controllerId
- the access controller idresult
- the access result- Returns:
- an label describing the result
-
explainAllPermissions
Map<AccessController.ExplanationObject,Map<AccessController.Permission, explainAllPermissionsAccessExplanation>> (UserIdentity identity, Set<GroupIdentity> groups) GetAccessExplanation
for each permission given to the user by this access controller. Returns a pair of permission/access explanation for each object with a granted or denied permission to this user by this access controller. Each explanation should be equivalent to calling theexplainPermission(UserIdentity, Set, String, Object)
orexplainReadAccessPermission(UserIdentity, Set, Object)
for the user, on the object with the corresponding right- Parameters:
identity
- the user identitygroups
- the groups the user belongs to.- Returns:
- all the user's permissions handled by this controller
-
getExplanationObject
Get the explanation object representing the object- Parameters:
object
- the object- Returns:
- the explanation object
-
getObjectLabel
Get a label describing the object handled by this access controller- Parameters:
object
- the object- Returns:
- the label
-
getObjectCategory
Get a label classifying the object handled by this access controller- Parameters:
object
- the object- Returns:
- the label
-
getObjectPriority
Get the priority of the object to order it in its category- Parameters:
object
- the object- Returns:
- the priority
-