Rollen-spezifische Module

This commit is contained in:
Peter Hormanns 2011-03-31 19:08:34 +00:00
parent d29c15f073
commit 834deec9d3
25 changed files with 367 additions and 28 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

View File

@ -7,33 +7,28 @@
<context-param>
<param-name>serverName</param-name>
<param-value>http://agnes.ostwall195.de:8180</param-value>
<param-value>http://agnes.ostwall195.de:8080</param-value>
</context-param>
<context-param>
<param-name>backendURL</param-name>
<param-value>https://config-dev.hostsharing.net:443/hsar/backend</param-value>
<param-value>https://agnes.ostwall195.de:9443/hsar/backend</param-value>
</context-param>
<context-param>
<param-name>xmlrpcURL</param-name>
<param-value>https://config-dev.hostsharing.net:443/hsar/xmlrpc/hsadmin</param-value>
<param-value>https://agnes.ostwall195.de:9443/hsar/xmlrpc/hsadmin</param-value>
</context-param>
<context-param>
<description>Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>HSAdmin Module</description>
<param-name>hsarmodules</param-name>
<param-value>de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule</param-value>
</context-param>
<filter>
<filter-name>CAS Authentication Filter</filter-name>
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
<init-param>
<param-name>casServerLoginUrl</param-name>
<param-value>https://login-dev.hostsharing.net:443/cas/login</param-value>
<param-value>https://agnes.ostwall195.de:9443/cas/login</param-value>
</init-param>
<init-param>
<param-name>service</param-name>
@ -46,7 +41,7 @@
<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>https://login-dev.hostsharing.net:443/cas</param-value>
<param-value>https://agnes.ostwall195.de:9443/cas</param-value>
</init-param>
<init-param>
<param-name>proxyReceptorUrl</param-name>

View File

@ -15,7 +15,6 @@
<classes dir="build/cls" />
<classes dir="src">
<include name="**/*.properties"/>
<include name="**/*.png"/>
</classes>
</war>
</target>

View File

@ -104,7 +104,6 @@ public abstract class AbstractModule implements Module {
}
layout.addComponent(component);
layout.setExpandRatio(component, 1.0f);
layout.addComponent(new Link(localeConfig.getText("impressum.label"), new ExternalResource(localeConfig.getText("impressum.link"))));
}

View File

@ -0,0 +1,31 @@
package de.hsadmin.web;
import java.util.Date;
import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyTableColumn;
public class DomainReadonlyModule extends AbstractModule {
private static final long serialVersionUID = 1L;
private ModuleConfig moduleConfig;
@Override
protected void initModule() {
moduleConfig = new ModuleConfig("domain", getApplication().getLocale());
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class));
}
@Override
public ModuleConfig getModuleConfig() {
return moduleConfig;
}
}

View File

