From fbbb1f4132027231d0d1bc9f29b879550daddca7 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 16 Oct 2012 15:39:55 +0200 Subject: [PATCH 01/15] error in update of file virtual.conf corrected --- hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java | 6 +++--- .../src/de/hsadmin/mods/pac/PacProcessorFactory.java | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java index 32ae06f..1ed2d7d 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java @@ -113,10 +113,10 @@ public class PacModuleImpl extends AbstractModuleImpl { public AbstractEntity update(AbstractEntity entity) throws HSAdminException { UnixUser loginUser = getTransaction().getLoginUser(); - if (entity instanceof Pac) { - Pac pac = (Pac) entity; - } else { + if (!(entity instanceof Pac)) { throw new AuthorisationException(loginUser, "update", entity); +// } else { +// Pac pac = (Pac) entity; } needsWriteAccessOn(entity, "update"); return super.update(entity); diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index f764792..27c8ed3 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -57,14 +57,17 @@ public class PacProcessorFactory implements EntityProcessorFactory { private Processor createHttpdVirtualProc( String pacName, List> pacValuesList) throws ProcessorException { Processor domSetupProcessor = new CompoundProcessor( - new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.jtpl", new HashMap(), pacValuesList.iterator(), "/etc/apache2/virtual.conf.tmp", "root", "root", "644", true), + new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.jtpl", + new HashMap(), pacValuesList.iterator(), + "/etc/apache2/virtual.conf.tmp", "root", "root", "644", true), new ShellProcessor("ls /etc/apache2/pems/" + pacName + ".pem >/dev/null 2>&1 " + "&& sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/apache.conf.tmp" + " && (ls /etc/apache2/pems/" + pacName + ".chain.pem >/dev/null 2>&1" + " || sed -i '/SSLCertificateChain.*" + pacName + "/d' " + "/etc/apache2/virtual.conf.tmp)" + " || sed -i '/SSLCertificate.*" + pacName + "/d' " + "/etc/apache2/virtual.conf.tmp"), - new ShellProcessor("(diff -q /etc/apache2/apache.conf.tmp /etc/apache2/apache.conf" - + " && rm /etc/apache2/apache.conf.tmp)" - + " || invoke-rc.d apache2 reload >/dev/null 2>&1")); + new ShellProcessor("(diff -q /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf" + + " && rm /etc/apache2/virtual.conf.tmp )" + + " || ( mv /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf " + + " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) ")); return domSetupProcessor; } From d5b27e5a5946a82f36ec580ecf04ecf9e8d0e27f Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 16 Oct 2012 17:11:10 +0200 Subject: [PATCH 02/15] correct cert-chain in vortual.conf --- .../hsadmin/mods/pac/PacProcessorFactory.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index 27c8ed3..7d65e53 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -60,10 +60,19 @@ public class PacProcessorFactory implements EntityProcessorFactory { new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.jtpl", new HashMap(), pacValuesList.iterator(), "/etc/apache2/virtual.conf.tmp", "root", "root", "644", true), - new ShellProcessor("ls /etc/apache2/pems/" + pacName + ".pem >/dev/null 2>&1 " + "&& sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/apache.conf.tmp" - + " && (ls /etc/apache2/pems/" + pacName + ".chain.pem >/dev/null 2>&1" - + " || sed -i '/SSLCertificateChain.*" + pacName + "/d' " + "/etc/apache2/virtual.conf.tmp)" - + " || sed -i '/SSLCertificate.*" + pacName + "/d' " + "/etc/apache2/virtual.conf.tmp"), + new ShellProcessor("for PEM in $( cat virtual.conf.tmp | grep SSLCertificateFile | cut -c24- ); do " + + "ls $PEM >/dev/null 2>&1 || ( " + + " sed -i \"/SSLCertificateFile.*${PEM:18}/c \\\n" + + "\\ \\ \\ \\ SSLCertificateFile \\/etc\\/apache2\\/pems\\/default.pem\" virtual.conf.tmp && " + + " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/c \\\n" + + "\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" virtual.conf.tmp " + + "); " + + "done"), + new ShellProcessor("for PEM in $( cat virtual.conf.tmp | grep SSLCertificateChainFile | cut -c24- ); do " + + "ls $PEM >/dev/null 2>&1 || " + + " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" virtual.conf.tmp " + + "); " + + "done"), new ShellProcessor("(diff -q /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf" + " && rm /etc/apache2/virtual.conf.tmp )" + " || ( mv /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf " From 787a086baf4030905bc79d6d9ab6eda9a5c50452 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 16 Oct 2012 17:35:14 +0200 Subject: [PATCH 03/15] fix errors in virtual.conf --- .../src/de/hsadmin/mods/pac/PacProcessorFactory.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index 7d65e53..67af241 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -60,18 +60,17 @@ public class PacProcessorFactory implements EntityProcessorFactory { new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.jtpl", new HashMap(), pacValuesList.iterator(), "/etc/apache2/virtual.conf.tmp", "root", "root", "644", true), - new ShellProcessor("for PEM in $( cat virtual.conf.tmp | grep SSLCertificateFile | cut -c24- ); do " + + new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateFile | cut -c24- ); do " + "ls $PEM >/dev/null 2>&1 || ( " + " sed -i \"/SSLCertificateFile.*${PEM:18}/c \\\n" + - "\\ \\ \\ \\ SSLCertificateFile \\/etc\\/apache2\\/pems\\/default.pem\" virtual.conf.tmp && " + + "\\ \\ \\ \\ SSLCertificateFile \\/etc\\/apache2\\/pems\\/default.pem\" /etc/apache2/virtual.conf.tmp && " + " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/c \\\n" + - "\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" virtual.conf.tmp " + + "\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" /etc/apache2/virtual.conf.tmp " + "); " + "done"), - new ShellProcessor("for PEM in $( cat virtual.conf.tmp | grep SSLCertificateChainFile | cut -c24- ); do " + + new ShellProcessor("for PEM in $( /etc/apache2/cat virtual.conf.tmp | grep SSLCertificateChainFile | cut -c24- ); do " + "ls $PEM >/dev/null 2>&1 || " + - " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" virtual.conf.tmp " + - "); " + + " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" /etc/apache2/virtual.conf.tmp ; " + "done"), new ShellProcessor("(diff -q /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf" + " && rm /etc/apache2/virtual.conf.tmp )" From fc0573874bbc72787c7e6a334b69f7c676ea3856 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 16 Oct 2012 17:42:19 +0200 Subject: [PATCH 04/15] fix error in virtual.conf --- hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index 67af241..436ea4c 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -68,7 +68,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { "\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" /etc/apache2/virtual.conf.tmp " + "); " + "done"), - new ShellProcessor("for PEM in $( /etc/apache2/cat virtual.conf.tmp | grep SSLCertificateChainFile | cut -c24- ); do " + + new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateChainFile | cut -c24- ); do " + "ls $PEM >/dev/null 2>&1 || " + " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" /etc/apache2/virtual.conf.tmp ; " + "done"), From 30a40d88f510e268efae5da6f3254b72d72e05f6 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 16 Oct 2012 17:44:26 +0200 Subject: [PATCH 05/15] fix error in httpd-virtual.conf --- hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl | 2 -- 1 file changed, 2 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl b/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl index 719f1db..81cf943 100644 --- a/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl +++ b/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl @@ -16,8 +16,6 @@ NameVirtualHost {PAC_IP}:443 SSLEngine On - SSLCertificateFile /etc/apache2/pems/default.pem - SSLCertificateChainFile /etc/apache2/pems/default.chain.pem SSLCertificateFile /etc/apache2/pems/{PAC}.pem SSLCertificateChainFile /etc/apache2/pems/{PAC}.chain.pem From e0d77d647b550bc0e4f881be8dce02b5ee9b8aea Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 16 Oct 2012 17:54:14 +0200 Subject: [PATCH 06/15] fix error in httpd-virtual.conf --- hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java | 2 +- hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index 436ea4c..b0013fb 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -68,7 +68,7 @@ public class PacProcessorFactory implements EntityProcessorFactory { "\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" /etc/apache2/virtual.conf.tmp " + "); " + "done"), - new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateChainFile | cut -c24- ); do " + + new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateChainFile | cut -c29- ); do " + "ls $PEM >/dev/null 2>&1 || " + " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" /etc/apache2/virtual.conf.tmp ; " + "done"), diff --git a/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl b/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl index 719f1db..81cf943 100644 --- a/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl +++ b/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl @@ -16,8 +16,6 @@ NameVirtualHost {PAC_IP}:443 SSLEngine On - SSLCertificateFile /etc/apache2/pems/default.pem - SSLCertificateChainFile /etc/apache2/pems/default.chain.pem SSLCertificateFile /etc/apache2/pems/{PAC}.pem SSLCertificateChainFile /etc/apache2/pems/{PAC}.chain.pem From 5b66f03aefb42fa47a218d6407073d7a78399cf7 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 16 Oct 2012 18:07:19 +0200 Subject: [PATCH 07/15] clean code --- hsarback/src/de/hsadmin/mods/dom/Domain.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hsarback/src/de/hsadmin/mods/dom/Domain.java b/hsarback/src/de/hsadmin/mods/dom/Domain.java index 0a0c112..07d2c32 100644 --- a/hsarback/src/de/hsadmin/mods/dom/Domain.java +++ b/hsarback/src/de/hsadmin/mods/dom/Domain.java @@ -6,7 +6,6 @@ import static javax.persistence.GenerationType.SEQUENCE; import java.util.Date; import java.util.Set; -import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityManager; From 51bb1e19ddaf4378b4abb42c7cb04dfc3d68b548 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 13:08:35 +0200 Subject: [PATCH 08/15] support legacy web-client --- hsarback/src/de/hsadmin/remote/EMailAddressRemote.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hsarback/src/de/hsadmin/remote/EMailAddressRemote.java b/hsarback/src/de/hsadmin/remote/EMailAddressRemote.java index 1982382..05bff40 100644 --- a/hsarback/src/de/hsadmin/remote/EMailAddressRemote.java +++ b/hsarback/src/de/hsadmin/remote/EMailAddressRemote.java @@ -65,6 +65,10 @@ public class EMailAddressRemote extends AbstractRemote { } } adr.setTarget(tBuff.toString()); + } else { + if (l != null && l instanceof String) { + adr.setTarget((String) l); + } } String domain = (String) map.get("domain"); if (assertNotNull(domain)) { From 75ea95b74f078e77950231385ee6e5cd2d4ad254 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 13:56:47 +0200 Subject: [PATCH 09/15] Typo --- hsarback/database/database_update.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql index 3f3f5dd..dd855d7 100644 --- a/hsarback/database/database_update.sql +++ b/hsarback/database/database_update.sql @@ -59,7 +59,7 @@ INSERT INTO domain__domain_option SELECT domain_option_id, domain_id WHERE domain_option.domain_option_name = 'greylisting' ; INSERT INTO domain__domain_option SELECT domain_option_id, domain_id FROM domain, domain_option - WHERE domain_option.domain_option_name = 'htdocsfalback' ; + WHERE domain_option.domain_option_name = 'htdocsfallback' ; INSERT INTO domain__domain_option SELECT domain_option_id, domain_id FROM domain, domain_option WHERE domain_option.domain_option_name = 'includes' ; From e0f98d7d3bde6c3643f91b0203f285da31f6c1d3 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 13:59:05 +0200 Subject: [PATCH 10/15] 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 From 925d9d3782b7b8b166b717dc5a2a54745c29fe04 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 14:02:04 +0200 Subject: [PATCH 11/15] local testing without https --- hsarweb/build.xml | 6 ++ hsarweb/conf/WEB-INF/web.xml | 20 +++---- hsarweb/src/de/hsadmin/web/Config.java | 57 +++++++++++++++++++ .../src/de/hsadmin/web/MainApplication.java | 29 +++++++++- 4 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 hsarweb/src/de/hsadmin/web/Config.java 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/Config.java b/hsarweb/src/de/hsadmin/web/Config.java new file mode 100644 index 0000000..83ef15d --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/Config.java @@ -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(); + } + +} 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 From aeab721f106ad134b1236508278b98c898e916f3 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 14:04:05 +0200 Subject: [PATCH 12/15] suppress warnings --- hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java index 59cd903..fd98b01 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java @@ -162,6 +162,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable { } if (valueObject != null && valueObject instanceof Map) { StringBuffer buf = new StringBuffer(); + @SuppressWarnings("rawtypes") Map valueMap = (Map) valueObject; for (Object o : valueMap.keySet()) { if (o instanceof String) { From fd516ce57ab9240daa1f979371528fb9ff74bd75 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 16:21:44 +0200 Subject: [PATCH 13/15] fix pac-domain migration --- .../mods/dom/DomainProcessorFactory.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index b09d7d3..de64e48 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -374,35 +374,36 @@ public class DomainProcessorFactory implements EntityProcessorFactory { private Processor createMovePacDomainContent(EntityManager em, Domain dom) { Pac pac = dom.getUser().getPac(); - String pacDir = "/home/pacs/" + pac.getName(); - String domDir = pacDir + "/doms/" + pac.getName() + ".hostsharing.net"; + String pacName = pac.getName(); + String pacDir = "/home/pacs/" + pacName; + String domDir = pacDir + "/doms/" + pacName + ".hostsharing.net"; String[] sourceDirs = new String[] { "web", "web-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ; String[] targetDirs = new String[] { "htdocs", "htdocs-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ; CompoundProcessor processor = new CompoundProcessor(); for (int idx = 0; idx < targetDirs.length; idx++) { processor.appendProcessor( - new ShellProcessor("rm -rf " + domDir + targetDirs[idx])); + new ShellProcessor("rm -rf " + domDir + "/" + targetDirs[idx])); } for (int idx = 0; idx < sourceDirs.length; idx++) { processor.appendProcessor( new ShellProcessor("shopt -s dotglob && ls " + pacDir + "/" + sourceDirs[idx] + " >/dev/null 2>&1" + - " && mv " + pacDir + "/" + sourceDirs[idx] + domDir + "/" + targetDirs[idx] + + " && mv " + pacDir + "/" + sourceDirs[idx] + " " + domDir + "/" + targetDirs[idx] + " || echo 'directory " + pacDir + "/" + sourceDirs[idx] + " not found'")); } processor.appendProcessor( new ShellProcessor("test -L " + domDir + "/htdocs" + - " && `stat -c '%N' " + domDir + "/htdocs |sed -e's/^.*`//' -e\"s/'$//\"` = web-ssl " + + " && `stat -c '%N' " + domDir + "/htdocs` |sed -e's/^.*`//' -e\"s/'$//\"` = web-ssl " + " && cd " + domDir + " && rm " + domDir + "/htdocs" + " && ln -sf htdocs-ssl htdocs" + - " && chown -h " + pac + ":" + pac + " " + domDir + "/htdocs")); + " && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs")); processor.appendProcessor( new ShellProcessor("test -L " + domDir + "/htdocs-ssl" + - " && `stat -c '%N' " + domDir + "/htdocs-ssl |sed -e's/^.*`//' -e\"s/'$//\"` = web " + + " && `stat -c '%N' " + domDir + "/htdocs-ssl` |sed -e's/^.*`//' -e\"s/'$//\"` = web " + " && cd " + domDir + " && rm " + domDir + "/htdocs-ssl" + " && ln -sf htdocs htdocs-ssl" + - " && chown -h " + pac + ":" + pac + " " + domDir + "/htdocs-ssl")); + " && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs-ssl")); return processor; } From 55bae82808ac07ae806fd431ab16ec819acb54b1 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 16:44:37 +0200 Subject: [PATCH 14/15] fix pac-domain migration --- hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index de64e48..e6851d5 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -392,14 +392,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory { } processor.appendProcessor( new ShellProcessor("test -L " + domDir + "/htdocs" + - " && `stat -c '%N' " + domDir + "/htdocs` |sed -e's/^.*`//' -e\"s/'$//\"` = web-ssl " + + " && `stat -c '%N' " + domDir + "/htdocs |sed -e\"s/[\\`']//g\" |cut -d ' ' -f 3` = web-ssl " + " && cd " + domDir + " && rm " + domDir + "/htdocs" + " && ln -sf htdocs-ssl htdocs" + " && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs")); processor.appendProcessor( new ShellProcessor("test -L " + domDir + "/htdocs-ssl" + - " && `stat -c '%N' " + domDir + "/htdocs-ssl` |sed -e's/^.*`//' -e\"s/'$//\"` = web " + + " && `stat -c '%N' " + domDir + "/htdocs-ssl |sed -e\"s/[\\`']//g\" |cut -d ' ' -f 3` = web " + " && cd " + domDir + " && rm " + domDir + "/htdocs-ssl" + " && ln -sf htdocs htdocs-ssl" + From f2c6ac85a48aa5d4096a9529ad1b8cc4a918230d Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Thu, 18 Oct 2012 16:53:50 +0200 Subject: [PATCH 15/15] fix pac-domain migration --- hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index de64e48..4d6fbfe 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -392,14 +392,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory { } processor.appendProcessor( new ShellProcessor("test -L " + domDir + "/htdocs" + - " && `stat -c '%N' " + domDir + "/htdocs` |sed -e's/^.*`//' -e\"s/'$//\"` = web-ssl " + + " && $( stat -c '%N' " + domDir + "/htdocs |sed -e\"s/[\\`']//g\" |cut -d ' ' -f 3 ) = web-ssl " + " && cd " + domDir + " && rm " + domDir + "/htdocs" + " && ln -sf htdocs-ssl htdocs" + " && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs")); processor.appendProcessor( new ShellProcessor("test -L " + domDir + "/htdocs-ssl" + - " && `stat -c '%N' " + domDir + "/htdocs-ssl` |sed -e's/^.*`//' -e\"s/'$//\"` = web " + + " && $( stat -c '%N' " + domDir + "/htdocs-ssl |sed -e\"s/[\\`']//g\" |cut -d ' ' -f 3 ) = web " + " && cd " + domDir + " && rm " + domDir + "/htdocs-ssl" + " && ln -sf htdocs htdocs-ssl" +