Package de.hybris.platform.jalo.security
Class AccessManager
java.lang.Object
de.hybris.platform.jalo.Manager
de.hybris.platform.jalo.security.AccessManager
- All Implemented Interfaces:
ItemLifecycleListener,Serializable
Manager of all security based functionality of the hybris Platform. Here you can defined new
There are two ways of assigning rights to a user (all Users are Principals): as global permission or as local permission. First is not bound to an Item and so can be checked without one. Local permissions are assignments of userrights for a user to a specific item. This permission can only be checked on this item.
You can combine both ways to have a hierarchical permission checking, if you assign one right global and optionally local. Example: A user might global be allowed to see all products (by globally assigning the right
UserRights, assign them to Principals and Items, and check
access on items. There are two ways of assigning rights to a user (all Users are Principals): as global permission or as local permission. First is not bound to an Item and so can be checked without one. Local permissions are assignments of userrights for a user to a specific item. This permission can only be checked on this item.
You can combine both ways to have a hierarchical permission checking, if you assign one right global and optionally local. Example: A user might global be allowed to see all products (by globally assigning the right
product.read), but is forbidden to see the special product MY_CHEFS_SECRET_CAR (by
negatively assigning this right to this product). The great advantage is that all other products must not have this
righ explicitely assigned, but can be checked anyway (because it is globally assigned).- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classNested classes/interfaces inherited from class de.hybris.platform.jalo.Manager
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringDeprecated.static final StringDeprecated.since ages - Instead usePermissionsConstants.CHANGE_PERMISSIONSstatic final StringDeprecated.since ages - Instead usePermissionsConstants.CREATEstatic final StringDeprecated.since ages - Instead usePermissionsConstants.READstatic final StringDeprecated.since ages - Instead usePermissionsConstants.REMOVE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGlobalNegativePermission(Principal caller, Principal principal, UserRight permission) Deprecated.since ages - please usePrincipal.addGlobalNegativePermission(UserRight)insteadvoidaddGlobalPermissions(Principal caller, Collection permissions) Assigns a list of global rightsvoidaddGlobalPositivePermission(Principal caller, Principal principal, UserRight permission) Deprecated.since ages - please usePrincipal.addGlobalPositivePermission(UserRight)insteadvoidaddNegativePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) Negatively assigns a right for a user to a item (prohibition).voidaddPositivePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) Positively assigns a right for a user to a item.protected voidcheckBeforeItemRemoval(SessionContext ctx, Item item) Superclass method overridden to avoid call to EJB layer.This Method returns a list withLicenceInfoobjects.booleancheckPermission(Principal principal, UserRight permission) Checks a global permission for a user and a right.booleancheckPermission(Principal principal, String permissionCode) Same ascheckPermission(Principal, UserRight)but with the permissions code instead of passing the whole UserRight object.booleancheckPermissionOn(Item item, Principal principal, UserRight permission) Checks permission on an item.booleancheckPermissionOn(Item item, Principal principal, String permissionCode) Same ascheckPermissionOn(Item, Principal, UserRight)but with the permissions code instead of passing the whole UserRight object.createUserRight(String code) Creates a new UserRight with a given code.getAllGlobalNegativePermissions(Principal principal) Returns all globally negatively assigned rights of a user.getAllGlobalPositivePermissions(Principal principal) Returns all globally positively assigned rights of a user.All existing userrights in the system.getGlobalNegativePermissions(Principal principal) Returns all globally negatively assigned rights of a user.getGlobalPositivePermissions(Principal principal) Returns all globally positively assigned rights of a user.getGlobalRestrictedPrincipals(PK permissionPK) getGlobalRestrictedPrincipals(UserRight permission) static AccessManagerConvenience method which first tries to get the user right with the given code and when such a user right does not exists, it will be created.getRestrictedItemsMapForPrincipal(Principal p, List permissionList) getRestrictedLanguages(Item item) Asks all those extensions which implement Extension.ResctrictedLanguageProvider for all available languages for the given item and returns the intersection of these languages.getUserRightByCode(String code) Returns the UserRight with the specified code.getUserRightsByCode(String code) Returns all UserRights which code matches the specified search string.booleanisEditable(Item item, AttributeDescriptor descriptor) Asks all those extensions which implement RightsProvider if the attribute should be editable.protected voidnotifyItemRemoval(SessionContext ctx, Item item) Clears all permissions which are set for this item.voidremoveGlobalPermission(Principal caller, Principal principal, UserRight permission) Deprecated.since ages - please usePrincipal.clearGlobalPermission(UserRight)insteadvoidremovePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) Removes the local assignment of a userright for a user on a specific item.Methods inherited from class de.hybris.platform.jalo.Manager
afterItemCreation, beforeItemCreation, destroy, extractNonRequiredRemoteFromItem, extractRequiredRemoteFromItem, getAllValuesSessionContext, getAttribute, getAttributeMap, getFirstItemByAttribute, getFirstItemByAttribute, getRemote, getRemoteManagerClass, getSession, getSingletonManagerInstance, getTenant, getTransientObject, getTransientObjectMap, init, setAttribute, setTenant, setTransientObject, wrap
-
Field Details
-
BEAN_NAME
- See Also:
-
READ
Deprecated.since ages - Instead usePermissionsConstants.READ- See Also:
-
CHANGE
Deprecated.since ages - Instead usePermissionsConstants.CHANGE- See Also:
-
CHANGE_PERMISSIONS
Deprecated.since ages - Instead usePermissionsConstants.CHANGE_PERMISSIONS- See Also:
-
CREATE
Deprecated.since ages - Instead usePermissionsConstants.CREATE- See Also:
-
REMOVE
Deprecated.since ages - Instead usePermissionsConstants.REMOVE- See Also:
-
-
Constructor Details
-
AccessManager
public AccessManager()
-
-
Method Details
-
getInstance
- Returns:
- instance of this manager
-
checkBeforeItemRemoval
protected void checkBeforeItemRemoval(SessionContext ctx, Item item) throws ConsistencyCheckException Superclass method overridden to avoid call to EJB layer.- Overrides:
checkBeforeItemRemovalin classManager- Parameters:
ctx- the current session contextitem- the item which should be removed- Throws:
ConsistencyCheckException- thrown to abort removal due to consistency errors- Since:
- 2.10
-
notifyItemRemoval
Clears all permissions which are set for this item. If the item is aPrincipalit clears its permissions on any other item too.- Overrides:
notifyItemRemovalin classManager- Parameters:
ctx- the currency session contextitem- the item which is going to be removed- Since:
- 2.10
-
checkPermissionOn
Checks permission on an item. This will give a positive result, if this userright was positively assigned to this item and user or (if not locally assigned) if it was positively globally assigned ti the user. If it was local (or global if not local ) negatively assigned the result is negative.
Since a user can be part of multipleUserGroupswhich might have their own rights assigned too, there is the case that positive and negative assignments might be found. In this case the reault is negative.
As you can see we have two kind of hierarchy in our security model: global and local permissions, and user and usergroup permissions. As a rule of thumb you should allwas expect local permissions and user permissions to be stronger than global and usergroup permissions. The return values for item i, Principal p and UserRight r as table:
Syntax: + ... positive permissionentry return value comment none false default is 'not allowed' (i,p,r,+) true user has permission (i,p,r,-) false user has negative permission (*,p,r,+) true user has global permission (item-independent) (*,p,r,-) false user has negative global permission (item-independent) (i,G(p),r,+) true (at least) one group of user has permission (i,G(p),r,-) false groups of user have negative permissions (or none!) (*,G(p),r,+) true (at least) one group of user has global permission (*,G(p),r,-) false groups of user have negative global permissions (or none) special cases (*,G1(p),r,+) but also (*,G2(p),r,-) false if one group is not allowed the user is not allowed (*,p,r,+) but also (i,p,r,-) false global permissions are overruled by item-permissions (i,G(p),r,+) but also (i,p,r,-) false group permissions are overruled by principal permissions
- ... negative permission
... permission is global (item-independent)
G(p)... the groups of principal p
G1(p), G2(p) ... groups of principal in two parts- Parameters:
item- the item to check the right forprincipal- the user to check the right forpermission- the right to check
-
checkPermissionOn
Same ascheckPermissionOn(Item, Principal, UserRight)but with the permissions code instead of passing the whole UserRight object. -
removePermissionOn
public void removePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) throws JaloSecurityException Removes the local assignment of a userright for a user on a specific item. Since assignments can only be removed by ACL-owners of this item such one must be specified too.- Parameters:
item- the item to remove the assignment fromcaller- the ACL-owner which is allowed to remove this assignment on this itemprincipal- the user to remove the assignment forpermission- the right to remove- Throws:
JaloSecurityException
-
addPositivePermissionOn
public void addPositivePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) throws JaloSecurityException Positively assigns a right for a user to a item. Since assignments can only be created by ACL-owners of this item such one must be specified too.- Parameters:
item- the item to add the assignment tocaller- the ACL-owner which is allowed to add this assignment to this itemprincipal- the user to add the assignment forpermission- the right to add- Throws:
JaloSecurityException
-
addNegativePermissionOn
public void addNegativePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) throws JaloSecurityException Negatively assigns a right for a user to a item (prohibition). Since assignments can only be created by ACL-owners of this item such one must be specified too.- Parameters:
item- the item to add the assignment tocaller- the ACL-owner which is allowed to add this assignment to this itemprincipal- the user to add the assignment forpermission- the right to add- Throws:
JaloSecurityException
-
addGlobalPermissions
public void addGlobalPermissions(Principal caller, Collection permissions) throws JaloSecurityException Assigns a list of global rights- Parameters:
caller- the ACL-owner which is allowed to add this assignmentpermissions- a collection ofPermissionContainers- Throws:
JaloSecurityException
-
checkPermission
Checks a global permission for a user and a right. The result will only be positive if a positive global assignment for this user and this right exists.
Since a user can be part of multipleUserGroupswhich might have their own rights assigned too, there is the case that positive and negative assignments might be found. In this case the result is negative.- Parameters:
principal- the user to check the right forpermission- the right to check
-
checkPermission
Same ascheckPermission(Principal, UserRight)but with the permissions code instead of passing the whole UserRight object. -
removeGlobalPermission
@Deprecated(since="ages", forRemoval=false) public void removeGlobalPermission(Principal caller, Principal principal, UserRight permission) throws JaloSecurityException Deprecated.since ages - please usePrincipal.clearGlobalPermission(UserRight)insteadRemoves the global assignment of a userright for a user on a specific item. Since assignments can only be removed by global ACL-owners such one must be specified too.- Parameters:
caller- the ACL-owner which is allowed to remove this assignmentprincipal- the user to remove the assignment forpermission- the right to remove- Throws:
JaloSecurityException
-
addGlobalPositivePermission
@Deprecated(since="ages", forRemoval=false) public void addGlobalPositivePermission(Principal caller, Principal principal, UserRight permission) throws JaloSecurityException Deprecated.since ages - please usePrincipal.addGlobalPositivePermission(UserRight)insteadPositively assigns a right for a user globally. Since assignments can only be created by global ACL-owners such one must be specified too.- Parameters:
caller- the ACL-owner which is allowed to add this assignmentprincipal- the user to add the assignment forpermission- the right to add- Throws:
JaloSecurityException
-
addGlobalNegativePermission
@Deprecated(since="ages", forRemoval=false) public void addGlobalNegativePermission(Principal caller, Principal principal, UserRight permission) throws JaloSecurityException Deprecated.since ages - please usePrincipal.addGlobalNegativePermission(UserRight)insteadNegatively assigns a right for a user globally(prohibition). Since assignments can only be created by global ACL-owners such one must be specified too.- Parameters:
caller- the ACL-owner which is allowed to add this assignmentprincipal- the user to add the assignment forpermission- the right to add- Throws:
JaloSecurityException
-
getGlobalPositivePermissions
Returns all globally positively assigned rights of a user.- Parameters:
principal- the user for which the rights are assigned
-
getGlobalNegativePermissions
Returns all globally negatively assigned rights of a user.- Parameters:
principal- the user for which the rights are assigned
-
getAllGlobalPositivePermissions
Returns all globally positively assigned rights of a user. Here also rights of usergroups which the user is in will be included.- Parameters:
principal- the user for which the rights are assigned
-
getAllGlobalNegativePermissions
Returns all globally negatively assigned rights of a user. Here also rights of usergroups which the user is in will be included.- Parameters:
principal- the user for which the rights are assigned
-
createUserRight
Creates a new UserRight with a given code. This code must be unique.- Parameters:
code- the code of the user right- Returns:
- a new user right object
- Throws:
ConsistencyCheckException- if this code is already in use- See Also:
-
getUserRightsByCode
Returns all UserRights which code matches the specified search string. The syntax of this string is equivalent to SQL LIKE statements.- Parameters:
code-- Returns:
- Collection
-
getUserRightByCode
Returns the UserRight with the specified code. Unlike getUserRightsByCode( String ) this method does only exact matching.- Parameters:
code-
-
getOrCreateUserRightByCode
Convenience method which first tries to get the user right with the given code and when such a user right does not exists, it will be created.- Parameters:
code-
-
getAllUserRights
All existing userrights in the system. -
isEditable
Asks all those extensions which implement RightsProvider if the attribute should be editable.- Since:
- 2.20
-
getRestrictedLanguages
Asks all those extensions which implement Extension.ResctrictedLanguageProvider for all available languages for the given item and returns the intersection of these languages.- Since:
- 3.00 (beta1)
-
checkLicence
This Method returns a list withLicenceInfoobjects. The size of this list is equal to how many licence terms exists.- Returns:
- a list
-
getRestrictedItemsMapForPrincipal
-
getGlobalRestrictedPrincipals
-
getGlobalRestrictedPrincipals
-
writeReplace
- Specified by:
writeReplacein classManager- Throws:
ObjectStreamException
-
PermissionsConstants.CHANGE