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' ; 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; diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index b09d7d3..3a320a3 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -374,35 +374,38 @@ 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 " + + " && test $( 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 " + pac + ":" + pac + " " + domDir + "/htdocs")); + " && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs" + + " || echo 'link htdocs not found'")); processor.appendProcessor( new ShellProcessor("test -L " + domDir + "/htdocs-ssl" + - " && `stat -c '%N' " + domDir + "/htdocs-ssl |sed -e's/^.*`//' -e\"s/'$//\"` = web " + + " && test $( 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" + - " && chown -h " + pac + ":" + pac + " " + domDir + "/htdocs-ssl")); + " && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs-ssl" + + " || echo 'link htdocs-ssl not found'")); return processor; } 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..b0013fb 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -57,14 +57,25 @@ 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 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 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 /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\" /etc/apache2/virtual.conf.tmp && " + + " sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/c \\\n" + + "\\ \\ \\ \\ 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 -c29- ); do " + + "ls $PEM >/dev/null 2>&1 || " + + " 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 )" + + " || ( mv /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf " + + " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) ")); return domSetupProcessor; } diff --git a/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl b/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl index 719f1db..1361e90 100644 --- a/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl +++ b/hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl @@ -4,6 +4,7 @@ # + NameVirtualHost {PAC_IP}:80 NameVirtualHost {PAC_IP}:443 @@ -16,13 +17,12 @@ 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 Redirect 404 / + \ No newline at end of file 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)) { 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 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) {