diff --git a/authenticator/.gitignore b/authenticator/.gitignore new file mode 100644 index 0000000..2f230b7 --- /dev/null +++ b/authenticator/.gitignore @@ -0,0 +1,2 @@ +/build +/bin \ No newline at end of file diff --git a/hsacppcli/.gitignore b/hsacppcli/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/hsacppcli/.gitignore @@ -0,0 +1 @@ +/build diff --git a/hsarback/.gitignore b/hsarback/.gitignore index e69de29..2f230b7 100644 --- a/hsarback/.gitignore +++ b/hsarback/.gitignore @@ -0,0 +1,2 @@ +/build +/bin \ No newline at end of file diff --git a/hsarback/database/data.sql b/hsarback/database/data.sql index c91a7fc..b9f87d6 100644 --- a/hsarback/database/data.sql +++ b/hsarback/database/data.sql @@ -166,3 +166,5 @@ INSERT INTO domain_option (domain_option_name) VALUES ('indexes'); INSERT INTO domain_option (domain_option_name) VALUES ('multiviews'); +INSERT INTO domain_option (domain_option_name) + VALUES ('php'); diff --git a/hsarback/database/database_update.sql b/hsarback/database/database_update.sql index dd855d7..04b41fb 100644 --- a/hsarback/database/database_update.sql +++ b/hsarback/database/database_update.sql @@ -1,80 +1,31 @@ --- Migrate database from version 2.1 to version 2.2 +-- Migrate database from version 2.2 to version 2.3 -- --- domain options --- -CREATE SEQUENCE domain_option_id_seq - INCREMENT BY 1 - NO MAXVALUE - NO MINVALUE - CACHE 1; - -CREATE TABLE domain_option ( - domain_option_id integer DEFAULT nextval(('"domain_option_id_seq"'::text)::regclass) NOT NULL, - domain_option_name character varying(50) NOT NULL -); - -ALTER TABLE ONLY domain_option - ADD CONSTRAINT pk_domain_option PRIMARY KEY (domain_option_id); - -CREATE UNIQUE INDEX domain_option_name_idx ON domain_option USING btree ( domain_option_name ); - -CREATE TABLE domain__domain_option ( - domain_option_id integer NOT NULL, - domain_id integer NOT NULL -); - -ALTER TABLE ONLY domain__domain_option - ADD CONSTRAINT pk_domain__domain_option PRIMARY KEY (domain_option_id, domain_id); - -ALTER TABLE ONLY domain__domain_option - ADD CONSTRAINT domain_option_id_fkey FOREIGN KEY (domain_option_id) - REFERENCES domain_option(domain_option_id) DEFERRABLE; - -ALTER TABLE ONLY domain__domain_option - ADD CONSTRAINT domain_id_fkey FOREIGN KEY (domain_id) - REFERENCES domain(domain_id) DEFERRABLE; -- -- table: domain_option -- -INSERT INTO domain_option (domain_option_name) - VALUES ('backupmxforexternalmx'); -INSERT INTO domain_option (domain_option_name) - VALUES ('greylisting'); INSERT INTO domain_option (domain_option_name) - VALUES ('htdocsfallback'); -INSERT INTO domain_option (domain_option_name) - VALUES ('includes'); -INSERT INTO domain_option (domain_option_name) - VALUES ('indexes'); -INSERT INTO domain_option (domain_option_name) - VALUES ('multiviews'); + VALUES ('php'); -- -- new domain options settings -- --- existing default = ON --- -INSERT INTO domain__domain_option SELECT domain_option_id, domain_id - FROM domain, domain_option - WHERE domain_option.domain_option_name = 'greylisting' ; +-- existing default = On for DW-packet, Off otherwise. +-- INSERT INTO domain__domain_option SELECT domain_option_id, domain_id - FROM domain, domain_option - 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' ; -INSERT INTO domain__domain_option SELECT domain_option_id, domain_id - FROM domain, domain_option - WHERE domain_option.domain_option_name = 'indexes' ; -INSERT INTO domain__domain_option SELECT domain_option_id, domain_id - FROM domain, domain_option - WHERE domain_option.domain_option_name = 'multiviews' ; + FROM domain + JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id ) + JOIN packet on ( unixuser.packet_id = packet.packet_id ) + JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id ) + , domain_option + WHERE basepacket.basepacket_code = 'DW/B' + AND domain_option.domain_option_name = 'php' ; +DELETE FROM domain__domain_option USING domain_option, domain + JOIN unixuser on ( domain.domain_owner = unixuser.unixuser_id ) + JOIN packet on ( unixuser.packet_id = packet.packet_id ) + JOIN basepacket on ( packet.bp_id = basepacket.basepacket_id ) + WHERE basepacket.basepacket_code != 'DW/B' + AND domain__domain_option.domain_option_id = domain_option.domain_option_id + AND domain_option.domain_option_name = 'php' ; -- --- existing default = OFF --- -DELETE FROM domain__domain_option USING domain_option - WHERE domain__domain_option.domain_option_id = domain_option.domain_option_id - AND domain_option.domain_option_name = 'backupmxforexternalmx' ; --- --- End of migratino to version 2.2 +-- End of migration to version 2.3 -- diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index b864e99..f4b05b1 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -59,7 +59,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, hiveInetAddr), queueName + ".hostsharing.net"); } for (String queueName : config.getProperty("queues.mail").split(",")) { - mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, domName, pac), queueName + ".hostsharing.net"); + mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net"); } templateVars = new HashMap(); templateVars.put("PAC", pacName); @@ -95,7 +95,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { WaitingTasksProcessor processor = new WaitingTasksProcessor(createApacheVHostSetupProcessor(em, dom, templateVars)); Config config = Config.getInstance(); for (String queueName : config.getProperty("queues.mail").split(",")) { - processor.appendProcessor(queueName, createPostgreyConfiguration(em), queueName + ".hostsharing.net"); + processor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net"); } return processor; } @@ -111,8 +111,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { mainProcessor.appendProcessor(queueName, createDNSServerRemoveProcessor(domName), queueName + ".hostsharing.net"); } for (String queueName : config.getProperty("queues.mail").split(",")) { - mainProcessor.appendProcessor(queueName, createMailinDeleteProcessor(domName), queueName + ".hostsharing.net"); - mainProcessor.appendProcessor(queueName, createPostgreyConfiguration(em), queueName + ".hostsharing.net"); + mainProcessor.appendProcessor(queueName, createMailinUnsetupProcessor(em, dom), queueName + ".hostsharing.net"); } mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost"); return mainProcessor; @@ -176,17 +175,30 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && invoke-rc.d bind9 reload"); } - private Processor createMailinSetupProcessor(EntityManager em, String domName, Pac pac) throws ProcessorException { + private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException { String inetAddr = pac.getCurINetAddr().getInetAddr(); - return new CompoundProcessor( + CompoundProcessor cp = new CompoundProcessor( createPostgreyConfiguration(em), new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains", - domName + " anything\n" + - "." + domName + " anything\n"), - new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport", - domName + " smtp:" + inetAddr + ":225\n" + - "." + domName + " smtp:" + inetAddr + ":225\n") - ); + dom.getName() + " anything\n" + + "." + dom.getName() + " anything\n")); + Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname"); + query.setParameter("domname", dom.getName()); + query.setParameter("option", "backupmxforexternalmx"); + if (query.getResultList().isEmpty()) { + cp.appendProcessor( + new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport", + dom.getName() + " smtp:" + inetAddr + ":225\n" + + "." + dom.getName() + " smtp:" + inetAddr + ":225\n") + ); + } else { + cp.appendProcessor( + new ShellProcessor( + "postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " + + "postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport") + ); + } + return cp; } private Processor createPostgreyConfiguration(EntityManager em) throws ProcessorException { @@ -213,12 +225,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory { ); } - private Processor createMailinDeleteProcessor(String domName) { - Processor mailQueueProcessor = new ShellProcessor( - "postmap -d '" + domName + "' /etc/postfix-mailin/relaydomains && " + - "postmap -d '" + domName + "' /etc/postfix-mailin/transport && " + - "postmap -d '." + domName + "' /etc/postfix-mailin/relaydomains && " + - "postmap -d '." + domName + "' /etc/postfix-mailin/transport"); + private Processor createMailinUnsetupProcessor(EntityManager em, Domain dom) throws ProcessorException { + Processor mailQueueProcessor = new CompoundProcessor( + createPostgreyConfiguration(em), + new ShellProcessor( + "postmap -d '" + dom.getName() + "' /etc/postfix-mailin/relaydomains && " + + "postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " + + "postmap -d '." + dom.getName() + "' /etc/postfix-mailin/relaydomains && " + + "postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport")); return mailQueueProcessor; } diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java b/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java index 71ada28..34d0988 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java @@ -23,12 +23,16 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory { CompoundProcessor cp = new CompoundProcessor(); cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual", email.getFullDomain() + " -" ) ); + WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); + Config config = Config.getInstance(); cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual", email.getEMailAddress() + " " + email.getTarget() ) ); - if (emailAddressCount(em, email) < 2) { - WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); - String domName = email.getDomain().getName(); - Config config = Config.getInstance(); + for (String queueName : config.getProperty("queues.mail").split(",")) { + waitingTasksProcessor.appendProcessor(queueName, new ShellProcessor( "postmap -r -i /etc/postfix-mailin/relayrecipients", + email.getEMailAddress() + " anything" ), "Add to relayrecipients" ); + } + if (emailAddressCount(em, email) <= 1) { + String domName = email.getDomain().getName(); for (String queueName : config.getProperty("queues.mail").split(",")) { waitingTasksProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net"); } @@ -49,14 +53,18 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory { EMailAddress email = (EMailAddress) entity; cp.appendProcessor( new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/virtual" ) ); + Config config = Config.getInstance(); + WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); + for (String queueName : config.getProperty("queues.mail").split(",")) { + waitingTasksProcessor.appendProcessor(queueName, + new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/relayrecipients" ), "Remove from relayrecipients" ); + } int emailAddressCount = emailAddressCount(em, email); if (emailAddressCount == 0) { // remove the domain from virtual.db String fullDomain = email.getFullDomain(); cp.appendProcessor( - new ShellProcessor( "postmap -d '" + fullDomain + "' /etc/postfix-mailin/virtual" ) ); - WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); - Config config = Config.getInstance(); + new ShellProcessor( "postmap -d '" + fullDomain + "' /etc/postfix-mailin/virtual" ) ); for (String queueName : config.getProperty("queues.mail").split(",")) { waitingTasksProcessor.appendProcessor(queueName, createMailinDeleteProcessor(fullDomain), queueName + ".hostsharing.net"); } diff --git a/hsarback/webapp/META-INF/.gitignore b/hsarback/webapp/META-INF/.gitignore new file mode 100644 index 0000000..67d823d --- /dev/null +++ b/hsarback/webapp/META-INF/.gitignore @@ -0,0 +1 @@ +/context.xml diff --git a/hsarback/webapp/WEB-INF/.gitignore b/hsarback/webapp/WEB-INF/.gitignore new file mode 100644 index 0000000..2ba34e6 --- /dev/null +++ b/hsarback/webapp/WEB-INF/.gitignore @@ -0,0 +1 @@ +/web.xml diff --git a/hsarjcli/.gitignore b/hsarjcli/.gitignore new file mode 100644 index 0000000..2f230b7 --- /dev/null +++ b/hsarjcli/.gitignore @@ -0,0 +1,2 @@ +/build +/bin \ No newline at end of file diff --git a/hsarweb/.gitignore b/hsarweb/.gitignore index 796b96d..2f230b7 100644 --- a/hsarweb/.gitignore +++ b/hsarweb/.gitignore @@ -1 +1,2 @@ /build +/bin \ No newline at end of file diff --git a/hsarweb/WebContent/WEB-INF/.gitignore b/hsarweb/WebContent/WEB-INF/.gitignore new file mode 100644 index 0000000..2ba34e6 --- /dev/null +++ b/hsarweb/WebContent/WEB-INF/.gitignore @@ -0,0 +1 @@ +/web.xml diff --git a/hsarweb/WebContent/index.jsp b/hsarweb/WebContent/index.jsp index 83c6cf9..f57fb9a 100644 --- a/hsarweb/WebContent/index.jsp +++ b/hsarweb/WebContent/index.jsp @@ -19,11 +19,13 @@ + -

