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 org.apache.commons.lang.StringUtils; |
19 | |
import org.apache.log4j.Logger; |
20 | |
import org.kuali.rice.kim.api.role.Role; |
21 | |
import org.kuali.rice.kim.api.role.RoleMembership; |
22 | |
import org.kuali.rice.kim.framework.type.KimDelegationTypeService; |
23 | |
import org.kuali.rice.kim.framework.type.KimRoleTypeService; |
24 | |
import org.kuali.rice.kim.impl.type.KimTypeServiceBase; |
25 | |
|
26 | |
import java.util.ArrayList; |
27 | |
import java.util.List; |
28 | |
import java.util.Map; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class KimRoleTypeServiceBase extends KimTypeServiceBase implements KimRoleTypeService, KimDelegationTypeService { |
37 | |
|
38 | 0 | private static final Logger LOG = Logger.getLogger(KimRoleTypeServiceBase.class); |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
public boolean doesRoleQualifierMatchQualification(Map<String, String> qualification, Map<String, String> roleQualifier) { |
48 | 0 | Map<String, String> translatedQualification = translateInputAttributes(qualification); |
49 | 0 | validateRequiredAttributesAgainstReceived(translatedQualification); |
50 | 0 | return performMatch(translatedQualification, roleQualifier); |
51 | |
} |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
public List<RoleMembership> doRoleQualifiersMatchQualification(Map<String, String> qualification, List<RoleMembership> roleMemberList) { |
57 | 0 | Map<String, String> translatedQualification = translateInputAttributes(qualification); |
58 | 0 | validateRequiredAttributesAgainstReceived(translatedQualification); |
59 | 0 | List<RoleMembership> matchingMemberships = new ArrayList<RoleMembership>(); |
60 | 0 | for ( RoleMembership roleMembership : roleMemberList ) { |
61 | 0 | if ( performMatch( translatedQualification, roleMembership.getQualifier() ) ) { |
62 | 0 | matchingMemberships.add( roleMembership ); |
63 | |
} |
64 | |
} |
65 | 0 | return matchingMemberships; |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
public List<RoleMembership> getRoleMembersFromApplicationRole(String namespaceCode, String roleName, Map<String, String> qualification) { |
75 | 0 | validateRequiredAttributesAgainstReceived(qualification); |
76 | 0 | if ( !isApplicationRoleType() ) { |
77 | 0 | throw new UnsupportedOperationException( this.getClass().getName() + " is not an application role." ); |
78 | |
} else { |
79 | 0 | throw new UnsupportedOperationException( this.getClass().getName() + " is an application role type but has not overridden this method." ); |
80 | |
} |
81 | |
} |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
public boolean hasApplicationRole(String principalId, List<String> groupIds, String namespaceCode, String roleName, Map<String, String> qualification) { |
89 | 0 | if ( !isApplicationRoleType() ) { |
90 | 0 | throw new UnsupportedOperationException( this.getClass().getName() + " is not an application role." ); |
91 | |
} |
92 | |
|
93 | 0 | if ( StringUtils.isNotBlank( principalId ) ) { |
94 | 0 | List<RoleMembership> members = getRoleMembersFromApplicationRole(namespaceCode, roleName, qualification); |
95 | 0 | for ( RoleMembership rm : members ) { |
96 | 0 | if ( StringUtils.isBlank( rm.getRoleMemberId() ) ) { |
97 | 0 | continue; |
98 | |
} |
99 | 0 | if ( rm.getMemberTypeCode().equals( Role.PRINCIPAL_MEMBER_TYPE ) ) { |
100 | 0 | if ( rm.getMemberId().equals( principalId ) ) { |
101 | 0 | return true; |
102 | |
} |
103 | |
} else { |
104 | 0 | if ( groupIds != null |
105 | |
&& groupIds.contains(rm.getMemberId())) { |
106 | 0 | return true; |
107 | |
} |
108 | |
} |
109 | |
} |
110 | |
} |
111 | 0 | return false; |
112 | |
} |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
public boolean isApplicationRoleType() { |
120 | 0 | return false; |
121 | |
} |
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
public Map<String, String> convertQualificationForMemberRoles(String namespaceCode, String roleName, String memberRoleNamespaceCode, String memberRoleName, Map<String, String> qualification) { |
129 | 0 | return qualification; |
130 | |
} |
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
public List<RoleMembership> sortRoleMembers(List<RoleMembership> roleMembers) { |
138 | 0 | return roleMembers; |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
public void principalInactivated(String principalId, String namespaceCode, |
147 | |
String roleName) { |
148 | 0 | if ( LOG.isDebugEnabled() ) { |
149 | 0 | LOG.debug( "Principal Inactivated called: principalId="+principalId+" role=" + namespaceCode + "/" + roleName ); |
150 | |
} |
151 | |
|
152 | 0 | } |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
public boolean doesDelegationQualifierMatchQualification(Map<String, String> qualification, Map<String, String> roleQualifier) { |
160 | 0 | Map<String, String> translatedQualification = translateInputAttributes(qualification); |
161 | 0 | validateRequiredAttributesAgainstReceived(translatedQualification); |
162 | 0 | return performMatch(translatedQualification, roleQualifier); |
163 | |
} |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
public boolean shouldCacheRoleMembershipResults(String namespaceCode, |
171 | |
String roleName) { |
172 | 0 | return true; |
173 | |
} |
174 | |
|
175 | |
public List<String> getQualifiersForExactMatch() { |
176 | 0 | return new ArrayList<String>(); |
177 | |
} |
178 | |
|
179 | |
} |