@ -13,18 +13,18 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
private static final long serialVersionUID = 1L;
public void insertRow(Map<String, String> paramHash) throws HsarwebException {
getApplication().getRemote().callAdd(getModuleConfig().getName(), paramHash);
getApplication().getRemote().callAdd(getModuleConfig().getRemoteName(), paramHash);
}
public void deleteRow(Map<String, String> paramHash) throws HsarwebException {
getApplication().getRemote().callDelete(getModuleConfig().getName(), paramHash);
getApplication().getRemote().callDelete(getModuleConfig().getRemoteName(), paramHash);
}
public void updateRow(Map<String, String> paramHash) throws HsarwebException {
Map<String, String> whereHash = new HashMap<String, String>();
String idKey = findIdKey();
whereHash.put(idKey, paramHash.get(idKey));
getApplication().getRemote().callUpdate(getModuleConfig().getName(), paramHash, whereHash);
getApplication().getRemote().callUpdate(getModuleConfig().getRemoteName(), paramHash, whereHash);
}
private String findIdKey() {

View File

@ -0,0 +1,173 @@
package de.hsadmin.web;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout;
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.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.GenericForm;
import de.hsadmin.web.vaadin.PasswordPropertyFieldFactory;
public class HomeModule extends AbstractModule implements ComponentFactory, UpdateAble {
private ModuleConfig moduleConfig;
private MainApplication application;
public HomeModule() {
super();
setComponentFactory(this);
}
public void updateRow(Map<String, String> paramHash) throws HsarwebException {
Map<String, String> whereHash = new HashMap<String, String>();
String idKey = findIdKey();
whereHash.put(idKey, paramHash.get(idKey));
paramHash.remove(idKey);
application.getRemote().callUpdate(moduleConfig.getRemoteName(), paramHash, whereHash);
}
private String findIdKey() {
List<PropertyConfig> propertyList = getModuleConfig().getPropertyList();
String idKey = null;
for (PropertyConfig propConf : propertyList) {
PropertyTableColumn propTableColumn = propConf.getPropTableColumn();
if (PropertyTableColumn.INTERNAL_KEY == propTableColumn) {
idKey = propConf.getId();
return idKey;
}
}
return idKey;
}
@Override
public ModuleConfig getModuleConfig() {
return moduleConfig;
}
@Override
protected void initModule() {
application = getApplication();
moduleConfig = new ModuleConfig("home", application.getLocale());
moduleConfig.setRemoteName("user");
PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN);
pacProp.setReadOnly(true);
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true);
PropertyConfig useridProp = new PropertyConfig(moduleConfig, "userid", Long.class, PropertyTableColumn.HIDDEN);
useridProp.setReadOnly(true);
PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class);
nameProp.setReadOnly(true);
PropertyConfig passwordProp = new PropertyConfig(moduleConfig, "password", String.class, PropertyTableColumn.NONE, new PasswordPropertyFieldFactory(this));
PropertyConfig commentProp = new PropertyConfig(moduleConfig, "comment", String.class);
commentProp.setReadOnly(true);
moduleConfig.addProperty(idProp);
moduleConfig.addProperty(pacProp);
moduleConfig.addProperty(useridProp);
moduleConfig.addProperty(nameProp);
moduleConfig.addProperty(commentProp);
moduleConfig.addProperty(passwordProp);
}
@Override
public Object initComponent() throws HsarwebException {
final Module thisModule = this;
VerticalLayout layout = new VerticalLayout();
Button button = new Button(moduleConfig.getLabel("change_password"));
ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon"));
button.setIcon(icon);
Map<String, String> whereHash = new HashMap<String, String>();
whereHash.put("name", application.getLogin());
Long key = -1L;
try {
Object object = application.getRemote().callSearch(moduleConfig.getRemoteName(), whereHash);
if (object instanceof Object[] && ((Object[]) object).length > 0) {
key = Long.parseLong((String) ((Map<?, ?>) ((Object[]) object)[0]).get("id"));
}
} catch (HsarwebException e) {
e.printStackTrace();
getApplication().showSystemException(e);
}
button.setData(key);
button.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
private Window childWindow;
@Override
public void buttonClick(ClickEvent event) {
Long data = (Long) event.getButton().getData();
final GenericForm genericForm = new GenericForm(thisModule, data);
final Form form = genericForm.createUpdateForm();
childWindow = new Window(moduleConfig.getLabel("update"));
childWindow.setWidth(640.0f, Sizeable.UNITS_PIXELS);
VerticalLayout vLayout = new VerticalLayout();
vLayout.setMargin(true);
vLayout.setSpacing(true);
vLayout.addComponent(form);
HorizontalLayout hLayout = new HorizontalLayout();
Button btSaveRow = new Button(moduleConfig.getLabel("save"));
btSaveRow.setData(data);
btSaveRow.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
application.getMainWindow().removeWindow(childWindow);
try {
Map<String, String> map = new HashMap<String, String>();
map.put("id", ((Long) event.getButton().getData()).toString());
Iterator<Component> componentIterator = form.getLayout().getComponentIterator();
while (componentIterator.hasNext()) {
Component component = (Component) componentIterator.next();
if (component instanceof AbstractComponent) {
Object data = ((AbstractComponent) component).getData();
String propName = (String) data;
if ("password".equals(propName)) {
PropertyConfig property = moduleConfig.getProperty(propName);
map.put(propName, property.getPropFieldFactory().getValue(property, component));
}
}
}
((UpdateAble) thisModule).updateRow(map);
} catch (HsarwebException e) {
application.showUserException(e);
}
}
});
Button btAbort = new Button(moduleConfig.getLabel("abort"));
btAbort.addListener(new Button.ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
application.getMainWindow().removeWindow(childWindow);
}
});
hLayout.addComponent(btSaveRow);
hLayout.addComponent(btAbort);
vLayout.addComponent(hLayout);
childWindow.setContent(vLayout);
childWindow.setModal(true);
application.getMainWindow().addWindow(childWindow);
}
});
layout.addComponent(button);
return layout;
}
@Override
public void loadData() throws HsarwebException {
}
}

