]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/CmsDeployProperty.java
Remove naming exceptions from DNS browser
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / CmsDeployProperty.java
1 package org.argeo.cms;
2
3 import java.util.Objects;
4
5 /** A property that can be used to configure a CMS node deployment. */
6 public enum CmsDeployProperty {
7 //
8 // DIRECTORY
9 //
10 DIRECTORY("argeo.directory", 64),
11 //
12 // DATABASE
13 //
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"),
20 //
21 // NETWORK
22 //
23 /** Either a host or an IP address. Restricts all servers to it. */
24 HOST("argeo.host"),
25 /** Either a host or an IP address. Restricts all servers to it. */
26 DNS("argeo.dns", 16),
27 //
28 // HTTP
29 //
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"),
34 /**
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.
37 */
38 HTTP_PROXY_SSL_HEADER_DN("argeo.http.proxy.ssl.header.dn"),
39 //
40 // SSL
41 //
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"),
64 //
65 // WEBSOCKET
66 //
67 /** Whether web socket should be enables in web server. */
68 WEBSOCKET_ENABLED("argeo.websocket.enabled"),
69 //
70 // INTERNATIONALIZATION
71 //
72 /** Locales enabled for this system, the first one is considered the default. */
73 LOCALE("argeo.locale", 256),
74 //
75 // NODE
76 //
77 /** Directories to copy to the data area during the first initialisation. */
78 NODE_INIT("argeo.node.init", 64),
79 //
80 // JAVA
81 //
82 /** Custom JAAS config. */
83 JAVA_LOGIN_CONFIG("java.security.auth.login.config", true),
84 //
85 // OSGi
86 //
87 /** OSGi writable data area. */
88 OSGI_INSTANCE_AREA("osgi.instance.area"),
89 /** OSGi writable configuration area. */
90 OSGI_CONFIGURATION_AREA("osgi.configuration.area"),
91 //
92 ;
93
94 private String property;
95 private boolean systemPropertyOnly = false;
96
97 private int maxCount = 1;
98
99 CmsDeployProperty(String property) {
100 this(property, 1, false);
101 }
102
103 CmsDeployProperty(String property, int maxCount) {
104 this(property, maxCount, false);
105 }
106
107 CmsDeployProperty(String property, boolean systemPropertyOnly) {
108 this.property = property;
109 }
110
111 CmsDeployProperty(String property, int maxCount, boolean systemPropertyOnly) {
112 this.property = property;
113 this.systemPropertyOnly = systemPropertyOnly;
114 this.maxCount = maxCount;
115 }
116
117 public String getProperty() {
118 return property;
119 }
120
121 public boolean isSystemPropertyOnly() {
122 return systemPropertyOnly;
123 }
124
125 public int getMaxCount() {
126 return maxCount;
127 }
128
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;
135 }
136 return null;
137 }
138
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).");
144 }
145 String lastSegment = property.substring(lastDot + 1);
146 int index;
147 try {
148 index = Integer.parseInt(lastSegment);
149 } catch (NumberFormatException e) {
150 index = 0;
151 }
152 return index;
153 }
154
155 }