Interface PermissionManagementService
- All Known Implementing Classes:
DefaultPermissionManagementService
This service does not provide permissions checking operations; use PermissionCheckingService for that.
However, permission management operations provided here can be used to build custom permission-checking logic if the
PermissionCheckingService does not provide required functionality.
Permission is a single object representing an abstract "user right", uniquely identified by name. Permission assignment is a relationship between permission, principal and some object that exists within the platform.
Conceptually permission assignment is defined by a tuple: PA=(Object, Principal, Name, Value), where:
- Object is one of: item instance, item type, attribute descriptor or special implicit "global" object used to specify "global permission assignments".
- Principal is an user or user group for which the permission is granted or denied.
- Name is the name of a permission. Permission is uniquely identified by its name.
- Value one of: DENIED or GRANTED.
There is a restriction over possible tuple values: It is not possible to define two permission assignments that refer to the same Object, Principal and Name, but have different Value e.g. PA1(O1,P1,N1,GRANTED) and PA2(O1,P1,N1,DENIED). When using this service to define such assignments, only one of them will be actually stored in the system (previously defined assignment will be overwritten).
This service allows to manage permission assignments defined by possible values of the tuple PA (as defined above), that is:
- grant/deny a permission to an item instance for a principal
- grant/deny a permission to a type for a principal
- grant/deny a permission to an attribute descriptor for a principal
- grant/deny a permission globally for a principal
Permission assignments to objects such as items, types and attributes allow to express arbitrary constraints on user access to these objects. One can for example define permissions that allow/forbid certain users to read items of specific type, or to restrict reading to only some attributes of the type, and so on.
Global permission assignments are special in that they do not refer to any specific platform object, they just define a relation between a permission and a principal. This can be useful to express constraints that are not related with any item/type/attribute. For example one might introduce "platform_initialization" permission, that enables a user to perform platform initialisation. Such a permission is not related to any specific item or type, so it's best modelled as global permission assignment. Global permission assignment can also be used to provide fall-back permission values when implementing complex permission checking scheme (e.g. "when no assignment has been found on an object, check global assignments").
Permissions and permission assignments defined and managed by this service are not automatically enforced in other core platform services, unless explicitly indicated in the service API. This generally means that the permissions will be "effective" only if some piece of client code performs explicit permission checking.
-
Note 1) This service only allows to do permission assignments management. This is quite different from permission
assignment checking (verifying), because for checking some additional rules could be used. For example one may define
a rule that grants a permission for a principal when the permission is granted for one of the groups the principal is
a member of. When such a rule is used, there might be no explicit permission assignment to the principal, but the
permission is granted anyway. Other rules might involve checking item types hierarchy, and so on. For these reasons,
this service should not be directly used for checking permissions - use
PermissionCheckingServiceinstead. - Note 2) This service also does not define any "meaning" for permissions. Permissions as defined here are totally abstract and it's up to the users of permission-related services (client code) to define the behaviour of a system when a permission to an object is granted/denied for a principal.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttributePermission(AttributeDescriptorModel attribute, PermissionAssignment... permissionAssignment) Adds a permission assignment(s) to an attribute descriptor.voidaddAttributePermissions(AttributeDescriptorModel attribute, Collection<PermissionAssignment> permissionAssignments) Adds all permission assignments defined in given collection to an attribute descriptor.voidaddGlobalPermission(PermissionAssignment... permissionAssignment) Adds new global permission assignments.voidaddGlobalPermissions(Collection<PermissionAssignment> permissionAssignments) Globally adds all permission assignments defined in given collection.voidaddItemPermission(ItemModel item, PermissionAssignment... permissionAssignment) Adds a permission assignment(s) to an item.voidaddItemPermissions(ItemModel item, Collection<PermissionAssignment> permissionAssignments) Adds all permission assignments defined in given collection to an item.voidaddTypePermission(ComposedTypeModel type, PermissionAssignment... permissionAssignment) Adds a permission assignment(s) to a type.voidaddTypePermissions(ComposedTypeModel type, Collection<PermissionAssignment> permissionAssignments) Adds all permission assignments defined in given collection to a type.voidRemove all permission assignments from a given attribute descriptor.voidRemove all permission assignments from a given item.voidRemove all permission assignments from a given type.voidcreatePermission(String permissionName) Creates a new permission with a given name.getAttributePermissions(AttributeDescriptorModel attribute) Returns a collection representing all permission assigned to given attribute.getAttributePermissionsForName(AttributeDescriptorModel attribute, String... permissionName) Returns a collection representing permissions with specified name(s) assigned to given attribute.getAttributePermissionsForPrincipal(AttributeDescriptorModel attribute, PrincipalModel... principal) Returns a collection representing permissions assigned to given attribute for specified principal(s).Returns a collection of names of all defined permissions.getGlobalPermissionsForName(String... permissionName) Deprecated, for removal: This API element is subject to removal in a future version.since 6.0.0 - this method is for remove in future versiongetGlobalPermissionsForPrincipal(PrincipalModel... principal) Returns a collection representing all global permission assignments for specified principal(s).getItemPermissions(ItemModel item) Returns a collection representing all permission assigned to given item.getItemPermissionsForName(ItemModel item, String... permissionName) Returns a collection representing permissions with specified name(s) assigned to given item.getItemPermissionsForPrincipal(ItemModel item, PrincipalModel... principal) Returns a collection representing permissions assigned to given item for specified principal(s).Returns a collection representing all permission assigned to given type.getTypePermissionsForName(ComposedTypeModel type, String... permissionName) Returns a collection representing permissions with specified name(s) assigned to given type.getTypePermissionsForPrincipal(ComposedTypeModel type, PrincipalModel... principal) Returns a collection representing permissions assigned to given type for specified principal(s).voidremoveAttributePermission(AttributeDescriptorModel attribute, PermissionAssignment... permissionAssignment) Removes permission assignments from an attribute descriptor.voidremoveAttributePermissions(AttributeDescriptorModel attribute, Collection<PermissionAssignment> permissionAssignments) Removes permission assignments from an item.voidremoveAttributePermissionsForName(AttributeDescriptorModel attribute, String... permissionName) Removes all permission assignments from an attribute descriptor that refer to given permission name(s).voidremoveAttributePermissionsForPrincipal(AttributeDescriptorModel attribute, PrincipalModel... principal) Removes all permission assignments from an attribute descriptor that refer to given principal(s).voidremoveGlobalPermission(PermissionAssignment... permissionAssignment) Removes global permission assignment(s).voidremoveGlobalPermissions(Collection<PermissionAssignment> permissionAssignments) Removes global permission assignments.voidremoveGlobalPermissionsForName(String... permissionName) Removes all global permission assignments that refer to given permission name(s).voidremoveGlobalPermissionsForPrincipal(PrincipalModel... principal) Removes all global permission assignments that refer to given principal(s).voidremoveItemPermission(ItemModel item, PermissionAssignment... permissionAssignment) Removes permission assignments from an item.voidremoveItemPermissions(ItemModel item, Collection<PermissionAssignment> permissionAssignments) Removes permission assignments from an item.voidremoveItemPermissionsForName(ItemModel item, String... permissionName) Removes all permission assignments from an item that refer to given permission name(s).voidremoveItemPermissionsForPrincipal(ItemModel item, PrincipalModel... principal) Removes all permission assignments from an item that refer to given principal(s).voidremoveTypePermission(ComposedTypeModel type, PermissionAssignment... permissionAssignment) Removes permission assignments from a type.voidremoveTypePermissions(ComposedTypeModel type, Collection<PermissionAssignment> permissionAssignments) Removes permission assignments from a type.voidremoveTypePermissionsForName(ComposedTypeModel type, String... permissionName) Removes all permission assignments from a type that refer to given permission name(s).voidremoveTypePermissionsForPrincipal(ComposedTypeModel type, PrincipalModel... principal) Removes all permission assignments from a type that refer to given principal(s).voidsetAttributePermissions(AttributeDescriptorModel attribute, Collection<PermissionAssignment> permissionAssignments) Replaces permission assignments to an attribute descriptor with the ones in given collection.voidsetItemPermissions(ItemModel item, Collection<PermissionAssignment> permissionAssignments) Replaces permission assignments to an item with the ones in given collection.voidsetTypePermissions(ComposedTypeModel type, Collection<PermissionAssignment> permissionAssignments) Replaces existing permission assignments to a type with the ones in given collection.
-
Method Details
-
createPermission
Creates a new permission with a given name.- Parameters:
permissionName- name for permission.- Throws:
ModelSavingException- when a permission with given name already exists.
-
getDefinedPermissions
Collection<String> getDefinedPermissions()Returns a collection of names of all defined permissions. -
getItemPermissions
Returns a collection representing all permission assigned to given item. -
getItemPermissionsForPrincipal
Collection<PermissionAssignment> getItemPermissionsForPrincipal(ItemModel item, PrincipalModel... principal) Returns a collection representing permissions assigned to given item for specified principal(s). -
getItemPermissionsForName
Collection<PermissionAssignment> getItemPermissionsForName(ItemModel item, String... permissionName) Returns a collection representing permissions with specified name(s) assigned to given item. -
addItemPermission
Adds a permission assignment(s) to an item.Corner case: This method will overwrite existing permission assignment if it involves the same item, principal and permission, but with opposite value of "isGranted" flag. In other words a permission to an item cannot be assigned twice: as "granted" and as "denied" for the same principal.
-
addItemPermissions
Adds all permission assignments defined in given collection to an item. Every single permission assignment is done as inaddItemPermission(ItemModel, PermissionAssignment...)). -
setItemPermissions
Replaces permission assignments to an item with the ones in given collection. -
removeItemPermission
Removes permission assignments from an item. The value of "isGranted" flag in the permissionAssignment argument(s) is ignored. This means that an existing "denying" permission assignment will be removed even if given permissionAssignment argument "granted" flag is true. -
removeItemPermissions
Removes permission assignments from an item. The behaviour is the same as inremoveItemPermission(ItemModel, PermissionAssignment...) -
removeItemPermissionsForPrincipal
Removes all permission assignments from an item that refer to given principal(s). -
removeItemPermissionsForName
Removes all permission assignments from an item that refer to given permission name(s). -
clearItemPermissions
Remove all permission assignments from a given item. -
getTypePermissions
Returns a collection representing all permission assigned to given type. -
getTypePermissionsForPrincipal
Collection<PermissionAssignment> getTypePermissionsForPrincipal(ComposedTypeModel type, PrincipalModel... principal) Returns a collection representing permissions assigned to given type for specified principal(s). -
getTypePermissionsForName
Collection<PermissionAssignment> getTypePermissionsForName(ComposedTypeModel type, String... permissionName) Returns a collection representing permissions with specified name(s) assigned to given type. -
addTypePermission
Adds a permission assignment(s) to a type.Corner case: This method will overwrite existing permission assignment if it involves the same type, principal and permission, but with opposite value of "isGranted" flag. In other words a permission to a type cannot be assigned twice: as "granted" and as "denied" for the same principal.
-
addTypePermissions
void addTypePermissions(ComposedTypeModel type, Collection<PermissionAssignment> permissionAssignments) Adds all permission assignments defined in given collection to a type. Every single permission assignment is done as inaddTypePermission(ComposedTypeModel, PermissionAssignment...)). -
setTypePermissions
void setTypePermissions(ComposedTypeModel type, Collection<PermissionAssignment> permissionAssignments) Replaces existing permission assignments to a type with the ones in given collection. -
removeTypePermission
Removes permission assignments from a type. The value of "isGranted" flag in the permissionAssignment argument(s) is ignored. This means that an existing "denying" permission assignment will be removed even if permissionAssignment argument "granted" flag is true.. -
removeTypePermissions
void removeTypePermissions(ComposedTypeModel type, Collection<PermissionAssignment> permissionAssignments) Removes permission assignments from a type. The behaviour is the same as inremoveTypePermission(ComposedTypeModel, PermissionAssignment...) -
removeTypePermissionsForPrincipal
Removes all permission assignments from a type that refer to given principal(s). -
removeTypePermissionsForName
Removes all permission assignments from a type that refer to given permission name(s). -
clearTypePermissions
Remove all permission assignments from a given type. -
getAttributePermissions
Returns a collection representing all permission assigned to given attribute. -
getAttributePermissionsForPrincipal
Collection<PermissionAssignment> getAttributePermissionsForPrincipal(AttributeDescriptorModel attribute, PrincipalModel... principal) Returns a collection representing permissions assigned to given attribute for specified principal(s). -
getAttributePermissionsForName
Collection<PermissionAssignment> getAttributePermissionsForName(AttributeDescriptorModel attribute, String... permissionName) Returns a collection representing permissions with specified name(s) assigned to given attribute. -
addAttributePermission
void addAttributePermission(AttributeDescriptorModel attribute, PermissionAssignment... permissionAssignment) Adds a permission assignment(s) to an attribute descriptor.Corner case: This method will overwrite existing permission assignment if it involves the same attribute, principal and permission, but with opposite value of "isGranted" flag. In other words a permission to an attribute cannot be assigned twice: as "granted" and as "denied" for the same principal.
-
addAttributePermissions
void addAttributePermissions(AttributeDescriptorModel attribute, Collection<PermissionAssignment> permissionAssignments) Adds all permission assignments defined in given collection to an attribute descriptor. Every single permission assignment is done as inaddAttributePermission(AttributeDescriptorModel, PermissionAssignment...)). -
setAttributePermissions
void setAttributePermissions(AttributeDescriptorModel attribute, Collection<PermissionAssignment> permissionAssignments) Replaces permission assignments to an attribute descriptor with the ones in given collection. -
removeAttributePermission
void removeAttributePermission(AttributeDescriptorModel attribute, PermissionAssignment... permissionAssignment) Removes permission assignments from an attribute descriptor. The value of "isGranted" flag in the permissionAssignment argument(s) is ignored. This means that an existing "denying" permission assignment will be removed even if given permissionAssignment argument "granted" flag is true. -
removeAttributePermissions
void removeAttributePermissions(AttributeDescriptorModel attribute, Collection<PermissionAssignment> permissionAssignments) Removes permission assignments from an item. The behaviour is the same as inremoveAttributePermission(AttributeDescriptorModel, PermissionAssignment...) -
removeAttributePermissionsForPrincipal
void removeAttributePermissionsForPrincipal(AttributeDescriptorModel attribute, PrincipalModel... principal) Removes all permission assignments from an attribute descriptor that refer to given principal(s). -
removeAttributePermissionsForName
void removeAttributePermissionsForName(AttributeDescriptorModel attribute, String... permissionName) Removes all permission assignments from an attribute descriptor that refer to given permission name(s). -
clearAttributePermissions
Remove all permission assignments from a given attribute descriptor. -
getGlobalPermissionsForPrincipal
Returns a collection representing all global permission assignments for specified principal(s). -
getGlobalPermissionsForName
@Deprecated(since="6.0.0", forRemoval=true) Collection<PermissionAssignment> getGlobalPermissionsForName(String... permissionName) Deprecated, for removal: This API element is subject to removal in a future version.since 6.0.0 - this method is for remove in future versionReturns a collection representing all global permission assignments with specified permission name(s). -
addGlobalPermission
Adds new global permission assignments.Corner case: This method will overwrite existing permission assignment if it involves the same principal and permission, but with opposite value of "isGranted" flag. In other words a permission cannot be globally assigned twice: as "granted" and as "denied" for the same principal.
-
addGlobalPermissions
Globally adds all permission assignments defined in given collection. Every single permission assignment is done as inaddGlobalPermission(PermissionAssignment...)). -
removeGlobalPermission
Removes global permission assignment(s). The value of "isGranted" flag in the permissionAssignment argument(s) is ignored. This means that an existing global "denying" permission assignment will be removed even if given permissionAssignment argument "granted" flag is true. -
removeGlobalPermissions
Removes global permission assignments. The behaviour is the same as inremoveGlobalPermission(PermissionAssignment...) -
removeGlobalPermissionsForPrincipal
Removes all global permission assignments that refer to given principal(s). -
removeGlobalPermissionsForName
Removes all global permission assignments that refer to given permission name(s).
-