Package com.cmobilecom.af.model.system
Class AccessControlAccessorWrapper
- java.lang.Object
-
- com.cmobilecom.af.model.system.AccessControlAccessorWrapper
-
public class AccessControlAccessorWrapper extends java.lang.Object
AccessControlAccessorWrapper wraps an AccessControlAccessor and an AccessControlContext instance. Delegate all method calls to the wrapped AccessControlAccessor.- Since:
- 5.0
-
-
Constructor Summary
Constructors Constructor Description AccessControlAccessorWrapper(AccessControlAccessor wrapped, AccessControlContext context)
Constructor with wrapped AccessControlAccessor and AccessControlContext instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
authorizeAccessEntity(User user, AccessType accessType, DataDescriptor dd)
Check if the user can access the data(entity or entity list).void
authorizeAccessEntityType(User user, AccessType accessType, java.lang.Class entityType)
Check if the user can access the entity.void
authorizeAccessProperty(User user, AccessType accessType, ModeType mode, java.lang.String property, DataDescriptor dd, boolean checkEntityAccess)
Check if the user can access the property.boolean
canAccessEntity(User user, AccessType accessType, DataDescriptor dd)
Can the user access the data described by the dataDescriptor? If the access control is not defined, the access is allowed.boolean
canAccessProperty(User user, AccessType accessType, ModeType mode, java.lang.String property, DataDescriptor dd, boolean checkEntityAccess)
Can user access the property? If the access control for the property is not defined, the access is allowed.boolean
canUserAccessType(User user, AccessType accessType, java.lang.Class entityType)
Whether the user has the permission to access the entityType.boolean
canUserTakeAction(User user, java.lang.String module, java.lang.String action)
Does the user has the permission to take the action?boolean
isAccessTokenHasPermission(AccessToken accessToken, java.lang.String scope, java.lang.String module, java.lang.String permission)
Does the accessToken have the permission on the scope?boolean
isUserHasPermission(User user, ModuleScopedName modulePermission)
Does the user have the permission defined in the module?boolean
isUserHasPermission(User user, java.lang.String module, java.lang.String permission)
Does the user have the permission defined in the module? Both super role relation and super permission relation are supported.
-
-
-
Constructor Detail
-
AccessControlAccessorWrapper
public AccessControlAccessorWrapper(AccessControlAccessor wrapped, AccessControlContext context)
Constructor with wrapped AccessControlAccessor and AccessControlContext instance- Parameters:
wrapped
- wrapped AccessControlAccessorcontext
- AccessControlContext instance, can be null
-
-
Method Detail
-
canAccessEntity
public boolean canAccessEntity(User user, AccessType accessType, DataDescriptor dd) throws SystemException
Can the user access the data described by the dataDescriptor? If the access control is not defined, the access is allowed.- Parameters:
user
- the user who accesses data, can be null.accessType
- access typedd
- dataDescriptor- Returns:
- true if allowed.
- Throws:
SystemException
- throw if an error occurs
-
canUserTakeAction
public boolean canUserTakeAction(User user, java.lang.String module, java.lang.String action) throws SystemException
Does the user has the permission to take the action?- Parameters:
user
- the user who is going to take the action, can be null.module
- the name of module that defines the action, can be nullaction
- action name- Returns:
- true if authorized to take the action
- Throws:
SystemException
- throw if an error occurs
-
canAccessProperty
public boolean canAccessProperty(User user, AccessType accessType, ModeType mode, java.lang.String property, DataDescriptor dd, boolean checkEntityAccess) throws SystemException
Can user access the property? If the access control for the property is not defined, the access is allowed. If checkEntityAccess is true, and the user can not access the entity in the mode, access to the property will be denied.- Parameters:
user
- the user who is going to access the propertyaccessType
- VIEW or EDITmode
- entity show mode: create, view, edit, or queryproperty
- the property to accessdd
- entity/entityList descriptorcheckEntityAccess
- whether to check entity access first- Returns:
- true if the user has the permission to access the property
- Throws:
SystemException
- throw if an error occurs
-
authorizeAccessEntityType
public void authorizeAccessEntityType(User user, AccessType accessType, java.lang.Class entityType) throws AccessDeniedException, SystemException
Check if the user can access the entity.- Parameters:
user
- the user who is tested for the permissionaccessType
- AccessTypeentityType
- the entityType to be accessed- Throws:
AccessDeniedException
- throw if access is deniedSystemException
- if any other error occurs
-
authorizeAccessEntity
public void authorizeAccessEntity(User user, AccessType accessType, DataDescriptor dd) throws AccessDeniedException, SystemException
Check if the user can access the data(entity or entity list).- Parameters:
user
- the user who is tested for the permissionaccessType
- AccessTypedd
- data descriptor- Throws:
AccessDeniedException
- throw if access is deniedSystemException
- if any other error occurs
-
authorizeAccessProperty
public void authorizeAccessProperty(User user, AccessType accessType, ModeType mode, java.lang.String property, DataDescriptor dd, boolean checkEntityAccess) throws AccessDeniedException, SystemException
Check if the user can access the property.- Parameters:
user
- the user who is tested for the permissionaccessType
- AccessTypemode
- entity show mode: create, view, edit, or queryproperty
- the property to accessdd
- entity/entityList descriptorcheckEntityAccess
- whether to check entity access first- Throws:
AccessDeniedException
- throw if access is deniedSystemException
- throw if any other error occurs
-
isUserHasPermission
public boolean isUserHasPermission(User user, ModuleScopedName modulePermission) throws SystemException
Does the user have the permission defined in the module?- Parameters:
user
- user the user for whom to check permissionmodulePermission
- module.permissionName- Returns:
- true if the user has the permission
- Throws:
SystemException
- throw if an error occurs
-
isUserHasPermission
public boolean isUserHasPermission(User user, java.lang.String module, java.lang.String permission) throws SystemException
Does the user have the permission defined in the module? Both super role relation and super permission relation are supported. For example:ManageXX is the super permission of CreateXX, EditXX, DeleteXX, ViewXX. EditXX is the super permission of ViewXX.
- Parameters:
user
- the user for whom to check permission. If user is null, return false.module
- the module of the permissionpermission
- the permission to check- Returns:
- true if the user has the permission.
- Throws:
SystemException
- throw if an error occurs
-
canUserAccessType
public boolean canUserAccessType(User user, AccessType accessType, java.lang.Class entityType) throws SystemException
Whether the user has the permission to access the entityType.- Parameters:
user
- the user who is tested for the permissionaccessType
- AccessTypeentityType
- the entityType to be managed- Returns:
- true if the user has the permission
- Throws:
SystemException
- throw if an error occurs
-
isAccessTokenHasPermission
public boolean isAccessTokenHasPermission(AccessToken accessToken, java.lang.String scope, java.lang.String module, java.lang.String permission)
Does the accessToken have the permission on the scope?- Parameters:
accessToken
- an AccessTokenscope
- accessItem scopemodule
- the module of the permissionpermission
- permission name- Returns:
- true or false
- Since:
- 5.16
-
-