%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.security.ldap.LDAPSecurityConstants |
|
|
1 | package org.apache.turbine.services.security.ldap; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import java.util.Properties; |
|
20 | ||
21 | import org.apache.turbine.services.security.TurbineSecurity; |
|
22 | ||
23 | /** |
|
24 | * <p>This is a static class for defining the default ldap confiquration |
|
25 | * keys used by core Turbine components.</p> |
|
26 | * |
|
27 | * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a> |
|
28 | * @author <a href="mailto:hhernandez@itweb.com.mx">Humberto Hernandez</a> |
|
29 | * @version $Id: LDAPSecurityConstants.java 264148 2005-08-29 14:21:04Z henning $ |
|
30 | */ |
|
31 | 0 | public class LDAPSecurityConstants |
32 | { |
|
33 | /** Property key */ |
|
34 | public static final String LDAP_ADMIN_USERNAME_KEY = "ldap.admin.username"; |
|
35 | ||
36 | /** Property key */ |
|
37 | public static final String LDAP_ADMIN_PASSWORD_KEY = "ldap.admin.password"; |
|
38 | ||
39 | /** Property key */ |
|
40 | public static final String LDAP_HOST_KEY = "ldap.host"; |
|
41 | ||
42 | /** Property default value */ |
|
43 | public static final String LDAP_HOST_DEFAULT = "localhost"; |
|
44 | ||
45 | /** Property key */ |
|
46 | public static final String LDAP_PORT_KEY = "ldap.port"; |
|
47 | ||
48 | /** Property default value */ |
|
49 | public static final String LDAP_PORT_DEFAULT = "389"; |
|
50 | ||
51 | /** Property key */ |
|
52 | public static final String LDAP_PROVIDER_KEY = "ldap.provider"; |
|
53 | ||
54 | /** Property default value */ |
|
55 | public static final String LDAP_PROVIDER_DEFAULT = |
|
56 | "com.sun.jndi.ldap.LdapCtxFactory"; |
|
57 | ||
58 | /** Property key */ |
|
59 | public static final String LDAP_BASE_SEARCH_KEY = "ldap.basesearch"; |
|
60 | ||
61 | /** Property key */ |
|
62 | public static final String LDAP_AUTH_KEY = "ldap.security.authentication"; |
|
63 | ||
64 | /** Property default value */ |
|
65 | public static final String LDAP_AUTH_DEFAULT = "simple"; |
|
66 | ||
67 | /** Property key */ |
|
68 | public static final String LDAP_USER_USERID_KEY = "ldap.user.userid"; |
|
69 | ||
70 | /** Property default value */ |
|
71 | public static final String LDAP_USER_USERID_DEFAULT = "uid"; |
|
72 | ||
73 | /** Property key */ |
|
74 | public static final String LDAP_USER_USERNAME_KEY = "ldap.user.username"; |
|
75 | ||
76 | /** Property default value */ |
|
77 | public static final String LDAP_USER_USERNAME_DEFAULT = "turbineUserUniqueId"; |
|
78 | ||
79 | /** Property key */ |
|
80 | public static final String LDAP_USER_FIRSTNAME_KEY = "ldap.user.firstname"; |
|
81 | ||
82 | /** Property default value */ |
|
83 | public static final String LDAP_USER_FIRSTNAME_DEFAULT = "turbineUserFirstName"; |
|
84 | ||
85 | /** Property key */ |
|
86 | public static final String LDAP_USER_LASTNAME_KEY = "ldap.user.lastname"; |
|
87 | ||
88 | /** Property default value */ |
|
89 | public static final String LDAP_USER_LASTNAME_DEFAULT = "turbineUserLastName"; |
|
90 | ||
91 | /** Property key */ |
|
92 | public static final String LDAP_USER_EMAIL_KEY = "ldap.user.email"; |
|
93 | ||
94 | /** Property default value */ |
|
95 | public static final String LDAP_USER_EMAIL_DEFAULT = "turbineUserMailAddress"; |
|
96 | ||
97 | /** Property key */ |
|
98 | public static final String LDAP_USER_PASSWORD_KEY = "ldap.user.password"; |
|
99 | ||
100 | /** Property default value */ |
|
101 | public static final String LDAP_USER_PASSWORD_DEFAULT = "userPassword"; |
|
102 | ||
103 | /** |
|
104 | * Get all the properties for the security service. |
|
105 | * @return all the properties of the security service. |
|
106 | */ |
|
107 | public static Properties getProperties() |
|
108 | { |
|
109 | 0 | return TurbineSecurity.getService().getProperties(); |
110 | } |
|
111 | ||
112 | /** |
|
113 | * Get a property from the LDAP security service. |
|
114 | * @param key The key to access the value of the property. |
|
115 | * @return The value of the property. |
|
116 | */ |
|
117 | public static String getProperty(String key) |
|
118 | { |
|
119 | 0 | return getProperties().getProperty(key); |
120 | } |
|
121 | ||
122 | /** |
|
123 | * Get a property from the LDAP security service. |
|
124 | * @param key The key to access the value of the property. |
|
125 | * @param defaultValue The value that the property takes |
|
126 | * when it doesn't exist. |
|
127 | * @return The value of the property. |
|
128 | */ |
|
129 | public static String getProperty(String key, String defaultValue) |
|
130 | { |
|
131 | 0 | return getProperties().getProperty(key, defaultValue); |
132 | } |
|
133 | ||
134 | /** |
|
135 | * Get the value of the property for the administration username. |
|
136 | * @return the value of the property. |
|
137 | */ |
|
138 | public static String getAdminUsername() |
|
139 | { |
|
140 | 0 | String str = getProperty(LDAP_ADMIN_USERNAME_KEY); |
141 | ||
142 | /* |
|
143 | * The adminUsername string contains some |
|
144 | * characters that need to be transformed. |
|
145 | */ |
|
146 | 0 | str = str.replace('/', '='); |
147 | 0 | str = str.replace('%', ','); |
148 | 0 | return str; |
149 | } |
|
150 | ||
151 | /** |
|
152 | * Get the value of the property for the administration password. |
|
153 | * @return the value of the property. |
|
154 | */ |
|
155 | public static String getAdminPassword() |
|
156 | { |
|
157 | 0 | return getProperty(LDAP_ADMIN_PASSWORD_KEY); |
158 | } |
|
159 | ||
160 | /** |
|
161 | * Get the value of the property for the LDAP Host. |
|
162 | * @return the value of the property. |
|
163 | */ |
|
164 | public static String getLDAPHost() |
|
165 | { |
|
166 | 0 | return getProperty(LDAP_HOST_KEY, LDAP_HOST_DEFAULT); |
167 | } |
|
168 | ||
169 | /** |
|
170 | * Get the value of the property for the LDAP Port. |
|
171 | * @return the value of the property. |
|
172 | */ |
|
173 | public static String getLDAPPort() |
|
174 | { |
|
175 | 0 | return getProperty(LDAP_PORT_KEY, LDAP_PORT_DEFAULT); |
176 | } |
|
177 | ||
178 | /** |
|
179 | * Get the value of the property for the LDAP Provider. |
|
180 | * @return the value of the property. |
|
181 | */ |
|
182 | public static String getLDAPProvider() |
|
183 | { |
|
184 | 0 | return getProperty(LDAP_PROVIDER_KEY, LDAP_PROVIDER_DEFAULT); |
185 | } |
|
186 | ||
187 | /** |
|
188 | * Get value of the property for the Base Search. |
|
189 | * @return the value of the property. |
|
190 | */ |
|
191 | public static String getBaseSearch() |
|
192 | { |
|
193 | 0 | String str = getProperty(LDAP_BASE_SEARCH_KEY); |
194 | ||
195 | /* |
|
196 | * The userBaseSearch string contains some |
|
197 | * characters that need to be transformed. |
|
198 | */ |
|
199 | 0 | str = str.replace('/', '='); |
200 | 0 | str = str.replace('%', ','); |
201 | 0 | return str; |
202 | } |
|
203 | ||
204 | /** |
|
205 | * Get the value of the property for the Authentication |
|
206 | * mechanism. Valid values are: none, simple, |
|
207 | * @return the value of the property. |
|
208 | */ |
|
209 | public static String getLDAPAuthentication() |
|
210 | { |
|
211 | 0 | return getProperty(LDAP_AUTH_KEY, LDAP_AUTH_DEFAULT); |
212 | } |
|
213 | ||
214 | /** |
|
215 | * Get the value of the User id Attribute. |
|
216 | * @return the value of the property. |
|
217 | */ |
|
218 | public static String getUserIdAttribute() |
|
219 | { |
|
220 | 0 | return getProperty(LDAP_USER_USERID_KEY, LDAP_USER_USERID_DEFAULT); |
221 | } |
|
222 | ||
223 | /** |
|
224 | * Get the value of the Username Attribute. |
|
225 | * @return the value of the property. |
|
226 | */ |
|
227 | public static String getNameAttribute() |
|
228 | { |
|
229 | 0 | return getProperty(LDAP_USER_USERNAME_KEY, LDAP_USER_USERNAME_DEFAULT); |
230 | } |
|
231 | ||
232 | /** |
|
233 | * Get the value of the Username Attribute. |
|
234 | * @return the value of the property. |
|
235 | * @deprecated Use getNameAttribute() |
|
236 | */ |
|
237 | public static String getUserNameAttribute() |
|
238 | { |
|
239 | 0 | return getNameAttribute(); |
240 | } |
|
241 | ||
242 | /** |
|
243 | * Get the value of the Firstname Attribute. |
|
244 | * @return the value of the property. |
|
245 | */ |
|
246 | public static String getFirstNameAttribute() |
|
247 | { |
|
248 | 0 | return getProperty(LDAP_USER_FIRSTNAME_KEY, |
249 | LDAP_USER_FIRSTNAME_DEFAULT); |
|
250 | } |
|
251 | ||
252 | /** |
|
253 | * Get the value of the Lastname Attribute. |
|
254 | * @return the value of the property. |
|
255 | */ |
|
256 | public static String getLastNameAttribute() |
|
257 | { |
|
258 | 0 | return getProperty(LDAP_USER_LASTNAME_KEY, LDAP_USER_LASTNAME_DEFAULT); |
259 | } |
|
260 | ||
261 | /** |
|
262 | * Get the value of the Password Attribute. |
|
263 | * @return the value of the property. |
|
264 | */ |
|
265 | public static String getPasswordAttribute() |
|
266 | { |
|
267 | 0 | return getProperty(LDAP_USER_PASSWORD_KEY, LDAP_USER_PASSWORD_DEFAULT); |
268 | } |
|
269 | ||
270 | /** |
|
271 | * Get the value of the E-Mail Attribute. |
|
272 | * @return the value of the property. |
|
273 | */ |
|
274 | public static String getEmailAttribute() |
|
275 | { |
|
276 | 0 | return getProperty(LDAP_USER_EMAIL_KEY, LDAP_USER_EMAIL_DEFAULT); |
277 | } |
|
278 | ||
279 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |