1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.service.impl; |
17 | |
|
18 | |
import java.util.Collections; |
19 | |
import java.util.List; |
20 | |
import java.util.Map; |
21 | |
|
22 | |
import org.apache.commons.collections.CollectionUtils; |
23 | |
import org.apache.commons.lang.StringUtils; |
24 | |
import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; |
25 | |
import org.kuali.rice.kim.api.identity.entity.Entity; |
26 | |
import org.kuali.rice.kim.api.identity.entity.EntityDefault; |
27 | |
import org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName; |
28 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
29 | |
import org.kuali.rice.kim.api.identity.privacy.EntityPrivacyPreferences; |
30 | |
import org.kuali.rice.kim.api.identity.IdentityService; |
31 | |
import org.kuali.rice.kim.impl.identity.IdentityServiceImpl; |
32 | |
|
33 | |
import org.kuali.rice.kim.dao.LdapPrincipalDao; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | 0 | public class LdapIdentityDelegateServiceImpl extends IdentityServiceImpl { |
43 | |
private LdapPrincipalDao principalDao; |
44 | |
|
45 | |
@Override |
46 | |
public Entity getEntity(String entityId) { |
47 | 0 | if (StringUtils.isBlank(entityId)) { |
48 | 0 | throw new RiceIllegalArgumentException("entityId is blank"); |
49 | |
} |
50 | |
|
51 | 0 | Entity edsInfo = getPrincipalDao().getEntity(entityId); |
52 | 0 | if (edsInfo != null) { |
53 | 0 | return edsInfo; |
54 | |
} else { |
55 | 0 | return super.getEntity(entityId); |
56 | |
} |
57 | |
} |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
@Override |
63 | |
public Entity getEntityByPrincipalId(String principalId) { |
64 | 0 | if (StringUtils.isBlank(principalId)) { |
65 | 0 | throw new RiceIllegalArgumentException("principalId is blank"); |
66 | |
} |
67 | |
|
68 | 0 | Entity edsInfo = getPrincipalDao().getEntityByPrincipalId(principalId); |
69 | 0 | if (edsInfo != null) { |
70 | 0 | return edsInfo; |
71 | |
} else { |
72 | 0 | return super.getEntityByPrincipalId(principalId); |
73 | |
} |
74 | |
} |
75 | |
|
76 | |
@Override |
77 | |
public Entity getEntityByPrincipalName(String principalName) { |
78 | 0 | if (StringUtils.isBlank(principalName)) { |
79 | 0 | throw new RiceIllegalArgumentException("principalName is blank"); |
80 | |
} |
81 | |
|
82 | 0 | final Entity edsInfo = getPrincipalDao().getEntityByPrincipalName(principalName); |
83 | 0 | if (edsInfo != null) { |
84 | 0 | return edsInfo; |
85 | |
} else { |
86 | 0 | return super.getEntityByPrincipalName(principalName); |
87 | |
} |
88 | |
} |
89 | |
|
90 | |
@Override |
91 | |
public EntityDefault getEntityDefault(String entityId) { |
92 | 0 | if (StringUtils.isBlank(entityId)) { |
93 | 0 | throw new RiceIllegalArgumentException("entityId is blank"); |
94 | |
} |
95 | |
|
96 | 0 | EntityDefault edsInfo = getPrincipalDao().getEntityDefault(entityId); |
97 | 0 | if (edsInfo != null) { |
98 | 0 | return edsInfo; |
99 | |
} |
100 | |
else { |
101 | 0 | return super.getEntityDefault(entityId); |
102 | |
} |
103 | |
} |
104 | |
|
105 | |
@Override |
106 | |
public EntityDefault getEntityDefaultByPrincipalId(String principalId) { |
107 | 0 | if (StringUtils.isBlank(principalId)) { |
108 | 0 | throw new RiceIllegalArgumentException("principalId is blank"); |
109 | |
} |
110 | |
|
111 | 0 | final EntityDefault retval = getPrincipalDao().getEntityDefaultByPrincipalId(principalId); |
112 | 0 | if (retval != null) { |
113 | 0 | return retval; |
114 | |
} |
115 | |
else { |
116 | 0 | return super.getEntityDefaultByPrincipalId(principalId); |
117 | |
} |
118 | |
} |
119 | |
|
120 | |
@Override |
121 | |
public EntityDefault getEntityDefaultByPrincipalName(String principalName) { |
122 | 0 | if (StringUtils.isBlank(principalName)) { |
123 | 0 | throw new RiceIllegalArgumentException("principalName is blank"); |
124 | |
} |
125 | |
|
126 | 0 | final EntityDefault retval = getPrincipalDao().getEntityDefaultByPrincipalName(principalName); |
127 | 0 | if (retval != null) { |
128 | 0 | return retval; |
129 | |
} |
130 | |
else { |
131 | 0 | return super.getEntityDefaultByPrincipalName(principalName); |
132 | |
} |
133 | |
} |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
@Override |
141 | |
@Deprecated |
142 | |
public Principal getPrincipalByPrincipalNameAndPassword(String principalName, String password) { |
143 | 0 | if (StringUtils.isBlank(principalName)) { |
144 | 0 | throw new RiceIllegalArgumentException("principalName is blank"); |
145 | |
} |
146 | |
|
147 | |
|
148 | |
|
149 | 0 | return getPrincipalByPrincipalName(principalName); |
150 | |
} |
151 | |
|
152 | |
@Override |
153 | |
public EntityPrivacyPreferences getEntityPrivacyPreferences(String entityId) { |
154 | 0 | if (StringUtils.isBlank(entityId)) { |
155 | 0 | throw new RiceIllegalArgumentException("entityId is blank"); |
156 | |
} |
157 | |
|
158 | 0 | return getPrincipalDao().getEntityPrivacyPreferences(entityId); |
159 | |
} |
160 | |
|
161 | |
@Override |
162 | |
public Principal getPrincipal(String principalId) { |
163 | 0 | if (StringUtils.isBlank(principalId)) { |
164 | 0 | throw new RiceIllegalArgumentException("principalId is blank"); |
165 | |
} |
166 | |
|
167 | 0 | final Principal edsInfo = getPrincipalDao().getPrincipal(principalId); |
168 | 0 | if (edsInfo != null) { |
169 | 0 | return edsInfo; |
170 | |
} else { |
171 | 0 | return super.getPrincipal(principalId); |
172 | |
} |
173 | |
} |
174 | |
|
175 | |
@Override |
176 | |
public Principal getPrincipalByPrincipalName(String principalName) { |
177 | 0 | if (StringUtils.isBlank(principalName)) { |
178 | 0 | throw new RiceIllegalArgumentException("principalName is blank"); |
179 | |
} |
180 | |
|
181 | 0 | final Principal edsInfo = getPrincipalDao().getPrincipalByName(principalName); |
182 | 0 | if (edsInfo != null) { |
183 | 0 | return edsInfo; |
184 | |
} else { |
185 | 0 | return super.getPrincipalByPrincipalName(principalName); |
186 | |
} |
187 | |
} |
188 | |
|
189 | |
public void setPrincipalDao(LdapPrincipalDao principalDao) { |
190 | 0 | this.principalDao = principalDao; |
191 | 0 | } |
192 | |
|
193 | |
public LdapPrincipalDao getPrincipalDao() { |
194 | 0 | return principalDao; |
195 | |
} |
196 | |
} |