org.kuali.rice.kim.api.permission
Interface PermissionService

All Known Implementing Classes:
PermissionServiceImpl

public interface PermissionService

This service provides operations for evaluating permissions and querying for permission data.

A permission is the ability to perform an action. All permissions have a permission template. Both permissions and permission templates are uniquely identified by a namespace code plus a name. The permission template defines the course-grained permission and specifies what additional permission details need to be collected on permissions that use that template. For example, a permission template might have a name of "Initiate Document" which requires a permission detail specifying the document type that can be initiated. A permission created from the "Initiate Document" template would define the name of the specific Document Type that can be initiated as a permission detail.

The isAuthorized and isAuthorizedByTemplateName operations on this service are used to execute authorization checks for a principal against a permission. Permissions are always assigned to roles (never directly to a principal or group). A particular principal will be authorized for a given permission if the permission evaluates to true (according to the permission evaluation logic and based on any supplied permission details) and that principal is assigned to a role which has been granted the permission.

The actual logic for how permission evaluation logic is defined and executed is dependent upon the permission service implementation. However, it will typically be associated with the permission template used on the permission.

Author:
Kuali Rice Team (rice.collab@kuali.org)

Method Summary
 Permission createPermission(Permission permission)
          This will create a Permission exactly like the permission passed in.
 Permission findPermByNamespaceCodeAndName(String namespaceCode, String name)
          Get the Permission object with the unique combination of namespace and permission name.
 PermissionQueryResults findPermissions(QueryByCriteria queryByCriteria)
          This method find Permissions based on a query criteria.
 TemplateQueryResults findPermissionTemplates(QueryByCriteria queryByCriteria)
          This method find Permission Templates based on a query criteria.
 List<Permission> findPermsByNamespaceCodeTemplateName(String namespaceCode, String templateName)
          Return the permission object for the given unique combination of namespace, component and permission template name.
 Template findPermTemplateByNamespaceCodeAndName(String namespaceCode, String name)
          Return the Permission Template given the Template Name and Namespace Code.
 List<Template> getAllTemplates()
          Return all Permission Templates.
 List<Permission> getAuthorizedPermissions(String principalId, String namespaceCode, String permissionName, Map<String,String> permissionDetails, Map<String,String> qualification)
          Returns permissions (with their details) that are granted to the principal given the passed qualification.
 List<Permission> getAuthorizedPermissionsByTemplateName(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.
 Permission getPermission(String id)
          Get the permission object with the given ID.
 List<Assignee> getPermissionAssignees(String namespaceCode, String permissionName, Map<String,String> permissionDetails, Map<String,String> qualification)
          Get the list of principals/groups who have a given permission.
 List<Assignee> getPermissionAssigneesByTemplateName(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.
 Template getPermissionTemplate(String id)
          Return the Permission Template given the Template ID.
 List<String> getRoleIdsForPermission(String namespaceCode, String permissionName, Map<String,String> permissionDetails)
          Get the role IDs for the given permission.
 boolean hasPermission(String principalId, String namespaceCode, String permissionName, Map<String,String> permissionDetails)
          Checks whether the principal has been granted a permission matching the given details without taking role qualifiers into account.
 boolean hasPermissionByTemplateName(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> permissionDetails, Map<String,String> qualification)
          Checks whether the given qualified permission is granted to the principal given the passed roleQualification.
 boolean isAuthorizedByTemplateName(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, Map<String,String> permissionDetails)
          Returns true if the given permission is defined on any Roles.
 boolean isPermissionDefinedByTemplateName(String namespaceCode, String permissionTemplateName, Map<String,String> permissionDetails)
          Returns true if the given permission template is defined on any Roles.
 Permission updatePermission(Permission permission)
          This will update a Permission.
 

Method Detail

createPermission

@CacheEvict(value={"http://rice.kuali.org/kim/v2_0/PermissionType","http://rice.kuali.org/kim/v2_0/TemplateType{Permission}"},
            allEntries=true)
Permission createPermission(Permission permission)
                            throws RiceIllegalArgumentException,
                                   RiceIllegalStateException
This will create a Permission exactly like the permission passed in.

Parameters:
permission - the permission to create
Returns:
the id of the newly created object. will never be null.
Throws:
IllegalArgumentException - if the permission is null
IllegalStateException - if the permission is already existing in the system
RiceIllegalArgumentException
RiceIllegalStateException

updatePermission

@CacheEvict(value={"http://rice.kuali.org/kim/v2_0/PermissionType","http://rice.kuali.org/kim/v2_0/TemplateType{Permission}"},
            allEntries=true)
Permission updatePermission(Permission permission)
                            throws RiceIllegalArgumentException,
                                   RiceIllegalStateException
This will update a Permission.

Parameters:
permission - the permission to update
Throws:
IllegalArgumentException - if the permission is null
IllegalStateException - if the permission does not exist in the system
RiceIllegalArgumentException
RiceIllegalStateException

hasPermission

boolean hasPermission(String principalId,
                      String namespaceCode,
                      String permissionName,
                      Map<String,String> permissionDetails)
                      throws RiceIllegalArgumentException
Checks whether the principal has been granted a permission matching the given details without taking role qualifiers into account. This method should not be used for true authorization checks since a principal may only have this permission within a given context. It could be used to identify that the user would have some permissions within a certain area. Later checks would identify exactly what permissions were granted. It can also be used when the client application KNOWS that this is a role which is never qualified.

Throws:
RiceIllegalArgumentException

isAuthorized

boolean isAuthorized(String principalId,
                     String namespaceCode,
                     String permissionName,
                     Map<String,String> permissionDetails,
                     Map<String,String> qualification)
                     throws RiceIllegalArgumentException
Checks whether the given qualified permission is granted to the principal given the passed roleQualification. If no roleQualification is passed (null or empty) then this method behaves the same as #hasPermission(String, String, String, Map). 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.

Throws:
RiceIllegalArgumentException

hasPermissionByTemplateName

boolean hasPermissionByTemplateName(String principalId,
                                    String namespaceCode,
                                    String permissionTemplateName,
                                    Map<String,String> permissionDetails)
                                    throws RiceIllegalArgumentException
Checks whether the principal has been granted a permission matching the given details without taking role qualifiers into account. This method should not be used for true authorization checks since a principal may only have this permission within a given context. It could be used to identify that the user would have some permissions within a certain area. Later checks would identify exactly what permissions were granted. It can also be used when the client application KNOWS that this is a role which is never qualified.

Throws:
RiceIllegalArgumentException

isAuthorizedByTemplateName

boolean isAuthorizedByTemplateName(String principalId,
                                   String namespaceCode,
                                   String permissionTemplateName,
                                   Map<String,String> permissionDetails,
                                   Map<String,String> qualification)
                                   throws RiceIllegalArgumentException
Checks whether the given qualified permission is granted to the principal given the passed roleQualification. If no roleQualification is passed (null or empty) then this method behaves the same as #hasPermission(String, String, String, Map). 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.

Throws:
RiceIllegalArgumentException

getPermissionAssignees

List<Assignee> getPermissionAssignees(String namespaceCode,
                                      String permissionName,
                                      Map<String,String> permissionDetails,
                                      Map<String,String> qualification)
                                      throws RiceIllegalArgumentException
Get the list of principals/groups who have a given permission. This also returns delegates for the given principals/groups who also have this permission given the context in the qualification parameter. 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.

Throws:
RiceIllegalArgumentException

getPermissionAssigneesByTemplateName

List<Assignee> getPermissionAssigneesByTemplateName(String namespaceCode,
                                                    String permissionTemplateName,
                                                    Map<String,String> permissionDetails,
                                                    Map<String,String> qualification)
                                                    throws RiceIllegalArgumentException
Get the list of principals/groups who have a given permission that match the given permission template and permission details. This also returns delegates for the given principals/groups who also have this permission given the context in the qualification parameter. 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.

Throws:
RiceIllegalArgumentException

isPermissionDefined

boolean isPermissionDefined(String namespaceCode,
                            String permissionName,
                            Map<String,String> permissionDetails)
                            throws RiceIllegalArgumentException
Returns true if the given permission is defined on any Roles.

Throws:
RiceIllegalArgumentException

isPermissionDefinedByTemplateName

boolean isPermissionDefinedByTemplateName(String namespaceCode,
                                          String permissionTemplateName,
                                          Map<String,String> permissionDetails)
                                          throws RiceIllegalArgumentException
Returns true if the given permission template is defined on any Roles.

Throws:
RiceIllegalArgumentException

getAuthorizedPermissions

List<Permission> getAuthorizedPermissions(String principalId,
                                          String namespaceCode,
                                          String permissionName,
                                          Map<String,String> permissionDetails,
                                          Map<String,String> qualification)
                                          throws RiceIllegalArgumentException
Returns permissions (with their details) that are granted to the principal given the passed qualification. If no qualification is passed (null or empty) then this method does not check any qualifications on the roles. All permissions with the given name are checked against the permissionDetails. The PermissionTypeService is called for each permission to see if the permissionDetails matches its details. An asterisk (*) as a value in any permissionDetails key-value pair will match any value. This forms a way to provide a wildcard to obtain multiple permissions in one call. After the permissions are determined, the roles that hold those permissions are determined. Each role that matches between the principal and the permission objects is checked for qualifications. If a qualifier exists on the principal's membership in that role, that is checked through the role's type service.

Throws:
RiceIllegalArgumentException

getAuthorizedPermissionsByTemplateName

List<Permission> getAuthorizedPermissionsByTemplateName(String principalId,
                                                        String namespaceCode,
                                                        String permissionTemplateName,
                                                        Map<String,String> permissionDetails,
                                                        Map<String,String> qualification)
                                                        throws RiceIllegalArgumentException
Returns permissions (with their details) that are granted to the principal given the passed qualification. If no qualification is passed (null or empty) then this method does not check any qualifications on the roles. All permissions with the given name are checked against the permissionDetails. The PermissionTypeService is called for each permission to see if the permissionDetails matches its details. An asterisk (*) as a value in any permissionDetails key-value pair will match any value. This forms a way to provide a wildcard to obtain multiple permissions in one call. After the permissions are determined, the roles that hold those permissions are determined. Each role that matches between the principal and the permission objects is checked for qualifications. If a qualifier exists on the principal's membership in that role, that is checked through the role's type service.

Throws:
RiceIllegalArgumentException

getPermission

@Cacheable(value="http://rice.kuali.org/kim/v2_0/PermissionType",
           key="\'id=\' + #p0")
Permission getPermission(String id)
Get the permission object with the given ID.


findPermByNamespaceCodeAndName

@Cacheable(value="http://rice.kuali.org/kim/v2_0/PermissionType",
           key="\'namespaceCode=\' + #p0 + \'|\' + \'name=\' + #p1")
Permission findPermByNamespaceCodeAndName(String namespaceCode,
                                                    String name)
                                          throws RiceIllegalArgumentException
Get the Permission object with the unique combination of namespace and permission name. If any parameter is blank, this method returns null.

Throws:
RiceIllegalArgumentException

findPermsByNamespaceCodeTemplateName

@Cacheable(value="http://rice.kuali.org/kim/v2_0/PermissionType",
           key="\'namespaceCode=\' + #p1 + \'|\' + \'templateName=\' + #p2")
List<Permission> findPermsByNamespaceCodeTemplateName(String namespaceCode,
                                                                String templateName)
                                                      throws RiceIllegalArgumentException
Return the permission object for the given unique combination of namespace, component and permission template name.

Throws:
RiceIllegalArgumentException

getPermissionTemplate

@Cacheable(value="http://rice.kuali.org/kim/v2_0/TemplateType{Permission}",
           key="\'id=\' + #p0")
Template getPermissionTemplate(String id)
                               throws RiceIllegalArgumentException
Return the Permission Template given the Template ID.

Parameters:
id -
Returns:
PermissionTemplate
Throws:
RiceIllegalArgumentException

findPermTemplateByNamespaceCodeAndName

@Cacheable(value="http://rice.kuali.org/kim/v2_0/TemplateType{Permission}",
           key="\'namespaceCode=\' + #p0 + \'|\' + \'name=\' + #p1")
Template findPermTemplateByNamespaceCodeAndName(String namespaceCode,
                                                          String name)
                                                throws RiceIllegalArgumentException
Return the Permission Template given the Template Name and Namespace Code.

Parameters:
namespaceCode, - permissionTemplateName
Returns:
PermissionTemplate
Throws:
RiceIllegalArgumentException

getAllTemplates

@Cacheable(value="http://rice.kuali.org/kim/v2_0/TemplateType{Permission}",
           key="\'all\'")
List<Template> getAllTemplates()
Return all Permission Templates.

Returns:
PermissionTemplate

getRoleIdsForPermission

List<String> getRoleIdsForPermission(String namespaceCode,
                                     String permissionName,
                                     Map<String,String> permissionDetails)
                                     throws RiceIllegalArgumentException
Get the role IDs for the given permission.

Throws:
RiceIllegalArgumentException

findPermissions

PermissionQueryResults findPermissions(QueryByCriteria queryByCriteria)
                                       throws RiceIllegalArgumentException
This method find Permissions based on a query criteria. The criteria cannot be null.

Parameters:
queryByCriteria - the criteria. Cannot be null.
Returns:
query results. will never return null.
Throws:
IllegalArgumentException - if the queryByCriteria is null
RiceIllegalArgumentException

findPermissionTemplates

TemplateQueryResults findPermissionTemplates(QueryByCriteria queryByCriteria)
                                             throws RiceIllegalArgumentException
This method find Permission Templates based on a query criteria. The criteria cannot be null.

Parameters:
queryByCriteria - the criteria. Cannot be null.
Returns:
query results. will never return null.
Throws:
IllegalArgumentException - if the queryByCriteria is null
RiceIllegalArgumentException


Copyright © 2005-2011 The Kuali Foundation. All Rights Reserved.