diff --git a/hsarweb/WebContent/WEB-INF/web.xml b/hsarweb/WebContent/WEB-INF/web.xml index ae5a4c8..f2d2dfe 100644 --- a/hsarweb/WebContent/WEB-INF/web.xml +++ b/hsarweb/WebContent/WEB-INF/web.xml @@ -22,6 +22,11 @@ productionMode false + + HSAdmin Module + hsarmodules + de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule + CAS Authentication Filter @@ -32,7 +37,7 @@ service - https://agnes.ostwall195.de:8443/HSAdmin + https://agnes.ostwall195.de:8443/hsarweb @@ -49,11 +54,11 @@ proxyCallbackUrl - https://agnes.ostwall195.de:8443/HSAdmin/proxyCallback + https://agnes.ostwall195.de:8443/hsarweb/proxyCallback service - https://agnes.ostwall195.de:8443/HSAdmin + https://agnes.ostwall195.de:8443/hsarweb @@ -73,7 +78,7 @@ Vaadin application class to start application - de.hsadmin.web.DomainModule + de.hsadmin.web.MainApplication diff --git a/hsarweb/src/de/hsadmin/web/EMailAddressModule.java b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java new file mode 100644 index 0000000..a153270 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java @@ -0,0 +1,30 @@ +package de.hsadmin.web; + +import de.hsadmin.web.config.ModuleConfig; +import de.hsadmin.web.config.PropertyConfig; + +public class EMailAddressModule extends GenericModule { + + private static final long serialVersionUID = 1L; + + private ModuleConfig moduleConfig; + + public EMailAddressModule() { + moduleConfig = new ModuleConfig("emailaddress"); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "emailaddress", String.class, "")); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "localpart", String.class, "", true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "subdomain", String.class, "", true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "domain", String.class, "", true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class, "")); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "admin", String.class, "", true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "fulldomain", String.class, "", true)); + } + + @Override + public ModuleConfig getModuleConfig() { + return moduleConfig; + } + +} diff --git a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java new file mode 100644 index 0000000..8c13985 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java @@ -0,0 +1,25 @@ +package de.hsadmin.web; + +import de.hsadmin.web.config.ModuleConfig; +import de.hsadmin.web.config.PropertyConfig; + +public class EMailAliasModule extends GenericModule { + + private static final long serialVersionUID = 1L; + + private ModuleConfig moduleConfig; + + public EMailAliasModule() { + moduleConfig = new ModuleConfig("emailalias"); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class, "")); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class, "")); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true)); + } + + @Override + public ModuleConfig getModuleConfig() { + return moduleConfig; + } + +} diff --git a/hsarweb/src/de/hsadmin/web/GenericModule.java b/hsarweb/src/de/hsadmin/web/GenericModule.java index bf9abca..65ffb3d 100644 --- a/hsarweb/src/de/hsadmin/web/GenericModule.java +++ b/hsarweb/src/de/hsadmin/web/GenericModule.java @@ -8,53 +8,44 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.jasig.cas.client.authentication.AttributePrincipal; -import org.jasig.cas.client.authentication.AuthenticationFilter; -import org.jasig.cas.client.validation.Assertion; - -import com.vaadin.Application; import com.vaadin.data.Property; import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.ThemeResource; -import com.vaadin.terminal.gwt.server.HttpServletRequestListener; import com.vaadin.ui.Button; +import com.vaadin.ui.Component; import com.vaadin.ui.Table; -import com.vaadin.ui.Window; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.themes.BaseTheme; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; -public abstract class GenericModule extends Application implements HttpServletRequestListener { +public abstract class GenericModule { private static final long serialVersionUID = 1L; private static final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); - private HttpSession httpSession; - private AttributePrincipal userPrincipal; - private ServletContext servletContext; private Table table; + private Remote remote; - - @Override - public void init() { - Window mainWindow = new Window(getModuleConfig().getName()); - mainWindow.setHeight(100.0f, Sizeable.UNITS_PERCENTAGE); - mainWindow.setWidth(100.0f, Sizeable.UNITS_PERCENTAGE); + public void setRemote(Remote remote) { + this.remote = remote; try { initTable(); - mainWindow.addComponent(table); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } - setMainWindow(mainWindow); + } + + public abstract ModuleConfig getModuleConfig(); + + public Component getComponent() { + return table; + } + + public void reload() { + loadTable(); } private void initTable() throws IllegalAccessException { @@ -92,14 +83,12 @@ public abstract class GenericModule extends Application implements HttpServletRe table.addContainerProperty("del", Button.class, null); table.setColumnWidth("del", 16); table.setColumnHeader("del", ""); - loadTable(); } private void loadTable() { - Remote remote = new Remote(this); table.removeAllItems(); try { - Object callSearch = remote.callSearch(userPrincipal.getName(), new HashMap()); + Object callSearch = remote.callSearch(getModuleConfig().getName(), new HashMap()); List propertyList = getModuleConfig().getPropertyList(); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { @@ -169,7 +158,7 @@ public abstract class GenericModule extends Application implements HttpServletRe } private Button createDeleteButton(long id) { - ThemeResource icon = new ThemeResource("../runo/icons/16/cancel.png"); + ThemeResource icon = new ThemeResource("../runo/icons/16/document-delete.png"); Button button = new Button(); button.setIcon(icon); button.setData(id); @@ -184,29 +173,5 @@ public abstract class GenericModule extends Application implements HttpServletRe }); return button; } - - public String getProxyTicket() { - return userPrincipal.getProxyTicketFor(servletContext.getInitParameter("backendURL")); - } - - public String getContextParam(String string) { - return servletContext.getInitParameter(string); - } - - @Override - public void onRequestStart(HttpServletRequest request, - HttpServletResponse response) { - httpSession = request.getSession(); - servletContext = httpSession.getServletContext(); - userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal(); - } - - @Override - public void onRequestEnd(HttpServletRequest request, - HttpServletResponse response) { - - } - - public abstract ModuleConfig getModuleConfig(); } diff --git a/hsarweb/src/de/hsadmin/web/MainApplication.java b/hsarweb/src/de/hsadmin/web/MainApplication.java new file mode 100644 index 0000000..ed03054 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/MainApplication.java @@ -0,0 +1,114 @@ +package de.hsadmin.web; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.jasig.cas.client.authentication.AttributePrincipal; +import org.jasig.cas.client.authentication.AuthenticationFilter; +import org.jasig.cas.client.validation.Assertion; + +import com.vaadin.Application; +import com.vaadin.terminal.Sizeable; +import com.vaadin.terminal.ThemeResource; +import com.vaadin.terminal.gwt.server.HttpServletRequestListener; +import com.vaadin.ui.Component; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.Window; +import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; +import com.vaadin.ui.TabSheet.Tab; + +import de.hsadmin.web.config.LocaleConfig; +import de.hsadmin.web.config.ModuleConfig; + +public class MainApplication extends Application implements HttpServletRequestListener, TabSheet.SelectedTabChangeListener { + + private static final long serialVersionUID = 1L; + + private HttpSession httpSession; + private ServletContext servletContext; + private AttributePrincipal userPrincipal; + private LocaleConfig localeConfig; + private Remote remote; + private Map modules; + + @Override + public void init() { + localeConfig = new LocaleConfig(Locale.getDefault(), "main"); + remote = new Remote(this); + Window mainWindow = new Window(localeConfig.getText("title")); + TabSheet tabs = new TabSheet(); + tabs.setWidth(100.0f, Sizeable.UNITS_PERCENTAGE); + tabs.setHeight(680.0f, Sizeable.UNITS_PIXELS); + String modulesParamString = getContextParam("hsarmodules"); + modules = new HashMap(); + GenericModule firstModule = null; + for (String className : modulesParamString.split(",")) { + try { + GenericModule module = (GenericModule) Class.forName(className).newInstance(); + module.setRemote(remote); + if (firstModule == null) { + firstModule = module; + } + ModuleConfig moduleConfig = module.getModuleConfig(); + String label = moduleConfig.getLabel("title"); + modules.put(label, module); + tabs.addTab(module.getComponent(), label, new ThemeResource(moduleConfig.getLabel("icon"))); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + tabs.addListener(this); + mainWindow.addComponent(tabs); + setMainWindow(mainWindow); + firstModule.reload(); + } + + public String getProxyTicket() { + return userPrincipal.getProxyTicketFor(servletContext.getInitParameter("backendURL")); + } + + public String getContextParam(String string) { + return servletContext.getInitParameter(string); + } + + public Object getLogin() { + return userPrincipal.getName(); + } + + @Override + public void onRequestStart(HttpServletRequest request, + HttpServletResponse response) { + httpSession = request.getSession(); + servletContext = httpSession.getServletContext(); + userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal(); + } + + @Override + public void onRequestEnd(HttpServletRequest request, + HttpServletResponse response) { + + } + + @Override + public void selectedTabChange(SelectedTabChangeEvent event) { + TabSheet tabSheet = event.getTabSheet(); + Component selectedTab = tabSheet.getSelectedTab(); + Tab tab = tabSheet.getTab(selectedTab); + GenericModule module = modules.get(tab.getCaption()); + module.reload(); + } + +} diff --git a/hsarweb/src/de/hsadmin/web/Remote.java b/hsarweb/src/de/hsadmin/web/Remote.java index ce4f683..d4649b0 100644 --- a/hsarweb/src/de/hsadmin/web/Remote.java +++ b/hsarweb/src/de/hsadmin/web/Remote.java @@ -11,20 +11,20 @@ import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; public class Remote { private XmlRpcClient client; - private GenericModule module; + private MainApplication app; - public Remote(GenericModule module) { - this.module = module; + public Remote(MainApplication application) { + this.app = application; } - public Object callSearch(String user, Map where) throws HsarwebException { + public Object callSearch(String module, Map where) throws HsarwebException { Object[] params = new Object[3]; - params[0] = user; - params[1] = module.getProxyTicket(); + params[0] = app.getLogin(); + params[1] = app.getProxyTicket(); params[2] = where; Object res; try { - res = getClient().execute(module.getModuleConfig().getName() + ".search", params); + res = getClient().execute(module + ".search", params); } catch (XmlRpcException e) { throw new HsarwebException("error in remote server call", e); } @@ -35,13 +35,14 @@ public class Remote { if (client == null) { XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); try { - String xmlrpcURL = module.getContextParam("xmlrpcURL"); + String xmlrpcURL = app.getContextParam("xmlrpcURL"); config.setServerURL(new URL(xmlrpcURL)); + config.setEnabledForExceptions(true); + client = new XmlRpcClient(); + client.setConfig(config); } catch (MalformedURLException e) { throw new HsarwebException("error in remote server url", e); } - client = new XmlRpcClient(); - client.setConfig(config); } return client; } diff --git a/hsarweb/src/texts/domain.properties b/hsarweb/src/texts/domain.properties index 848f402..98e6858 100644 --- a/hsarweb/src/texts/domain.properties +++ b/hsarweb/src/texts/domain.properties @@ -3,4 +3,6 @@ name=domain user=admin pac=packet hive=host -since=connected since \ No newline at end of file +since=connected since +title=domains +icon=../runo/icons/16/document-web.png \ No newline at end of file diff --git a/hsarweb/src/texts/domain_de.properties b/hsarweb/src/texts/domain_de.properties index 7ed475c..0ebc6f6 100644 --- a/hsarweb/src/texts/domain_de.properties +++ b/hsarweb/src/texts/domain_de.properties @@ -3,4 +3,6 @@ name=Domain user=Administrator pac=Paket hive=Server -since=aufgeschaltet seit \ No newline at end of file +since=aufgeschaltet seit +title=Domains +icon=../runo/icons/16/document-web.png \ No newline at end of file diff --git a/hsarweb/src/texts/emailaddress.properties b/hsarweb/src/texts/emailaddress.properties new file mode 100644 index 0000000..c550d86 --- /dev/null +++ b/hsarweb/src/texts/emailaddress.properties @@ -0,0 +1,11 @@ +id=identifier +emailaddress=adress +localpart=local part +subdomain=subdomain +domain=main domain +target=target(s) +admin=admin user +pac=packet +fulldomain=full domain +title=email addresses +icon=../runo/icons/16/email.png \ No newline at end of file diff --git a/hsarweb/src/texts/emailaddress_de.properties b/hsarweb/src/texts/emailaddress_de.properties new file mode 100644 index 0000000..94205eb --- /dev/null +++ b/hsarweb/src/texts/emailaddress_de.properties @@ -0,0 +1,11 @@ +id=Schlüssel +emailaddress=EMail Adresse +localpart=lokaler Teil +subdomain=Sub-Domain +domain=Haupt-Domain +target=Ziel(e) +admin=Administrator +pac=Paket +fulldomain=volle Domain +title=EMail Adressen +icon=../runo/icons/16/email.png \ No newline at end of file diff --git a/hsarweb/src/texts/emailalias.properties b/hsarweb/src/texts/emailalias.properties new file mode 100644 index 0000000..9d8a5b5 --- /dev/null +++ b/hsarweb/src/texts/emailalias.properties @@ -0,0 +1,6 @@ +id=identifier +name=name +target=target(s) +pac=packet +title=email aliases +icon=../runo/icons/16/email-send.png \ No newline at end of file diff --git a/hsarweb/src/texts/emailalias_de.properties b/hsarweb/src/texts/emailalias_de.properties new file mode 100644 index 0000000..595f3d5 --- /dev/null +++ b/hsarweb/src/texts/emailalias_de.properties @@ -0,0 +1,6 @@ +id=Schlüssel +name=Alias +target=Ziel(e) +pac=Paket +title=EMail Aliases +icon=../runo/icons/16/email-send.png \ No newline at end of file diff --git a/hsarweb/src/texts/main.properties b/hsarweb/src/texts/main.properties new file mode 100644 index 0000000..22c0a0c --- /dev/null +++ b/hsarweb/src/texts/main.properties @@ -0,0 +1 @@ +title=HSAdmin Web Application \ No newline at end of file