%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.security.spi.impl.ldap.LdapGroupDaoImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.security.spi.impl.ldap; |
|
18 | ||
19 | import java.security.Principal; |
|
20 | ||
21 | import javax.naming.directory.Attributes; |
|
22 | import javax.naming.directory.BasicAttribute; |
|
23 | import javax.naming.directory.BasicAttributes; |
|
24 | ||
25 | import org.apache.commons.lang.StringUtils; |
|
26 | import org.apache.jetspeed.security.SecurityException; |
|
27 | import org.apache.jetspeed.security.impl.GroupPrincipalImpl; |
|
28 | ||
29 | /** |
|
30 | * <p> |
|
31 | * DAO for handling group objects. |
|
32 | * </p> |
|
33 | * |
|
34 | * @author <a href="mailto:mike.long@dataline.com">Mike Long </a>, <a |
|
35 | * href="mailto:dlestrat@apache.org">David Le Strat</a> |
|
36 | */ |
|
37 | public class LdapGroupDaoImpl extends LdapPrincipalDaoImpl |
|
38 | { |
|
39 | ||
40 | /** |
|
41 | * <p> |
|
42 | * Default constructor. |
|
43 | * </p> |
|
44 | * |
|
45 | * @throws SecurityException A {@link SecurityException}. |
|
46 | */ |
|
47 | public LdapGroupDaoImpl() throws SecurityException |
|
48 | { |
|
49 | 0 | super(); |
50 | 0 | } |
51 | ||
52 | /** |
|
53 | * <p> |
|
54 | * Initializes the dao. |
|
55 | * </p> |
|
56 | * |
|
57 | * @param ldapConfig Holds the ldap binding configuration. |
|
58 | * @throws SecurityException A {@link SecurityException}. |
|
59 | */ |
|
60 | public LdapGroupDaoImpl(LdapBindingConfig ldapConfig) throws SecurityException |
|
61 | { |
|
62 | 0 | super(ldapConfig); |
63 | 0 | } |
64 | ||
65 | /** |
|
66 | * <p> |
|
67 | * A template method for defining the attributes for a particular LDAP class. |
|
68 | * </p> |
|
69 | * |
|
70 | * @param principalUid The principal uid. |
|
71 | * @return The LDAP attributes object for the particular class. |
|
72 | */ |
|
73 | protected Attributes defineLdapAttributes(final String principalUid) |
|
74 | { |
|
75 | 0 | Attributes attrs = new BasicAttributes(true); |
76 | 0 | BasicAttribute classes = new BasicAttribute("objectclass"); |
77 | ||
78 | 0 | for (int i=0 ; i<getObjectClasses().length ; i++) |
79 | 0 | classes.add(getObjectClasses()[i]); |
80 | 0 | attrs.put(classes); |
81 | 0 | attrs.put(getEntryPrefix(), principalUid); |
82 | 0 | if(!StringUtils.isEmpty(getGroupObjectRequiredAttributeClasses())) |
83 | { |
|
84 | 0 | String[] required = getGroupObjectRequiredAttributeClasses().split(","); |
85 | 0 | for (int i=0; i<required.length; i++) |
86 | 0 | attrs.put(required[i], ""); |
87 | } |
|
88 | 0 | for (int i=0;i<getAttributes().length;i++) |
89 | 0 | attrs.put(parseAttr(getAttributes()[i],principalUid)[0], parseAttr(getAttributes()[i],principalUid)[1]); |
90 | ||
91 | 0 | return attrs; |
92 | } |
|
93 | ||
94 | /** |
|
95 | * @see org.apache.jetspeed.security.spi.impl.ldap.LdapPrincipalDaoImpl#getDnSuffix() |
|
96 | */ |
|
97 | protected String getDnSuffix() |
|
98 | { |
|
99 | 0 | return getGroupFilterBase(); |
100 | } |
|
101 | ||
102 | /** |
|
103 | * <p> |
|
104 | * Creates a GroupPrincipal object. |
|
105 | * </p> |
|
106 | * |
|
107 | * @param principalUid The principal uid. |
|
108 | * @return A group principal object. |
|
109 | */ |
|
110 | protected Principal makePrincipal(String principalUid) |
|
111 | { |
|
112 | 0 | return new GroupPrincipalImpl(principalUid); |
113 | } |
|
114 | ||
115 | ||
116 | protected String getEntryPrefix() { |
|
117 | 0 | return this.getGroupIdAttribute(); |
118 | } |
|
119 | ||
120 | protected String getSearchSuffix() { |
|
121 | 0 | return this.getGroupFilter(); |
122 | } |
|
123 | ||
124 | protected String getSearchDomain() { |
|
125 | 0 | return this.getGroupFilterBase(); |
126 | } |
|
127 | ||
128 | protected String[] getObjectClasses() { |
|
129 | 0 | return this.getGroupObjectClasses(); |
130 | } |
|
131 | ||
132 | protected String getUidAttributeForPrincipal() { |
|
133 | 0 | return this.getGroupUidAttribute(); |
134 | } |
|
135 | ||
136 | protected String[] getAttributes() { |
|
137 | 0 | return this.getGroupAttributes(); |
138 | } |
|
139 | ||
140 | ||
141 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |