public class AccessManager extends Manager
UserRights, assign them to Principals and Items, and check
access on items. 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).| Modifier and Type | Class and Description |
|---|---|
protected static class |
AccessManager.AccessManagerSerializableDTO |
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BEAN_NAME |
static java.lang.String |
CHANGE
Deprecated.
since ages - Instead use
PermissionsConstants.CHANGE |
static java.lang.String |
CHANGE_PERMISSIONS
Deprecated.
since ages - Instead use
PermissionsConstants.CHANGE_PERMISSIONS |
static java.lang.String |
CREATE
Deprecated.
since ages - Instead use
PermissionsConstants.CREATE |
static java.lang.String |
READ
Deprecated.
since ages - Instead use
PermissionsConstants.READ |
static java.lang.String |
REMOVE
Deprecated.
since ages - Instead use
PermissionsConstants.REMOVE |
| Constructor and Description |
|---|
AccessManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
addGlobalNegativePermission(Principal caller,
Principal principal,
UserRight permission)
Deprecated.
since ages - please use
Principal.addGlobalNegativePermission(UserRight) instead |
void |
addGlobalPermissions(Principal caller,
java.util.Collection permissions)
Assigns a list of global rights
|
void |
addGlobalPositivePermission(Principal caller,
Principal principal,
UserRight permission)
Deprecated.
since ages - please use
Principal.addGlobalPositivePermission(UserRight) instead |
void |
addNegativePermissionOn(Item item,
Principal caller,
Principal principal,
UserRight permission)
Negatively assigns a right for a user to a item (prohibition).
|
void |
addPositivePermissionOn(Item item,
Principal caller,
Principal principal,
UserRight permission)
Positively assigns a right for a user to a item.
|
protected void |
checkBeforeItemRemoval(SessionContext ctx,
Item item)
Superclass method overridden to avoid call to EJB layer.
|
java.util.ArrayList |
checkLicence()
This Method returns a list with
LicenceInfo objects. |
boolean |
checkPermission(Principal principal,
java.lang.String permissionCode)
Same as
checkPermission(Principal,UserRight) but with the permissions code instead of passing the whole
UserRight object. |
boolean |
checkPermission(Principal principal,
UserRight permission)
Checks a global permission for a user and a right.
|
boolean |
checkPermissionOn(Item item,
Principal principal,
java.lang.String permissionCode)
Same as
checkPermissionOn(Item,Principal,UserRight) but with the permissions code instead of passing the
whole UserRight object. |
boolean |
checkPermissionOn(Item item,
Principal principal,
UserRight permission)
Checks permission on an item.
|
UserRight |
createUserRight(java.lang.String code)
Creates a new UserRight with a given code.
|
java.util.Collection |
getAllGlobalNegativePermissions(Principal principal)
Returns all globally negatively assigned rights of a user.
|
java.util.Collection |
getAllGlobalPositivePermissions(Principal principal)
Returns all globally positively assigned rights of a user.
|
java.util.Collection |
getAllUserRights()
All existing userrights in the system.
|
java.util.Collection |
getGlobalNegativePermissions(Principal principal)
Returns all globally negatively assigned rights of a user.
|
java.util.Collection |
getGlobalPositivePermissions(Principal principal)
Returns all globally positively assigned rights of a user.
|
java.util.Collection |
getGlobalRestrictedPrincipals(PK permissionPK) |
java.util.Collection |
getGlobalRestrictedPrincipals(UserRight permission) |
static AccessManager |
getInstance() |
UserRight |
getOrCreateUserRightByCode(java.lang.String code)
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.
|
java.util.Map |
getRestrictedItemsMapForPrincipal(Principal p,
java.util.List permissionList) |
java.util.Set<Language> |
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.
|
UserRight |
getUserRightByCode(java.lang.String code)
Returns the UserRight with the specified code.
|
java.util.Collection |
getUserRightsByCode(java.lang.String code)
Returns all UserRights which code matches the specified search string.
|
boolean |
isEditable(Item item,
AttributeDescriptor descriptor)
Asks all those extensions which implement RightsProvider if the attribute should be editable.
|
protected void |
notifyItemRemoval(SessionContext ctx,
Item item)
Clears all permissions which are set for this item.
|
void |
removeGlobalPermission(Principal caller,
Principal principal,
UserRight permission)
Deprecated.
since ages - please use
Principal.clearGlobalPermission(UserRight) instead |
void |
removePermissionOn(Item item,
Principal caller,
Principal principal,
UserRight permission)
Removes the local assignment of a userright for a user on a specific item.
|
java.lang.Object |
writeReplace() |
afterItemCreation, beforeItemCreation, destroy, getAllValuesSessionContext, getAttribute, getAttributeMap, getFirstItemByAttribute, getFirstItemByAttribute, getRemote, getRemoteManagerClass, getSession, getSingletonManagerInstance, getTenant, getTransientObject, getTransientObjectMap, init, setAttribute, setTenant, setTransientObject, unwrap, unwrap, wrappublic static final java.lang.String BEAN_NAME
@Deprecated public static final java.lang.String READ
PermissionsConstants.READ@Deprecated public static final java.lang.String CHANGE
PermissionsConstants.CHANGE@Deprecated public static final java.lang.String CHANGE_PERMISSIONS
PermissionsConstants.CHANGE_PERMISSIONS@Deprecated public static final java.lang.String CREATE
PermissionsConstants.CREATE@Deprecated public static final java.lang.String REMOVE
PermissionsConstants.REMOVEpublic static AccessManager getInstance()
protected void checkBeforeItemRemoval(SessionContext ctx, Item item) throws ConsistencyCheckException
checkBeforeItemRemoval in class Managerctx - the current session contextitem - the item which should be removedConsistencyCheckException - thrown to abort removal due to consistency errorsprotected void notifyItemRemoval(SessionContext ctx, Item item)
Principal it clears its permissions
on any other item too.notifyItemRemoval in class Managerctx - the currency session contextitem - the item which is going to be removedpublic boolean checkPermissionOn(Item item, Principal principal, UserRight permission)
UserGroups which 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. | entry | 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 | |
item - the item to check the right forprincipal - the user to check the right forpermission - the right to checkpublic boolean checkPermissionOn(Item item, Principal principal, java.lang.String permissionCode)
checkPermissionOn(Item,Principal,UserRight) but with the permissions code instead of passing the
whole UserRight object.public void removePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) throws JaloSecurityException
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 removeJaloSecurityExceptionpublic void addPositivePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) throws JaloSecurityException
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 addJaloSecurityExceptionpublic void addNegativePermissionOn(Item item, Principal caller, Principal principal, UserRight permission) throws JaloSecurityException
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 addJaloSecurityExceptionpublic void addGlobalPermissions(Principal caller, java.util.Collection permissions) throws JaloSecurityException
caller - the ACL-owner which is allowed to add this assignmentpermissions - a collection of PermissionContainersJaloSecurityExceptionpublic boolean checkPermission(Principal principal, UserRight permission)
UserGroups which 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.principal - the user to check the right forpermission - the right to checkpublic boolean checkPermission(Principal principal, java.lang.String permissionCode)
checkPermission(Principal,UserRight) but with the permissions code instead of passing the whole
UserRight object.@Deprecated public void removeGlobalPermission(Principal caller, Principal principal, UserRight permission) throws JaloSecurityException
Principal.clearGlobalPermission(UserRight) insteadcaller - the ACL-owner which is allowed to remove this assignmentprincipal - the user to remove the assignment forpermission - the right to removeJaloSecurityException@Deprecated public void addGlobalPositivePermission(Principal caller, Principal principal, UserRight permission) throws JaloSecurityException
Principal.addGlobalPositivePermission(UserRight) insteadcaller - the ACL-owner which is allowed to add this assignmentprincipal - the user to add the assignment forpermission - the right to addJaloSecurityException@Deprecated public void addGlobalNegativePermission(Principal caller, Principal principal, UserRight permission) throws JaloSecurityException
Principal.addGlobalNegativePermission(UserRight) insteadcaller - the ACL-owner which is allowed to add this assignmentprincipal - the user to add the assignment forpermission - the right to addJaloSecurityExceptionpublic java.util.Collection getGlobalPositivePermissions(Principal principal)
principal - the user for which the rights are assignedpublic java.util.Collection getGlobalNegativePermissions(Principal principal)
principal - the user for which the rights are assignedpublic java.util.Collection getAllGlobalPositivePermissions(Principal principal)
principal - the user for which the rights are assignedpublic java.util.Collection getAllGlobalNegativePermissions(Principal principal)
principal - the user for which the rights are assignedpublic UserRight createUserRight(java.lang.String code) throws ConsistencyCheckException
code - the code of the user rightConsistencyCheckException - if this code is already in usefor notes on code name conventionspublic java.util.Collection getUserRightsByCode(java.lang.String code)
code - public UserRight getUserRightByCode(java.lang.String code)
code - public UserRight getOrCreateUserRightByCode(java.lang.String code)
code - public java.util.Collection getAllUserRights()
public boolean isEditable(Item item, AttributeDescriptor descriptor)
public java.util.Set<Language> getRestrictedLanguages(Item item)
public java.util.ArrayList checkLicence()
LicenceInfo objects. The size of this list is equal to how many licence
terms exists.public java.util.Map getRestrictedItemsMapForPrincipal(Principal p, java.util.List permissionList)
public java.util.Collection getGlobalRestrictedPrincipals(UserRight permission)
public java.util.Collection getGlobalRestrictedPrincipals(PK permissionPK)
public java.lang.Object writeReplace()
throws java.io.ObjectStreamException
writeReplace in class Managerjava.io.ObjectStreamExceptionCopyright © 2018 SAP SE. All Rights Reserved.