1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.cms.gui.control;
35
36 import info.magnolia.cms.core.Content;
37
38 import org.apache.commons.codec.binary.Base64;
39 import org.apache.commons.lang.StringUtils;
40
41
42
43
44
45
46
47 public class Password extends ControlImpl {
48
49 public Password() {
50 }
51
52 public Password(String name, String value) {
53 super(name, value);
54 }
55
56 public Password(String name, Content websiteNode) {
57 super(name, websiteNode);
58 }
59
60 @Override
61 public String getHtml() {
62 StringBuffer html = new StringBuffer();
63 String value = StringUtils.EMPTY;
64 if (this.getEncoding() == ControlImpl.ENCRYPTION_NO_ENCODING_BASE64) {
65
66 String valueDecoded = new String(Base64.decodeBase64(this.getValue().getBytes()));
67
68 for (int i = 0; i < valueDecoded.length(); i++) {
69 value += " ";
70 }
71 } else if (this.getEncoding() == ControlImpl.ENCRYPTION_HASH_SHA || this.getEncoding() == ControlImpl.ENCRYPTION_HASH_BCRYPT) {
72 value = StringUtils.EMPTY;
73 } else {
74 value = this.getValue();
75 }
76 value = StringUtils.strip(value);
77 html.append("<input type=\"password\"");
78 html.append(" autocomplete=\"off\"");
79 html.append(" name=\"" + this.getName() + "\"");
80 html.append(" id=\"" + this.getName() + "\"");
81 html.append(" value=\"" + value + "\"");
82 html.append(getHtmlEvents());
83 html.append(this.getHtmlCssClass());
84 html.append(this.getHtmlCssStyles());
85 html.append(" />");
86 if (this.getSaveInfo()) {
87 html.append(this.getHtmlSaveInfo());
88 }
89 return html.toString();
90 }
91 }