HSAdmin Backend Domains, E-Mail, Datenbanken
Michael Hierweck
2013-04-12 953f0320d252b39a984488154fbc23e62a271189
Exit pac processor factory when processing "unknown" pac types.
Renamed DW/B and SW/B to PAC/DB and PAC/SW.
Introduced new pac type PAC/WEB.
Fixed tests.
13 files modified
90 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/dom/Domain.java 9 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 11 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/httpd-vhost.vm 6 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/Pac.java 4 ●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java 32 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/remote/RoleRemote.java 6 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/processor/PacProcessor.java 2 ●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/InitDataTest.java 2 ●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/LongCustomerNameTest.java 6 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/PacTest.java 6 ●●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/RemoteTest.java 2 ●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/RoleTest.java 2 ●●● patch | view | raw | blame | history
hsarback/test/de/hsadmin/remote/SSLCertDomainTest.java 2 ●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/Domain.java
@@ -180,4 +180,13 @@
        this.domainoptions = domainOptions;
    }
    public boolean isDynamic() {
        String pacType = getUser().getPac().getBasepac().getName();
        return isPacDomain() || (pacType == "PAC/WEB") || (pacType == "PAC/DW");
    }
    public boolean isStatic() {
        return !isDynamic();
    }
}
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -25,12 +25,12 @@
import de.hsadmin.mods.user.UnixUser;
public class DomainProcessorFactory implements EntityProcessorFactory {
    private static final String[] DW_STRUCTURE = new String[] {
    private static final String[] DYNAMIC_STRUCTURE = new String[] {
        "htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "cgi", "fastcgi", "cgi-ssl", "fastcgi-ssl", "etc", "var" 
    };
    
    private static final String[] SW_STRUCTURE = new String[] {
    private static final String[] STATIC_STRUCTURE = new String[] {
        "htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "etc", "var" 
    };
@@ -205,13 +205,12 @@
        UnixUser domUser = dom.getUser();
        String domName = dom.getName();
        Pac pac = domUser.getPac();
        boolean dynamicWeb = pac.isDynamicWeb() || dom.isPacDomain();
        String pacName = pac.getName();
        String homeDir = domUser.getHomedir();
        String domsDir = homeDir + "/doms";
        String userName = domUser.getName();
        String domainDir = domsDir + "/" + dom.getName();
        String[] subDirs = dynamicWeb ? DW_STRUCTURE : SW_STRUCTURE;
        String[] subDirs = dom.isDynamic() ? DYNAMIC_STRUCTURE : STATIC_STRUCTURE;
        String httpdRights = "";
        if (pacName != userName) {
            httpdRights =
@@ -248,7 +247,7 @@
        domDirsProcessor.appendProcessor(
                new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
            );
        if (dynamicWeb) {
        if (dom.isDynamic()) {
            domDirsProcessor.appendProcessor(
                    new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.vm", templateVars, dom, domainDir + "/cgi/test.cgi", userName, pacName, "755", false)
                );
hsarback/src/de/hsadmin/mods/dom/httpd-vhost.vm
@@ -13,7 +13,7 @@
    DocumentRoot /home/doms/${dom.name}/htdocs
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
#if( ${dom.isDynamic} )
    Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
    Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
#end
@@ -26,7 +26,7 @@
        AllowOverride AuthConfig FileInfo Indexes Limit
    </Directory>
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
#if( ${dom.isDynamic} )
    <Location /cgi-bin/>
        SetHandler cgi-script
        Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
@@ -63,7 +63,7 @@
    RewriteRule ^(.*) - [redirect=404,last]
#end
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
#if( ${dom.isDynamic} )
    AddType application/x-httpd-php .php .php5 .php4 .php3
    Action application/x-httpd-php /fastcgi-bin/phpstub
#end
hsarback/src/de/hsadmin/mods/pac/Pac.java
@@ -294,10 +294,6 @@
                || super.isReadAllowedFor(loginUser);
    }
    public boolean isDynamicWeb() {
        return getBasepac().getName().startsWith("DW");
    }
    public static String restriction() {
        return
            // all pacs of customer
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -23,11 +23,12 @@
    public <T extends AbstractEntity> Processor createCreateProcessor(
            EntityManager em, T entity) throws ProcessorException {
        Pac pac = (Pac) entity;
        String pacName = pac.getName();
        Hive hive = pac.getHive();
        UnixUser unixUser = getPacAdminUser(pac);
        String password = PasswordTool.generatePassword();
        return new CompoundProcessor(
        if (pac.getBasepac().getName().startsWith("PAC/")) {
            String pacName = pac.getName();
            Hive hive = pac.getHive();
            UnixUser unixUser = getPacAdminUser(pac);
            String password = PasswordTool.generatePassword();
            return new CompoundProcessor(
                createAddUserProc(pacName, unixUser, password), 
                createSetQuotaProc(pac),
                createEtcHostsProc(hive), 
@@ -39,6 +40,9 @@
                createIfUp(pacName),
                createHttpdVirtualProc(hive),
                createAccountingRulesProc());
        } else {
            return new ShellProcessor("exit 0"); //TODO: Nothing should happen here.
        }
    }
    private Processor createAccountingRulesProc() {
@@ -72,15 +76,20 @@
    public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) 
            throws ProcessorException {
        Pac pac = (Pac) entity;
        return createSetQuotaProc(pac);
        if (pac.getBasepac().getName().startsWith("PAC/")) {
            return createSetQuotaProc(pac);
        } else {
            return new ShellProcessor("exit 0"); //TODO: Nothing should happen here.
        }
    }
    @Override
    public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException {
        Pac pac = (Pac) entity;
        Hive hive = pac.getHive();
        WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName()));
        waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor(
        if (pac.getBasepac().getName().startsWith("PAC/")) {
            Hive hive = pac.getHive();
            WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName()));
            waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor(
                createIfDown(pac.getName()),
                createEtcHostsProc(hive), 
                createNetworkInterfacesProc(hive), 
@@ -88,7 +97,10 @@
                createProftpdConfProc(hive),
                createHttpdVirtualProc(hive),
                createAccountingRulesProc()), "remove packet");
        return waiting;
            return waiting;
        } else {
            return new ShellProcessor("exit 0"); //TODO: Nothing should happen here.
        }
    }
    private Processor createEtcHostsProc(Hive hive) throws ProcessorException {
hsarback/src/de/hsadmin/remote/RoleRemote.java
@@ -34,11 +34,7 @@
                role = "HOSTMASTER";
            }
            if (user.equals(pacName)) {
                if (pac.isDynamicWeb()) {
                    role = "PAC_ADMIN_DW";
                } else {
                    role = "PAC_ADMIN_SW";
                }
                role = "PAC_ADMIN";
            }
            if (role.equals("USER")) {
                GenericModuleImpl module = new GenericModuleImpl(transaction);
hsarback/test/de/hsadmin/processor/PacProcessor.java
@@ -69,7 +69,7 @@
    private BasePac findBasePacDW() {
        Query basepacQuery = entityManager.createQuery("SELECT b FROM BasePacs b WHERE b.name = :basepacName AND b.valid = :valid");
        basepacQuery.setParameter("basepacName", "DW/B");
        basepacQuery.setParameter("basepacName", "PAC/WEB");
        basepacQuery.setParameter("valid", Boolean.TRUE);
        return (BasePac) basepacQuery.getSingleResult();
    }
hsarback/test/de/hsadmin/remote/InitDataTest.java
@@ -77,7 +77,7 @@
        setParams.put("name", "aaa00");
        setParams.put("hive", "h99");
        setParams.put("customer", "hsh00-aaa");
        setParams.put("basepac", "DW/B");
        setParams.put("basepac", "PAC/WEB");
        setParams.put("curinetaddr", "176.9.242.74");
        Object[] params = new Object[] { user, 
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
hsarback/test/de/hsadmin/remote/LongCustomerNameTest.java
@@ -100,12 +100,12 @@
        pacParams.put("name", "p#");
        pacParams.put("hive", "h99");
        pacParams.put("customer", customer);
        pacParams.put("basepac", "DW/B");
        pacParams.put("basepac", "WEB/PAC");
        pacParams.put("curinetaddr", "176.9.242.76");
        HashMap<String, String> pacComponents = new HashMap<String, String>();
        pacComponents.put("QUOTA", "512");
        pacComponents.put("TRAFFIC", "8");
        pacComponents.put("TOMCAT", "0");
        pacComponents.put("TRAFFIC", "5");
        pacComponents.put("DAEMON", "1");
        pacParams.put("components", pacComponents);
        Object[] pacCallBlock = new Object[] { user, 
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
hsarback/test/de/hsadmin/remote/PacTest.java
@@ -92,12 +92,12 @@
        setParams.put("name", "aaa01");
        setParams.put("hive", "h99");
        setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
        setParams.put("basepac", "DW/B");
        setParams.put("basepac", "PAC/WEB");
        setParams.put("curinetaddr", "176.9.242.76");
        HashMap<String, String> components = new HashMap<String, String>();
        components.put("QUOTA", "512");
        components.put("TRAFFIC", "8");
        components.put("TOMCAT", "1");
        components.put("TRAFFIC", "5");
        components.put("DAEMON", "1");
        setParams.put("components", components);
        Object[] params = new Object[] { user, 
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
hsarback/test/de/hsadmin/remote/RemoteTest.java
@@ -16,8 +16,8 @@
    EMailAliasTest.class,
    DomainTest.class,
    EMailAddressTest.class,
    LongCustomerNameTest.class
//    CustomerTest.class,
    LongCustomerNameTest.class
//    QueueTaskTest.class
})
hsarback/test/de/hsadmin/remote/RoleTest.java
@@ -45,7 +45,7 @@
            Object[] result = (Object[]) execute;
            assertTrue(result.length == 1);
            String role = (String) ((Map<?, ?>) result[0]).get("role");
            assertEquals("PAC_ADMIN_DW", role);
            assertEquals("PAC_ADMIN", role);
        } catch (XmlRpcException e) {
            fail(e.getMessage());
        }
hsarback/test/de/hsadmin/remote/SSLCertDomainTest.java
@@ -46,7 +46,7 @@
        setParams.put("name", "aaa02");
        setParams.put("hive", "h99");
        setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
        setParams.put("basepac", "DW/B");
        setParams.put("basepac", "PAC/WEB");
        setParams.put("curinetaddr", "176.9.242.77");
        Object[] params = new Object[] { user, 
                cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),