]> WPIA git - gigi.git/blob - src/org/cacert/gigi/util/ServerConstants.java
09317c3ec643f8c53dfc16b3b27309b4b7ac2883
[gigi.git] / src / org / cacert / gigi / util / ServerConstants.java
1 package org.cacert.gigi.util;
2
3 import java.util.Properties;
4
5 public class ServerConstants {
6
7     private static String wwwHostName = "www.cacert.local";
8
9     private static String secureHostName = "secure.cacert.local";
10
11     private static String staticHostName = "static.cacert.local";
12
13     private static String apiHostName = "api.cacert.local";
14
15     private static String securePort, port;
16
17     private static String suffix = "cacert.local";
18
19     public static void init(Properties conf) {
20         securePort = port = "";
21         if ( !conf.getProperty("https.port").equals("443")) {
22             securePort = ":" + conf.getProperty("https.port");
23         }
24         if ( !conf.getProperty("http.port").equals("80")) {
25             port = ":" + conf.getProperty("http.port");
26         }
27         wwwHostName = conf.getProperty("name.www");
28         secureHostName = conf.getProperty("name.secure");
29         staticHostName = conf.getProperty("name.static");
30         apiHostName = conf.getProperty("name.api");
31         suffix = conf.getProperty("name.suffix", conf.getProperty("name.www").substring(4));
32
33     }
34
35     public static String getSecureHostName() {
36         return secureHostName;
37     }
38
39     public static String getStaticHostName() {
40         return staticHostName;
41     }
42
43     public static String getWwwHostName() {
44         return wwwHostName;
45     }
46
47     public static String getApiHostName() {
48         return apiHostName;
49     }
50
51     public static String getSecureHostNamePort() {
52         return secureHostName + securePort;
53     }
54
55     public static String getStaticHostNamePortSecure() {
56         return staticHostName + securePort;
57     }
58
59     public static String getWwwHostNamePortSecure() {
60         return wwwHostName + securePort;
61     }
62
63     public static String getStaticHostNamePort() {
64         return staticHostName + port;
65     }
66
67     public static String getWwwHostNamePort() {
68         return wwwHostName + port;
69     }
70
71     public static String getApiHostNamePort() {
72         return apiHostName + securePort;
73     }
74
75     public static int getSecurePort() {
76         if (securePort.isEmpty()) {
77             return 443;
78         }
79         return Integer.parseInt(securePort.substring(1, securePort.length()));
80     }
81
82     public static int getPort() {
83         if (port.isEmpty()) {
84             return 80;
85         }
86         return Integer.parseInt(port.substring(1, port.length()));
87     }
88
89     public static String getSuffix() {
90         return suffix;
91     }
92
93     public static String getSupportMailAddress() {
94         return "support@" + ServerConstants.getWwwHostName().replaceFirst("^www\\.", "");
95     }
96
97 }