Coverage Report - org.kuali.rice.kim.service.support.impl.PrincipalDerivedRoleTypeServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
PrincipalDerivedRoleTypeServiceImpl
0%
0/23
0%
0/16
3.75
 
 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.support.impl;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import org.kuali.rice.kim.bo.Role;
 22  
 import org.kuali.rice.kim.bo.entity.KimPrincipal;
 23  
 import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo;
 24  
 import org.kuali.rice.kim.bo.impl.KimAttributes;
 25  
 import org.kuali.rice.kim.bo.role.dto.RoleMembershipInfo;
 26  
 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
 27  
 import org.kuali.rice.kim.service.IdentityManagementService;
 28  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 29  
 
 30  
 /**
 31  
  * This is a description of what this class does - kellerj don't forget to fill this in. 
 32  
  * 
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  *
 35  
  */
 36  0
 public class PrincipalDerivedRoleTypeServiceImpl extends KimDerivedRoleTypeServiceBase {
 37  
         
 38  
         private IdentityManagementService identityManagementService;
 39  
         
 40  
         {
 41  0
                 requiredAttributes.add( KimAttributes.PRINCIPAL_ID );
 42  0
                 checkRequiredAttributes = false;
 43  0
         }
 44  
         
 45  
         /**
 46  
          * @see org.kuali.rice.kim.service.support.impl.KimTypeServiceBase#performMatch(org.kuali.rice.kim.bo.types.dto.AttributeSet, org.kuali.rice.kim.bo.types.dto.AttributeSet)
 47  
          */
 48  
         @Override
 49  
         public boolean performMatch(AttributeSet inputAttributeSet, AttributeSet storedAttributeSet) {
 50  0
                 return true;
 51  
         }
 52  
 
 53  
         /**
 54  
          * Since this is potentially the entire set of users, just check the qualification for the user we are interested in and return it.
 55  
          * 
 56  
          * @see org.kuali.rice.kim.service.support.impl.RoleTypeServiceBase#getRoleMembersFromApplicationRole(String, String, AttributeSet)
 57  
          */
 58  
         @Override
 59  
     public List<RoleMembershipInfo> getRoleMembersFromApplicationRole(String namespaceCode, String roleName, AttributeSet qualification) {
 60  0
                 ArrayList<RoleMembershipInfo> tempIdList = new ArrayList<RoleMembershipInfo>();
 61  0
                 if ( qualification == null || qualification.isEmpty() ) {
 62  0
                         return tempIdList;
 63  
                 }
 64  0
                 qualification = translateInputAttributeSet(qualification);
 65  
                 // check that the principal ID is not null
 66  0
                 String principalId = qualification.get( KimAttributes.PRINCIPAL_ID );
 67  0
                 if ( hasApplicationRole(principalId, null, namespaceCode, roleName, qualification)) {
 68  0
                 tempIdList.add( new RoleMembershipInfo(null/*roleId*/, null, principalId, Role.PRINCIPAL_MEMBER_TYPE, null) );
 69  
                 }
 70  0
                 return tempIdList;
 71  
         }
 72  
         
 73  
         @Override
 74  
         public boolean hasApplicationRole(String principalId, List<String> groupIds, String namespaceCode, String roleName, AttributeSet qualification) {
 75  
         // check that the principal exists and is active
 76  0
         KimPrincipal principal = getIdentityManagementService().getPrincipal( principalId );
 77  0
         if ( principal == null || !principal.isActive() ) {
 78  0
             return false;
 79  
         }
 80  
         // check that the entity is active
 81  0
         KimEntityDefaultInfo entity = getIdentityManagementService().getEntityDefaultInfo( principal.getEntityId() );
 82  0
         if ( entity == null || !entity.isActive() ) {
 83  0
             return false;
 84  
         }
 85  0
         return true;
 86  
         }
 87  
         
 88  
         protected IdentityManagementService getIdentityManagementService() {
 89  0
                 if ( identityManagementService == null ) {
 90  0
                         identityManagementService = KIMServiceLocator.getIdentityManagementService();
 91  
                 }
 92  0
                 return identityManagementService;
 93  
         }
 94  
 }