HSAdmin Web

+
+ \ No newline at end of file diff --git a/hsarweb/conf/WEB-INF/web.xml b/hsarweb/conf/WEB-INF/web.xml index e9a46ec..2acd982 100644 --- a/hsarweb/conf/WEB-INF/web.xml +++ b/hsarweb/conf/WEB-INF/web.xml @@ -57,6 +57,7 @@ + CAS Validation Filter /* @@ -66,7 +67,7 @@ CAS Authentication Filter /* - + Logout Servlet de.hsadmin.logout.LogoutServlet @@ -93,11 +94,15 @@ HSAdmin Web - /* + /MainApplication/* + + + + HSAdmin Web + /VAADIN/* - index.html index.jsp \ No newline at end of file diff --git a/hsarweb/src/de/hsadmin/web/AbstractModule.java b/hsarweb/src/de/hsadmin/web/AbstractModule.java index 4b37670..8726124 100644 --- a/hsarweb/src/de/hsadmin/web/AbstractModule.java +++ b/hsarweb/src/de/hsadmin/web/AbstractModule.java @@ -4,15 +4,21 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Select; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -import com.vaadin.ui.Button.ClickEvent; import de.hsadmin.web.config.ComponentFactory; import de.hsadmin.web.config.LocaleConfig; @@ -28,22 +34,28 @@ public abstract class AbstractModule implements Module, Serializable { private VerticalLayout layout; private Component component; private ComponentFactory componentFactory; + private Select selRunAs; public Component getComponent() { return layout; } public void reload() throws HsarwebException { + if (selRunAs != null) { + selRunAs.select(application.getRunAs()); + selRunAs.setScrollToSelectedItem(true); + } componentFactory.loadData(); } - private void initLayout() { + private void initLayout() throws HsarwebException { layout = new VerticalLayout(); layout.setSizeFull(); final Module thisModule = this; final ModuleConfig moduleConfig = getModuleConfig(); final LocaleConfig localeConfig = application.getLocaleConfig(); - if (this instanceof SearchAble || this instanceof InsertAble) { + if (this instanceof SearchAble || this instanceof InsertAble || + !("USER".equals(application.getLoginUserRole()) || "NONE".equals(application.getLoginUserRole()))) { HorizontalLayout toolbar = new HorizontalLayout(); if (this instanceof InsertAble) { Button btNew = new Button(moduleConfig.getLabel("new")); @@ -97,16 +109,53 @@ public abstract class AbstractModule implements Module, Serializable { }); toolbar.addComponent(btNew); } -// if (this instanceof SearchAble) { -// Button btSearch = new Button("search"); -// toolbar.addComponent(btSearch); -// } + toolbar.setWidth("100%"); + Label space = new Label(" "); + space.setWidth("100%"); + toolbar.addComponent(space); + toolbar.setExpandRatio(space, 1.0f); + createRunAsSelect(toolbar); + Button btLogout = new Button(localeConfig.getText("logout")); + btLogout.addListener(new ClickListener() { + private static final long serialVersionUID = 1L; + @Override + public void buttonClick(ClickEvent event) { + ExternalResource logoutLink = new ExternalResource("logout"); + application.getMainWindow().open(logoutLink); + } + }); + toolbar.addComponent(btLogout); + ThemeResource icon = new ThemeResource("../runo/icons/16/cancel.png"); + btLogout.setIcon(icon); layout.addComponent(toolbar); } layout.addComponent(component); layout.setExpandRatio(component, 1.0f); } + private void createRunAsSelect(HorizontalLayout toolbar) throws UnsupportedOperationException, HsarwebException { + selRunAs = new Select(); + selRunAs.setWidth(100.0f, Sizeable.UNITS_PIXELS); + selRunAs.setImmediate(true); + selRunAs.setNewItemsAllowed(true); + selRunAs.setNullSelectionAllowed(false); + selRunAs.addItem(application.getLogin()); + for (Object item : application.readSelectRunAsItems()) { + selRunAs.addItem(item); + } + selRunAs.select(application.getRunAs()); + selRunAs.setScrollToSelectedItem(true); + selRunAs.addListener(new Property.ValueChangeListener() { + private static final long serialVersionUID = 1L; + @Override + public void valueChange(ValueChangeEvent event) { + Property property = event.getProperty(); + application.setRunAs(property.getValue().toString()); + } + }); + selRunAs.setDescription(application.getLocaleConfig().getText("runas")); + toolbar.addComponent(selRunAs); + } public void setApplication(MainApplication app) throws HsarwebException { application = app; diff --git a/hsarweb/src/de/hsadmin/web/DatabaseModule.java b/hsarweb/src/de/hsadmin/web/DatabaseModule.java index 3ccea15..8a70b38 100644 --- a/hsarweb/src/de/hsadmin/web/DatabaseModule.java +++ b/hsarweb/src/de/hsadmin/web/DatabaseModule.java @@ -29,7 +29,7 @@ public abstract class DatabaseModule extends GenericModule { protected void initModule() { MainApplication application = getApplication(); moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale()); - String login = application.getLogin(); + String login = application.getRunAs(); final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); idProp.setReadOnly(true); diff --git a/hsarweb/src/de/hsadmin/web/DatabaseUserModule.java b/hsarweb/src/de/hsadmin/web/DatabaseUserModule.java index c42d5a5..6f80135 100644 --- a/hsarweb/src/de/hsadmin/web/DatabaseUserModule.java +++ b/hsarweb/src/de/hsadmin/web/DatabaseUserModule.java @@ -24,7 +24,7 @@ public abstract class DatabaseUserModule extends GenericModule { protected void initModule() { MainApplication application = getApplication(); moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale()); - String login = application.getLogin(); + String login = application.getRunAs(); final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); idProp.setReadOnly(true); diff --git a/hsarweb/src/de/hsadmin/web/DomainModule.java b/hsarweb/src/de/hsadmin/web/DomainModule.java index ef39e5f..d1ddfef 100644 --- a/hsarweb/src/de/hsadmin/web/DomainModule.java +++ b/hsarweb/src/de/hsadmin/web/DomainModule.java @@ -23,7 +23,7 @@ public class DomainModule extends GenericModule { protected void initModule() { MainApplication application = getApplication(); moduleConfig = new ModuleConfig("domain", application.getLocale()); - String login = application.getLogin(); + String login = application.getRunAs(); final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); idProp.setReadOnly(true); diff --git a/hsarweb/src/de/hsadmin/web/EMailAddressModule.java b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java index 8bdc8d5..3e99c6f 100644 --- a/hsarweb/src/de/hsadmin/web/EMailAddressModule.java +++ b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java @@ -22,7 +22,7 @@ public class EMailAddressModule extends GenericModule { protected void initModule() { MainApplication application = getApplication(); moduleConfig = new ModuleConfig("emailaddress", application.getLocale()); - String login = application.getLogin(); + String login = application.getRunAs(); final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); idProp.setReadOnly(true); diff --git a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java index 21769e4..51a4139 100644 --- a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java +++ b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java @@ -22,7 +22,7 @@ public class EMailAliasModule extends GenericModule { protected void initModule() { MainApplication application = getApplication(); moduleConfig = new ModuleConfig("emailalias", application.getLocale()); - String login = application.getLogin(); + String login = application.getRunAs(); final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); idProp.setReadOnly(true); diff --git a/hsarweb/src/de/hsadmin/web/HomeModule.java b/hsarweb/src/de/hsadmin/web/HomeModule.java index d71e536..e6bc473 100644 --- a/hsarweb/src/de/hsadmin/web/HomeModule.java +++ b/hsarweb/src/de/hsadmin/web/HomeModule.java @@ -95,7 +95,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon")); button.setIcon(icon); Map whereHash = new HashMap(); - whereHash.put("name", application.getLogin()); + whereHash.put("name", application.getRunAs()); Long key = -1L; try { Object object = application.getRemote().callSearch(moduleConfig.getRemoteName(), whereHash); diff --git a/hsarweb/src/de/hsadmin/web/ItemsReader.java b/hsarweb/src/de/hsadmin/web/ItemsReader.java new file mode 100644 index 0000000..95e22f2 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/ItemsReader.java @@ -0,0 +1,25 @@ +package de.hsadmin.web; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ItemsReader { + + public static List readItemList(MainApplication app, String module, String property) throws HsarwebException { + final List itemsList = new ArrayList(); + Object custListObj = app.getRemote().callSearch(module, new HashMap()); + if (custListObj instanceof Object[]) { + Object[] custList = (Object[]) custListObj; + for (Object custObj : custList) { + if (custObj instanceof Map) { + Map custHash = (Map)custObj; + itemsList.add(custHash.get(property)); + } + } + } + return itemsList; + } + +} \ No newline at end of file diff --git a/hsarweb/src/de/hsadmin/web/MainApplication.java b/hsarweb/src/de/hsadmin/web/MainApplication.java index 5a883c9..fc81e35 100644 --- a/hsarweb/src/de/hsadmin/web/MainApplication.java +++ b/hsarweb/src/de/hsadmin/web/MainApplication.java @@ -1,6 +1,8 @@ package de.hsadmin.web; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Locale; import java.util.Map; @@ -46,6 +48,11 @@ public class MainApplication extends Application implements HttpServletRequestLi private Remote remote; private Map modules; private Locale requestLocale; + private String loginUserRole = "NONE"; + private String runAs = null; + private TabSheet tabSheet; + private Window mainWindow; + private List runAsList = null; @Override @@ -56,41 +63,9 @@ public class MainApplication extends Application implements HttpServletRequestLi } localeConfig = new LocaleConfig(locale, "main"); remote = new Remote(this); - String role = "NONE"; - try { - Object rolesArrayObj = remote.callSearch("role", null); - if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) { - Object[] rolesArray = (Object[]) rolesArrayObj; - if (rolesArray.length > 0 && rolesArray[0] instanceof Map) { - role = (String) ((Map) rolesArray[0]).get("role"); - } - } - } catch (HsarwebException e) { - showSystemException(e); - } - Window mainWindow = new Window(localeConfig.getText("applicationtitle")); - TabSheet tabs = new TabSheet(); - tabs.setSizeFull(); - String modulesParamString = localeConfig.getText("modules." + role); - modules = new HashMap(); - Module firstModule = null; - for (String className : modulesParamString.split(",")) { - try { - Module module = (Module) Class.forName(className).newInstance(); - module.setApplication(this); - if (firstModule == null) { - firstModule = module; - } - ModuleConfig moduleConfig = module.getModuleConfig(); - String label = moduleConfig.getLabel("moduletitle"); - modules.put(label, module); - tabs.addTab((Component) module.getComponent(), label, new ThemeResource(moduleConfig.getLabel("moduleicon"))); - } catch (Exception e) { - showSystemException(e); - } - } - tabs.addListener(this); - mainWindow.setContent(tabs); + loginUserRole = readUserRole(); + mainWindow = new Window(localeConfig.getText("applicationtitle")); + Module firstModule = initTabSheet(); setMainWindow(mainWindow); setErrorHandler(new Terminal.ErrorListener() { private static final long serialVersionUID = 1L; @@ -106,6 +81,51 @@ public class MainApplication extends Application implements HttpServletRequestLi } } + private String readUserRole() { + try { + Object rolesArrayObj = remote.callSearch("role", null); + if (rolesArrayObj != null && rolesArrayObj instanceof Object[]) { + Object[] rolesArray = (Object[]) rolesArrayObj; + if (rolesArray.length > 0 && rolesArray[0] instanceof Map) { + return (String) ((Map) rolesArray[0]).get("role"); + } + } + } catch (HsarwebException e) { + showSystemException(e); + } + return "NONE"; + } + + private Module initTabSheet() { + tabSheet = new TabSheet(); + tabSheet.setSizeFull(); + String modulesParamString = localeConfig.getText("modules." + readUserRole()); + modules = new HashMap(); + Module firstModule = null; + for (String className : modulesParamString.split(",")) { + try { + Module module = (Module) Class.forName(className).newInstance(); + module.setApplication(this); + if (firstModule == null) { + firstModule = module; + } + ModuleConfig moduleConfig = module.getModuleConfig(); + String label = moduleConfig.getLabel("moduletitle"); + modules.put(label, module); + tabSheet.addTab((Component) module.getComponent(), label, new ThemeResource(moduleConfig.getLabel("moduleicon"))); + } catch (Exception e) { + showSystemException(e); + } + } + tabSheet.addListener(this); + mainWindow.setContent(tabSheet); + return firstModule; + } + + public String getLoginUserRole() { + return loginUserRole; + } + public String getProxyTicket() { return userPrincipal.getProxyTicketFor(servletContext.getInitParameter("backendURL")); } @@ -186,4 +206,41 @@ public class MainApplication extends Application implements HttpServletRequestLi getMainWindow().showNotification("System-Fehler", "
Bitte informieren Sie den Support
" + e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } + public String getRunAs() { + if (runAs == null) { + return getLogin(); + } + return runAs; + } + + public void setRunAs(String runAs) { + this.runAs = runAs; + initTabSheet(); + Component selectedTab = tabSheet.getSelectedTab(); + Tab tab = tabSheet.getTab(selectedTab); + Module module = modules.get(tab.getCaption()); + try { + module.reload(); + } catch (HsarwebException e) { + e.printStackTrace(); + showSystemException(e); + } + } + + public List readSelectRunAsItems() throws HsarwebException { + if (runAsList == null) { + runAsList = new ArrayList(); + if ("HOSTMASTER".equals(loginUserRole)) { + runAsList = ItemsReader.readItemList(this, "member", "membercode"); + } + if ("CUSTOMER".equals(loginUserRole)) { + runAsList = ItemsReader.readItemList(this, "pac", "name"); + } + if (loginUserRole.startsWith("PAC")) { + runAsList = ItemsReader.readItemList(this, "user", "name"); + } + } + return runAsList; + } + } diff --git a/hsarweb/src/de/hsadmin/web/Remote.java b/hsarweb/src/de/hsadmin/web/Remote.java index 512d7de..b9771a6 100644 --- a/hsarweb/src/de/hsadmin/web/Remote.java +++ b/hsarweb/src/de/hsadmin/web/Remote.java @@ -36,7 +36,7 @@ public class Remote { private Object xmlrpcCall(String module, String operation, Map param1) throws HsarwebException { Object[] params = new Object[3]; - params[0] = app.getLogin(); + params[0] = app.getRunAs(); params[1] = app.getProxyTicket(); params[2] = param1 != null ? param1 : new HashMap(); return xmlrpcCall(module + "." + operation, params); @@ -44,7 +44,7 @@ public class Remote { private Object xmlrpcCall(String module, String operation, Map param1, Map param2) throws HsarwebException { Object[] params = new Object[4]; - params[0] = app.getLogin(); + params[0] = app.getRunAs(); params[1] = app.getProxyTicket(); params[2] = param1 != null ? param1 : new HashMap(); params[3] = param2 != null ? param2 : new HashMap(); diff --git a/hsarweb/src/de/hsadmin/web/UnixUserModule.java b/hsarweb/src/de/hsadmin/web/UnixUserModule.java index 09732f5..7cc59e8 100644 --- a/hsarweb/src/de/hsadmin/web/UnixUserModule.java +++ b/hsarweb/src/de/hsadmin/web/UnixUserModule.java @@ -22,7 +22,7 @@ public class UnixUserModule extends GenericModule { protected void initModule() { MainApplication application = getApplication(); moduleConfig = new ModuleConfig("user", application.getLocale()); - String login = application.getLogin(); + String login = application.getRunAs(); final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory()); pacProp.setSelectValues(new PropertySelectValues() { diff --git a/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java b/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java index a854c29..3c3a308 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java @@ -75,6 +75,38 @@ public class GenericForm { return null; } + public Form createDeleteForm() { + try { + MainApplication application = module.getApplication(); + ModuleConfig config = module.getModuleConfig(); + Map where = new HashMap(); + where.put(findIdKey(), entityId.toString()); + Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where); + if (searchResult instanceof Object[]) { + Map row = (Map) (((Object[]) searchResult)[0]); + Form f = new Form(); + f.setCaption(config.getLabel("delete")); + f.setData(entityId); + Layout layout = f.getLayout(); + for (PropertyConfig prop : config.getPropertyList()) { + if (prop.getPropFieldFactory().getClass().equals(DefaultPropertyFieldFactory.class) + && prop.getPropTableColumn().equals(PropertyTableColumn.DISPLAY)) { + PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory(); + Object value = row.get(prop.getId()); + Component component = (Component) propFieldFactory.createFieldComponent(prop, value); + component.setReadOnly(true); + layout.addComponent(component); + } + } + return f; + } + } catch (HsarwebException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + private String findIdKey() { List propertyList = module.getModuleConfig().getPropertyList(); String idKey = null; diff --git a/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java index fd98b01..83951af 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java @@ -13,13 +13,12 @@ import com.vaadin.data.Property; import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.themes.BaseTheme; import de.hsadmin.web.DeleteAble; @@ -260,6 +259,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable { private Button createDeleteButton(long id) { ThemeResource icon = new ThemeResource("../runo/icons/16/document-delete.png"); final Button button = new Button(); + final Module thisModule = module; button.setIcon(icon); button.setDescription(module.getApplication().getLocaleConfig().getText("delete")); button.setData(id); @@ -269,14 +269,16 @@ public class TableComponentFactory implements ComponentFactory, Serializable { private Window childWindow; @Override public void buttonClick(ClickEvent event) { + final GenericForm genericForm = new GenericForm(thisModule, (Long) button.getData()); + final Form form = genericForm.createDeleteForm(); final MainApplication application = module.getApplication(); LocaleConfig localeConfig = application.getLocaleConfig(); childWindow = new Window(module.getModuleConfig().getLabel("moduletitle") + " " + localeConfig.getText("delete")); - childWindow.setWidth(320.0f, Sizeable.UNITS_PIXELS); + childWindow.setWidth(640.0f, Sizeable.UNITS_PIXELS); VerticalLayout vLayout = new VerticalLayout(); vLayout.setMargin(true); vLayout.setSpacing(true); - vLayout.addComponent(new Label(localeConfig.getText("confirmdelete"))); + vLayout.addComponent(form); HorizontalLayout hLayout = new HorizontalLayout(); Button btDeleteRow = new Button(localeConfig.getText("delete")); btDeleteRow.addListener(new Button.ClickListener() { diff --git a/hsarweb/src/texts/domain.properties b/hsarweb/src/texts/domain.properties index 6f6b42c..6d5a419 100644 --- a/hsarweb/src/texts/domain.properties +++ b/hsarweb/src/texts/domain.properties @@ -7,4 +7,5 @@ since=connected since moduletitle=domains moduleicon=../runo/icons/16/document-web.png new=configure domain -update=update domain \ No newline at end of file +update=update domain +delete=delete domain \ No newline at end of file diff --git a/hsarweb/src/texts/domain_de.properties b/hsarweb/src/texts/domain_de.properties index b6f93f3..c75bfbc 100644 --- a/hsarweb/src/texts/domain_de.properties +++ b/hsarweb/src/texts/domain_de.properties @@ -7,4 +7,5 @@ since=aufgeschaltet seit moduletitle=Domains moduleicon=../runo/icons/16/document-web.png new=Domain konfigurieren -update=Domaindaten ändern \ No newline at end of file +update=Domainkonfiguration ändern +delete=Domainkonfiguration löschen \ No newline at end of file diff --git a/hsarweb/src/texts/emailaddress.properties b/hsarweb/src/texts/emailaddress.properties index c307618..6564ba8 100644 --- a/hsarweb/src/texts/emailaddress.properties +++ b/hsarweb/src/texts/emailaddress.properties @@ -10,4 +10,5 @@ fulldomain=full domain moduletitle=email addresses moduleicon=../runo/icons/16/email.png new=create address -update=update address \ No newline at end of file +update=update address +delete=delete address \ No newline at end of file diff --git a/hsarweb/src/texts/emailaddress_de.properties b/hsarweb/src/texts/emailaddress_de.properties index 20fef93..c42a41c 100644 --- a/hsarweb/src/texts/emailaddress_de.properties +++ b/hsarweb/src/texts/emailaddress_de.properties @@ -10,4 +10,5 @@ fulldomain=volle Domain moduletitle=EMail Adressen moduleicon=../runo/icons/16/email.png new=EMail-Adresse anlegen -update=EMail-Adresse ändern \ No newline at end of file +update=EMail-Adresse ändern +delete=EMail-Adresse löschen \ No newline at end of file diff --git a/hsarweb/src/texts/emailalias.properties b/hsarweb/src/texts/emailalias.properties index 9f07ec9..02d411d 100644 --- a/hsarweb/src/texts/emailalias.properties +++ b/hsarweb/src/texts/emailalias.properties @@ -5,4 +5,5 @@ pac=packet moduletitle=email aliases moduleicon=../runo/icons/16/email-send.png new=create alias -update=update alias \ No newline at end of file +update=update alias +delete=delete alias \ No newline at end of file diff --git a/hsarweb/src/texts/emailalias_de.properties b/hsarweb/src/texts/emailalias_de.properties index ec50929..6b385f5 100644 --- a/hsarweb/src/texts/emailalias_de.properties +++ b/hsarweb/src/texts/emailalias_de.properties @@ -5,4 +5,5 @@ pac=Paket moduletitle=EMail Aliases moduleicon=../runo/icons/16/email-send.png new=EMail-Alias anlegen -update=EMail-Alias ändern \ No newline at end of file +update=EMail-Alias ändern +delete=EMail-Alias löschen \ No newline at end of file diff --git a/hsarweb/src/texts/main.properties b/hsarweb/src/texts/main.properties index 3ef0f73..e73a51d 100644 --- a/hsarweb/src/texts/main.properties +++ b/hsarweb/src/texts/main.properties @@ -5,6 +5,8 @@ confirmdelete=confirm delete save=save abort=abort new=new +runas=select
change user perspective +logout=logout modules.NONE=de.hsadmin.web.HomeModule modules.USER=de.hsadmin.web.HomeModule modules.DOM_ADMIN=de.hsadmin.web.DomainReadonlyModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.HomeModule diff --git a/hsarweb/src/texts/main_de.properties b/hsarweb/src/texts/main_de.properties index 25e3e77..190998b 100644 --- a/hsarweb/src/texts/main_de.properties +++ b/hsarweb/src/texts/main_de.properties @@ -5,3 +5,5 @@ confirmdelete=Diesen Eintrag l save=speichern abort=abbrechen new=Eintrag anlegen +runas=Auswahl/Eingabe:
zur Ansicht eines anderen
Benutzers wechseln +logout=abmelden diff --git a/hsarweb/src/texts/mysqldb.properties b/hsarweb/src/texts/mysqldb.properties index 4366f23..b4bbda8 100644 --- a/hsarweb/src/texts/mysqldb.properties +++ b/hsarweb/src/texts/mysqldb.properties @@ -4,6 +4,7 @@ pac=packet encoding=encoding owner=owner moduletitle=mysql db -new=create db -update=update db +new=create database +update=database +delete=delete database moduleicon=../hs/icons/table.png \ No newline at end of file diff --git a/hsarweb/src/texts/mysqldb_de.properties b/hsarweb/src/texts/mysqldb_de.properties index dcdf1dc..09fdebd 100644 --- a/hsarweb/src/texts/mysqldb_de.properties +++ b/hsarweb/src/texts/mysqldb_de.properties @@ -5,5 +5,6 @@ encoding=Zeichensatz owner=Verwalter moduletitle=MySQL DB new=Datenbank anlegen -update=Datenbank ändern +update=Datenbank +delete=Datenbank löschen moduleicon=../hs/icons/table.png \ No newline at end of file diff --git a/hsarweb/src/texts/mysqluser.properties b/hsarweb/src/texts/mysqluser.properties index 434f936..cb622f8 100644 --- a/hsarweb/src/texts/mysqluser.properties +++ b/hsarweb/src/texts/mysqluser.properties @@ -7,4 +7,5 @@ pac=packet moduletitle=mysql user new=create user update=change password +delete=delete user moduleicon=../hs/icons/table_key.png \ No newline at end of file diff --git a/hsarweb/src/texts/mysqluser_de.properties b/hsarweb/src/texts/mysqluser_de.properties index 6c75274..df73d5c 100644 --- a/hsarweb/src/texts/mysqluser_de.properties +++ b/hsarweb/src/texts/mysqluser_de.properties @@ -7,4 +7,5 @@ pac=Paket moduletitle=MySQL User new=User anlegen update=Passwort ändern +delete=User löschen moduleicon=../hs/icons/table_key.png \ No newline at end of file diff --git a/hsarweb/src/texts/postgresqldb.properties b/hsarweb/src/texts/postgresqldb.properties index fe6c0a9..c8a1333 100644 --- a/hsarweb/src/texts/postgresqldb.properties +++ b/hsarweb/src/texts/postgresqldb.properties @@ -4,6 +4,7 @@ pac=packet encoding=encoding owner=owner moduletitle=postgresql db -new=create db +new=create database update=database +delete=delete database moduleicon=../hs/icons/database.png \ No newline at end of file diff --git a/hsarweb/src/texts/postgresqldb_de.properties b/hsarweb/src/texts/postgresqldb_de.properties index 439285c..0651de5 100644 --- a/hsarweb/src/texts/postgresqldb_de.properties +++ b/hsarweb/src/texts/postgresqldb_de.properties @@ -6,4 +6,5 @@ owner=Verwalter moduletitle=PostgreSQL DB new=Datenbank anlegen update=Datenbank +delete=Datenbank löschen moduleicon=../hs/icons/database.png \ No newline at end of file diff --git a/hsarweb/src/texts/postgresqluser.properties b/hsarweb/src/texts/postgresqluser.properties index 2cef6f8..b163a8d 100644 --- a/hsarweb/src/texts/postgresqluser.properties +++ b/hsarweb/src/texts/postgresqluser.properties @@ -7,4 +7,5 @@ pac=packet moduletitle=postgres user new=create user update=change password +delete=delete user moduleicon=../hs/icons/database_key.png \ No newline at end of file diff --git a/hsarweb/src/texts/postgresqluser_de.properties b/hsarweb/src/texts/postgresqluser_de.properties index 9bebc83..34dc4eb 100644 --- a/hsarweb/src/texts/postgresqluser_de.properties +++ b/hsarweb/src/texts/postgresqluser_de.properties @@ -7,4 +7,5 @@ pac=Paket moduletitle=PostgreSQL User new=User anlegen update=Passwort ändern +delete=User löschen moduleicon=../hs/icons/database_key.png \ No newline at end of file diff --git a/hsarweb/src/texts/user.properties b/hsarweb/src/texts/user.properties index 8e5f4fd..dae491c 100644 --- a/hsarweb/src/texts/user.properties +++ b/hsarweb/src/texts/user.properties @@ -13,4 +13,5 @@ quota_hardlimit=quota hard limit moduletitle=unix user new=create user update=update user +delete=delete user moduleicon=../runo/icons/16/users.png \ No newline at end of file diff --git a/hsarweb/src/texts/user_de.properties b/hsarweb/src/texts/user_de.properties index 9ca69c5..424ef35 100644 --- a/hsarweb/src/texts/user_de.properties +++ b/hsarweb/src/texts/user_de.properties @@ -13,4 +13,5 @@ quota_hardlimit=Hard-Quota [MB] moduletitle=Unix User moduleicon=../runo/icons/16/users.png new=Benutzer anlegen -update=Benutzer ändern \ No newline at end of file +update=Benutzer ändern +delete=Benutzer löschen \ No newline at end of file