View File

@ -14,10 +14,15 @@ import org.jasig.cas.client.authentication.AuthenticationFilter;
import org.jasig.cas.client.validation.Assertion;
import com.vaadin.Application;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.terminal.Terminal;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.gwt.server.HttpServletRequestListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
@ -49,12 +54,33 @@ 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"));
VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setSizeFull();
HorizontalLayout banner = new HorizontalLayout();
Embedded image = new Embedded(null, new ThemeResource("../hs/icons/logo.png"));
image.setMimeType("image/png");
Embedded bgImage = new Embedded(null, new ThemeResource("../hs/icons/bg.png"));
bgImage.setMimeType("image/png");
banner.addComponent(image);
banner.addComponent(bgImage);
banner.setExpandRatio(bgImage, 1.0f);
verticalLayout.addComponent(banner);
TabSheet tabs = new TabSheet();
tabs.setSizeFull();
String modulesParamString = getContextParam("hsarmodules");
String modulesParamString = localeConfig.getText("modules." + role);
modules = new HashMap<String, Module>();
Module firstModule = null;
for (String className : modulesParamString.split(",")) {
@ -74,6 +100,8 @@ public class MainApplication extends Application implements HttpServletRequestLi
}
tabs.addListener(this);
verticalLayout.addComponent(tabs);
verticalLayout.setExpandRatio(tabs, 1.0f);
verticalLayout.addComponent(new Link(localeConfig.getText("impressum.label"), new ExternalResource(localeConfig.getText("impressum.link"))));
mainWindow.setContent(verticalLayout);
setMainWindow(mainWindow);
setErrorHandler(new Terminal.ErrorListener() {

View File

@ -0,0 +1,33 @@
package de.hsadmin.web;
import java.util.Date;
import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyTableColumn;
public class PacketReadonlyModule extends AbstractModule {
private static final long serialVersionUID = 1L;
private ModuleConfig moduleConfig;
@Override
protected void initModule() {
moduleConfig = new ModuleConfig("pac", getApplication().getLocale());
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "basepac", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "components", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "curinetaddr", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "created", Date.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "customer", String.class, PropertyTableColumn.HIDDEN));
}
@Override
public ModuleConfig getModuleConfig() {
return moduleConfig;
}
}

View File

@ -2,6 +2,7 @@ package de.hsadmin.web;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
@ -37,7 +38,7 @@ public class Remote {
Object[] params = new Object[3];
params[0] = app.getLogin();
params[1] = app.getProxyTicket();
params[2] = param1;
params[2] = param1 != null ? param1 : new HashMap<String, String>();
return xmlrpcCall(module + "." + operation, params);
}
@ -45,8 +46,8 @@ public class Remote {
Object[] params = new Object[4];
params[0] = app.getLogin();
params[1] = app.getProxyTicket();
params[2] = param1;
params[3] = param2;
params[2] = param1 != null ? param1 : new HashMap<String, String>();
params[3] = param2 != null ? param2 : new HashMap<String, String>();
return xmlrpcCall(module + "." + operation, params);
}

View File

