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.
| | |
| | | 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(); |
| | | } |
| | | |
| | | } |
| | |
| | | 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" |
| | | }; |
| | | |
| | |
| | | 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 = |
| | |
| | | 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) |
| | | ); |
| | |
| | | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | || super.isReadAllowedFor(loginUser); |
| | | } |
| | | |
| | | public boolean isDynamicWeb() { |
| | | return getBasepac().getName().startsWith("DW"); |
| | | } |
| | | |
| | | public static String restriction() { |
| | | return |
| | | // all pacs of customer |
| | |
| | | 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), |
| | |
| | | createIfUp(pacName), |
| | | createHttpdVirtualProc(hive), |
| | | createAccountingRulesProc()); |
| | | } else { |
| | | return new ShellProcessor("exit 0"); //TODO: Nothing should happen here. |
| | | } |
| | | } |
| | | |
| | | private Processor createAccountingRulesProc() { |
| | |
| | | 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), |
| | |
| | | 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 { |
| | |
| | | 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); |
| | |
| | | |
| | | 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(); |
| | | } |
| | |
| | | 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()), |
| | |
| | | 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()), |
| | |
| | | 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()), |
| | |
| | | EMailAliasTest.class, |
| | | DomainTest.class, |
| | | EMailAddressTest.class, |
| | | LongCustomerNameTest.class |
| | | // CustomerTest.class, |
| | | LongCustomerNameTest.class |
| | | // QueueTaskTest.class |
| | | }) |
| | | |
| | |
| | | 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()); |
| | | } |
| | |
| | | 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()), |