3 import java
.util
.Objects
;
5 /** A property that can be used to configure a CMS node deployment. */
6 public enum CmsDeployProperty
{
10 DIRECTORY("argeo.directory", 64),
14 /** URL of the database backend. */
15 DB_URL("argeo.db.url"),
16 /** DB user of the database backend. */
17 DB_USER("argeo.db.user"),
18 /** DB user password of the database backend. */
19 DB_PASSWORD("argeo.db.password"),
23 /** Either a host or an IP address. Restricts all servers to it. */
25 /** Either a host or an IP address. Restricts all servers to it. */
30 /** Request an HTTP server on this port. */
31 HTTP_PORT("argeo.http.port"),
32 /** Request an HTTPS server on this port. */
33 HTTPS_PORT("argeo.https.port"),
35 * The HTTP header used to convey the DN of a client verified by a reverse
36 * proxy. Typically SSL_CLIENT_S_DN for Apache.
38 HTTP_PROXY_SSL_HEADER_DN("argeo.http.proxy.ssl.header.dn"),
42 /** SSL keystore for the system. */
43 SSL_KEYSTORE("argeo.ssl.keystore"),
44 /** SSL keystore password for the system. */
45 SSL_PASSWORD("argeo.ssl.password"),
46 /** SSL keystore type password for the system. */
47 SSL_KEYSTORETYPE("argeo.ssl.keystoretype"),
48 /** SSL password for the private key. */
49 SSL_KEYPASSWORD("argeo.ssl.keypassword"),
50 /** Whether a client certificate is required. */
51 SSL_NEEDCLIENTAUTH("argeo.ssl.needclientauth"),
52 /** Whether a client certificate can be used. */
53 SSL_WANTCLIENTAUTH("argeo.ssl.wantclientauth"),
54 /** SSL protocol to use. */
55 SSL_PROTOCOL("argeo.ssl.protocol"),
56 /** SSL algorithm to use. */
57 SSL_ALGORITHM("argeo.ssl.algorithm"),
58 /** Custom SSL trust store. */
59 SSL_TRUSTSTORE("argeo.ssl.truststore"),
60 /** Custom SSL trust store type. */
61 SSL_TRUSTSTORETYPE("argeo.ssl.truststoretype"),
62 /** Custom SSL trust store type. */
63 SSL_TRUSTSTOREPASSWORD("argeo.ssl.truststorepassword"),
67 /** Whether web socket should be enables in web server. */
68 WEBSOCKET_ENABLED("argeo.websocket.enabled"),
72 /** Request an HTTP server on this port. */
73 SSHD_PORT("argeo.sshd.port"),
75 // INTERNATIONALIZATION
77 /** Locales enabled for this system, the first one is considered the default. */
78 LOCALE("argeo.locale", 256),
82 /** Directories to copy to the data area during the first initialisation. */
83 NODE_INIT("argeo.node.init", 64),
87 /** Custom JAAS config. */
88 JAVA_LOGIN_CONFIG("java.security.auth.login.config", true),
92 /** OSGi writable data area. */
93 OSGI_INSTANCE_AREA("osgi.instance.area"),
94 /** OSGi writable configuration area. */
95 OSGI_CONFIGURATION_AREA("osgi.configuration.area"),
99 private String property
;
100 private boolean systemPropertyOnly
= false;
102 private int maxCount
= 1;
104 CmsDeployProperty(String property
) {
105 this(property
, 1, false);
108 CmsDeployProperty(String property
, int maxCount
) {
109 this(property
, maxCount
, false);
112 CmsDeployProperty(String property
, boolean systemPropertyOnly
) {
113 this.property
= property
;
116 CmsDeployProperty(String property
, int maxCount
, boolean systemPropertyOnly
) {
117 this.property
= property
;
118 this.systemPropertyOnly
= systemPropertyOnly
;
119 this.maxCount
= maxCount
;
122 public String
getProperty() {
126 public boolean isSystemPropertyOnly() {
127 return systemPropertyOnly
;
130 public int getMaxCount() {
134 public static CmsDeployProperty
find(String property
) {
135 int index
= getPropertyIndex(property
);
136 String propertyName
= index
== 0 ? property
: property
.substring(0, property
.lastIndexOf('.'));
137 for (CmsDeployProperty deployProperty
: values()) {
138 if (deployProperty
.getProperty().equals(propertyName
))
139 return deployProperty
;
144 public static int getPropertyIndex(String property
) {
145 Objects
.requireNonNull(property
);
146 int lastDot
= property
.lastIndexOf('.');
147 if (lastDot
<= 0 || lastDot
== (property
.length() - 1)) {
148 throw new IllegalArgumentException("Property " + property
+ " is not qualified (must contain a dot).");
150 String lastSegment
= property
.substring(lastDot
+ 1);
153 index
= Integer
.parseInt(lastSegment
);
154 } catch (NumberFormatException e
) {