@ -12,12 +12,14 @@ public class ModuleConfig implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String remoteName;
private List<PropertyConfig> propertyList;
private Map<String, PropertyConfig> propertyMap;
private LocaleConfig localeConfig;
public ModuleConfig(String name, Locale locale) {
this.name = name;
this.remoteName = name;
propertyList = new ArrayList<PropertyConfig>();
propertyMap = new HashMap<String, PropertyConfig>();
localeConfig = new LocaleConfig(locale, name);
@ -27,6 +29,14 @@ public class ModuleConfig implements Serializable {
return name;
}
public String getRemoteName() {
return remoteName;
}
public void setRemoteName(String name) {
remoteName = name;
}
public void addProperty(PropertyConfig property) {
propertyList.add(property);
propertyMap.put(property.getId(), property);

View File

@ -141,8 +141,12 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory {
leftPart.setNewItemsAllowed(false);
leftPart.setNullSelectionAllowed(false);
leftPart.addItem(" ");
if (users != null && users.size() > 0) {
leftPart.addItem("User");
}
if (mailAliases != null && mailAliases.size() > 0) {
leftPart.addItem("Alias");
}
leftPart.addItem("EMail");
String type = "";
if (target != null && target.length() > 0) {

View File

@ -48,7 +48,7 @@ public class GenericForm {
ModuleConfig config = module.getModuleConfig();
Map<String, String> where = new HashMap<String, String>();
where.put(findIdKey(), entityId.toString());
Object searchResult = application.getRemote().callSearch(config.getName(), where);
Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where);
if (searchResult instanceof Object[]) {
Map<?, ?> row = (Map<?, ?>) (((Object[]) searchResult)[0]);
Form f = new Form();

View File

@ -36,13 +36,15 @@ import de.hsadmin.web.config.PropertyTableColumn;
public class TableComponentFactory implements ComponentFactory, Serializable {
private static final long serialVersionUID = 1L;
private static final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
private static final DateFormat serverDateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
private Module module;
private Table table;
private DateFormat browserDateFormat;
public TableComponentFactory(Module module) {
this.module = module;
this.browserDateFormat = DateFormat.getDateInstance(DateFormat.SHORT, module.getApplication().getLocale());
}
@Override
@ -55,7 +57,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable {
Property property) {
if (Date.class == property.getType()) {
try {
return df.format(property.getValue());
return browserDateFormat.format(property.getValue());
} catch (IllegalArgumentException e) {
return "---";
}
@ -104,7 +106,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable {
table.removeAllItems();
try {
ModuleConfig moduleConfig = module.getModuleConfig();
Object callSearch = module.getApplication().getRemote().callSearch(moduleConfig.getName(), new HashMap<String, String>());
Object callSearch = module.getApplication().getRemote().callSearch(moduleConfig.getRemoteName(), new HashMap<String, String>());
List<PropertyConfig> propertyList = moduleConfig.getPropertyList();
if (callSearch instanceof Object[]) {
for (Object row : ((Object[])callSearch)) {
@ -129,7 +131,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable {
}
if (Date.class.equals(prop.getType())) {
try {
itemData[idx] = df.parse((String) valueObject);
itemData[idx] = serverDateFormat.parse((String) valueObject);
} catch (ParseException e) {
Calendar cal = Calendar.getInstance();
cal.clear();

View File

@ -0,0 +1,18 @@
id=identifier
name=username
password=password
password1=new password
password2=repeat password
comment=comment
shell=shell
userid=numeric userid
homedir=home directory
pac=packet
moduletitle=password
moduleicon=../runo/icons/16/lock.png
change_password_icon=../runo/icons/16/lock.png
hello=Hello world!
change_password=change password
update=change password
save=save password
abort=abort

View File

@ -0,0 +1,18 @@
id=Schlüssel
name=Benutzername
password=Passwort
password1=neues Passwort
password2=Passwort-Wiederholung
comment=Kommentar
shell=Shell
userid=Benutzerkennung
homedir=Heimat Verzeichnis
pac=Paket
moduletitle=Passwort
moduleicon=../runo/icons/16/lock.png
change_password_icon=../runo/icons/16/lock.png
hello=Hallo Welt!
change_password=Passwort ändern
update=Passwort ändern
save=Passwort speichern
abort=abbrechen

View File

@ -6,4 +6,11 @@ save=save
abort=abort
new=new
impressum.label=Published by
impressum.link=http://www.hostsharing.net/impressum
impressum.link=https://www.hostsharing.net/impressum
logo.link=https://www.hostsharing.net/logo.png
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
modules.PAC_ADMIN=de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule
modules.CUSTOMER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule
modules.HOSTMASTER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule

View File

@ -6,4 +6,5 @@ save=speichern
abort=abbrechen
new=Eintrag anlegen
impressum.label=Impressum
impressum.link=http://www.hostsharing.net/impressum
impressum.link=https://www.hostsharing.net/impressum
logo.link=https://www.hostsharing.net/logo.png

View File

@ -0,0 +1,10 @@
id=identifier
name=packet
curinetaddr=inet address
created=created
basepac=packet type
components=packet options
hive=host
customer=customer
moduletitle=packets
moduleicon=../runo/icons/16/document.png

View File

@ -0,0 +1,10 @@
id=Schlüssel
name=Paket
curinetaddr=IP Adresse
created=angelegt
basepac=Pakettyp
components=Paket-Optionen
hive=Server
customer=Mitglied
moduletitle=Pakete
moduleicon=../runo/icons/16/document.png