Coverage Report - org.kuali.rice.kim.service.PermissionService
 
Classes in this File Line Coverage Branch Coverage Complexity
PermissionService
N/A
N/A
1
 
 1  
 /*
 2  
  * Copyright 2008 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kim.service;
 17  
 
 18  
 import org.kuali.rice.core.util.jaxb.MapStringStringAdapter;
 19  
 import org.kuali.rice.kim.api.permission.Permission;
 20  
 import org.kuali.rice.kim.bo.role.dto.KimPermissionTemplateInfo;
 21  
 import org.kuali.rice.kim.bo.role.dto.PermissionAssigneeInfo;
 22  
 import org.kuali.rice.kim.util.KIMWebServiceConstants;
 23  
 
 24  
 import javax.jws.WebParam;
 25  
 import javax.jws.WebService;
 26  
 import javax.jws.soap.SOAPBinding;
 27  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 28  
 import java.util.List;
 29  
 import java.util.Map;
 30  
 
 31  
 /**
 32  
  * This service provides operations for evaluating permissions and querying for permission data.
 33  
  * 
 34  
  * <p>A permission is the ability to perform an action.  All permissions have a permission template.
 35  
  * Both permissions and permission templates are uniquely identified by a namespace code plus a name.
 36  
  * The permission template defines the course-grained permission and specifies what additional
 37  
  * permission details need to be collected on permissions that use that template.  For example, a
 38  
  * permission template might have a name of "Initiate Document" which requires a permission detail
 39  
  * specifying the document type that can be initiated.  A permission created from the "Initiate Document"
 40  
  * template would define the name of the specific Document Type that can be initiated as a permission
 41  
  * detail.
 42  
  * 
 43  
  * <p>The isAuthorized and isAuthorizedByTemplateName operations
 44  
  * on this service are used to execute authorization checks for a principal against a
 45  
  * permission.  Permissions are always assigned to roles (never directly to a principal or
 46  
  * group).  A particular principal will be authorized for a given permission if the permission
 47  
  * evaluates to true (according to the permission evaluation logic and based on any supplied
 48  
  * permission details) and that principal is assigned to a role which has been granted the permission.
 49  
  * 
 50  
  * <p>The actual logic for how permission evaluation logic is defined and executed is dependent upon
 51  
  * the permission service implementation.  However, it will typically be associated with the permission
 52  
  * template used on the permission. 
 53  
  * 
 54  
  * <p>This service provides read-only operations.  For write operations, see
 55  
  * {@link PermissionUpdateService}.
 56  
  * 
 57  
  * @see PermissionUpdateService
 58  
  * 
 59  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 60  
  */
 61  
 @WebService(name = KIMWebServiceConstants.PermissionService.WEB_SERVICE_NAME, targetNamespace = KIMWebServiceConstants.MODULE_TARGET_NAMESPACE)
 62  
 @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
 63  
 public interface PermissionService {
 64  
             
 65  
     // --------------------
 66  
     // Authorization Checks
 67  
     // --------------------
 68  
 
 69  
     /**
 70  
      * Checks whether the principal has been granted a permission matching the given details
 71  
      * without taking role qualifiers into account.
 72  
      * 
 73  
          * This method should not be used for true authorization checks since a principal
 74  
          * may only have this permission within a given context.  It could be used to
 75  
          * identify that the user would have some permissions within a certain area.
 76  
          * Later checks would identify exactly what permissions were granted.
 77  
          * 
 78  
          * It can also be used when the client application KNOWS that this is a role which
 79  
          * is never qualified.
 80  
      */
 81  
     boolean hasPermission( @WebParam(name="principalId") String principalId,
 82  
                                                @WebParam(name="namespaceCode") String namespaceCode,
 83  
                                                @WebParam(name="permissionName") String permissionName,
 84  
                                                @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails );
 85  
 
 86  
     /**
 87  
      * Checks whether the given qualified permission is granted to the principal given
 88  
      * the passed roleQualification.  If no roleQualification is passed (null or empty)
 89  
      * then this method behaves the same as {@link #hasPermission(String, String, String, Map<String, String>)}.
 90  
      * 
 91  
      * Each role assigned to the principal is checked for qualifications.  If a qualifier 
 92  
      * exists on the principal's membership in that role, that is checked first through
 93  
      * the role's type service.  Once it is determined that the principal has the role
 94  
      * in the given context (qualification), the permissions are examined.
 95  
      * 
 96  
      * Each permission is checked against the permissionDetails.  The KimPermissionTypeService
 97  
      * is called for each permission with the given permissionName to see if the 
 98  
      * permissionDetails matches its details.
 99  
      */
 100  
     boolean isAuthorized( @WebParam(name="principalId") String principalId,
 101  
                                               @WebParam(name="namespaceCode") String namespaceCode,
 102  
                                               @WebParam(name="permissionName") String permissionName,
 103  
                                               @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails,
 104  
                                               @WebParam(name="qualification") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> qualification  );
 105  
 
 106  
     /**
 107  
      * Checks whether the principal has been granted a permission matching the given details
 108  
      * without taking role qualifiers into account.
 109  
      * 
 110  
          * This method should not be used for true authorization checks since a principal
 111  
          * may only have this permission within a given context.  It could be used to
 112  
          * identify that the user would have some permissions within a certain area.
 113  
          * Later checks would identify exactly what permissions were granted.
 114  
          * 
 115  
          * It can also be used when the client application KNOWS that this is a role which
 116  
          * is never qualified.
 117  
      */
 118  
     boolean hasPermissionByTemplateName( @WebParam(name="principalId") String principalId,
 119  
                                                                              @WebParam(name="namespaceCode") String namespaceCode,
 120  
                                                                              @WebParam(name="permissionTemplateName") String permissionTemplateName,
 121  
                                                                              @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails );
 122  
     
 123  
     /**
 124  
      * Checks whether the given qualified permission is granted to the principal given
 125  
      * the passed roleQualification.  If no roleQualification is passed (null or empty)
 126  
      * then this method behaves the same as {@link #hasPermission(String, String, String, Map<String, String>)}.
 127  
      * 
 128  
      * Each role assigned to the principal is checked for qualifications.  If a qualifier 
 129  
      * exists on the principal's membership in that role, that is checked first through
 130  
      * the role's type service.  Once it is determined that the principal has the role
 131  
      * in the given context (qualification), the permissions are examined.
 132  
      * 
 133  
      * Each permission is checked against the permissionDetails.  The KimPermissionTypeService
 134  
      * is called for each permission with the given permissionName to see if the 
 135  
      * permissionDetails matches its details.
 136  
      */
 137  
     boolean isAuthorizedByTemplateName( @WebParam(name="principalId") String principalId,
 138  
                                                                             @WebParam(name="namespaceCode") String namespaceCode,
 139  
                                                                             @WebParam(name="permissionTemplateName") String permissionTemplateName,
 140  
                                                                             @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails,
 141  
                                                                             @WebParam(name="qualification") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> qualification  );
 142  
     
 143  
     
 144  
     /**
 145  
      * Get the list of principals/groups who have a given permission.  This also returns delegates
 146  
      * for the given principals/groups who also have this permission given the context in the
 147  
      * qualification parameter.
 148  
      * 
 149  
      * Each role assigned to the principal is checked for qualifications.  If a qualifier 
 150  
      * exists on the principal's membership in that role, that is checked first through
 151  
      * the role's type service.  Once it is determined that the principal has the role
 152  
      * in the given context (qualification), the permissions are examined.
 153  
      * 
 154  
      */
 155  
     List<PermissionAssigneeInfo> getPermissionAssignees( @WebParam(name="namespaceCode") String namespaceCode,
 156  
                                                                                                              @WebParam(name="permissionName") String permissionName,
 157  
                                                                                                              @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails,
 158  
                                                                                                              @WebParam(name="qualification") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> qualification );
 159  
 
 160  
     /**
 161  
      * Get the list of principals/groups who have a given permission that match the given 
 162  
      * permission template and permission details.  This also returns delegates
 163  
      * for the given principals/groups who also have this permission given the context in the
 164  
      * qualification parameter.
 165  
      * 
 166  
      * Each role assigned to the principal is checked for qualifications.  If a qualifier 
 167  
      * exists on the principal's membership in that role, that is checked first through
 168  
      * the role's type service.  Once it is determined that the principal has the role
 169  
      * in the given context (qualification), the permissions are examined.
 170  
      * 
 171  
      */
 172  
     List<PermissionAssigneeInfo> getPermissionAssigneesForTemplateName( @WebParam(name="namespaceCode") String namespaceCode,
 173  
                                                                                                                                             @WebParam(name="permissionTemplateName") String permissionTemplateName,
 174  
                                                                                                                                             @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails,
 175  
                                                                                                                                             @WebParam(name="qualification") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> qualification );
 176  
     
 177  
     /**
 178  
      * Returns true if the given permission is defined on any Roles.
 179  
      */
 180  
     boolean isPermissionDefined( @WebParam(name="namespaceCode") String namespaceCode,
 181  
                                                              @WebParam(name="permissionName") String permissionName,
 182  
                                                              @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails );
 183  
     
 184  
     /**
 185  
      * Returns true if the given permission template is defined on any Roles.
 186  
      */
 187  
     boolean isPermissionDefinedForTemplateName( @WebParam(name="namespaceCode") String namespaceCode,
 188  
                                                                                             @WebParam(name="permissionTemplateName") String permissionTemplateName,
 189  
                                                                                             @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails );
 190  
     
 191  
     /**
 192  
      * Returns permissions (with their details) that are granted to the principal given
 193  
      * the passed qualification.  If no qualification is passed (null or empty)
 194  
      * then this method does not check any qualifications on the roles.
 195  
      * 
 196  
      * All permissions with the given name are checked against the permissionDetails.  
 197  
      * The KimPermissionTypeService is called for each permission to see if the 
 198  
      * permissionDetails matches its details.
 199  
      * 
 200  
      * An asterisk (*) as a value in any permissionDetails key-value pair will match any value.
 201  
      * This forms a way to provide a wildcard to obtain multiple permissions in one call.
 202  
      * 
 203  
      * After the permissions are determined, the roles that hold those permissions are determined.
 204  
      * Each role that matches between the principal and the permission objects is checked for 
 205  
      * qualifications.  If a qualifier 
 206  
      * exists on the principal's membership in that role, that is checked through
 207  
      * the role's type service. 
 208  
      * 
 209  
      */
 210  
     List<Permission> getAuthorizedPermissions(@WebParam(name = "principalId") String principalId,
 211  
                                               @WebParam(name = "namespaceCode") String namespaceCode,
 212  
                                               @WebParam(name = "permissionName") String permissionName,
 213  
                                               @WebParam(name = "permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails,
 214  
                                               @WebParam(name = "qualification") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> qualification);
 215  
 
 216  
     /**
 217  
      * Returns permissions (with their details) that are granted to the principal given
 218  
      * the passed qualification.  If no qualification is passed (null or empty)
 219  
      * then this method does not check any qualifications on the roles.
 220  
      * 
 221  
      * All permissions with the given name are checked against the permissionDetails.  
 222  
      * The KimPermissionTypeService is called for each permission to see if the 
 223  
      * permissionDetails matches its details.
 224  
      * 
 225  
      * An asterisk (*) as a value in any permissionDetails key-value pair will match any value.
 226  
      * This forms a way to provide a wildcard to obtain multiple permissions in one call.
 227  
      * 
 228  
      * After the permissions are determined, the roles that hold those permissions are determined.
 229  
      * Each role that matches between the principal and the permission objects is checked for 
 230  
      * qualifications.  If a qualifier 
 231  
      * exists on the principal's membership in that role, that is checked through
 232  
      * the role's type service. 
 233  
      * 
 234  
      */
 235  
     List<Permission> getAuthorizedPermissionsByTemplateName(@WebParam(name = "principalId") String principalId,
 236  
                                                             @WebParam(name = "namespaceCode") String namespaceCode,
 237  
                                                             @WebParam(name = "permissionTemplateName") String permissionTemplateName,
 238  
                                                             @WebParam(name = "permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails,
 239  
                                                             @WebParam(name = "qualification") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> qualification);
 240  
 
 241  
     // --------------------
 242  
     // Permission Data
 243  
     // --------------------
 244  
 
 245  
     /**
 246  
      * Get the permission object with the given ID.
 247  
      */
 248  
     Permission getPermission(@WebParam(name = "permissionId") String permissionId);
 249  
    
 250  
         /** 
 251  
          * Return the permission object for the given unique combination of namespace,
 252  
          * component and permission template name.
 253  
          */
 254  
     List<Permission> getPermissionsByTemplateName(@WebParam(name = "namespaceCode") String namespaceCode,
 255  
             @WebParam(name = "permissionTemplateName") String permissionTemplateName);
 256  
 
 257  
         /** 
 258  
          * Return the permission object for the given unique combination of namespace,
 259  
          * component and permission name.
 260  
          */
 261  
     Permission getPermissionsByName(@WebParam(name = "namespaceCode") String namespaceCode,
 262  
                                           @WebParam(name = "permissionName") String permissionName);
 263  
     
 264  
     KimPermissionTemplateInfo getPermissionTemplate( @WebParam(name="permissionTemplateId") String permissionTemplateId );
 265  
 
 266  
     KimPermissionTemplateInfo getPermissionTemplateByName( @WebParam(name="namespaceCode") String namespaceCode,
 267  
                                                                                                                      @WebParam(name="permissionTemplateName") String permissionTemplateName );
 268  
     public List<KimPermissionTemplateInfo> getAllTemplates();
 269  
     /**
 270  
      * Search for permissions using arbitrary search criteria.  JavaBeans property syntax 
 271  
      * should be used to reference the properties.
 272  
      * 
 273  
      * If the searchCriteria parameter is null or empty, an empty list will be returned.
 274  
      */
 275  
     List<Permission> lookupPermissions(@WebParam(name = "searchCriteria") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> searchCriteria,
 276  
                                        @WebParam(name = "unbounded") boolean unbounded);
 277  
     
 278  
     /**
 279  
      * Get the role IDs for the given permission.
 280  
      */
 281  
     List<String> getRoleIdsForPermission( @WebParam(name="namespaceCode") String namespaceCode,
 282  
                                                                               @WebParam(name="permissionName") String permissionName,
 283  
                                                                               @WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> permissionDetails);
 284  
     
 285  
     /**
 286  
      * Get the role IDs for the given list of permissions.
 287  
      */
 288  
     List<String> getRoleIdsForPermissions( @WebParam(name="permissions") List<Permission> permissions );
 289  
     
 290  
     /**
 291  
      * Returns the label of the permission detail for the given permissionId, kimType and attributeName. 
 292  
      */
 293  
     public String getPermissionDetailLabel( String permissionId, String kimTypeId, String attributeName);
 294  
 
 295  
     /**
 296  
      * Get the role IDs for the given permission.
 297  
      */
 298  
     List<String> getRoleIdsForPermissionId(@WebParam(name = "permissionId") String permissionId);
 299  
 
 300  
     /**
 301  
      * Return the permission object for the given unique combination of namespace, component and permission name. Inactive
 302  
      * permissions are also returned
 303  
      */
 304  
     Permission getPermissionsByNameIncludingInactive(@WebParam(name = "namespaceCode") String namespaceCode, @WebParam(name = "permissionName") String permissionName);
 305  
 }