HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2012-10-18 925d9d3782b7b8b166b717dc5a2a54745c29fe04
local testing without https
3 files modified
1 files added
112 ■■■■■ changed files
hsarweb/build.xml 6 ●●●●● patch | view | raw | blame | history
hsarweb/conf/WEB-INF/web.xml 20 ●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/Config.java 57 ●●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/MainApplication.java 29 ●●●●● patch | view | raw | blame | history
hsarweb/build.xml
@@ -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>
hsarweb/conf/WEB-INF/web.xml
@@ -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>
    
hsarweb/src/de/hsadmin/web/Config.java
New 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();
    }
}
hsarweb/src/de/hsadmin/web/MainApplication.java
@@ -32,6 +32,14 @@
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 @@
        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