1 package club.wpia.gigi.util;
3 import java.util.Properties;
5 public class ServerConstants {
7 private static String wwwHostName = "www.wpia.local";
9 private static String secureHostName = "secure.wpia.local";
11 private static String staticHostName = "static.wpia.local";
13 private static String apiHostName = "api.wpia.local";
15 private static String securePort, port, secureBindPort, bindPort;
17 private static String suffix = "wpia.local";
19 public static void init(Properties conf) {
20 securePort = port = "";
21 if ( !conf.getProperty("https.port").equals("443")) {
22 securePort = ":" + conf.getProperty("https.port");
24 if ( !conf.getProperty("http.port").equals("80")) {
25 port = ":" + conf.getProperty("http.port");
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));
37 public static String getSecureHostName() {
38 return secureHostName;
41 public static String getStaticHostName() {
42 return staticHostName;
45 public static String getWwwHostName() {
49 public static String getApiHostName() {
53 public static String getSecureHostNamePortSecure() {
54 return secureHostName + securePort;
57 public static String getStaticHostNamePortSecure() {
58 return staticHostName + securePort;
61 public static String getWwwHostNamePortSecure() {
62 return wwwHostName + securePort;
65 public static String getStaticHostNamePort() {
66 return staticHostName + port;
69 public static String getWwwHostNamePort() {
70 return wwwHostName + port;
73 public static String getApiHostNamePort() {
74 return apiHostName + securePort;
77 public static String getLinkHostNamePort() {
78 return "link." + getSuffix() + port;
81 public static String getLinkHostNamePortSecure() {
82 return "link." + getSuffix() + securePort;
85 public static int getSecurePort() {
86 if (secureBindPort != null && !secureBindPort.isEmpty()) {
87 if (secureBindPort.equals("stdin")) {
90 return Integer.parseInt(secureBindPort);
93 if (securePort.isEmpty()) {
96 return Integer.parseInt(securePort.substring(1, securePort.length()));
99 public static int getPort() {
100 if (bindPort != null && !bindPort.isEmpty()) {
101 if (bindPort.equals("stdin")) {
104 return Integer.parseInt(bindPort);
107 if (port.isEmpty()) {
110 return Integer.parseInt(port.substring(1, port.length()));
113 public static String getSuffix() {
117 public static String getSupportMailAddress() {
118 return "support@" + getSuffix();
121 public static String getBoardMailAddress() {
122 return "board@" + getSuffix();
125 public static String getQuizMailAddress() {
126 return "quiz@" + getSuffix();
129 public static String getQuizAdminMailAddress() {
130 return "quiz-admin@" + getSuffix();