- Timestamp:
- 2018-09-06T22:32:58+12:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/util/GlobalProperties.java
r32357 r32429 38 38 private static String gsdl3_writablehome = null; 39 39 private static String gsdl3_web_address = null; 40 private static String full_gsdl3_web_address = null; 41 42 private static String http_full_gsdl3_web_address = null; 43 private static String https_full_gsdl3_web_address = null; 40 private static String full_gsdl3_web_address = null; // for the default protocol 41 42 private static String http_full_gsdl3_web_address = null; // if http or both protocols supported 43 private static String https_full_gsdl3_web_address = null; // if https or both protocols supported 44 45 // The locally accessible url such as for solr is always available at http://127.0.0.1:<httpPort> 46 // regardless of whether http is listed as one of the server protocols 47 private static String localhost_http_web_address = null; 44 48 45 49 /** get the value of the property 'key'. returns null if not found */ … … 81 85 { 82 86 return full_gsdl3_web_address; 87 } 88 89 public static String getLocalHttpBaseAddress() 90 { 91 return localhost_http_web_address; 83 92 } 84 93 … … 155 164 String protocolSpecifier = null, hostSpecifier = null, portSpecifier = null, contextSpecifier = null; 156 165 157 // protocol166 // default protocol 158 167 protocolSpecifier = properties.getProperty("server.protocol"); 159 168 if (protocolSpecifier == null || protocolSpecifier.equals("")) … … 180 189 } 181 190 182 // port191 //default port (port for the default protocol) 183 192 portSpecifier = properties.getProperty("tomcat.port"); // support for legacy tomcat.port? 184 if(portSpecifier == null) {185 portSpecifier = protocolSpecifier.startsWith("https") ? properties.getProperty("tomcat.port.https") : properties.getProperty("tomcat.port.http");186 }187 193 if (portSpecifier == null || portSpecifier.equals("") 188 194 || (protocolSpecifier.equals("http://") && portSpecifier.equals("80")) … … 214 220 gsdl3_web_address = contextSpecifier; 215 221 222 // Set the always available internal root address that is locally accessible (http://127.0.0.1:<httpPort>) 223 // Used by solr. 224 String httpPort = properties.getProperty("localhost.port.http"); 225 localhost_http_web_address = properties.getProperty("localhost.protocol.http") + "://" 226 + properties.getProperty("localhost.server.http") // always uses 127.0.0.1 (not localhost, which can be modified and is therefore unsafe!) 227 + httpPort; 228 229 230 216 231 // set the http and https variants of the full web address, if they're meant to be available 217 if(protocolSpecifier.startsWith("https")) { // check the default protocol, then set the address for the other protocol too 232 // First check the default protocol, then set the web address for the other protocol too 233 String supportedProtocols = properties.getProperty("server.protocols", "http"); 234 String isHttpRestrictedToLocal = properties.getProperty("restrict.http.to.local", "true"); 235 236 if(protocolSpecifier.startsWith("https")) { 218 237 https_full_gsdl3_web_address = full_gsdl3_web_address; 219 238 220 // and set http version, if sufficient properties are available 221 String httpPort = properties.getProperty("tomcat.port.http"); 222 if(httpPort != null && !httpPort.equals("")) { 239 // and set http version of URL, if http is made public (if http is in server.protocols list) 240 if(isHttpRestrictedToLocal.equals("false")) { 223 241 http_full_gsdl3_web_address = "http://" + hostSpecifier + httpPort + contextSpecifier; 224 242 } … … 226 244 http_full_gsdl3_web_address = full_gsdl3_web_address; 227 245 228 // and set https version, if sufficient properties are available229 String httpsPort = properties.getProperty("tomcat.port.https");230 if(httpsPort != null && !httpsPort.equals("")) {246 // and set https version, if https enabled 247 if(supportedProtocols.contains("https")) { 248 String httpsPort = properties.getProperty("tomcat.port.https"); 231 249 https_full_gsdl3_web_address = "https://" + hostSpecifier + httpsPort + contextSpecifier; 232 250 }
Note:
See TracChangeset
for help on using the changeset viewer.