1 package org.enhydra.shark.authentication; 2 3 import org.enhydra.shark.api.internal.working.CallbackUtilities; 4 5 11 public class LDAPOptions { 12 private int ldapPort; 13 private int searchScope = 2; private boolean attributeOnly = false; private String ldapHost; 16 private int structureType; 18 private String searchBase; 19 private String userObjectClasses; 20 private String groupObjectClasses; 21 private String userUniqueAttributeName; 22 private String groupUniqueAttributeName; 23 private String userPasswordAttributeName; 24 private String ldapUser; 25 private String ldapPassword; 26 private String groupUsersName; 27 28 private CallbackUtilities cus; 29 30 33 public LDAPOptions (CallbackUtilities cus) { 34 this.cus=cus; 35 java.util.Properties properties=cus.getProperties(); 36 try { 37 ldapPort=Integer.valueOf(properties.getProperty("LDAPPort")).intValue(); 38 } catch (Exception ex) { 39 cus.error("LDAPOptions -> Port invalid, using default port 389"); 40 ldapPort=389 ; 41 } 42 43 try { 44 structureType=Integer.valueOf(properties.getProperty("LDAPStructureType")).intValue(); 45 } catch (Exception ex) { 46 cus.error("LDAPOptions -> Structure type invalid, using default - complex"); 47 structureType=1; 48 } 49 if (structureType<0 || structureType>1) { 50 cus.error("LDAPOptions -> Structure type invalid, using default - complex"); 51 structureType=1; 52 } 53 54 56 try { 57 ldapHost=properties.getProperty("LDAPHost"); 58 } catch (Exception ex) { 59 cus.error("LDAPOptions -> Host invalid, using default localhost"); 60 ldapHost="localhost"; 61 } 62 if (ldapHost==null) { 63 cus.error("LDAPOptions -> Host invalid, using default localhost"); 64 ldapHost="localhost"; 65 } 66 67 try { 68 searchBase=properties.getProperty("LDAPSearchBase"); 69 } catch (Exception ex) { 70 cus.error("LDAPOptions -> Search base invalid, not using search base"); 71 searchBase=""; 72 } 73 if (searchBase==null) { 74 cus.error("LDAPOptions -> Search base invalid, not using search base"); 75 searchBase=""; 76 } 77 78 try { 79 groupObjectClasses=properties.getProperty("LDAPGroupObjectClasses"); 80 } catch (Exception ex) { 81 cus.error("LDAPOptions -> Group object classes filter invalid, using organizationalUnit"); 82 groupObjectClasses="organizationalUnit"; 83 } 84 if (groupObjectClasses==null) { 85 cus.error("LDAPOptions -> Group object classes filter invalid, using organizationalUnit"); 86 groupObjectClasses="organizationalUnit"; 87 } 88 89 try { 90 userObjectClasses=properties.getProperty("LDAPUserObjectClasses"); 91 } catch (Exception ex) { 92 cus.error("LDAPOptions -> User object classes filter invalid, using inetOrgPerson"); 93 userObjectClasses="inetOrgPerson"; 94 } 95 if (userObjectClasses==null) { 96 cus.error("LDAPOptions -> User object classes filter invalid, using inetOrgPerson"); 97 userObjectClasses="inetOrgPerson"; 98 } 99 100 try { 101 groupUniqueAttributeName=properties.getProperty("LDAPGroupUniqueAttributeName"); 102 } catch (Exception ex) { 103 cus.error("LDAPOptions -> Group unique attribute name invalid, using ou"); 104 groupUniqueAttributeName="ou"; 105 } 106 if (groupUniqueAttributeName==null) { 107 cus.error("LDAPOptions -> Group unique attribute name invalid, using ou"); 108 groupUniqueAttributeName="ou"; 109 } 110 111 try { 112 userUniqueAttributeName=properties.getProperty("LDAPUserUniqueAttributeName"); 113 } catch (Exception ex) { 114 cus.error("LDAPOptions -> User unique attribute name invalid, using uid"); 115 userUniqueAttributeName="uid"; 116 } 117 if (userUniqueAttributeName==null) { 118 cus.error("LDAPOptions -> User unique attribute name invalid, using uid"); 119 userUniqueAttributeName="uid"; 120 } 121 122 try { 123 userPasswordAttributeName=properties.getProperty("LDAPUserPasswordAttributeName"); 124 } catch (Exception ex) { 125 cus.error("LDAPOptions -> User password attribute name invalid, using password"); 126 userPasswordAttributeName="password"; 127 } 128 if (userPasswordAttributeName==null) { 129 cus.error("LDAPOptions -> User password attribute name invalid, using password"); 130 userPasswordAttributeName="password"; 131 } 132 133 try { 134 ldapUser=properties.getProperty("LDAPUser"); 135 } catch (Exception ex) { 136 cus.error("LDAPOptions -> User invalid, leaving empty"); 137 ldapUser=""; 138 } 139 if (ldapUser==null) { 140 cus.error("LDAPOptions -> User invalid, leaving empty"); 141 ldapUser=""; 142 } 143 144 try { 145 ldapPassword=properties.getProperty("LDAPPassword"); 146 } catch (Exception ex) { 147 cus.error("LDAPOptions -> Password invalid, leaving empty"); 148 ldapPassword=""; 149 } 150 if (ldapPassword==null) { 151 cus.error("LDAPOptions -> Password invalid, leaving empty"); 152 ldapPassword=""; 153 } 154 155 try { 156 groupUsersName=properties.getProperty("LDAPGroupUsersName"); 157 } catch (Exception ex) { 158 cus.error("LDAPOptions -> Name of group users invalid, using Users"); 159 groupUsersName="Users"; 160 } 161 if (groupUsersName==null) { 162 cus.error("LDAPOptions -> Name of group users invalid, using Users"); 163 groupUsersName="Users"; 164 } 165 } 166 167 172 public int getPort () { 173 return ldapPort; 174 } 175 176 181 public void setPort (int port) { 182 this.ldapPort=port; 183 } 184 185 public int getStructureType () { 186 return structureType; 187 } 188 189 public void setStructureType (int structureType) { 190 this.structureType=structureType; 191 } 192 193 198 public int getSearchScope () { 199 return searchScope; 200 } 201 202 207 public boolean getAttributeOnly () { 208 return attributeOnly; 209 } 210 211 216 public void setAttributeOnly (boolean attrOnly) { 217 this.attributeOnly=attrOnly; 218 } 219 220 225 public String getHost () { 226 return ldapHost; 227 } 228 229 234 public void setHost (String host) { 235 this.ldapHost=host; 236 } 237 238 243 public String getSearchBase () { 244 return searchBase; 245 } 246 247 252 public void setSearchBase (String searchBase) { 253 this.searchBase=searchBase; 254 } 255 256 public String getGroupObjectClasses () { 257 return groupObjectClasses; 258 } 259 260 public void setGroupObjectClasses (String groupObjectClasses) { 261 this.groupObjectClasses=groupObjectClasses; 262 } 263 264 269 public String getUserObjectClasses () { 270 return userObjectClasses; 271 } 272 273 278 public void setUserObjectClasses (String userObjectClasses) { 279 this.userObjectClasses=userObjectClasses; 280 } 281 282 public String getGroupUniqueAttributeName () { 283 return groupUniqueAttributeName; 284 } 285 286 public void setGroupUniqueAttributeName (String groupUniqueAttributeName) { 287 this.groupUniqueAttributeName=groupUniqueAttributeName; 288 } 289 290 295 public String getUserUniqueAttributeName () { 296 return userUniqueAttributeName; 297 } 298 299 304 public void setUserUniqueAttributeName (String userUniqueAttributeName) { 305 this.userUniqueAttributeName=userUniqueAttributeName; 306 } 307 308 313 public String getUserPasswordAttributeName () { 314 return userPasswordAttributeName; 315 } 316 317 322 public void setUserPasswordAttributeName (String userPasswordAttributeName) { 323 this.userPasswordAttributeName=userPasswordAttributeName; 324 } 325 326 331 public String getUser () { 332 return ldapUser; 333 } 334 335 340 public void setUser (String user) { 341 this.ldapUser=user; 342 } 343 344 349 public String getPassword () { 350 return ldapPassword; 351 } 352 353 358 public void setPassword (String password) { 359 this.ldapPassword=password; 360 } 361 362 public String getGroupUsersName () { 363 return groupUsersName; 364 } 365 366 public void setGroupUsersName (String groupUsersName) { 367 this.groupUsersName=groupUsersName; 368 } 369 370 } 371 372 | Popular Tags |