Coverage Report - org.kuali.student.common.ui.server.gwt.SecurityRpcGwtServlet
 
Classes in this File Line Coverage Branch Coverage Complexity
SecurityRpcGwtServlet
0%
0/14
0%
0/2
1.5
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.common.ui.server.gwt;
 17  
 
 18  
 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
 19  
 import org.kuali.rice.kim.service.IdentityManagementService;
 20  
 import org.kuali.student.common.rice.StudentIdentityConstants;
 21  
 import org.kuali.student.common.rice.authorization.PermissionType;
 22  
 import org.kuali.student.common.ui.client.service.SecurityRpcService;
 23  
 import org.kuali.student.common.ui.client.service.exceptions.OperationFailedException;
 24  
 import org.kuali.student.common.util.security.SecurityUtils;
 25  
 
 26  
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 27  
 
 28  
 /**
 29  
  * This is a description of what this class does - Will Gomes don't forget to fill this in. 
 30  
  * 
 31  
  * @author Kuali Student Team
 32  
  *
 33  
  */
 34  0
 public class SecurityRpcGwtServlet extends RemoteServiceServlet implements SecurityRpcService{
 35  
 
 36  
     private static final long serialVersionUID = 1L;
 37  
     private IdentityManagementService permissionService;
 38  
        
 39  
     public String getPrincipalUsername(){
 40  0
             return SecurityUtils.getPrincipalUserName();
 41  
     }
 42  
 
 43  
         @Override
 44  
         public Boolean checkAdminPermission(String principalId, String screenComponent)  throws OperationFailedException {
 45  0
                 System.out.println("SecurityRpcGwtServlet.checkAdminPermission for : " + principalId + " component " + screenComponent);
 46  0
         AttributeSet permDetails = new AttributeSet();
 47  0
         permDetails.put(StudentIdentityConstants.SCREEN_COMPONENT,screenComponent);
 48  0
         boolean hasAccess = false;
 49  0
         hasAccess = getPermissionService().isAuthorizedByTemplateName(principalId, 
 50  
                                         PermissionType.KS_ADMIN_SCREEN.getPermissionNamespace(), 
 51  
                                         PermissionType.KS_ADMIN_SCREEN.getPermissionTemplateName(), permDetails, 
 52  
                                         permDetails);
 53  0
         System.out.println(principalId + " has access : " + hasAccess);
 54  0
                 return hasAccess;
 55  
         }
 56  
 
 57  
         public void setPermissionService(IdentityManagementService permissionService) {
 58  0
                 this.permissionService = permissionService;
 59  0
         }
 60  
 
 61  
         public IdentityManagementService getPermissionService()throws OperationFailedException{
 62  0
                 if(permissionService==null){
 63  0
                 throw new OperationFailedException("Permission Service is unavailable");
 64  
         }
 65  
 
 66  0
                 return permissionService;
 67  
         }
 68  
 }