1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.security.spi.impl.ldap;
18
19 import javax.naming.ldap.LdapContext;
20
21 import org.apache.commons.configuration.ConfigurationException;
22 import org.apache.commons.configuration.PropertiesConfiguration;
23 import org.apache.commons.lang.StringUtils;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27 /***
28 * <p>
29 * Holds the configuration for ldap binding.
30 * </p>
31 *
32 * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
33 */
34 public class LdapBindingConfig
35 {
36 /*** The logger. */
37 private static final Log logger = LogFactory.getLog(LdapBindingConfig.class);
38
39 private LdapContext context;
40
41 private String initialContextFactory;
42 private String ldapSocketFactory;
43 private String ldapScheme = "ldap";
44 private String ldapServerName;
45 private String ldapServerPort;
46 private String ldapSecurityLevel = "simple";
47 private String ldapSecurityProtocol;
48 private String rootDn;
49 private String rootPassword;
50 private String rootContext;
51
52 private PropertiesConfiguration props = null;
53
54 private String groupFilter;
55 private String userFilter;
56
57 private String userRoleMembershipAttributes;
58
59 private String groupMembershipAttributes;
60 private String userGroupMembershipAttributes;
61
62 private String defaultSearchBase;
63
64 private String groupFilterBase;
65 private String userFilterBase;
66
67 private String groupIdAttribute;
68 private String userIdAttribute;
69
70 private String uidAttribute;
71 private String memberShipSearchScope;
72
73 private String[] groupObjectClasses;
74
75 private String[] userObjectClasses;
76
77 private String groupMembershipForRoleAttributes;
78
79 private String groupUidAttribute;
80 private String userUidAttribute;
81
82 private String[] groupAttributes;
83 private String[] userAttributes;
84
85 private String groupObjectRequiredAttributeClasses;
86
87 private String[] roleObjectClasses;
88 private String roleGroupMembershipForRoleAttributes;
89 private String[] roleAttributes;
90 private String roleObjectRequiredAttributeClasses;
91 private String roleFilter;
92 private String roleFilterBase;
93 private String roleIdAttribute;
94 private String roleUidAttribute;
95 private String roleMembershipAttributes;
96
97 private String userPasswordAttribute;
98
99 private String[] knownAttributes;
100
101 public LdapBindingConfig()
102 {
103
104 }
105
106 public LdapBindingConfig(String factory,
107 String name,
108 String port,
109 String context,
110 String dn,
111 String password,
112 String roleFilter,
113 String groupFilter,
114 String userFilter,
115 String roleMembershipAttributes,
116 String userRoleMembershipAttributes,
117 String groupMembershipAttributes,
118 String userGroupMembershipAttributes,
119 String groupMembershipForRoleAttributes,
120 String roleGroupMembershipForRoleAttributes,
121 String defaultSearchBase,
122 String roleFilterBase,
123 String groupFilterBase,
124 String userFilterBase,
125 String roleObjectClasses,
126 String groupObjectClasses,
127 String userObjectClasses,
128 String roleIdAttribute,
129 String groupIdAttribute,
130 String userIdAttribute,
131 String uidAttribute,
132 String memberShipSearchScope,
133 String roleUidAttribute,
134 String groupUidAttribute,
135 String userUidAttribute,
136 String roleObjectRequiredAttributeClasses,
137 String groupObjectRequiredAttributeClasses,
138 String userAttributes,
139 String roleAttributes,
140 String groupAttributes,
141 String userPasswordAttribute,
142 String knownAttributes)
143 {
144 initialContextFactory = factory;
145 ldapServerName = name;
146 ldapServerPort = port;
147 rootContext = context;
148 rootDn = dn;
149 rootPassword = password;
150
151 this.roleFilter=roleFilter;
152 this.groupFilter=groupFilter;
153 this.userFilter=userFilter;
154
155 this.roleMembershipAttributes=roleMembershipAttributes;
156 this.userRoleMembershipAttributes=userRoleMembershipAttributes;
157
158 this.groupMembershipAttributes=groupMembershipAttributes;
159 this.userGroupMembershipAttributes=userGroupMembershipAttributes;
160
161 this.groupMembershipForRoleAttributes=groupMembershipForRoleAttributes;
162 this.roleGroupMembershipForRoleAttributes=roleGroupMembershipForRoleAttributes;
163 this.defaultSearchBase=defaultSearchBase;
164
165 this.roleFilterBase=roleFilterBase;
166 this.groupFilterBase=groupFilterBase;
167 this.userFilterBase=userFilterBase;
168
169
170 this.roleObjectClasses=StringUtils.split(roleObjectClasses,",");
171 this.groupObjectClasses=StringUtils.split(groupObjectClasses,",");
172 this.userObjectClasses=StringUtils.split(userObjectClasses,",");
173
174 this.roleIdAttribute=roleIdAttribute;
175 this.groupIdAttribute=groupIdAttribute;
176 this.userIdAttribute=userIdAttribute;
177
178 this.uidAttribute = uidAttribute;
179 this.memberShipSearchScope=memberShipSearchScope;
180
181
182 this.roleUidAttribute=roleUidAttribute;
183 this.groupUidAttribute=groupUidAttribute;
184 this.userUidAttribute=userUidAttribute;
185
186 this.roleObjectRequiredAttributeClasses=roleObjectRequiredAttributeClasses;
187 this.groupObjectRequiredAttributeClasses=groupObjectRequiredAttributeClasses;
188
189 this.roleAttributes=StringUtils.split(roleAttributes,",");
190 this.groupAttributes = StringUtils.split(groupAttributes,",");
191 this.userAttributes = StringUtils.split(userAttributes,",");
192
193 this.userPasswordAttribute = userPasswordAttribute;
194
195 this.knownAttributes = StringUtils.split(knownAttributes,",");
196 }
197
198 /***
199 * <p>
200 * Default constructor. By default instantiates LdapBindingConfig from
201 * JETSPEED-INF/ldap/ldap.properties in the classpath.
202 * </p>
203 */
204 public LdapBindingConfig(String ldapType)
205 {
206 try
207 {
208 props = new PropertiesConfiguration("JETSPEED-INF/directory/config/" + ldapType + "/ldap.properties");
209 initialContextFactory = props.getString("org.apache.jetspeed.ldap.initialContextFactory");
210 ldapServerName = props.getString("org.apache.jetspeed.ldap.ldapServerName");
211 ldapServerPort = props.getString("org.apache.jetspeed.ldap.ldapServerPort");
212 rootContext = props.getString("org.apache.jetspeed.ldap.rootContext");
213 rootDn = props.getString("org.apache.jetspeed.ldap.rootDn");
214 rootPassword = props.getString("org.apache.jetspeed.ldap.rootPassword");
215
216 roleFilter=props.getString("org.apache.jetspeed.ldap.RoleFilter");
217 groupFilter=props.getString("org.apache.jetspeed.ldap.GroupFilter");
218 userFilter=props.getString("org.apache.jetspeed.ldap.UserFilter");
219
220 roleMembershipAttributes=props.getString("org.apache.jetspeed.ldap.RoleMembershipAttributes");
221 userRoleMembershipAttributes=props.getString("org.apache.jetspeed.ldap.UserRoleMembershipAttributes");
222
223 groupMembershipAttributes=props.getString("org.apache.jetspeed.ldap.GroupMembershipAttributes");
224 userGroupMembershipAttributes=props.getString("org.apache.jetspeed.ldap.UserGroupMembershipAttributes");
225
226 groupMembershipForRoleAttributes=props.getString("org.apache.jetspeed.ldap.GroupMembershipForRoleAttributes");
227 roleGroupMembershipForRoleAttributes=props.getString("org.apache.jetspeed.ldap.RoleGroupMembershipForRoleAttributes");
228
229
230 defaultSearchBase=props.getString("org.apache.jetspeed.ldap.DefaultSearchBase");
231
232 roleFilterBase=props.getString("org.apache.jetspeed.ldap.RoleFilterBase");
233 groupFilterBase=props.getString("org.apache.jetspeed.ldap.GroupFilterBase");
234 userFilterBase=props.getString("org.apache.jetspeed.ldap.UserFilterBase");
235
236 this.roleObjectClasses=StringUtils.split(props.getString("org.apache.jetspeed.ldap.RoleObjectClasses"),",");
237 this.groupObjectClasses=StringUtils.split(props.getString("org.apache.jetspeed.ldap.GroupObjectClasses"),",");
238 this.userObjectClasses=StringUtils.split(props.getString("org.apache.jetspeed.ldap.UserObjectClasses"),",");
239
240 roleIdAttribute=props.getString("org.apache.jetspeed.ldap.RoleIdAttribute");
241 groupIdAttribute=props.getString("org.apache.jetspeed.ldap.GroupIdAttribute");
242 userIdAttribute=props.getString("org.apache.jetspeed.ldap.UserIdAttribute");
243
244 uidAttribute =props.getString("org.apache.jetspeed.ldap.UidAttribute");
245 memberShipSearchScope = props.getString("org.apache.jetspeed.ldap.MemberShipSearchScope");
246
247 this.roleUidAttribute=props.getString("org.apache.jetspeed.ldap.roleUidAttribute");
248 this.groupUidAttribute=props.getString("org.apache.jetspeed.ldap.groupUidAttribute");
249 this.userUidAttribute=props.getString("org.apache.jetspeed.ldap.userUidAttribute");
250
251 this.roleObjectRequiredAttributeClasses=props.getString("org.apache.jetspeed.ldap.roleObjectRequiredAttributeClasses");
252 this.groupObjectRequiredAttributeClasses=props.getString("org.apache.jetspeed.ldap.groupObjectRequiredAttributeClasses");
253
254 this.roleAttributes=StringUtils.split(props.getString("org.apache.jetspeed.ldap.roleAttributes"),",");
255 this.groupAttributes=StringUtils.split(props.getString("org.apache.jetspeed.ldap.groupAttributes"),",");
256 this.userAttributes=StringUtils.split(props.getString("org.apache.jetspeed.ldap.userAttributes"),",");
257 this.userPasswordAttribute=props.getString("org.apache.jetspeed.ldap.userPasswordAttribute");
258
259 this.knownAttributes=StringUtils.split(props.getString("org.apache.jetspeed.ldap.knownAttributes"),",");
260 }
261 catch (ConfigurationException ce)
262 {
263 logger.error("Could not configure LdapBindingConfig: " + ce);
264 }
265 }
266
267 LdapContext getContext()
268 {
269 return context;
270 }
271
272 void setContext(LdapContext context)
273 {
274 this.context = context;
275 }
276
277 /***
278 * @return Returns the initialContextFactory.
279 */
280 public String getInitialContextFactory()
281 {
282 return initialContextFactory;
283 }
284
285 /***
286 * @param initialContextFactory The initialContextFactory to set.
287 */
288 public void setInitialContextFactory(String initialContextFactory)
289 {
290 this.initialContextFactory = initialContextFactory;
291 }
292
293 /***
294 * @return the ldapScheme
295 */
296 public String getLdapScheme()
297 {
298 return ldapScheme;
299 }
300
301 /***
302 * @param ldapScheme the ldapScheme to set
303 */
304 public void setLdapScheme(String ldapScheme)
305 {
306 this.ldapScheme = ldapScheme;
307 }
308
309 /***
310 * @return the ldapSocketFactory
311 */
312 public String getLdapSocketFactory()
313 {
314 return ldapSocketFactory;
315 }
316
317 /***
318 * @param ldapSocketFactory the ldapSocketFactory to set
319 */
320 public void setLdapSocketFactory(String ldapSocketFactory)
321 {
322 this.ldapSocketFactory = ldapSocketFactory;
323 }
324
325 /***
326 * @return Returns the ldapServerName.
327 */
328 public String getLdapServerName()
329 {
330 return ldapServerName;
331 }
332
333 /***
334 * @param ldapServerName The ldapServerName to set.
335 */
336 public void setLdapServerName(String ldapServerName)
337 {
338 this.ldapServerName = ldapServerName;
339 }
340
341 /***
342 * @return Returns the ldapServerPort.
343 */
344 public String getLdapServerPort()
345 {
346 return ldapServerPort;
347 }
348
349 /***
350 * @param ldapServerPort The ldapServerPort to set.
351 */
352 public void setLdapServerPort(String ldapServerPort)
353 {
354 this.ldapServerPort = ldapServerPort;
355 }
356
357 /***
358 * @return the ldapSecurityLevel
359 */
360 public String getLdapSecurityLevel()
361 {
362 return ldapSecurityLevel;
363 }
364
365 /***
366 * @param ldapSecurityLevel the ldapSecurityLevel to set
367 */
368 public void setLdapSecurityLevel(String ldapSecurityLevel)
369 {
370 this.ldapSecurityLevel = ldapSecurityLevel;
371 }
372
373 /***
374 * @return the ldapSecurityProtocol
375 */
376 public String getLdapSecurityProtocol()
377 {
378 return ldapSecurityProtocol;
379 }
380
381 /***
382 * @param ldapSecurityProtocol the ldapSecurityProtocol to set
383 */
384 public void setLdapSecurityProtocol(String ldapSecurityProtocol)
385 {
386 this.ldapSecurityProtocol = ldapSecurityProtocol;
387 }
388
389 /***
390 * @return Returns the rootContext.
391 */
392 public String getRootContext()
393 {
394 return rootContext;
395 }
396
397 /***
398 * @param rootContext The rootContext to set.
399 */
400 public void setRootContext(String rootContext)
401 {
402 this.rootContext = rootContext;
403 }
404
405 /***
406 * @return Returns the rootDn.
407 */
408 public String getRootDn()
409 {
410 return rootDn;
411 }
412
413 /***
414 * @param rootDn The rootDn to set.
415 */
416 public void setRootDn(String rootDn)
417 {
418 this.rootDn = rootDn;
419 }
420
421 /***
422 * @return Returns the rootPassword.
423 */
424 public String getRootPassword()
425 {
426 return rootPassword;
427 }
428
429 /***
430 * @param rootPassword The rootPassword to set.
431 */
432 public void setRootPassword(String rootPassword)
433 {
434 this.rootPassword = rootPassword;
435 }
436
437 public String getUserFilter() {
438 return userFilter;
439 }
440
441 public void setUserFilter(String userFilter) {
442 this.userFilter = userFilter;
443 }
444
445 public String getUserFilterBase() {
446 return userFilterBase;
447 }
448
449 public void setUserFilterBase(String userFilterBase) {
450 this.userFilterBase = userFilterBase;
451 }
452
453 public String getUserGroupMembershipAttributes() {
454 return userGroupMembershipAttributes;
455 }
456
457 public void setUserGroupMembershipAttributes(
458 String userGroupMembershipAttributes) {
459 this.userGroupMembershipAttributes = userGroupMembershipAttributes;
460 }
461
462 public String getUserRoleMembershipAttributes() {
463 return userRoleMembershipAttributes;
464 }
465
466 public void setUserRoleMembershipAttributes(String userRoleMembershipAttributes) {
467 this.userRoleMembershipAttributes = userRoleMembershipAttributes;
468 }
469
470 public String getDefaultSearchBase() {
471 return defaultSearchBase;
472 }
473
474 public void setDefaultSearchBase(String defaultSearchBase) {
475 this.defaultSearchBase = defaultSearchBase;
476 }
477
478 public String getGroupFilter() {
479 return groupFilter;
480 }
481
482 public void setGroupFilter(String groupFilter) {
483 this.groupFilter = groupFilter;
484 }
485
486 public String getGroupFilterBase() {
487 return groupFilterBase;
488 }
489
490 public void setGroupFilterBase(String groupFilterBase) {
491 this.groupFilterBase = groupFilterBase;
492 }
493
494 public String getGroupMembershipAttributes() {
495 return groupMembershipAttributes;
496 }
497
498 public void setGroupMembershipAttributes(String groupMembershipAttributes) {
499 this.groupMembershipAttributes = groupMembershipAttributes;
500 }
501
502 public String getGroupIdAttribute() {
503 return groupIdAttribute;
504 }
505
506 public void setGroupIdAttribute(String groupIdAttribute) {
507 this.groupIdAttribute = groupIdAttribute;
508 }
509
510
511 public String getUserIdAttribute() {
512 return userIdAttribute;
513 }
514
515 public void setUserIdAttribute(String userIdAttribute) {
516 this.userIdAttribute = userIdAttribute;
517 }
518
519 public String[] getGroupObjectClasses() {
520 return groupObjectClasses;
521 }
522
523 public void setGroupObjectClasses(String[] groupObjectClasses) {
524 this.groupObjectClasses = groupObjectClasses;
525 }
526
527
528
529 public String[] getUserObjectClasses() {
530 return userObjectClasses;
531 }
532
533 public void setUserObjectClasses(String[] userObjectClasses) {
534 this.userObjectClasses = userObjectClasses;
535 }
536
537
538 public String getGroupMembershipForRoleAttributes() {
539 return this.groupMembershipForRoleAttributes;
540 }
541
542
543
544 public void setGroupMembershipForRoleAttributes(String groupMembershipForRoleAttributes) {
545 this.groupMembershipForRoleAttributes=groupMembershipForRoleAttributes;
546 }
547
548 public String getUidAttribute() {
549 return uidAttribute;
550 }
551
552 public void setUidAttribute(String uidAttribute) {
553 this.uidAttribute = uidAttribute;
554 }
555
556 public String getMemberShipSearchScope() {
557 return memberShipSearchScope;
558 }
559
560 public void setMemberShipSearchScope(String memberShipSearchScope) {
561 this.memberShipSearchScope = memberShipSearchScope;
562 }
563
564 public String getGroupUidAttribute() {
565 return this.groupUidAttribute;
566 }
567
568 public void setGroupUidAttribute(String groupUidAttribute) {
569 this.groupUidAttribute = groupUidAttribute;
570 }
571
572 public String getUserUidAttribute() {
573 return this.userUidAttribute;
574 }
575
576 public void setUserUidAttribute(String userUidAttribute) {
577 this.userUidAttribute = userUidAttribute;
578 }
579
580 public String getGroupObjectRequiredAttributeClasses() {
581 return groupObjectRequiredAttributeClasses;
582 }
583
584 public void setGroupObjectRequiredAttributeClasses(
585 String groupObjectRequiredAttributeClasses) {
586 this.groupObjectRequiredAttributeClasses = groupObjectRequiredAttributeClasses;
587 }
588
589
590
591 public String[] getGroupAttributes() {
592 return groupAttributes;
593 }
594
595 public void setGroupAttributes(String[] groupAttributes) {
596 this.groupAttributes = groupAttributes;
597 }
598
599 public String[] getUserAttributes() {
600 return userAttributes;
601 }
602
603 public void setUserAttributes(String[] userAttributes) {
604 this.userAttributes = userAttributes;
605 }
606
607 public String getRoleObjectRequiredAttributeClasses() {
608 return roleObjectRequiredAttributeClasses;
609 }
610
611 public void setRoleObjectRequiredAttributeClasses(
612 String roleObjectRequiredAttributeClasses) {
613 this.roleObjectRequiredAttributeClasses = roleObjectRequiredAttributeClasses;
614 }
615
616 public String[] getRoleAttributes() {
617 return roleAttributes;
618 }
619
620 public void setRoleAttributes(String[] roleAttributes) {
621 this.roleAttributes = roleAttributes;
622 }
623
624 public String[] getRoleObjectClasses() {
625 return roleObjectClasses;
626 }
627
628 public void setRoleObjectClasses(String[] roleObjectClasses) {
629 this.roleObjectClasses = roleObjectClasses;
630 }
631
632
633 public String getRoleGroupMembershipForRoleAttributes() {
634 return this.roleGroupMembershipForRoleAttributes;
635 }
636
637 public void setRoleGroupMembershipForRoleAttributes(String roleGroupMembershipForRoleAttributes) {
638 this.roleGroupMembershipForRoleAttributes=roleGroupMembershipForRoleAttributes;
639 }
640
641 public String getRoleFilter() {
642 return roleFilter;
643 }
644
645 public void setRoleFilter(String roleFilter) {
646 this.roleFilter = roleFilter;
647 }
648
649 public String getRoleFilterBase() {
650 return roleFilterBase;
651 }
652
653 public void setRoleFilterBase(String roleFilterBase) {
654 this.roleFilterBase = roleFilterBase;
655 }
656
657 public String getRoleMembershipAttributes() {
658 return roleMembershipAttributes;
659 }
660
661 public void setRoleMembershipAttributes(String roleMembershipAttributes) {
662 this.roleMembershipAttributes = roleMembershipAttributes;
663 }
664
665 public String getRoleUidAttribute() {
666 return this.roleUidAttribute;
667 }
668
669 public void setRoleUidAttribute(String roleUidAttribute) {
670 this.roleUidAttribute = roleUidAttribute;
671 }
672
673
674 public String getRoleIdAttribute() {
675 return roleIdAttribute;
676 }
677
678 public void setRoleIdAttribute(String roleIdAttribute) {
679 this.roleIdAttribute = roleIdAttribute;
680 }
681
682 public String getUserPasswordAttribute() {
683 return userPasswordAttribute;
684 }
685
686 public void setUserPasswordAttribute(String userPasswordAttribute) {
687 this.userPasswordAttribute = userPasswordAttribute;
688 }
689
690 public String[] getKnownAttributes() {
691 return this.knownAttributes;
692 }
693
694 public void setKnownAttributes(String[] knownAttributes) {
695 this.knownAttributes = knownAttributes;
696 }
697
698 }