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 | 0 | 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 | 0 | ActionErrors errors = new ActionErrors(); |
48 | |
|
49 | 0 | if (StringUtils.isBlank(getAlias())) { |
50 | 0 | errors.add("property", new ActionMessage("Alias must have a valid value.",false)); |
51 | |
} |
52 | 0 | if (StringUtils.isBlank(getPassword()) || StringUtils.isBlank(getPasswordVerify()) ) { |
53 | 0 | errors.add("property", new ActionMessage("Password must have a valid value in both fields.",false)); |
54 | |
} |
55 | 0 | if (errors.isEmpty()) { |
56 | |
|
57 | 0 | if (!StringUtils.equals(getPassword(), getPasswordVerify())) { |
58 | 0 | errors.add("property", new ActionMessage("Passwords do not match.",false)); |
59 | |
} |
60 | |
} |
61 | 0 | if (errors.isEmpty()) { |
62 | |
try { |
63 | 0 | if (KSBServiceLocator.getJavaSecurityManagementService().isAliasInKeystore(getAlias())) { |
64 | 0 | errors.add("property", new ActionMessage("Alias '" + getAlias() + "' already exists in keystore.",false)); |
65 | |
} |
66 | 0 | } catch (KeyStoreException e) { |
67 | 0 | errors.add("property", new ActionMessage("Could not check keystore file for alias '" + getAlias(),false)); |
68 | 0 | } |
69 | |
} |
70 | 0 | return errors; |
71 | |
} |
72 | |
|
73 | |
public String getAlias() { |
74 | 0 | return this.alias; |
75 | |
} |
76 | |
public void setAlias(String alias) { |
77 | 0 | if (alias == null) { |
78 | 0 | this.alias = null; |
79 | |
} else { |
80 | 0 | this.alias = alias.trim(); |
81 | |
} |
82 | 0 | } |
83 | |
public String getPassword() { |
84 | 0 | return this.password; |
85 | |
} |
86 | |
public void setPassword(String password) { |
87 | 0 | this.password = password; |
88 | 0 | } |
89 | |
public String getPasswordVerify() { |
90 | 0 | return this.passwordVerify; |
91 | |
} |
92 | |
public void setPasswordVerify(String passwordVerify) { |
93 | 0 | this.passwordVerify = passwordVerify; |
94 | 0 | } |
95 | |
|
96 | |
} |