Class PermissionUtils
java.lang.Object
com.broadleafcommerce.adminuser.security.domain.PermissionUtils
Convenience methods used for processing permissions and authorities
- Author:
- Phillip Verheyden (phillipuniverse)
-
Method Summary
Modifier and TypeMethodDescriptionexpandAllPermission
(String permission) Transforms a given permission into the expanded version with all of the permission types.getPermissionRoot
(String permission) Obtains the 'root' of the permission which is defined as anything that comes after one of thePermissionType.prefixes()
.static String
getPermissionType
(String permission) Obtains the permission type of the given permission based onPermissionType.prefixes()
.
-
Method Details
-
expandAllPermission
Transforms a given permission into the expanded version with all of the permission types. For example, given a permission ALL_PRODUCT this will return [CREATE_PRODUCT, READ_PRODUCT, UPDATE_PRODUCT, DELETE_PRODUCT]. Note that the result list will include the given permission if the given permission does not start with ALL_. For example, given a permission DANCE_PRODUCT, this will return [DANCE_PRODUCT].- Parameters:
permission
- a permission name- Returns:
- the CRUD-expanded ALL_ permission or a singleton list of given permission if this is not an ALL_ permission
-
getPermissionRoot
Obtains the 'root' of the permission which is defined as anything that comes after one of thePermissionType.prefixes()
. Example: given ALL_PRODUCT this will return PRODUCT and given SOME_PERMISSION this will return an empty optional- Parameters:
permission
- a permission- Returns:
- the root of permission or an empty Optional if permission does not
start with
PermissionType.prefixes()
- See Also:
-
getPermissionType
Obtains the permission type of the given permission based onPermissionType.prefixes()
. This assumes that the type is coded as a prefix in the given permission. If no permission type can be found, this returns the entire given permission unchanged.- Parameters:
permission
- a permission to get the prefix for- Returns:
- the prefix of the given permission from
PermissionType.prefixes()
or the permission unchanged if it does not have a prefix - See Also:
-