1 package org.apache.turbine.services.security.ldap;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Properties;
23
24 import org.apache.turbine.services.security.TurbineSecurity;
25
26
27
28
29
30
31
32
33
34 public class LDAPSecurityConstants
35 {
36
37 public static final String LDAP_ADMIN_USERNAME_KEY = "ldap.admin.username";
38
39
40 public static final String LDAP_ADMIN_PASSWORD_KEY = "ldap.admin.password";
41
42
43 public static final String LDAP_HOST_KEY = "ldap.host";
44
45
46 public static final String LDAP_HOST_DEFAULT = "localhost";
47
48
49 public static final String LDAP_PORT_KEY = "ldap.port";
50
51
52 public static final String LDAP_PORT_DEFAULT = "389";
53
54
55 public static final String LDAP_PROVIDER_KEY = "ldap.provider";
56
57
58 public static final String LDAP_PROVIDER_DEFAULT =
59 "com.sun.jndi.ldap.LdapCtxFactory";
60
61
62 public static final String LDAP_BASE_SEARCH_KEY = "ldap.basesearch";
63
64
65 public static final String LDAP_AUTH_KEY = "ldap.security.authentication";
66
67
68 public static final String LDAP_AUTH_DEFAULT = "simple";
69
70
71 public static final String LDAP_USER_USERID_KEY = "ldap.user.userid";
72
73
74 public static final String LDAP_USER_USERID_DEFAULT = "uid";
75
76
77 public static final String LDAP_USER_USERNAME_KEY = "ldap.user.username";
78
79
80 public static final String LDAP_USER_USERNAME_DEFAULT = "turbineUserUniqueId";
81
82
83 public static final String LDAP_USER_FIRSTNAME_KEY = "ldap.user.firstname";
84
85
86 public static final String LDAP_USER_FIRSTNAME_DEFAULT = "turbineUserFirstName";
87
88
89 public static final String LDAP_USER_LASTNAME_KEY = "ldap.user.lastname";
90
91
92 public static final String LDAP_USER_LASTNAME_DEFAULT = "turbineUserLastName";
93
94
95 public static final String LDAP_USER_EMAIL_KEY = "ldap.user.email";
96
97
98 public static final String LDAP_USER_EMAIL_DEFAULT = "turbineUserMailAddress";
99
100
101 public static final String LDAP_USER_PASSWORD_KEY = "ldap.user.password";
102
103
104 public static final String LDAP_USER_PASSWORD_DEFAULT = "userPassword";
105
106
107
108
109
110 public static Properties getProperties()
111 {
112 return TurbineSecurity.getService().getProperties();
113 }
114
115
116
117
118
119
120 public static String getProperty(String key)
121 {
122 return getProperties().getProperty(key);
123 }
124
125
126
127
128
129
130
131
132 public static String getProperty(String key, String defaultValue)
133 {
134 return getProperties().getProperty(key, defaultValue);
135 }
136
137
138
139
140
141 public static String getAdminUsername()
142 {
143 String str = getProperty(LDAP_ADMIN_USERNAME_KEY);
144
145
146
147
148
149 str = str.replace('/', '=');
150 str = str.replace('%', ',');
151 return str;
152 }
153
154
155
156
157
158 public static String getAdminPassword()
159 {
160 return getProperty(LDAP_ADMIN_PASSWORD_KEY);
161 }
162
163
164
165
166
167 public static String getLDAPHost()
168 {
169 return getProperty(LDAP_HOST_KEY, LDAP_HOST_DEFAULT);
170 }
171
172
173
174
175
176 public static String getLDAPPort()
177 {
178 return getProperty(LDAP_PORT_KEY, LDAP_PORT_DEFAULT);
179 }
180
181
182
183
184
185 public static String getLDAPProvider()
186 {
187 return getProperty(LDAP_PROVIDER_KEY, LDAP_PROVIDER_DEFAULT);
188 }
189
190
191
192
193
194 public static String getBaseSearch()
195 {
196 String str = getProperty(LDAP_BASE_SEARCH_KEY);
197
198
199
200
201
202 str = str.replace('/', '=');
203 str = str.replace('%', ',');
204 return str;
205 }
206
207
208
209
210
211
212 public static String getLDAPAuthentication()
213 {
214 return getProperty(LDAP_AUTH_KEY, LDAP_AUTH_DEFAULT);
215 }
216
217
218
219
220
221 public static String getUserIdAttribute()
222 {
223 return getProperty(LDAP_USER_USERID_KEY, LDAP_USER_USERID_DEFAULT);
224 }
225
226
227
228
229
230 public static String getNameAttribute()
231 {
232 return getProperty(LDAP_USER_USERNAME_KEY, LDAP_USER_USERNAME_DEFAULT);
233 }
234
235
236
237
238
239
240 public static String getUserNameAttribute()
241 {
242 return getNameAttribute();
243 }
244
245
246
247
248
249 public static String getFirstNameAttribute()
250 {
251 return getProperty(LDAP_USER_FIRSTNAME_KEY,
252 LDAP_USER_FIRSTNAME_DEFAULT);
253 }
254
255
256
257
258
259 public static String getLastNameAttribute()
260 {
261 return getProperty(LDAP_USER_LASTNAME_KEY, LDAP_USER_LASTNAME_DEFAULT);
262 }
263
264
265
266
267
268 public static String getPasswordAttribute()
269 {
270 return getProperty(LDAP_USER_PASSWORD_KEY, LDAP_USER_PASSWORD_DEFAULT);
271 }
272
273
274
275
276
277 public static String getEmailAttribute()
278 {
279 return getProperty(LDAP_USER_EMAIL_KEY, LDAP_USER_EMAIL_DEFAULT);
280 }
281
282 }