1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.admin.resources.representation.html;
17
18 import java.io.OutputStream;
19 import java.util.List;
20
21 import de.smartics.html5.jatl.HtmlResourceContext;
22 import de.smartics.properties.admin.domain.model.Paths;
23 import de.smartics.properties.admin.domain.model.Security;
24 import de.smartics.properties.admin.resources.representation.html.share.AbstractHtmlRepresentationRenderer;
25 import de.smartics.resteasy.hypermedia.renderer.LinkDescriptor;
26
27
28
29
30 public final class SecurityHtmlRepresentationRenderer extends
31 AbstractHtmlRepresentationRenderer<Security>
32 {
33
34
35
36
37
38
39
40 private static final String TITLE = "Security Tool";
41
42
43
44
45
46
47 private final Security domainObject;
48
49
50
51
52
53
54
55
56
57
58
59
60 public SecurityHtmlRepresentationRenderer(
61 final HtmlResourceContext htmlContext, final Security domainObject,
62 final OutputStream entityStream)
63 {
64 super(htmlContext, entityStream);
65 this.domainObject = domainObject;
66 }
67
68
69
70
71
72
73
74
75
76
77
78 @Override
79 protected void bodyContents()
80 {
81 renderPageTitle(">>>");
82 html.p()
83 .text(
84 "This form allows to en- and decrypt property values using the"
85 + " symmetric key deployed with the application.").end();
86
87 renderForm();
88 }
89
90 private void renderForm()
91 {
92 html.form().method("POST").classAttr("form-horizontal");
93
94 html.fieldset().legend().text("En- and decrypt property values").end();
95 renderInputField(Paths.PARAM_SECURITY_ENCRYPT, "Encrypt",
96 domainObject.getPlainText(), "Enter plain text here ...");
97 renderInputField(Paths.PARAM_SECURITY_DECRYPT, "Decrypt",
98 domainObject.getEncryptedText(), "Enter encrypted text here ...");
99 createSubmitButton();
100 html.end();
101
102 html.end();
103 }
104
105 private void renderInputField(final String id, final String label,
106 final String value, final String placeholder)
107 {
108 html.div().classAttr("control-group");
109
110 html.label().classAttr("control-label")
111 .forAttr(Paths.PARAM_SECURITY_ENCRYPT).text(label).end();
112
113 html.div().classAttr("controls");
114 html.input().type("text").id(id).name(id).classAttr("input-xlarge")
115 .value(value);
116 html.attr("placeholder", placeholder);
117 html.end(3);
118 }
119
120 private void createSubmitButton()
121 {
122 html.button().type("submit").id("submit").classAttr("btn btn-default");
123 html.text("Submit").end();
124 }
125
126 @Override
127 protected String getTitle()
128 {
129 return TITLE;
130 }
131
132 @Override
133 protected List<LinkDescriptor> breadcrumbLinks()
134 {
135 return breadcrumb.security();
136 }
137
138
139
140 }