]> WPIA git - gigi.git/blob - src/club/wpia/gigi/util/ServerConstants.java
upd: use a link-redirector for all external links.
[gigi.git] / src / club / wpia / gigi / util / ServerConstants.java
1 package club.wpia.gigi.util;
2
3 import java.util.Properties;
4
5 public class ServerConstants {
6
7     private static String wwwHostName = "www.wpia.local";
8
9     private static String secureHostName = "secure.wpia.local";
10
11     private static String staticHostName = "static.wpia.local";
12
13     private static String apiHostName = "api.wpia.local";
14
15     private static String securePort, port, secureBindPort, bindPort;
16
17     private static String suffix = "wpia.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         secureBindPort = conf.getProperty("https.bindPort", conf.getProperty("https.port"));
28         bindPort = conf.getProperty("http.bindPort", conf.getProperty("http.port"));
29         wwwHostName = conf.getProperty("name.www");
30         secureHostName = conf.getProperty("name.secure");
31         staticHostName = conf.getProperty("name.static");
32         apiHostName = conf.getProperty("name.api");
33         suffix = conf.getProperty("name.suffix", conf.getProperty("name.www").substring(4));
34
35     }
36
37     public static String getSecureHostName() {
38         return secureHostName;
39     }
40
41     public static String getStaticHostName() {
42         return staticHostName;
43     }
44
45     public static String getWwwHostName() {
46         return wwwHostName;
47     }
48
49     public static String getApiHostName() {
50         return apiHostName;
51     }
52
53     public static String getSecureHostNamePortSecure() {
54         return secureHostName + securePort;
55     }
56
57     public static String getStaticHostNamePortSecure() {
58         return staticHostName + securePort;
59     }
60
61     public static String getWwwHostNamePortSecure() {
62         return wwwHostName + securePort;
63     }
64
65     public static String getStaticHostNamePort() {
66         return staticHostName + port;
67     }
68
69     public static String getWwwHostNamePort() {
70         return wwwHostName + port;
71     }
72
73     public static String getApiHostNamePort() {
74         return apiHostName + securePort;
75     }
76
77     public static String getLinkHostNamePort() {
78         return "link." + getSuffix() + port;
79     }
80
81     public static String getLinkHostNamePortSecure() {
82         return "link." + getSuffix() + securePort;
83     }
84
85     public static int getSecurePort() {
86         if (secureBindPort != null && !secureBindPort.isEmpty()) {
87             if (secureBindPort.equals("stdin")) {
88                 return -1;
89             } else {
90                 return Integer.parseInt(secureBindPort);
91             }
92         }
93         if (securePort.isEmpty()) {
94             return 443;
95         }
96         return Integer.parseInt(securePort.substring(1, securePort.length()));
97     }
98
99     public static int getPort() {
100         if (bindPort != null && !bindPort.isEmpty()) {
101             if (bindPort.equals("stdin")) {
102                 return -1;
103             } else {
104                 return Integer.parseInt(bindPort);
105             }
106         }
107         if (port.isEmpty()) {
108             return 80;
109         }
110         return Integer.parseInt(port.substring(1, port.length()));
111     }
112
113     public static String getSuffix() {
114         return suffix;
115     }
116
117     public static String getSupportMailAddress() {
118         return "support@" + getSuffix();
119     }
120
121     public static String getBoardMailAddress() {
122         return "board@" + getSuffix();
123     }
124
125     public static String getQuizMailAddress() {
126         return "quiz@" + getSuffix();
127     }
128
129     public static String getQuizAdminMailAddress() {
130         return "quiz-admin@" + getSuffix();
131     }
132
133 }