local testing without https
This commit is contained in:
parent
75ea95b74f
commit
925d9d3782
@ -21,6 +21,7 @@
|
||||
<filter token="CONFIG_PORT" value="${hsar.https.port}"/>
|
||||
<filter token="ADMIN_HOST" value="${hsarweb.domain.name}"/>
|
||||
<filter token="ADMIN_PORT" value="${hsarweb.https.port}"/>
|
||||
<filter token="HTTPS" value="${hsar.https}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
<war destfile="build/hsarweb.war" basedir="WebContent">
|
||||
@ -38,4 +39,9 @@
|
||||
/>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="build"/>
|
||||
<delete file="WebContent/WEB-INF/web.xml"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
@ -7,15 +7,15 @@
|
||||
|
||||
<context-param>
|
||||
<param-name>serverName</param-name>
|
||||
<param-value>https://@ADMIN_HOST@:@ADMIN_PORT@</param-value>
|
||||
<param-value>@HTTPS@://@ADMIN_HOST@:@ADMIN_PORT@</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>backendURL</param-name>
|
||||
<param-value>https://@CONFIG_HOST@:@CONFIG_PORT@/hsar/backend</param-value>
|
||||
<param-value>@HTTPS@://@CONFIG_HOST@:@CONFIG_PORT@/hsar/backend</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>xmlrpcURL</param-name>
|
||||
<param-value>https://@CONFIG_HOST@:@CONFIG_PORT@/hsar/xmlrpc/hsadmin</param-value>
|
||||
<param-value>@HTTPS@://@CONFIG_HOST@:@CONFIG_PORT@/hsar/xmlrpc/hsadmin</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<description>Vaadin production mode</description>
|
||||
@ -28,11 +28,11 @@
|
||||
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>casServerLoginUrl</param-name>
|
||||
<param-value>https://@LOGIN_HOST@:@LOGIN_PORT@/cas/login</param-value>
|
||||
<param-value>@HTTPS@://@LOGIN_HOST@:@LOGIN_PORT@/cas/login</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>service</param-name>
|
||||
<param-value>https://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb</param-value>
|
||||
<param-value>@HTTPS@://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>casServerUrlPrefix</param-name>
|
||||
<param-value>https://@LOGIN_HOST@:@LOGIN_PORT@/cas</param-value>
|
||||
<param-value>@HTTPS@://@LOGIN_HOST@:@LOGIN_PORT@/cas</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>proxyReceptorUrl</param-name>
|
||||
@ -49,11 +49,11 @@
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>proxyCallbackUrl</param-name>
|
||||
<param-value>https://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb/proxyCallback</param-value>
|
||||
<param-value>@HTTPS@://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb/proxyCallback</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>service</param-name>
|
||||
<param-value>https://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb</param-value>
|
||||
<param-value>@HTTPS@://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
|
||||
@ -66,13 +66,13 @@
|
||||
<filter-name>CAS Authentication Filter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Logout Servlet</servlet-name>
|
||||
<servlet-class>de.hsadmin.logout.LogoutServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>redirect</param-name>
|
||||
<param-value>https://@LOGIN_HOST@:@LOGIN_PORT@/cas/logout</param-value>
|
||||
<param-value>@HTTPS@://@LOGIN_HOST@:@LOGIN_PORT@/cas/logout</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
|
57
hsarweb/src/de/hsadmin/web/Config.java
Normal file
57
hsarweb/src/de/hsadmin/web/Config.java
Normal file
@ -0,0 +1,57 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Config {
|
||||
|
||||
private static Config instance;
|
||||
|
||||
private Properties props;
|
||||
|
||||
private Config() {
|
||||
props = new Properties();
|
||||
File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
|
||||
if (!file.canRead()) {
|
||||
file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File("/etc/hsadmin.properties");
|
||||
}
|
||||
if (!file.canRead()) {
|
||||
file = new File("/etc/hsadmin/hsadmin.properties");
|
||||
}
|
||||
if (file.canRead()) {
|
||||
try {
|
||||
props.load(new FileReader(file));
|
||||
} catch (Exception e) {
|
||||
// should not happen
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Config getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Config();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getProperty(String propertyName) {
|
||||
String property = props.getProperty(propertyName);
|
||||
if (property == null) {
|
||||
return null;
|
||||
}
|
||||
return property.trim();
|
||||
}
|
||||
|
||||
public String getProperty(String propertyName, String defaultValue) {
|
||||
return props.getProperty(propertyName, defaultValue).trim();
|
||||
}
|
||||
|
||||
}
|
@ -32,6 +32,14 @@ import de.hsadmin.web.config.ModuleConfig;
|
||||
public class MainApplication extends Application implements HttpServletRequestListener, TabSheet.SelectedTabChangeListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String LOGIN_URL = "https://login.hostsharing.net:443/cas/v1/tickets";
|
||||
private static boolean isTestEnvironment = false;
|
||||
|
||||
static {
|
||||
Config config = Config.getInstance();
|
||||
Object loginURL = config.getProperty("loginURL", LOGIN_URL);
|
||||
isTestEnvironment = "TestUmgebung".equals(loginURL);
|
||||
}
|
||||
|
||||
private HttpSession httpSession;
|
||||
private ServletContext servletContext;
|
||||
@ -138,7 +146,26 @@ public class MainApplication extends Application implements HttpServletRequestLi
|
||||
requestLocale = request.getLocale();
|
||||
httpSession = request.getSession();
|
||||
servletContext = httpSession.getServletContext();
|
||||
userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal();
|
||||
if (isTestEnvironment) {
|
||||
userPrincipal = new AttributePrincipal() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ad";
|
||||
}
|
||||
@Override
|
||||
public String getProxyTicketFor(String arg0) {
|
||||
return "user:ad";
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Map getAttributes() {
|
||||
return new HashMap();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user