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"),
70 // INTERNATIONALIZATION
72 /** Locales enabled for this system, the first one is considered the default. */
73 LOCALE("argeo.locale", 256),
77 /** Directories to copy to the data area during the first initialisation. */
78 NODE_INIT("argeo.node.init", 64),
82 /** Custom JAAS config. */
83 JAVA_LOGIN_CONFIG("java.security.auth.login.config", true),
87 /** OSGi writable data area. */
88 OSGI_INSTANCE_AREA("osgi.instance.area"),
89 /** OSGi writable configuration area. */
90 OSGI_CONFIGURATION_AREA("osgi.configuration.area"),
94 private String property
;
95 private boolean systemPropertyOnly
= false;
97 private int maxCount
= 1;
99 CmsDeployProperty(String property
) {
100 this(property
, 1, false);
103 CmsDeployProperty(String property
, int maxCount
) {
104 this(property
, maxCount
, false);
107 CmsDeployProperty(String property
, boolean systemPropertyOnly
) {
108 this.property
= property
;
111 CmsDeployProperty(String property
, int maxCount
, boolean systemPropertyOnly
) {
112 this.property
= property
;
113 this.systemPropertyOnly
= systemPropertyOnly
;
114 this.maxCount
= maxCount
;
117 public String
getProperty() {
121 public boolean isSystemPropertyOnly() {
122 return systemPropertyOnly
;
125 public int getMaxCount() {
129 public static CmsDeployProperty
find(String property
) {
130 int index
= getPropertyIndex(property
);
131 String propertyName
= index
== 0 ? property
: property
.substring(0, property
.lastIndexOf('.'));
132 for (CmsDeployProperty deployProperty
: values()) {
133 if (deployProperty
.getProperty().equals(propertyName
))
134 return deployProperty
;
139 public static int getPropertyIndex(String property
) {
140 Objects
.requireNonNull(property
);
141 int lastDot
= property
.lastIndexOf('.');
142 if (lastDot
<= 0 || lastDot
== (property
.length() - 1)) {
143 throw new IllegalArgumentException("Property " + property
+ " is not qualified (must contain a dot).");
145 String lastSegment
= property
.substring(lastDot
+ 1);
148 index
= Integer
.parseInt(lastSegment
);
149 } catch (NumberFormatException e
) {