Package org.ametys.core.right
Class RightManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.right.RightManager
-
- All Implemented Interfaces:
LogEnabled,Initializable,Component,Configurable,Contextualizable,Serviceable,ThreadSafe
public class RightManager extends AbstractLogEnabled implements Serviceable, Configurable, ThreadSafe, Component, Contextualizable, Initializable
Abstraction for testing a right associated with a resource and a user from a single source.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRightManager.RightResultEnumeration of all possible values returned by hasRight(user, right, context)
-
Field Summary
Fields Modifier and Type Field Description protected static UserIdentity__ANONYMOUS_USER_IDENTITYThe instance of ObjectUserIdentity for anonymousprotected static UserIdentity__ANY_CONNECTED_USER_IDENTITYThe instance of ObjectUserIdentity for any connected userprotected AccessControllerExtensionPoint_accessControllerEPThe extension point for Access Controllersprotected AbstractCacheManager_cacheManagerCache Managerprotected CurrentUserProvider_currentUserProviderThe current user providerprotected GroupDirectoryDAO_groupDirectoryDAOThe DAO for group directoriesprotected GroupManager_groupManagerThe group managerprotected ServiceManager_managerAvalon ServiceManagerprotected RightProfilesDAO_profilesDAOThe rights DAOprotected SourceResolver_resolverAvalon SourceResolverprotected RightContextConvertorExtensionPoint_rightContextConvertorEPThe extension point for the Right Context Convertorsprotected RightsExtensionPoint_rightsEPThe rights' list containerprotected UserManager_userManagerThe user managerprotected UserPopulationDAO_userPopulationDAOThe DAO for user populationsstatic StringREADER_PROFILE_IDThe id of the READER profilestatic StringROLEFor avalon service manager
-
Constructor Summary
Constructors Constructor Description RightManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RightProfilesDAO_getProfileDAO()Returns the DAO for profilesvoidclearCaches()clear all caches related to RightManager and AccesControllersvoidconfigure(Configuration configuration)voidcontextualize(Context context)booleancurrentUserHasReadAccess(Object object)Returns true if the current user has READ access on the given objectRightManager.RightResultcurrentUserHasRight(String rightId, Object object)Checks a permission for the current logged user, on a given object (or context).
If null, it checks if there is at least one object with this permissionAllowedUsersgetAllowedUsers(String rightId, Object object)Get the list of users that have a particular right in a particular context.AllowedUsersgetReadAccessAllowedUsers(Object object)Get the users with a READ access on given objectSet<String>getUserRights(UserIdentity userIdentity, Object object)Get the list of rights a user is allowed, on a particular object.booleanhasAnonymousReadAccess(Object object)Returns true if the object is not restricted, i.e.RightManager.RightResulthasAnonymousRight(String rightId, Object object)Gets the right result for anonymous with given right on given object contextbooleanhasAnyConnectedUserReadAccess(Object object)Returns true if any connected user has READ access allowed on the objectRightManager.RightResulthasAnyConnectedUserRight(String rightId, Object object)Gets the right result for any connected user with given profile on given object contextbooleanhasReadAccess(UserIdentity userIdentity, Object object)Returns true if the given user has READ access on the given objectRightManager.RightResulthasRight(UserIdentity userIdentity, String rightId, Object object)Checks a permission for a user, on a given object (or context).
If null, it checks if there is at least one object with this permissionvoidinitialize()voidservice(ServiceManager manager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
READER_PROFILE_ID
public static final String READER_PROFILE_ID
The id of the READER profile- See Also:
- Constant Field Values
-
__ANONYMOUS_USER_IDENTITY
protected static final UserIdentity __ANONYMOUS_USER_IDENTITY
The instance of ObjectUserIdentity for anonymous
-
__ANY_CONNECTED_USER_IDENTITY
protected static final UserIdentity __ANY_CONNECTED_USER_IDENTITY
The instance of ObjectUserIdentity for any connected user
-
_manager
protected ServiceManager _manager
Avalon ServiceManager
-
_resolver
protected SourceResolver _resolver
Avalon SourceResolver
-
_rightsEP
protected RightsExtensionPoint _rightsEP
The rights' list container
-
_rightContextConvertorEP
protected RightContextConvertorExtensionPoint _rightContextConvertorEP
The extension point for the Right Context Convertors
-
_accessControllerEP
protected AccessControllerExtensionPoint _accessControllerEP
The extension point for Access Controllers
-
_userManager
protected UserManager _userManager
The user manager
-
_groupManager
protected GroupManager _groupManager
The group manager
-
_userPopulationDAO
protected UserPopulationDAO _userPopulationDAO
The DAO for user populations
-
_groupDirectoryDAO
protected GroupDirectoryDAO _groupDirectoryDAO
The DAO for group directories
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_profilesDAO
protected RightProfilesDAO _profilesDAO
The rights DAO
-
_cacheManager
protected AbstractCacheManager _cacheManager
Cache Manager
-
-
Constructor Detail
-
RightManager
public RightManager()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
_getProfileDAO
protected RightProfilesDAO _getProfileDAO()
Returns the DAO for profiles- Returns:
- The DAO
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
currentUserHasRight
public RightManager.RightResult currentUserHasRight(String rightId, Object object) throws RightsException
Checks a permission for the current logged user, on a given object (or context).
If null, it checks if there is at least one object with this permission- Parameters:
rightId- The name of the right to check. Cannot be null.object- The object to check the right. Can be null to search on any object.- Returns:
RightManager.RightResult.RIGHT_ALLOW,RightManager.RightResult.RIGHT_DENYorRightManager.RightResult.RIGHT_UNKNOWN- Throws:
RightsException- if an error occurs.
-
hasRight
public RightManager.RightResult hasRight(UserIdentity userIdentity, String rightId, Object object) throws RightsException
Checks a permission for a user, on a given object (or context).
If null, it checks if there is at least one object with this permission- Parameters:
userIdentity- The user identity. Can be null for anonymousrightId- The name of the right to check. Cannot be null.object- The object to check the right. Can be null to search on any object.- Returns:
RightManager.RightResult.RIGHT_ALLOW,RightManager.RightResult.RIGHT_DENYorRightManager.RightResult.RIGHT_UNKNOWN- Throws:
RightsException- if an error occurs.
-
hasAnonymousRight
public RightManager.RightResult hasAnonymousRight(String rightId, Object object)
Gets the right result for anonymous with given right on given object context- Parameters:
rightId- The id of the rightobject- The object to check- Returns:
- the right result for anonymous with given profile on given object context
-
hasAnyConnectedUserRight
public RightManager.RightResult hasAnyConnectedUserRight(String rightId, Object object)
Gets the right result for any connected user with given profile on given object context- Parameters:
rightId- The right id to testobject- The object to check- Returns:
- the right result for any connected user with given profile on given object context
-
currentUserHasReadAccess
public boolean currentUserHasReadAccess(Object object)
Returns true if the current user has READ access on the given object- Parameters:
object- The object to check the right. Can be null to search on any object.- Returns:
- true if the given user has READ access on the given object
-
hasReadAccess
public boolean hasReadAccess(UserIdentity userIdentity, Object object)
Returns true if the given user has READ access on the given object- Parameters:
userIdentity- The user identity. Cannot be null.object- The object to check the right. Can be null to search on any object.- Returns:
- true if the given user has READ access on the given object
-
hasAnonymousReadAccess
public boolean hasAnonymousReadAccess(Object object)
Returns true if the object is not restricted, i.e. an anonymous user has READ access (is allowed) on the object- Parameters:
object- The object to check. Cannot be null- Returns:
- true if the object is restricted, i.e. an anonymous user has READ access (is allowed) on the object
-
hasAnyConnectedUserReadAccess
public boolean hasAnyConnectedUserReadAccess(Object object)
Returns true if any connected user has READ access allowed on the object- Parameters:
object- The object to check. Cannot be null- Returns:
- true if any connected user has READ access allowed on the object
-
getAllowedUsers
public AllowedUsers getAllowedUsers(String rightId, Object object)
Get the list of users that have a particular right in a particular context.- Parameters:
rightId- The name of the right to check. Cannot be null.object- The object to check the right. Cannot be null.- Returns:
- The list of users allowed with that right as a Set of String (user identities).
- Throws:
RightsException- if an error occurs.
-
getReadAccessAllowedUsers
public AllowedUsers getReadAccessAllowedUsers(Object object)
Get the users with a READ access on given object- Parameters:
object- The object- Returns:
- The representation of allowed users
-
getUserRights
public Set<String> getUserRights(UserIdentity userIdentity, Object object) throws RightsException
Get the list of rights a user is allowed, on a particular object.- Parameters:
userIdentity- the user identity. Cannot be null.object- The object to check the right. Cannot be null.- Returns:
- The list of rights as a Set of String (id).
- Throws:
RightsException- if an error occurs.
-
clearCaches
public void clearCaches()
clear all caches related to RightManager and AccesControllers
-
-