1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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.core.xml.dto.AttributeSet; |
22 | |
import org.kuali.rice.kim.bo.Role; |
23 | |
import org.kuali.rice.kim.bo.entity.KimPrincipal; |
24 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo; |
25 | |
import org.kuali.rice.kim.bo.role.dto.RoleMembershipInfo; |
26 | |
import org.kuali.rice.kim.service.IdentityManagementService; |
27 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
28 | |
import org.kuali.rice.kim.util.KimConstants; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public class PrincipalDerivedRoleTypeServiceImpl extends KimDerivedRoleTypeServiceBase { |
38 | |
|
39 | |
private IdentityManagementService identityManagementService; |
40 | |
|
41 | |
{ |
42 | 0 | requiredAttributes.add( KimConstants.AttributeConstants.PRINCIPAL_ID ); |
43 | 0 | checkRequiredAttributes = false; |
44 | 0 | } |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
@Override |
50 | |
public boolean performMatch(AttributeSet inputAttributeSet, AttributeSet storedAttributeSet) { |
51 | 0 | return true; |
52 | |
} |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
@Override |
60 | |
public List<RoleMembershipInfo> getRoleMembersFromApplicationRole(String namespaceCode, String roleName, AttributeSet qualification) { |
61 | 0 | ArrayList<RoleMembershipInfo> tempIdList = new ArrayList<RoleMembershipInfo>(); |
62 | 0 | if ( qualification == null || qualification.isEmpty() ) { |
63 | 0 | return tempIdList; |
64 | |
} |
65 | 0 | qualification = translateInputAttributeSet(qualification); |
66 | |
|
67 | 0 | String principalId = qualification.get( KimConstants.AttributeConstants.PRINCIPAL_ID ); |
68 | 0 | if ( hasApplicationRole(principalId, null, namespaceCode, roleName, qualification)) { |
69 | 0 | tempIdList.add( new RoleMembershipInfo(null, null, principalId, Role.PRINCIPAL_MEMBER_TYPE, null) ); |
70 | |
} |
71 | 0 | return tempIdList; |
72 | |
} |
73 | |
|
74 | |
@Override |
75 | |
public boolean hasApplicationRole(String principalId, List<String> groupIds, String namespaceCode, String roleName, AttributeSet qualification) { |
76 | |
|
77 | 0 | KimPrincipal principal = getIdentityManagementService().getPrincipal( principalId ); |
78 | 0 | if ( principal == null || !principal.isActive() ) { |
79 | 0 | return false; |
80 | |
} |
81 | |
|
82 | 0 | KimEntityDefaultInfo entity = getIdentityManagementService().getEntityDefaultInfo( principal.getEntityId() ); |
83 | 0 | if ( entity == null || !entity.isActive() ) { |
84 | 0 | return false; |
85 | |
} |
86 | 0 | return true; |
87 | |
} |
88 | |
|
89 | |
protected IdentityManagementService getIdentityManagementService() { |
90 | 0 | if ( identityManagementService == null ) { |
91 | 0 | identityManagementService = KIMServiceLocator.getIdentityManagementService(); |
92 | |
} |
93 | 0 | return identityManagementService; |
94 | |
} |
95 | |
} |