]> WPIA git - gigi.git/blob - src/org/cacert/gigi/util/ServerConstants.java
ADD: !Configchange! http serve
[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     public static void init(Properties conf) {
18         securePort = port = "";
19         if ( !conf.getProperty("https.port").equals("443")) {
20             securePort = ":" + conf.getProperty("https.port");
21         }
22         if ( !conf.getProperty("http.port").equals("80")) {
23             port = ":" + conf.getProperty("http.port");
24         }
25         wwwHostName = conf.getProperty("name.www");
26         secureHostName = conf.getProperty("name.secure");
27         staticHostName = conf.getProperty("name.static");
28         apiHostName = conf.getProperty("name.api");
29
30     }
31
32     public static String getSecureHostName() {
33         return secureHostName;
34     }
35
36     public static String getStaticHostName() {
37         return staticHostName;
38     }
39
40     public static String getWwwHostName() {
41         return wwwHostName;
42     }
43
44     public static String getApiHostName() {
45         return apiHostName;
46     }
47
48     public static String getSecureHostNamePort() {
49         return secureHostName + securePort;
50     }
51
52     public static String getStaticHostNamePortSecure() {
53         return staticHostName + securePort;
54     }
55
56     public static String getWwwHostNamePortSecure() {
57         return wwwHostName + securePort;
58     }
59
60     public static String getStaticHostNamePort() {
61         return staticHostName + port;
62     }
63
64     public static String getWwwHostNamePort() {
65         return wwwHostName + port;
66     }
67
68     public static String getApiHostNamePort() {
69         return apiHostName + securePort;
70     }
71
72     public static int getSecurePort() {
73         if (securePort.isEmpty()) {
74             return 443;
75         }
76         return Integer.parseInt(securePort.substring(1, securePort.length()));
77     }
78
79     public static int getPort() {
80         if (port.isEmpty()) {
81             return 80;
82         }
83         return Integer.parseInt(port.substring(1, port.length()));
84     }
85
86 }