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 public class LdapIdentityDelegateServiceImpl extends IdentityServiceImpl {
43 private LdapPrincipalDao principalDao;
44
45 @Override
46 public Entity getEntity(String entityId) {
47 if (StringUtils.isBlank(entityId)) {
48 throw new RiceIllegalArgumentException("entityId is blank");
49 }
50
51 Entity edsInfo = getPrincipalDao().getEntity(entityId);
52 if (edsInfo != null) {
53 return edsInfo;
54 } else {
55 return super.getEntity(entityId);
56 }
57 }
58
59
60
61
62 @Override
63 public Entity getEntityByPrincipalId(String principalId) {
64 if (StringUtils.isBlank(principalId)) {
65 throw new RiceIllegalArgumentException("principalId is blank");
66 }
67
68 Entity edsInfo = getPrincipalDao().getEntityByPrincipalId(principalId);
69 if (edsInfo != null) {
70 return edsInfo;
71 } else {
72 return super.getEntityByPrincipalId(principalId);
73 }
74 }
75
76 @Override
77 public Entity getEntityByPrincipalName(String principalName) {
78 if (StringUtils.isBlank(principalName)) {
79 throw new RiceIllegalArgumentException("principalName is blank");
80 }
81
82 final Entity edsInfo = getPrincipalDao().getEntityByPrincipalName(principalName);
83 if (edsInfo != null) {
84 return edsInfo;
85 } else {
86 return super.getEntityByPrincipalName(principalName);
87 }
88 }
89
90 @Override
91 public EntityDefault getEntityDefault(String entityId) {
92 if (StringUtils.isBlank(entityId)) {
93 throw new RiceIllegalArgumentException("entityId is blank");
94 }
95
96 EntityDefault edsInfo = getPrincipalDao().getEntityDefault(entityId);
97 if (edsInfo != null) {
98 return edsInfo;
99 }
100 else {
101 return super.getEntityDefault(entityId);
102 }
103 }
104
105 @Override
106 public EntityDefault getEntityDefaultByPrincipalId(String principalId) {
107 if (StringUtils.isBlank(principalId)) {
108 throw new RiceIllegalArgumentException("principalId is blank");
109 }
110
111 final EntityDefault retval = getPrincipalDao().getEntityDefaultByPrincipalId(principalId);
112 if (retval != null) {
113 return retval;
114 }
115 else {
116 return super.getEntityDefaultByPrincipalId(principalId);
117 }
118 }
119
120 @Override
121 public EntityDefault getEntityDefaultByPrincipalName(String principalName) {
122 if (StringUtils.isBlank(principalName)) {
123 throw new RiceIllegalArgumentException("principalName is blank");
124 }
125
126 final EntityDefault retval = getPrincipalDao().getEntityDefaultByPrincipalName(principalName);
127 if (retval != null) {
128 return retval;
129 }
130 else {
131 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 if (StringUtils.isBlank(principalName)) {
144 throw new RiceIllegalArgumentException("principalName is blank");
145 }
146
147
148
149 return getPrincipalByPrincipalName(principalName);
150 }
151
152 @Override
153 public EntityPrivacyPreferences getEntityPrivacyPreferences(String entityId) {
154 if (StringUtils.isBlank(entityId)) {
155 throw new RiceIllegalArgumentException("entityId is blank");
156 }
157
158 return getPrincipalDao().getEntityPrivacyPreferences(entityId);
159 }
160
161 @Override
162 public Principal getPrincipal(String principalId) {
163 if (StringUtils.isBlank(principalId)) {
164 throw new RiceIllegalArgumentException("principalId is blank");
165 }
166
167 final Principal edsInfo = getPrincipalDao().getPrincipal(principalId);
168 if (edsInfo != null) {
169 return edsInfo;
170 } else {
171 return super.getPrincipal(principalId);
172 }
173 }
174
175 @Override
176 public Principal getPrincipalByPrincipalName(String principalName) {
177 if (StringUtils.isBlank(principalName)) {
178 throw new RiceIllegalArgumentException("principalName is blank");
179 }
180
181 final Principal edsInfo = getPrincipalDao().getPrincipalByName(principalName);
182 if (edsInfo != null) {
183 return edsInfo;
184 } else {
185 return super.getPrincipalByPrincipalName(principalName);
186 }
187 }
188
189 public void setPrincipalDao(LdapPrincipalDao principalDao) {
190 this.principalDao = principalDao;
191 }
192
193 public LdapPrincipalDao getPrincipalDao() {
194 return principalDao;
195 }
196 }