From e0f98d7d3bde6c3643f91b0203f285da31f6c1d3 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 13:59:05 +0200 Subject: [PATCH] local testing without https --- hsarweb/build.xml | 6 ++++ hsarweb/conf/WEB-INF/web.xml | 20 ++++++------- .../src/de/hsadmin/web/MainApplication.java | 29 ++++++++++++++++++- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/hsarweb/build.xml b/hsarweb/build.xml index 530142d..eaad198 100644 --- a/hsarweb/build.xml +++ b/hsarweb/build.xml @@ -21,6 +21,7 @@ + @@ -38,4 +39,9 @@ /> + + + + + diff --git a/hsarweb/conf/WEB-INF/web.xml b/hsarweb/conf/WEB-INF/web.xml index efabea9..e9a46ec 100644 --- a/hsarweb/conf/WEB-INF/web.xml +++ b/hsarweb/conf/WEB-INF/web.xml @@ -7,15 +7,15 @@ serverName - https://@ADMIN_HOST@:@ADMIN_PORT@ + @HTTPS@://@ADMIN_HOST@:@ADMIN_PORT@ backendURL - https://@CONFIG_HOST@:@CONFIG_PORT@/hsar/backend + @HTTPS@://@CONFIG_HOST@:@CONFIG_PORT@/hsar/backend xmlrpcURL - https://@CONFIG_HOST@:@CONFIG_PORT@/hsar/xmlrpc/hsadmin + @HTTPS@://@CONFIG_HOST@:@CONFIG_PORT@/hsar/xmlrpc/hsadmin Vaadin production mode @@ -28,11 +28,11 @@ org.jasig.cas.client.authentication.AuthenticationFilter casServerLoginUrl - https://@LOGIN_HOST@:@LOGIN_PORT@/cas/login + @HTTPS@://@LOGIN_HOST@:@LOGIN_PORT@/cas/login service - https://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb + @HTTPS@://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb @@ -41,7 +41,7 @@ org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter casServerUrlPrefix - https://@LOGIN_HOST@:@LOGIN_PORT@/cas + @HTTPS@://@LOGIN_HOST@:@LOGIN_PORT@/cas proxyReceptorUrl @@ -49,11 +49,11 @@ proxyCallbackUrl - https://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb/proxyCallback + @HTTPS@://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb/proxyCallback service - https://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb + @HTTPS@://@ADMIN_HOST@:@ADMIN_PORT@/hsarweb @@ -66,13 +66,13 @@ CAS Authentication Filter /* - + Logout Servlet de.hsadmin.logout.LogoutServlet redirect - https://@LOGIN_HOST@:@LOGIN_PORT@/cas/logout + @HTTPS@://@LOGIN_HOST@:@LOGIN_PORT@/cas/logout diff --git a/hsarweb/src/de/hsadmin/web/MainApplication.java b/hsarweb/src/de/hsadmin/web/MainApplication.java index 5f256a2..9d87716 100644 --- a/hsarweb/src/de/hsadmin/web/MainApplication.java +++ b/hsarweb/src/de/hsadmin/web/MainApplication.java @@ -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