Skip to content

Commit 103b36e

Browse files
support server security root directory
1 parent 0a80086 commit 103b36e

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

src/main/java/org/terracotta/tinypounder/Settings.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class Settings {
2323
@Value("${kitPath}")
2424
private String kitPath;
2525

26+
@Value("${securityPath}")
27+
private String securityPath;
28+
2629
@Value("${licensePath}")
2730
private String licensePath;
2831

@@ -55,6 +58,16 @@ public void load() {
5558
}
5659
}
5760
// always prefer system props over saved config
61+
if (securityPath == null || securityPath.isEmpty()) {
62+
securityPath = properties.getProperty("securityPath");
63+
if (securityPath != null) {
64+
File folder = new File(securityPath);
65+
if (!folder.exists() || !folder.isDirectory()) {
66+
securityPath = null;
67+
}
68+
}
69+
}
70+
5871
if (kitPath == null || kitPath.isEmpty()) {
5972
kitPath = properties.getProperty("kitPath");
6073
if(kitPath != null) {
@@ -111,6 +124,9 @@ public void save() {
111124
if (kitPath != null) {
112125
properties.setProperty("kitPath", kitPath);
113126
}
127+
if (securityPath != null) {
128+
properties.setProperty("securityPath", securityPath);
129+
}
114130
if (licensePath != null) {
115131
properties.setProperty("licensePath", licensePath);
116132
}
@@ -136,6 +152,14 @@ public void save() {
136152
}
137153
}
138154

155+
public String getSecurityPath() {
156+
return securityPath;
157+
}
158+
159+
public void setSecurityPath(String securityPath) {
160+
this.securityPath = securityPath;
161+
}
162+
139163
public String getKitPath() {
140164
return kitPath;
141165
}

src/main/java/org/terracotta/tinypounder/TinyPounderMainUI.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class TinyPounderMainUI extends UI {
8686
private static final String VERSION = getVersion();
8787
private static final String AVAILABILITY = "Availability";
8888
private static final String CONSISTENCY = "Consistency";
89+
private static final String SECURITY = "Security";
8990

9091
@Autowired
9192
private CacheManagerBusiness cacheManagerBusiness;
@@ -125,6 +126,7 @@ public class TinyPounderMainUI extends UI {
125126
private Slider reconnectWindow;
126127
private GridLayout dataRootGrid;
127128
private GridLayout consistencyGrid;
129+
private HorizontalLayout securityGrid;
128130
private Slider dataRoots;
129131
private CheckBox platformPersistence;
130132
private CheckBox platformBackup;
@@ -142,7 +144,9 @@ public class TinyPounderMainUI extends UI {
142144
private TextField baseLocation;
143145
private Button trashDataButton;
144146
private RadioButtonGroup<String> consistencyGroup;
147+
private CheckBox securityCheckBox;
145148
private TextField votersCountTextField;
149+
private TextField securityField;
146150

147151
@Override
148152
protected void init(VaadinRequest vaadinRequest) {
@@ -699,6 +703,28 @@ private void addVoltronConfigControls() {
699703

700704
layout.addComponentsAndExpand(dataRootGrid);
701705

706+
//security
707+
securityGrid = new HorizontalLayout();
708+
securityCheckBox = new CheckBox();
709+
securityCheckBox.setCaption(SECURITY);
710+
711+
securityCheckBox.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
712+
713+
securityGrid.addComponent(securityCheckBox);
714+
securityCheckBox.addStyleName("align-bottom25");
715+
securityField = new TextField("Security Root Directory");
716+
securityField.setValue(settings.getSecurityPath() != null ? settings.getSecurityPath() : "");
717+
718+
securityCheckBox.addValueChangeListener(event -> {
719+
if (!event.getValue()) {
720+
securityGrid.removeComponent(securityField);
721+
} else {
722+
securityGrid.addComponentsAndExpand(securityField);
723+
}
724+
});
725+
layout.addComponentsAndExpand(securityGrid);
726+
727+
702728
//consistency and voters
703729
consistencyGrid = new GridLayout(2, 1);
704730
consistencyGroup = new RadioButtonGroup<>();
@@ -914,6 +940,21 @@ private void generateXML(boolean skipConfirmOverwrite) {
914940
" </service>\n" +
915941
"\n");
916942
}
943+
944+
// security
945+
if (securityCheckBox.getValue()) {
946+
947+
sb.append(" <service xmlns:security=\"http://www.terracottatech.com/config/security\">\n" +
948+
" <security:security>\n" +
949+
" <security:security-root-directory>" + securityField.getValue() + "</security:security-root-directory>\n" +
950+
" <security:ssl-tls/>\n" +
951+
" <security:authentication>\n" +
952+
" <security:file/>\n" +
953+
" </security:authentication>\n" +
954+
" </security:security>\n" +
955+
" </service>\n" +
956+
"\n");
957+
}
917958
}
918959

919960
// servers
@@ -975,6 +1016,8 @@ private void generateXML(boolean skipConfirmOverwrite) {
9751016
}
9761017

9771018
tcConfigXml.setValue(tcConfigXml.getValue() + xml + "\n\n");
1019+
settings.setSecurityPath(securityField.getValue());
1020+
9781021
}
9791022
}
9801023

src/main/resources/VAADIN/themes/tinypounder/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ $v-layout-margin-bottom: 16px;
1919
margin-top: 3px !important;
2020
}
2121

22+
.align-bottom25, v-textfield-align-bottom25 {
23+
margin-top: 25px !important;
24+
}
25+
2226
.align-top {
2327
top: -5px !important;
2428
}

src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
kitPath=
2+
securityPath=
23
licensePath=
34
# loaded by Settings. Keep it to 0.
45
offheapCount=0

0 commit comments

Comments
 (0)