1 package org.apache.turbine.services.security.ldap; 2 3 18 19 import java.util.Properties ; 20 21 import org.apache.turbine.services.security.TurbineSecurity; 22 23 31 public class LDAPSecurityConstants 32 { 33 34 public static final String LDAP_ADMIN_USERNAME_KEY = "ldap.admin.username"; 35 36 37 public static final String LDAP_ADMIN_PASSWORD_KEY = "ldap.admin.password"; 38 39 40 public static final String LDAP_HOST_KEY = "ldap.host"; 41 42 43 public static final String LDAP_HOST_DEFAULT = "localhost"; 44 45 46 public static final String LDAP_PORT_KEY = "ldap.port"; 47 48 49 public static final String LDAP_PORT_DEFAULT = "389"; 50 51 52 public static final String LDAP_PROVIDER_KEY = "ldap.provider"; 53 54 55 public static final String LDAP_PROVIDER_DEFAULT = 56 "com.sun.jndi.ldap.LdapCtxFactory"; 57 58 59 public static final String LDAP_BASE_SEARCH_KEY = "ldap.basesearch"; 60 61 62 public static final String LDAP_AUTH_KEY = "ldap.security.authentication"; 63 64 65 public static final String LDAP_AUTH_DEFAULT = "simple"; 66 67 68 public static final String LDAP_USER_USERID_KEY = "ldap.user.userid"; 69 70 71 public static final String LDAP_USER_USERID_DEFAULT = "uid"; 72 73 74 public static final String LDAP_USER_USERNAME_KEY = "ldap.user.username"; 75 76 77 public static final String LDAP_USER_USERNAME_DEFAULT = "turbineUserUniqueId"; 78 79 80 public static final String LDAP_USER_FIRSTNAME_KEY = "ldap.user.firstname"; 81 82 83 public static final String LDAP_USER_FIRSTNAME_DEFAULT = "turbineUserFirstName"; 84 85 86 public static final String LDAP_USER_LASTNAME_KEY = "ldap.user.lastname"; 87 88 89 public static final String LDAP_USER_LASTNAME_DEFAULT = "turbineUserLastName"; 90 91 92 public static final String LDAP_USER_EMAIL_KEY = "ldap.user.email"; 93 94 95 public static final String LDAP_USER_EMAIL_DEFAULT = "turbineUserMailAddress"; 96 97 98 public static final String LDAP_USER_PASSWORD_KEY = "ldap.user.password"; 99 100 101 public static final String LDAP_USER_PASSWORD_DEFAULT = "userPassword"; 102 103 107 public static Properties getProperties() 108 { 109 return TurbineSecurity.getService().getProperties(); 110 } 111 112 117 public static String getProperty(String key) 118 { 119 return getProperties().getProperty(key); 120 } 121 122 129 public static String getProperty(String key, String defaultValue) 130 { 131 return getProperties().getProperty(key, defaultValue); 132 } 133 134 138 public static String getAdminUsername() 139 { 140 String str = getProperty(LDAP_ADMIN_USERNAME_KEY); 141 142 146 str = str.replace('/', '='); 147 str = str.replace('%', ','); 148 return str; 149 } 150 151 155 public static String getAdminPassword() 156 { 157 return getProperty(LDAP_ADMIN_PASSWORD_KEY); 158 } 159 160 164 public static String getLDAPHost() 165 { 166 return getProperty(LDAP_HOST_KEY, LDAP_HOST_DEFAULT); 167 } 168 169 173 public static String getLDAPPort() 174 { 175 return getProperty(LDAP_PORT_KEY, LDAP_PORT_DEFAULT); 176 } 177 178 182 public static String getLDAPProvider() 183 { 184 return getProperty(LDAP_PROVIDER_KEY, LDAP_PROVIDER_DEFAULT); 185 } 186 187 191 public static String getBaseSearch() 192 { 193 String str = getProperty(LDAP_BASE_SEARCH_KEY); 194 195 199 str = str.replace('/', '='); 200 str = str.replace('%', ','); 201 return str; 202 } 203 204 209 public static String getLDAPAuthentication() 210 { 211 return getProperty(LDAP_AUTH_KEY, LDAP_AUTH_DEFAULT); 212 } 213 214 218 public static String getUserIdAttribute() 219 { 220 return getProperty(LDAP_USER_USERID_KEY, LDAP_USER_USERID_DEFAULT); 221 } 222 223 227 public static String getNameAttribute() 228 { 229 return getProperty(LDAP_USER_USERNAME_KEY, LDAP_USER_USERNAME_DEFAULT); 230 } 231 232 237 public static String getUserNameAttribute() 238 { 239 return getNameAttribute(); 240 } 241 242 246 public static String getFirstNameAttribute() 247 { 248 return getProperty(LDAP_USER_FIRSTNAME_KEY, 249 LDAP_USER_FIRSTNAME_DEFAULT); 250 } 251 252 256 public static String getLastNameAttribute() 257 { 258 return getProperty(LDAP_USER_LASTNAME_KEY, LDAP_USER_LASTNAME_DEFAULT); 259 } 260 261 265 public static String getPasswordAttribute() 266 { 267 return getProperty(LDAP_USER_PASSWORD_KEY, LDAP_USER_PASSWORD_DEFAULT); 268 } 269 270 274 public static String getEmailAttribute() 275 { 276 return getProperty(LDAP_USER_EMAIL_KEY, LDAP_USER_EMAIL_DEFAULT); 277 } 278 279 } 280 | Popular Tags |