hsarback/database/database_update.sql
@@ -59,7 +59,7 @@ 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' ; hsarback/src/de/hsadmin/mods/dom/Domain.java
@@ -6,7 +6,6 @@ import java.util.Date; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityManager; hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -374,35 +374,38 @@ 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; } hsarback/src/de/hsadmin/mods/pac/PacModuleImpl.java
@@ -113,10 +113,10 @@ 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); hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -57,14 +57,25 @@ private Processor createHttpdVirtualProc( String pacName, List<Map<String, String>> pacValuesList) throws ProcessorException { Processor domSetupProcessor = new CompoundProcessor( new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.jtpl", new HashMap<String, String>(), 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<String, String>(), 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; } hsarback/src/de/hsadmin/mods/pac/httpd-virtual.jtpl
@@ -4,6 +4,7 @@ # <!-- BEGIN: iterate --> NameVirtualHost {PAC_IP}:80 NameVirtualHost {PAC_IP}:443 @@ -16,13 +17,12 @@ <VirtualHost {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 / </VirtualHost> <!-- END: iterate --> <!-- END: main --> hsarback/src/de/hsadmin/remote/EMailAddressRemote.java
@@ -65,6 +65,10 @@ } } adr.setTarget(tBuff.toString()); } else { if (l != null && l instanceof String) { adr.setTarget((String) l); } } String domain = (String) map.get("domain"); if (assertNotNull(domain)) { 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 hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java
@@ -162,6 +162,7 @@ } 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) {