1 16 17 package org.apache.webapp.admin.realm; 18 19 import javax.servlet.http.HttpServletRequest ; 20 import org.apache.struts.action.ActionError; 21 import org.apache.struts.action.ActionErrors; 22 import org.apache.struts.action.ActionForm; 23 import org.apache.struts.action.ActionMapping; 24 import java.net.InetAddress ; 25 import java.util.List ; 26 27 import org.apache.webapp.admin.ApplicationServlet; 28 import org.apache.webapp.admin.LabelValueBean; 29 30 36 37 public final class JNDIRealmForm extends RealmForm { 38 39 41 44 private String connectionName = null; 45 46 49 private String connectionPassword = null; 50 51 54 private String connectionURL = null; 55 56 59 private String contextFactory = null; 60 61 64 private String digest = null; 65 66 69 private String roleBase = null; 70 71 74 private String roleName = null; 75 76 79 private String rolePattern = null; 80 81 84 private String roleSubtree = "false"; 85 86 89 private String userBase = null; 90 91 94 private String userPassword = null; 95 96 99 private String userPattern = null; 100 101 104 private String userRoleName = null; 105 106 109 private String userSearch = null; 110 111 114 private String userSubtree = "false"; 115 116 119 private List searchVals = null; 120 121 122 124 127 public List getSearchVals() { 128 129 return this.searchVals; 130 131 } 132 133 136 public void setSearchVals(List searchVals) { 137 138 this.searchVals = searchVals; 139 140 } 141 142 145 public String getRoleSubtree() { 146 147 return this.roleSubtree; 148 149 } 150 151 154 public void setRoleSubtree(String roleSubtree) { 155 156 this.roleSubtree = roleSubtree; 157 158 } 159 160 163 public String getUserSubtree() { 164 165 return this.userSubtree; 166 167 } 168 169 172 public void setUserSubtree(String userSubtree) { 173 174 this.userSubtree = userSubtree; 175 176 } 177 178 181 public String getDigest() { 182 183 return this.digest; 184 185 } 186 187 190 public void setDigest(String digest) { 191 192 this.digest = digest; 193 194 } 195 196 199 public String getRoleBase() { 200 201 return this.roleBase ; 202 203 } 204 205 208 public void setRoleBase(String roleBase ) { 209 210 this.roleBase = roleBase ; 211 212 } 213 214 217 public String getRoleName() { 218 219 return this.roleName ; 220 221 } 222 223 226 public void setRoleName(String roleName) { 227 228 this.roleName = roleName ; 229 230 } 231 232 235 public String getUserBase() { 236 237 return this.userBase ; 238 239 } 240 241 244 public void setUserBase(String userBase ) { 245 246 this.userBase = userBase ; 247 248 } 249 250 253 public String getUserRoleName() { 254 255 return this.userRoleName ; 256 257 } 258 259 262 public void setUserRoleName(String userRoleName) { 263 264 this.userRoleName = userRoleName ; 265 266 } 267 268 271 public String getRolePattern() { 272 273 return this.rolePattern ; 274 275 } 276 277 280 public void setRolePattern(String rolePattern ) { 281 282 this.rolePattern = rolePattern ; 283 284 } 285 286 289 public String getUserPassword() { 290 291 return this.userPassword ; 292 293 } 294 295 298 public void setUserPassword(String userPassword ) { 299 300 this.userPassword = userPassword ; 301 302 } 303 304 305 308 public String getUserPattern() { 309 310 return this.userPattern ; 311 312 } 313 314 317 public void setUserPattern(String userPattern) { 318 319 this.userPattern = userPattern ; 320 321 } 322 323 326 public String getUserSearch() { 327 328 return this.userSearch; 329 330 } 331 332 335 public void setUserSearch(String userSearch) { 336 337 this.userSearch = userSearch; 338 339 } 340 341 344 public String getConnectionName() { 345 346 return this.connectionName; 347 348 } 349 350 353 public void setConnectionName(String connectionName) { 354 355 this.connectionName = connectionName; 356 357 } 358 359 360 363 public String getConnectionPassword() { 364 365 return this.connectionPassword; 366 367 } 368 369 372 public void setConnectionPassword(String connectionPassword) { 373 374 this.connectionPassword = connectionPassword; 375 376 } 377 378 379 382 public String getConnectionURL() { 383 384 return this.connectionURL; 385 386 } 387 388 391 public void setConnectionURL(String connectionURL) { 392 393 this.connectionURL = connectionURL; 394 395 } 396 397 400 public String getContextFactory() { 401 402 return this.contextFactory ; 403 404 } 405 406 409 public void setContextFactory(String contextFactory ) { 410 411 this.contextFactory = contextFactory ; 412 413 } 414 415 417 423 public void reset(ActionMapping mapping, HttpServletRequest request) { 424 425 super.reset(mapping, request); 426 this.roleSubtree="false"; 427 this.userSubtree="false"; 428 429 this.digest = null; 430 this.roleName = null; 431 this.userRoleName = null; 432 433 this.connectionName = null; 434 this.connectionPassword = null; 435 this.connectionURL = null; 436 437 this.rolePattern = null; 438 this.roleBase = null; 439 this.userBase = null; 440 this.userPassword = null; 441 this.userPattern = null; 442 this.userSearch = null; 443 this.contextFactory = null; 444 } 445 446 449 public String toString() { 450 451 StringBuffer sb = new StringBuffer ("UserDatabaseRealmForm[adminAction="); 452 sb.append(getAdminAction()); 453 sb.append(",userSubtree="); 454 sb.append(userSubtree); 455 sb.append(",roleSubtree="); 456 sb.append(roleSubtree); 457 sb.append(",digest="); 458 sb.append(digest); 459 sb.append("',userRoleName='"); 460 sb.append(userRoleName); 461 sb.append("',roleName='"); 462 sb.append(roleName); 463 sb.append("',connectionName="); 464 sb.append(connectionName); 465 sb.append(",connectionPassword="); 466 sb.append(connectionPassword); 467 sb.append("',connectionURL='"); 468 sb.append(connectionURL); 469 sb.append("',rolePattern="); 470 sb.append(rolePattern); 471 sb.append(",roleBase="); 472 sb.append(roleBase); 473 sb.append("',userPassword='"); 474 sb.append(userPassword); 475 sb.append(",userBase="); 476 sb.append(userBase); 477 sb.append("',userPattern="); 478 sb.append(userPattern); 479 sb.append("',userSearch="); 480 sb.append(userSearch); 481 sb.append(",contextFactory="); 482 sb.append(contextFactory); 483 sb.append("',objectName='"); 484 sb.append(getObjectName()); 485 sb.append("',realmType="); 486 sb.append(getRealmType()); 487 sb.append("]"); 488 return (sb.toString()); 489 490 } 491 492 502 503 public ActionErrors validate(ActionMapping mapping, 504 HttpServletRequest request) { 505 506 ActionErrors errors = new ActionErrors(); 507 508 String submit = request.getParameter("submit"); 509 510 514 if ((connectionURL == null) || (connectionURL.length() < 1)) { 515 errors.add("connectionURL", 516 new ActionError("error.connURL.required")); 517 } 518 519 boolean isUserPatternSpecified = false; 521 boolean isUserSearchSpecified = false; 522 if ((userPattern != null) && (userPattern.length() > 0)) { 523 isUserPatternSpecified = true; 524 } 525 526 if ((userSearch != null) && (userSearch.length() > 0)) { 527 isUserSearchSpecified = true; 528 } 529 530 if (isUserPatternSpecified && isUserSearchSpecified) { 531 errors.add("userPattern" , 532 new ActionError("error.userPattern.userSearch.defined")); 533 } 534 535 539 540 594 596 return errors; 597 } 598 } 599 | Popular Tags |