1 25 26 package org.objectweb.jonas.webapp.jonasadmin.security; 27 28 import java.util.List ; 29 30 import javax.servlet.http.HttpServletRequest ; 31 32 import org.apache.struts.action.ActionMessage; 33 import org.apache.struts.action.ActionErrors; 34 import org.apache.struts.action.ActionMapping; 35 import org.objectweb.jonas.webapp.jonasadmin.Jlists; 36 37 40 public class LdapRealmForm extends FactoryRealmForm { 41 42 44 46 private String authenticationMode = null; 47 private String baseDn = null; 48 private String initialContextFactory = null; 49 private String language = null; 50 private String providerUrl = null; 51 private String referral = null; 52 private String roleDn = null; 53 private String roleNameAttribute = null; 54 private String roleSearchFilter = null; 55 private String securityAuthentication = null; 56 private String securityCredentials = null; 57 private String securityPrincipal = null; 58 private String securityProtocol = null; 59 private String stateFactories = null; 60 private String userDn = null; 61 private String userPasswordAttribute = null; 62 private String userRolesAttribute = null; 63 private String userSearchFilter = null; 64 private String algorithm = null; 65 66 private List securityAuthenticationLdapValues = Jlists.getSecurityAuthenticationLdapValues(); 67 private List authenticationModeLdapValues = Jlists.getAuthenticationModeLdapValues(); 68 private List securityAlgorithms = Jlists.getSecurityAlgorithms(); 69 70 72 78 79 public void reset(ActionMapping mapping, HttpServletRequest request) { 80 super.reset(mapping, request); 81 82 authenticationMode = "bind"; 83 baseDn = null; 84 initialContextFactory = "com.sun.jndi.ldap.LdapCtxFactory"; 85 language = null; 86 providerUrl = "ldap://localhost:389"; 87 referral = null; 88 roleDn = null; 89 roleNameAttribute = "cn"; 90 roleSearchFilter = "uniqueMember={0}"; 91 securityAuthentication = "simple"; 92 securityCredentials = null; 93 securityPrincipal = null; 94 securityProtocol = null; 95 stateFactories = null; 96 userDn = null; 97 userPasswordAttribute = "userPassword"; 98 userRolesAttribute = "memberOf"; 99 userSearchFilter = "uid={0}"; 100 } 101 102 113 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 114 ActionErrors oErrors = new ActionErrors(); 115 if ((getName() == null) || (getName().length() == 0)) { 116 oErrors.add("name", new ActionMessage("error.security.factory.ldap.realm.name.required")); 117 } 118 if ((baseDn == null) || (baseDn.length() == 0)) { 119 oErrors.add("baseDn" 120 , new ActionMessage("error.security.factory.ldap.realm.baseDn.required")); 121 } 122 if ((initialContextFactory == null) || (initialContextFactory.length() == 0)) { 123 oErrors.add("initialContextFactory" 124 , new ActionMessage("error.security.factory.ldap.realm.initialContextFactory.required")); 125 initialContextFactory = "com.sun.jndi.ldap.LdapCtxFactory"; 126 } 127 if ((providerUrl == null) || (providerUrl.length() == 0)) { 128 oErrors.add("providerUrl" 129 , new ActionMessage("error.security.factory.ldap.realm.providerUrl.required")); 130 providerUrl = "ldap://localhost:389"; 131 } 132 if ((roleNameAttribute == null) || (roleNameAttribute.length() == 0)) { 133 oErrors.add("roleNameAttribute" 134 , new ActionMessage("error.security.factory.ldap.realm.roleNameAttribute.required")); 135 roleNameAttribute = "cn"; 136 } 137 if ((roleSearchFilter == null) || (roleSearchFilter.length() == 0)) { 138 oErrors.add("roleSearchFilter" 139 , new ActionMessage("error.security.factory.ldap.realm.roleSearchFilter.required")); 140 roleSearchFilter = "uniqueMember={0}"; 141 } 142 if ((userPasswordAttribute == null) || (userPasswordAttribute.length() == 0)) { 143 oErrors.add("userPasswordAttribute" 144 , new ActionMessage("error.security.factory.ldap.realm.userPasswordAttribute.required")); 145 userPasswordAttribute = "userPassword"; 146 } 147 if ((userRolesAttribute == null) || (userRolesAttribute.length() == 0)) { 148 oErrors.add("userRolesAttribute" 149 , new ActionMessage("error.security.factory.ldap.realm.userRolesAttribute.required")); 150 userRolesAttribute = "memberOf"; 151 } 152 if ((userSearchFilter == null) || (userSearchFilter.length() == 0)) { 153 oErrors.add("userSearchFilter" 154 , new ActionMessage("error.security.factory.ldap.realm.userSearchFilter.required")); 155 userSearchFilter = "uid={0}"; 156 } 157 return oErrors; 158 } 159 160 162 public String getAuthenticationMode() { 163 return authenticationMode; 164 } 165 166 public void setAuthenticationMode(String authenticationMode) { 167 this.authenticationMode = authenticationMode; 168 } 169 170 public String getBaseDn() { 171 return baseDn; 172 } 173 174 public void setBaseDn(String baseDn) { 175 this.baseDn = baseDn; 176 } 177 178 public String getInitialContextFactory() { 179 return initialContextFactory; 180 } 181 182 public void setInitialContextFactory(String initialContextFactory) { 183 this.initialContextFactory = initialContextFactory; 184 } 185 186 public String getLanguage() { 187 return language; 188 } 189 190 public void setLanguage(String language) { 191 this.language = language; 192 } 193 194 public String getProviderUrl() { 195 return providerUrl; 196 } 197 198 public void setProviderUrl(String providerUrl) { 199 this.providerUrl = providerUrl; 200 } 201 202 public String getReferral() { 203 return referral; 204 } 205 206 public void setReferral(String referral) { 207 this.referral = referral; 208 } 209 210 public String getRoleDn() { 211 return roleDn; 212 } 213 214 public void setRoleDn(String roleDn) { 215 this.roleDn = roleDn; 216 } 217 218 public String getRoleNameAttribute() { 219 return roleNameAttribute; 220 } 221 222 public void setRoleNameAttribute(String roleNameAttribute) { 223 this.roleNameAttribute = roleNameAttribute; 224 } 225 226 public String getRoleSearchFilter() { 227 return roleSearchFilter; 228 } 229 230 public void setRoleSearchFilter(String roleSearchFilter) { 231 this.roleSearchFilter = roleSearchFilter; 232 } 233 234 public String getSecurityAuthentication() { 235 return securityAuthentication; 236 } 237 238 public void setSecurityAuthentication(String securityAuthentication) { 239 this.securityAuthentication = securityAuthentication; 240 } 241 242 public String getSecurityCredentials() { 243 return securityCredentials; 244 } 245 246 public void setSecurityCredentials(String securityCredentials) { 247 this.securityCredentials = securityCredentials; 248 } 249 250 public String getSecurityPrincipal() { 251 return securityPrincipal; 252 } 253 254 public void setSecurityPrincipal(String securityPrincipal) { 255 this.securityPrincipal = securityPrincipal; 256 } 257 258 public String getSecurityProtocol() { 259 return securityProtocol; 260 } 261 262 public void setSecurityProtocol(String securityProtocol) { 263 this.securityProtocol = securityProtocol; 264 } 265 266 public String getStateFactories() { 267 return stateFactories; 268 } 269 270 public void setStateFactories(String stateFactories) { 271 this.stateFactories = stateFactories; 272 } 273 274 public String getUserDn() { 275 return userDn; 276 } 277 278 public void setUserDn(String userDn) { 279 this.userDn = userDn; 280 } 281 282 public String getUserPasswordAttribute() { 283 return userPasswordAttribute; 284 } 285 286 public void setUserPasswordAttribute(String userPasswordAttribute) { 287 this.userPasswordAttribute = userPasswordAttribute; 288 } 289 290 public String getUserRolesAttribute() { 291 return userRolesAttribute; 292 } 293 294 public void setUserRolesAttribute(String userRolesAttribute) { 295 this.userRolesAttribute = userRolesAttribute; 296 } 297 298 public String getUserSearchFilter() { 299 return userSearchFilter; 300 } 301 302 public void setUserSearchFilter(String userSearchFilter) { 303 this.userSearchFilter = userSearchFilter; 304 } 305 306 public List getSecurityAuthenticationLdapValues() { 307 return securityAuthenticationLdapValues; 308 } 309 310 public List getAuthenticationModeLdapValues() { 311 return authenticationModeLdapValues; 312 } 313 314 public String getAlgorithm() { 315 return algorithm; 316 } 317 318 public void setAlgorithm(String algorithm) { 319 this.algorithm = algorithm; 320 } 321 322 public List getSecurityAlgorithms() { 323 return securityAlgorithms; 324 } 325 326 } | Popular Tags |