]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms/src/org/argeo/cms/CmsDeployProperty.java
Working SPNEGO clients.
[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 //
59 // WEBSOCKET
60 //
61 /** Whether web socket should be enables in web server. */
62 WEBSOCKET_ENABLED("argeo.websocket.enabled"),
63 //
64 // INTERNATIONALIZATION
65 //
66 /** Locales enabled for this system, the first one is considered the default. */
67 LOCALE("argeo.locale", 256),
68 //
69 // NODE
70 //
71 /** Directories to copy to the data area during the first initialisation. */
72 NODE_INIT("argeo.node.init", 64),
73 //
74 // JAVA
75 //
76 /** Custom JAAS config. */
77 JAVA_LOGIN_CONFIG("java.security.auth.login.config", true),
78 //
79 // OSGi
80 //
81 /** OSGi writable data area. */
82 OSGI_INSTANCE_AREA("osgi.instance.area"),
83 /** OSGi writable configuration area. */
84 OSGI_CONFIGURATION_AREA("osgi.configuration.area"),
85 //
86 ;
87
88 private String property;
89 private boolean systemPropertyOnly = false;
90
91 private int maxCount = 1;
92
93 CmsDeployProperty(String property) {
94 this(property, 1, false);
95 }
96
97 CmsDeployProperty(String property, int maxCount) {
98 this(property, maxCount, false);
99 }
100
101 CmsDeployProperty(String property, boolean systemPropertyOnly) {
102 this.property = property;
103 }
104
105 CmsDeployProperty(String property, int maxCount, boolean systemPropertyOnly) {
106 this.property = property;
107 this.systemPropertyOnly = systemPropertyOnly;
108 this.maxCount = maxCount;
109 }
110
111 public String getProperty() {
112 return property;
113 }
114
115 public boolean isSystemPropertyOnly() {
116 return systemPropertyOnly;
117 }
118
119 public int getMaxCount() {
120 return maxCount;
121 }
122
123 public static CmsDeployProperty find(String property) {
124 int index = getPropertyIndex(property);
125 String propertyName = index == 0 ? property : property.substring(0, property.lastIndexOf('.'));
126 for (CmsDeployProperty deployProperty : values()) {
127 if (deployProperty.getProperty().equals(propertyName))
128 return deployProperty;
129 }
130 return null;
131 }
132
133 public static int getPropertyIndex(String property) {
134 Objects.requireNonNull(property);
135 int lastDot = property.lastIndexOf('.');
136 if (lastDot <= 0 || lastDot == (property.length() - 1)) {
137 throw new IllegalArgumentException("Property " + property + " is not qualified (must contain a dot).");
138 }
139 String lastSegment = property.substring(lastDot + 1);
140 int index;
141 try {
142 index = Integer.parseInt(lastSegment);
143 } catch (NumberFormatException e) {
144 index = 0;
145 }
146 return index;
147 }
148
149 }