1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.security.admin.web;
17
18 import java.security.KeyStoreException;
19
20 import javax.servlet.http.HttpServletRequest;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.apache.struts.action.ActionErrors;
24 import org.apache.struts.action.ActionForm;
25 import org.apache.struts.action.ActionMapping;
26 import org.apache.struts.action.ActionMessage;
27 import org.kuali.rice.ksb.service.KSBServiceLocator;
28
29
30
31
32
33
34
35 public class JavaSecurityManagementForm extends ActionForm {
36
37 private static final long serialVersionUID = -46462912979586142L;
38
39 private String alias;
40 private String password;
41 private String passwordVerify;
42
43
44
45
46 public ActionErrors validateGenerateClientKeystore(ActionMapping mapping, HttpServletRequest request) {
47 ActionErrors errors = new ActionErrors();
48
49 if (StringUtils.isBlank(getAlias())) {
50 errors.add("property", new ActionMessage("Alias must have a valid value.",false));
51 }
52 if (StringUtils.isBlank(getPassword()) || StringUtils.isBlank(getPasswordVerify()) ) {
53 errors.add("property", new ActionMessage("Password must have a valid value in both fields.",false));
54 }
55 if (errors.isEmpty()) {
56
57 if (!StringUtils.equals(getPassword(), getPasswordVerify())) {
58 errors.add("property", new ActionMessage("Passwords do not match.",false));
59 }
60 }
61 if (errors.isEmpty()) {
62 try {
63 if (KSBServiceLocator.getJavaSecurityManagementService().isAliasInKeystore(getAlias())) {
64 errors.add("property", new ActionMessage("Alias '" + getAlias() + "' already exists in keystore.",false));
65 }
66 } catch (KeyStoreException e) {
67 errors.add("property", new ActionMessage("Could not check keystore file for alias '" + getAlias(),false));
68 }
69 }
70 return errors;
71 }
72
73 public String getAlias() {
74 return this.alias;
75 }
76 public void setAlias(String alias) {
77 if (alias == null) {
78 this.alias = null;
79 } else {
80 this.alias = alias.trim();
81 }
82 }
83 public String getPassword() {
84 return this.password;
85 }
86 public void setPassword(String password) {
87 this.password = password;
88 }
89 public String getPasswordVerify() {
90 return this.passwordVerify;
91 }
92 public void setPasswordVerify(String passwordVerify) {
93 this.passwordVerify = passwordVerify;
94 }
95
96 }