public class PermissionServiceImpl extends Object implements PermissionService
Modifier and Type | Field and Description |
---|---|
protected org.springframework.cache.CacheManager |
cacheManager |
protected DataObjectService |
dataObjectService |
protected PermissionTypeService |
defaultPermissionTypeService |
protected KimTypeInfoService |
kimTypeInfoService |
protected RoleService |
roleService |
Constructor and Description |
---|
PermissionServiceImpl() |
Modifier and Type | Method and Description |
---|---|
Permission |
createPermission(Permission permission)
This will create a
Permission exactly like the permission passed in. |
Permission |
findPermByNamespaceCodeAndName(String namespaceCode,
String permissionName)
Gets a
Permission with the unique combination of namespace and name. |
PermissionQueryResults |
findPermissions(QueryByCriteria queryByCriteria)
This method find Permissions based on a query criteria.
|
List<Permission> |
findPermissionsByTemplate(String namespaceCode,
String permissionTemplateName)
Return the permissions for the given unique combination of namespace,
component and permission template name.
|
TemplateQueryResults |
findPermissionTemplates(QueryByCriteria queryByCriteria)
This method find Permission Templates based on a query criteria.
|
Template |
findPermTemplateByNamespaceCodeAndName(String namespaceCode,
String permissionTemplateName)
Finds a
Template for namespaceCode and name. |
List<Template> |
getAllTemplates()
Finds a
Template for namespaceCode and name. |
List<Permission> |
getAuthorizedPermissions(String principalId,
String namespaceCode,
String permissionName,
Map<String,String> qualification)
Returns permissions (with their details) that are granted to the principal given
the passed qualification.
|
List<Permission> |
getAuthorizedPermissionsByTemplate(String principalId,
String namespaceCode,
String permissionTemplateName,
Map<String,String> permissionDetails,
Map<String,String> qualification)
Returns permissions (with their details) that are granted to the principal given
the passed qualification.
|
protected List<Permission> |
getMatchingPermissions(List<Permission> permissions,
Map<String,String> permissionDetails)
Compare each of the passed in permissions with the given permissionDetails.
|
Permission |
getPermission(String permissionId)
Gets a
Permission from an id. |
List<Assignee> |
getPermissionAssignees(String namespaceCode,
String permissionName,
Map<String,String> qualification)
Get the list of principals/groups who have a given permission.
|
List<Assignee> |
getPermissionAssigneesByTemplate(String namespaceCode,
String permissionTemplateName,
Map<String,String> permissionDetails,
Map<String,String> qualification)
Get the list of principals/groups who have a given permission that match the given
permission template and permission details.
|
protected PermissionBo |
getPermissionBoByName(String namespaceCode,
String permissionName) |
protected PermissionBo |
getPermissionImpl(String permissionId) |
protected List<Permission> |
getPermissionsByName(String namespaceCode,
String permissionName) |
protected List<Permission> |
getPermissionsByTemplateName(String namespaceCode,
String permissionTemplateName) |
protected List<Permission> |
getPermissionsForUser(String principalId,
List<Permission> permissions,
Map<String,String> qualification)
Checks the list of permissions against the principal's roles and returns a subset of the list which match.
|
Template |
getPermissionTemplate(String permissionTemplateId)
Gets a
Template from an id. |
protected PermissionTypeService |
getPermissionTypeService(Template permissionTemplate) |
protected Map<String,PermissionTypeService> |
getPermissionTypeServicesByTemplateId(Collection<Permission> permissions) |
List<String> |
getRoleIdsForPermission(String namespaceCode,
String permissionName)
Get the role IDs for the given permission.
|
protected List<String> |
getRoleIdsForPermissionTemplate(String namespaceCode,
String permissionTemplateName,
Map<String,String> permissionDetails) |
protected Map<String,List<Permission>> |
groupPermissionsByTemplate(Collection<Permission> permissions) |
boolean |
hasPermission(String principalId,
String namespaceCode,
String permissionName)
Checks in a given principal id has a permission using the passed in permission information.
|
boolean |
hasPermissionByTemplate(String principalId,
String namespaceCode,
String permissionTemplateName,
Map<String,String> permissionDetails)
Checks whether the principal has been granted a permission matching the given details
without taking role qualifiers into account.
|
boolean |
isAuthorized(String principalId,
String namespaceCode,
String permissionName,
Map<String,String> qualification)
Checks whether the given qualified permission is granted to the principal given
the passed roleQualification.
|
boolean |
isAuthorizedByTemplate(String principalId,
String namespaceCode,
String permissionTemplateName,
Map<String,String> permissionDetails,
Map<String,String> qualification)
Checks whether the given qualified permission is granted to the principal given
the passed roleQualification.
|
boolean |
isPermissionDefined(String namespaceCode,
String permissionName)
Returns true if the given permission is defined on any Roles.
|
boolean |
isPermissionDefinedByTemplate(String namespaceCode,
String permissionTemplateName,
Map<String,String> permissionDetails)
Returns true if the given permission template is defined on any Roles.
|
protected void |
logAuthorizationCheck(String checkType,
String principalId,
String namespaceCode,
String permissionName,
Map<String,String> qualification) |
protected void |
logAuthorizationCheckByTemplate(String checkType,
String principalId,
String namespaceCode,
String permissionName,
Map<String,String> permissionDetails,
Map<String,String> qualification) |
void |
setCacheManager(org.springframework.cache.CacheManager cacheManager)
Sets the cache manager which this service implementation can for internal caching.
|
void |
setDataObjectService(DataObjectService dataObjectService)
Sets the dataObjectService attribute value.
|
void |
setDefaultPermissionTypeService(PermissionTypeService defaultPermissionTypeService)
Sets the defaultPermissionTypeService attribute value.
|
void |
setKimTypeInfoService(KimTypeInfoService kimTypeInfoService)
Sets the kimTypeInfoService attribute value.
|
void |
setRoleService(RoleService roleService)
Sets the roleService attribute value.
|
Permission |
updatePermission(Permission permission)
This will update a
Permission . |
protected RoleService roleService
protected PermissionTypeService defaultPermissionTypeService
protected KimTypeInfoService kimTypeInfoService
protected DataObjectService dataObjectService
protected org.springframework.cache.CacheManager cacheManager
public PermissionServiceImpl()
protected PermissionTypeService getPermissionTypeService(Template permissionTemplate)
public boolean hasPermission(String principalId, String namespaceCode, String permissionName) throws RiceIllegalArgumentException
PermissionService
hasPermission
in interface PermissionService
principalId
- the principal id to check. cannot be null or blank.namespaceCode
- the namespace code. cannot be null or blank.permissionName
- the permission name. cannot be null or blank.RiceIllegalArgumentException
- if the principalId, namespaceCode, permissionName is null or blankpublic boolean isAuthorized(String principalId, String namespaceCode, String permissionName, Map<String,String> qualification) throws RiceIllegalArgumentException
PermissionService
PermissionService.hasPermission(String, String, String)
.
Each role assigned to the principal is checked for qualifications. If a qualifier
exists on the principal's membership in that role, that is checked first through
the role's type service. Once it is determined that the principal has the role
in the given context (qualification), the permissions are examined.isAuthorized
in interface PermissionService
principalId
- the principal id to check. cannot be null or blank.namespaceCode
- the namespace code. cannot be null or blank.permissionName
- the permission name. cannot be null or blank.qualification
- the qualifications to test against.RiceIllegalArgumentException
- if the principalId, namespaceCode, permissionName is null or blankpublic boolean hasPermissionByTemplate(String principalId, String namespaceCode, String permissionTemplateName, Map<String,String> permissionDetails) throws RiceIllegalArgumentException
PermissionService
hasPermissionByTemplate
in interface PermissionService
principalId
- the principal id to check. cannot be null or blank.namespaceCode
- the namespace code. cannot be null or blank.permissionTemplateName
- the permission name. cannot be null or blank.permissionDetails
- the permission detailsRiceIllegalArgumentException
- if the principalId, namespaceCode, permissionName is null or blankpublic boolean isAuthorizedByTemplate(String principalId, String namespaceCode, String permissionTemplateName, Map<String,String> permissionDetails, Map<String,String> qualification) throws RiceIllegalArgumentException
PermissionService
PermissionService.hasPermission(String, String, String)
.
Each role assigned to the principal is checked for qualifications. If a qualifier
exists on the principal's membership in that role, that is checked first through
the role's type service. Once it is determined that the principal has the role
in the given context (qualification), the permissions are examined.
Each permission is checked against the permissionDetails. The PermissionTypeService
is called for each permission with the given permissionName to see if the
permissionDetails matches its details.isAuthorizedByTemplate
in interface PermissionService
principalId
- the principal id to check. cannot be null or blank.namespaceCode
- the namespace code. cannot be null or blank.permissionTemplateName
- the permission name. cannot be null or blank.permissionDetails
- the permission detailsqualification
- the permission qualificationsRiceIllegalArgumentException
- if the principalId, namespaceCode, permissionName is null or blankpublic List<Permission> getAuthorizedPermissions(String principalId, String namespaceCode, String permissionName, Map<String,String> qualification) throws RiceIllegalArgumentException
PermissionService
getAuthorizedPermissions
in interface PermissionService
principalId
- the principal Id. cannot be null or blank.namespaceCode
- the namespace code. cannot be null or blank.permissionName
- the permission name. cannot be null or blank.qualification
- the permission qualificationsRiceIllegalArgumentException
- if the principalId, namespaceCode or permissionName is null or blankpublic List<Permission> getAuthorizedPermissionsByTemplate(String principalId, String namespaceCode, String permissionTemplateName, Map<String,String> permissionDetails, Map<String,String> qualification) throws RiceIllegalArgumentException
PermissionService
getAuthorizedPermissionsByTemplate
in interface PermissionService
principalId
- the principal Id. cannot be null or blank.namespaceCode
- the namespace code. cannot be null or blank.permissionTemplateName
- the permission name. cannot be null or blank.permissionDetails
- the permission template details.qualification
- the permission qualificationsRiceIllegalArgumentException
- if the principalId, namespaceCode or permissionTemplateName is null or blankprotected List<Permission> getPermissionsForUser(String principalId, List<Permission> permissions, Map<String,String> qualification)
protected Map<String,PermissionTypeService> getPermissionTypeServicesByTemplateId(Collection<Permission> permissions)
protected Map<String,List<Permission>> groupPermissionsByTemplate(Collection<Permission> permissions)
protected List<Permission> getMatchingPermissions(List<Permission> permissions, Map<String,String> permissionDetails)
public List<Assignee> getPermissionAssignees(String namespaceCode, String permissionName, Map<String,String> qualification) throws RiceIllegalArgumentException
PermissionService
getPermissionAssignees
in interface PermissionService
namespaceCode
- the namespace code. cannot be null or blank.permissionName
- the permission name. cannot be null or blank.qualification
- the permission qualificationsRiceIllegalArgumentException
- if the principalId, namespaceCode, permissionName is null or blankpublic List<Assignee> getPermissionAssigneesByTemplate(String namespaceCode, String permissionTemplateName, Map<String,String> permissionDetails, Map<String,String> qualification) throws RiceIllegalArgumentException
PermissionService
getPermissionAssigneesByTemplate
in interface PermissionService
namespaceCode
- the namespace code. cannot be null or blank.permissionTemplateName
- the permission name. cannot be null or blank.permissionDetails
- the permission details.qualification
- the permission qualificationsRiceIllegalArgumentException
- if the principalId, namespaceCode, permissionName is null or blankpublic boolean isPermissionDefined(String namespaceCode, String permissionName) throws RiceIllegalArgumentException
PermissionService
isPermissionDefined
in interface PermissionService
namespaceCode
- the namespace code. cannot be null or blank.permissionName
- the permission name. cannot be null or blank.RiceIllegalArgumentException
- if the namespaceCode or permissionName is null or blankpublic boolean isPermissionDefinedByTemplate(String namespaceCode, String permissionTemplateName, Map<String,String> permissionDetails) throws RiceIllegalArgumentException
PermissionService
isPermissionDefinedByTemplate
in interface PermissionService
namespaceCode
- the namespace code. cannot be null or blank.permissionTemplateName
- the permission name. cannot be null or blank.permissionDetails
- the permission template detailsRiceIllegalArgumentException
- if the namespaceCode or permissionName is null or blankpublic List<String> getRoleIdsForPermission(String namespaceCode, String permissionName) throws RiceIllegalArgumentException
PermissionService
getRoleIdsForPermission
in interface PermissionService
namespaceCode
- the permission namespace code. cannot be null or blank.permissionName
- the permission name. cannot be null or blank.RiceIllegalArgumentException
- if the namespaceCode or permissionName is null or blankprotected List<String> getRoleIdsForPermissionTemplate(String namespaceCode, String permissionTemplateName, Map<String,String> permissionDetails)
public Permission getPermission(String permissionId) throws RiceIllegalArgumentException
PermissionService
Permission
from an id.
This method will return null if the permission does not exist.
getPermission
in interface PermissionService
permissionId
- the unique id to retrieve the permission by. cannot be null or blank.Permission
or nullRiceIllegalArgumentException
- if the id is null or blankpublic List<Permission> findPermissionsByTemplate(String namespaceCode, String permissionTemplateName) throws RiceIllegalArgumentException
PermissionService
findPermissionsByTemplate
in interface PermissionService
namespaceCode
- namespace code for permission. cannot be null or blank.permissionTemplateName
- name of permission template. cannot be null or blank.Permission
or nullRiceIllegalArgumentException
- if the namespaceCode or name is null or blankprotected PermissionBo getPermissionImpl(String permissionId) throws RiceIllegalArgumentException
RiceIllegalArgumentException
protected List<Permission> getPermissionsByTemplateName(String namespaceCode, String permissionTemplateName)
protected List<Permission> getPermissionsByName(String namespaceCode, String permissionName)
public Template getPermissionTemplate(String permissionTemplateId) throws RiceIllegalArgumentException
PermissionService
Template
from an id.
This method will return null if the template does not exist.
getPermissionTemplate
in interface PermissionService
permissionTemplateId
- the unique id to retrieve the template by. cannot be null or blank.Template
or nullRiceIllegalArgumentException
- if the id is null or blankpublic Template findPermTemplateByNamespaceCodeAndName(String namespaceCode, String permissionTemplateName) throws RiceIllegalArgumentException
PermissionService
Template
for namespaceCode and name.findPermTemplateByNamespaceCodeAndName
in interface PermissionService
namespaceCode
- the namespace code. cannot be null or blank.permissionTemplateName
- the template name. cannot be null or blank.Template
or nullRiceIllegalArgumentException
- if the id or namespaceCode is null or blankpublic List<Template> getAllTemplates()
PermissionService
Template
for namespaceCode and name.getAllTemplates
in interface PermissionService
Template
or an empty list if none foundpublic Permission createPermission(Permission permission) throws RiceIllegalArgumentException, RiceIllegalStateException
PermissionService
Permission
exactly like the permission passed in.createPermission
in interface PermissionService
permission
- the permission to createRiceIllegalArgumentException
- if the permission is nullRiceIllegalStateException
- if the permission is already existing in the systempublic Permission updatePermission(Permission permission) throws RiceIllegalArgumentException, RiceIllegalStateException
PermissionService
Permission
.updatePermission
in interface PermissionService
permission
- the permission to updateRiceIllegalArgumentException
- if the permission is nullRiceIllegalStateException
- if the permission does not exist in the systempublic Permission findPermByNamespaceCodeAndName(String namespaceCode, String permissionName) throws RiceIllegalArgumentException
PermissionService
Permission
with the unique combination of namespace and name.
This method will return null if the permission does not exist.
findPermByNamespaceCodeAndName
in interface PermissionService
namespaceCode
- namespace code for permission. cannot be null or blank.permissionName
- name of permission. cannot be null or blank.Permission
or nullRiceIllegalArgumentException
- if the namespaceCode or name is null or blankprotected PermissionBo getPermissionBoByName(String namespaceCode, String permissionName)
public PermissionQueryResults findPermissions(QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException
PermissionService
findPermissions
in interface PermissionService
queryByCriteria
- the criteria. Cannot be null.RiceIllegalArgumentException
- if the queryByCriteria is nullpublic TemplateQueryResults findPermissionTemplates(QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException
PermissionService
findPermissionTemplates
in interface PermissionService
queryByCriteria
- the criteria. Cannot be null.RiceIllegalArgumentException
- if the queryByCriteria is nullpublic void setKimTypeInfoService(KimTypeInfoService kimTypeInfoService)
kimTypeInfoService
- The kimTypeInfoService to set.public void setDefaultPermissionTypeService(PermissionTypeService defaultPermissionTypeService)
defaultPermissionTypeService
- The defaultPermissionTypeService to set.public void setRoleService(RoleService roleService)
roleService
- The roleService to set.public void setDataObjectService(DataObjectService dataObjectService)
dataObjectService
- The dataObjectService to set.public void setCacheManager(org.springframework.cache.CacheManager cacheManager)
cacheManager
- the cache manager to use for internal caching, must not be nullIllegalArgumentException
- if a null cache manager is passedprotected void logAuthorizationCheck(String checkType, String principalId, String namespaceCode, String permissionName, Map<String,String> qualification)
Copyright © 2005–2016 The Kuali Foundation. All rights reserved.