Coverage Report - org.kuali.rice.krms.impl.authorization.AgendaAuthorizationServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
AgendaAuthorizationServiceImpl
0%
0/9
0%
0/2
1.333
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.krms.impl.authorization;
 17  
 
 18  
 import org.kuali.rice.kim.api.permission.PermissionService;
 19  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 20  
 import org.kuali.rice.krad.util.GlobalVariables;
 21  
 import org.kuali.rice.krms.api.KrmsConstants;
 22  
 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
 23  
 import org.kuali.rice.krms.impl.repository.ContextBoService;
 24  
 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
 25  
 
 26  
 import java.util.HashMap;
 27  
 import java.util.Map;
 28  
 
 29  0
 public class AgendaAuthorizationServiceImpl implements AgendaAuthorizationService {
 30  
 
 31  
     static final String NAMESPACE_CODE = "namespaceCode";
 32  
 
 33  
     @Override
 34  
     public boolean isAuthorized(String permissionName, String contextId) {
 35  0
         ContextDefinition context = getContextBoService().getContextByContextId(contextId);
 36  
 
 37  0
         Map qualification = new HashMap<String, String>();
 38  0
         if (contextId != null) {
 39  0
             qualification.put(NAMESPACE_CODE, context.getNamespace());
 40  
         }
 41  0
         boolean isAuthorized = getPermissionService().isAuthorized(
 42  
                 GlobalVariables.getUserSession().getPrincipalId(),
 43  
                 KrmsConstants.KRMS_NAMESPACE,
 44  
                 permissionName,
 45  
                 qualification,
 46  
                 new HashMap<String, String>());
 47  0
         return isAuthorized;
 48  
     }
 49  
 
 50  
     /**
 51  
      * return the contextBoService
 52  
      */
 53  
     private ContextBoService getContextBoService() {
 54  0
         return KrmsRepositoryServiceLocator.getContextBoService();
 55  
     }
 56  
 
 57  
     /**
 58  
      * returns the permissionService
 59  
      */
 60  
     private PermissionService getPermissionService() {
 61  0
         return KimApiServiceLocator.getPermissionService();
 62  
     }
 63  
 }