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.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 | |
|
32 | |
|
33 | |
|
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 | |
|
47 | |
|
48 | |
@Override |
49 | |
public boolean performMatch(AttributeSet inputAttributeSet, AttributeSet storedAttributeSet) { |
50 | 0 | return true; |
51 | |
} |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
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 | |
|
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, 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 | |
|
76 | 0 | KimPrincipal principal = getIdentityManagementService().getPrincipal( principalId ); |
77 | 0 | if ( principal == null || !principal.isActive() ) { |
78 | 0 | return false; |
79 | |
} |
80 | |
|
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 | |
} |