From 1d5797d81de3f9f4c10cc68d7a59e7440aee38ca Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@hostsharing.net>
Date: Wed, 30 Mar 2011 18:26:43 +0200
Subject: [PATCH] Locale aus Request RoleRemote

---
 hsarweb/src/de/hsadmin/web/UnixUserModule.java                    |    5 
 hsarback/src/de/hsadmin/mods/user/UnixUser.java                   |    3 
 hsarback/test/de/hsadmin/remote/PacTest.java                      |   28 ++-
 hsarweb/src/de/hsadmin/web/EMailAddressModule.java                |    5 
 hsarback/test/de/hsadmin/remote/RoleTest.java                     |  111 +++++++++++++
 hsarweb/src/de/hsadmin/web/DomainModule.java                      |    5 
 hsarback/src/de/hsadmin/mods/pac/Pac.java                         |    1 
 hsarweb/src/de/hsadmin/web/QueueTaskModule.java                   |    2 
 hsarback/test/de/hsadmin/remote/UnixUserTest.java                 |   72 ++++----
 hsarback/src/de/hsadmin/remote/RoleRemote.java                    |   82 ++++++++++
 hsarback/src/de/hsadmin/core/model/onetier/TicketValidator.java   |    4 
 hsarback/conf/jndi.properties                                     |    5 
 /dev/null                                                         |    0 
 hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties |    1 
 hsarweb/src/de/hsadmin/web/MainApplication.java                   |   12 +
 hsarback/test/de/hsadmin/remote/InitDataTest.java                 |   72 +++++++--
 hsarback/lib/activemq-all-5.4.2.jar                               |    0 
 hsarweb/src/de/hsadmin/web/config/ModuleConfig.java               |    4 
 hsarback/conf/qserv.properties                                    |    5 
 hsarback/src/de/hsadmin/core/model/Transaction.java               |    6 
 hsarweb/src/de/hsadmin/web/EMailAliasModule.java                  |    5 
 hsarweb/WebContent/WEB-INF/web.xml                                |    8 
 22 files changed, 353 insertions(+), 83 deletions(-)

diff --git a/hsarback/conf/jndi.properties b/hsarback/conf/jndi.properties
new file mode 100644
index 0000000..f9e97d8
--- /dev/null
+++ b/hsarback/conf/jndi.properties
@@ -0,0 +1,5 @@
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=ssl://agnes.ostwall195.de:61617
+connectionFactoryNames=QueueCF
+queue.hsadminSystem-h81=queue.hsadminSystem-h81
+queue.hsadminStatus=queue.hsadminStatus
\ No newline at end of file
diff --git a/hsarback/conf/qserv.properties b/hsarback/conf/qserv.properties
new file mode 100644
index 0000000..9e11197
--- /dev/null
+++ b/hsarback/conf/qserv.properties
@@ -0,0 +1,5 @@
+hsadmin.jms.factory=QueueCF
+hsadmin.jms.system-queue=hsadminSystem-h81
+hsadmin.jms.status-queue=hsadminStatus
+hsadmin.jms.username=user-h81
+hsadmin.jms.password=geheim
diff --git a/hsarback/lib/activemq-all-5.4.2.jar b/hsarback/lib/activemq-all-5.4.2.jar
new file mode 100644
index 0000000..8688a4c
--- /dev/null
+++ b/hsarback/lib/activemq-all-5.4.2.jar
Binary files differ
diff --git a/hsarback/lib/commons-logging-1.0.4.jar b/hsarback/lib/commons-logging-1.0.4.jar
deleted file mode 100644
index b73a80f..0000000
--- a/hsarback/lib/commons-logging-1.0.4.jar
+++ /dev/null
Binary files differ
diff --git a/hsarback/src/de/hsadmin/core/model/Transaction.java b/hsarback/src/de/hsadmin/core/model/Transaction.java
index 27cfb87..254a26f 100644
--- a/hsarback/src/de/hsadmin/core/model/Transaction.java
+++ b/hsarback/src/de/hsadmin/core/model/Transaction.java
@@ -23,6 +23,7 @@
 import de.hsadmin.core.model.onetier.PersistenceManager;
 import de.hsadmin.core.qserv.QueueClient;
 import de.hsadmin.core.qserv.QueueTask;
+import de.hsadmin.core.util.Config;
 import de.hsadmin.mods.user.UnixUser;
 
 public class Transaction {
@@ -181,7 +182,10 @@
 	public UnixUser getLoginUser() {
 		String loginName = getLoginName();
 		if (loginName != null && loginName.length() == 2) {
-			loginName = "hsh01-" + loginName;
+			loginName = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-" + loginName;
+		}
+		if (loginName != null && loginName.length() == 3) {
+			loginName = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-" + loginName;
 		}
 		Query userQuery = getEntityManager().createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username");
 		userQuery.setParameter("username", loginName);
diff --git a/hsarback/src/de/hsadmin/core/model/onetier/TicketValidator.java b/hsarback/src/de/hsadmin/core/model/onetier/TicketValidator.java
index 65685f4..bb081cd 100644
--- a/hsarback/src/de/hsadmin/core/model/onetier/TicketValidator.java
+++ b/hsarback/src/de/hsadmin/core/model/onetier/TicketValidator.java
@@ -45,6 +45,8 @@
 				(runAsUser.equals(ticketUser)		// user himself
 					|| (ticketUser.length() == 5 && runAsUser.startsWith(ticketUser))
 													// pac-admin
+					|| (ticketUser.length() == 3 && runAsUser.startsWith(ticketUser))
+													// member
 					|| ticketUser.length() == 2)	// hostmaster
 					// TODO: add test for member-account
 				) {
@@ -54,7 +56,7 @@
 		}
 	}
 
-	public String validateTicket(String ticket) throws AuthenticationException {
+	private String validateTicket(String ticket) throws AuthenticationException {
 		if (proxyServiceURL == null || proxyServiceURL == null) {
 			log.fatal("TicketValidator is not initialized.");
 			throw new RuntimeException("TicketValidator is not initialized.");
diff --git a/hsarback/src/de/hsadmin/mods/pac/Pac.java b/hsarback/src/de/hsadmin/mods/pac/Pac.java
index 398efaf..1fb53fb 100644
--- a/hsarback/src/de/hsadmin/mods/pac/Pac.java
+++ b/hsarback/src/de/hsadmin/mods/pac/Pac.java
@@ -268,6 +268,7 @@
 
 	public boolean isReadAllowedFor(UnixUser loginUser) {
 		return getName().equals(loginUser.getName())
+				|| getCustomer().getName().equals(loginUser.getName())
 				|| super.isReadAllowedFor(loginUser);
 	}
 
diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUser.java b/hsarback/src/de/hsadmin/mods/user/UnixUser.java
index f3d27fe..28874cf 100644
--- a/hsarback/src/de/hsadmin/mods/user/UnixUser.java
+++ b/hsarback/src/de/hsadmin/mods/user/UnixUser.java
@@ -19,6 +19,7 @@
 import de.hsadmin.core.model.AbstractEntity;
 import de.hsadmin.core.model.EntityInfo;
 import de.hsadmin.core.model.FieldValidation;
+import de.hsadmin.core.util.Config;
 import de.hsadmin.mods.pac.Pac;
 
 @Entity(name = "UnixUsers")
@@ -271,7 +272,7 @@
 	public boolean hasHostmasterRole() {
 		// TODO: hardcoded Hostsharing conventions
 		String login = getName();
-		return login.length() == 2 || ((login.startsWith("hsh01-") && login.length() == 8));
+		return login.length() == 2 || ((login.startsWith(Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-") && login.length() == 8));
 	}
 
 	/**
diff --git a/hsarback/src/de/hsadmin/remote/RoleRemote.java b/hsarback/src/de/hsadmin/remote/RoleRemote.java
new file mode 100644
index 0000000..1deba2a
--- /dev/null
+++ b/hsarback/src/de/hsadmin/remote/RoleRemote.java
@@ -0,0 +1,82 @@
+package de.hsadmin.remote;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import de.hsadmin.core.model.AbstractEntity;
+import de.hsadmin.core.model.AuthenticationException;
+import de.hsadmin.core.model.GenericModuleImpl;
+import de.hsadmin.core.model.HSAdminException;
+import de.hsadmin.core.model.TicketAuthentication;
+import de.hsadmin.core.model.Transaction;
+import de.hsadmin.core.util.Config;
+import de.hsadmin.mods.dom.Domain;
+
+public class RoleRemote implements IRemote {
+
+	private TicketAuthentication authentication;
+
+	public RoleRemote() {
+		authentication = new TicketAuthentication();
+	}
+	
+	@Override
+	public List<Map<String, String>> search(String runAsUser, String ticket,
+			Map<String, String> whereParams) throws HSAdminException {
+		String user = runAsUser;
+		Transaction transaction = new Transaction(user);
+		if (authentication.login(user, ticket)) {
+			String role = "USER";
+			String accoutPrefixCustomer = Config.getInstance().getProperty("accountprefix.customer");
+			String accoutPrefixHostmaster = Config.getInstance().getProperty("accountprefix.hostmaster");
+			String pacName = transaction.getLoginUser().getPac().getName();
+			if (accoutPrefixCustomer.equals(pacName)) {
+				role = "CUSTOMER";
+			}
+			if (accoutPrefixHostmaster.equals(pacName)) {
+				role = "HOSTMASTER";
+			}
+			if (user.equals(pacName)) {
+				role = "PAC_ADMIN";
+			}
+			if (role.equals("USER")) {
+				GenericModuleImpl module = new GenericModuleImpl(transaction);
+				List<AbstractEntity> list = module.search(Domain.class, "obj.user.name = '" + user + "'", null);
+				if (list != null && list.size() > 0) {
+					role = "DOM_ADMIN";
+				}
+			}
+			List<Map<String, String>> result = new ArrayList<Map<String,String>>();
+			Map<String, String> record = new HashMap<String, String>();
+			record.put("role", role);
+			result.add(record);
+			transaction.close();
+			return result;
+		} else {
+			transaction.close();
+			throw new AuthenticationException("authentication failed");
+		}
+	}
+
+	@Override
+	public Map<String, String> add(String runAsUser, String ticket,
+			Map<String, String> setParams) throws HSAdminException {
+		throw new HSAdminException("not implemented");
+	}
+
+	@Override
+	public List<Map<String, String>> update(String runAsUser, String ticket,
+			Map<String, String> setParams, Map<String, String> whereParams)
+			throws HSAdminException {
+		throw new HSAdminException("not implemented");
+	}
+
+	@Override
+	public void delete(String runAsUser, String ticket,
+			Map<String, String> whereParams) throws HSAdminException {
+		throw new HSAdminException("not implemented");
+	}
+
+}
diff --git a/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties b/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
index 252796c..5c73e91 100644
--- a/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
+++ b/hsarback/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties
@@ -5,3 +5,4 @@
 emailalias=de.hsadmin.remote.EMailAliasRemote
 emailaddress=de.hsadmin.remote.EMailAddressRemote
 q=de.hsadmin.remote.QueueTaskRemote
+role=de.hsadmin.remote.RoleRemote
diff --git a/hsarback/test/de/hsadmin/remote/InitDataTest.java b/hsarback/test/de/hsadmin/remote/InitDataTest.java
index d4daa74..cebacaf 100644
--- a/hsarback/test/de/hsadmin/remote/InitDataTest.java
+++ b/hsarback/test/de/hsadmin/remote/InitDataTest.java
@@ -37,14 +37,10 @@
 	public void testAddMember() {
 		String user = "pe";
 		int membersCount = -9999;
-		try {
-			membersCount = getMembersCount(user);
-		} catch (XmlRpcException e) {
-			fail(e.getMessage());
-		}
+		membersCount = getMembersCount();
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> setParams = new HashMap<String, String>();
-		setParams.put("membercode", "hsh00-aaa");
+		setParams.put("membercode", "hsh90-aaa");
 		setParams.put("password", "geheimnIs");
 		setParams.put("memberno", "20001");
 		setParams.put("membersince", "01.10.2010");
@@ -64,10 +60,10 @@
 				setParams };
 		try {
 			client.execute(CUST_MODULE + ".add", params);
-//			Object execute = client.execute(MODULE + ".add", params);
+//			Object execute = client.execute(CUST_MODULE + ".add", params);
 //			Map<?, ?> result = (Map<?, ?>) execute;
 //			System.out.println(result);
-			assertEquals(membersCount + 1, getMembersCount(user));
+			assertEquals(membersCount + 1, getMembersCount());
 		} catch (XmlRpcException e) {
 			fail(e.getMessage());
 		}
@@ -80,10 +76,10 @@
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> setParams = new HashMap<String, String>();
 		setParams.put("name", "aaa00");
-		setParams.put("hive", "h81");
-		setParams.put("customer", "hsh00-aaa");
+		setParams.put("hive", "h90");
+		setParams.put("customer", "hsh90-aaa");
 		setParams.put("basepac", "DW/B");
-		setParams.put("curinetaddr", "192.168.108.203");
+		setParams.put("curinetaddr", "83.223.95.132");
 		Object[] params = new Object[] { user, 
 				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 				setParams };
@@ -96,15 +92,59 @@
 		assertEquals(count + 1, getPacsCount());
 	}
 
-	private int getMembersCount(String user) throws XmlRpcException {
+	@Test
+	public void testDelPac() {
+		int count = getPacsCount();
+		String user = "pe";
+		String grantingTicketURL = cas.getGrantingTicketURL(user);
+		Map<String, String> whereParams = new HashMap<String, String>();
+		whereParams.put("name", "aaa00");
+		Object[] params = new Object[] { user, 
+				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+				whereParams };
+		try {
+			client.execute(PAC_MODULE + ".delete", params);
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+		assertEquals(count - 1, getPacsCount());
+	}
+
+	@Test
+	public void testDelMember() {
+		int count = getMembersCount();
+		String user = "pe";
+		String grantingTicketURL = cas.getGrantingTicketURL(user);
+		Map<String, String> whereParams = new HashMap<String, String>();
+		whereParams.put("membercode", "hsh90-aaa");
+		Object[] params = new Object[] { user, 
+				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+				whereParams };
+		try {
+			client.execute(CUST_MODULE + ".delete", params);
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+		assertEquals(count - 1, getMembersCount());
+	}
+
+	private int getMembersCount() {
+		int count = 0;
+		String user = "pe";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
 		Object[] params = new Object[] { user, 
 				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 				whereParams };
-		Object execute = client.execute(CUST_MODULE + ".search", params);
-		Object[] result = (Object[]) execute;
-		return result.length;
+		Object execute;
+		try {
+			execute = client.execute(CUST_MODULE + ".search", params);
+			Object[] result = (Object[]) execute;
+			count = result.length;
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+		return count;
 	}
 
 	private int getPacsCount() {
@@ -112,7 +152,7 @@
 		String user = "pe";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
-		whereParams.put("customer", "hsh00-aaa");
+		whereParams.put("customer", "hsh90-aaa");
 		Object[] params = new Object[] { user, 
 				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 				whereParams };
diff --git a/hsarback/test/de/hsadmin/remote/PacTest.java b/hsarback/test/de/hsadmin/remote/PacTest.java
index 3918277..3a6c238 100644
--- a/hsarback/test/de/hsadmin/remote/PacTest.java
+++ b/hsarback/test/de/hsadmin/remote/PacTest.java
@@ -15,17 +15,21 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import de.hsadmin.core.util.Config;
+
 public class PacTest {
 
 	private static final String MODULE = "pac";
 	
 	private XmlRpcClient client;
 	private RemoteCASHelper cas;
+	private Config config;
 
 	@Before
 	public void setUp() throws Exception {
 		client = RemoteTestHelper.getClient();
 		cas = new RemoteCASHelper();
+		config = Config.getInstance();
 	}
 
 	@After
@@ -36,7 +40,7 @@
 
 	@Test
 	public void testSearchAllAsPacAdmin() {
-		String user = "peh00";
+		String user = "aaa00";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
 		Object[] params = new Object[] { user, 
@@ -49,7 +53,7 @@
 			for (Object o : result) {
 				if (o instanceof Map<?, ?>) {
 					Map<?, ?> row = (Map<?, ?>) o;
-					assertEquals("hsh00-peh", row.get("customer"));
+					assertEquals(config.getProperty("accountprefix.customer") + "-aaa", row.get("customer"));
 				} else {
 					fail("map expected");
 				}
@@ -61,12 +65,12 @@
 
 	@Test
 	public void testUpdate() {
-		String user = "peh00";
+		String user = "aaa00";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> setParams = new HashMap<String, String>();
 		Map<String, String> whereParams = new HashMap<String, String>();
 		setParams.put("curinetaddr", "192.168.10.2");
-		whereParams.put("name", "peh00");
+		whereParams.put("name", "aaa00");
 		Object[] params = new Object[] { user, 
 				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 				setParams, whereParams };
@@ -85,11 +89,11 @@
 		String user = "pe";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> setParams = new HashMap<String, String>();
-		setParams.put("name", "peh07");
-		setParams.put("hive", "h05");
-		setParams.put("customer", "hsh00-peh");
-		setParams.put("basepac", "DW/S");
-		setParams.put("curinetaddr", "212.42.230.178");
+		setParams.put("name", "aaa01");
+		setParams.put("hive", "h90");
+		setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
+		setParams.put("basepac", "DW/B");
+		setParams.put("curinetaddr", "83.223.95.133");
 		Object[] params = new Object[] { user, 
 				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 				setParams };
@@ -108,7 +112,7 @@
 		String user = "pe";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
-		whereParams.put("name", "peh07");
+		whereParams.put("name", "aaa01");
 		Object[] params = new Object[] { user, 
 				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 				whereParams };
@@ -123,10 +127,10 @@
 
 	private int getPacsCount() {
 		int count = 0;
-		String user = "pe";
+		String user = "hsh90-aaa";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
-		whereParams.put("customer", "hsh00-peh");
+		whereParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
 		Object[] params = new Object[] { user, 
 				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 				whereParams };
diff --git a/hsarback/test/de/hsadmin/remote/RoleTest.java b/hsarback/test/de/hsadmin/remote/RoleTest.java
new file mode 100644
index 0000000..ff888f9
--- /dev/null
+++ b/hsarback/test/de/hsadmin/remote/RoleTest.java
@@ -0,0 +1,111 @@
+package de.hsadmin.remote;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.client.XmlRpcClient;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RoleTest {
+
+	private static final String MODULE = "role";
+	
+	private XmlRpcClient client;
+	private RemoteCASHelper cas;
+
+	@Before
+	public void setUp() throws Exception {
+		client = RemoteTestHelper.getClient();
+		cas = new RemoteCASHelper();
+	}
+
+	@After
+	public void tearDown() throws Exception {
+		client = null;
+		cas = null;
+	}
+
+	@Test
+	public void testPacAdmin() {
+		String user = "aaa00";
+		String grantingTicketURL = cas.getGrantingTicketURL(user);
+		Map<String, String> whereParams = new HashMap<String, String>();
+		Object[] params = new Object[] { user, 
+				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+				whereParams };
+		try {
+			Object execute = client.execute(MODULE + ".search", params);
+			Object[] result = (Object[]) execute;
+			assertTrue(result.length == 1);
+			String role = (String) ((Map<?, ?>) result[0]).get("role");
+			assertEquals("PAC_ADMIN", role);
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+	}
+
+	@Test
+	public void testDomAdmin() {
+		String user = "aaa00-admin";
+		String grantingTicketURL = cas.getGrantingTicketURL(user);
+		Map<String, String> whereParams = new HashMap<String, String>();
+		Object[] params = new Object[] { user, 
+				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+				whereParams };
+		try {
+			Object execute = client.execute(MODULE + ".search", params);
+			Object[] result = (Object[]) execute;
+			assertTrue(result.length == 1);
+			String role = (String) ((Map<?, ?>) result[0]).get("role");
+			assertEquals("DOM_ADMIN", role);
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+	}
+
+	@Test
+	public void testCustomer() {
+		String user = "aaa";
+		String grantingTicketURL = cas.getGrantingTicketURL(user);
+		Map<String, String> whereParams = new HashMap<String, String>();
+		Object[] params = new Object[] { user, 
+				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+				whereParams };
+		try {
+			Object execute = client.execute(MODULE + ".search", params);
+			Object[] result = (Object[]) execute;
+			assertTrue(result.length == 1);
+			String role = (String) ((Map<?, ?>) result[0]).get("role");
+			assertEquals("CUSTOMER", role);
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+	}
+
+	@Test
+	public void testHostmaster() {
+		String user = "pe";
+		String grantingTicketURL = cas.getGrantingTicketURL(user);
+		Map<String, String> whereParams = new HashMap<String, String>();
+		Object[] params = new Object[] { user, 
+				cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+				whereParams };
+		try {
+			Object execute = client.execute(MODULE + ".search", params);
+			Object[] result = (Object[]) execute;
+			assertTrue(result.length == 1);
+			String role = (String) ((Map<?, ?>) result[0]).get("role");
+			assertEquals("HOSTMASTER", role);
+		} catch (XmlRpcException e) {
+			fail(e.getMessage());
+		}
+	}
+
+}
diff --git a/hsarback/test/de/hsadmin/remote/UnixUserTest.java b/hsarback/test/de/hsadmin/remote/UnixUserTest.java
index 4708a0e..4ff0f30 100644
--- a/hsarback/test/de/hsadmin/remote/UnixUserTest.java
+++ b/hsarback/test/de/hsadmin/remote/UnixUserTest.java
@@ -34,7 +34,7 @@
 
 	@Test
 	public void testSearchAsPacAdmin() {
-		String user = "peh00";
+		String user = "aaa00";
 		String grantingTicketURL = cas.getGrantingTicketURL(user);
 		Map<String, String> whereParams = new HashMap<String, String>();
 		Object[] params = new Object[] { user, 
@@ -43,11 +43,11 @@
 		try {
 			Object execute = client.execute(MODULE + ".search", params);
 			Object[] result = (Object[]) execute;
-			assertEquals(21, result.length);
+			assertEquals(1, result.length);
 			for (Object o : result) {
 				if (o instanceof Map<?, ?>) {
 					Map<?, ?> row = (Map<?, ?>) o;
-					assertEquals("peh00", row.get("pac"));
+					assertEquals("aaa00", row.get("pac"));
 				} else {
 					fail("map expected");
 				}
@@ -61,10 +61,10 @@
 	public void testAddAsPacAdmin() {
 		int count = getObjectCount();
 		try {
-			String user = "peh00";
+			String user = "aaa00";
 			String grantingTicketURL = cas.getGrantingTicketURL(user);
 			Map<String, String> setParams = new HashMap<String, String>();
-			setParams.put("name", "peh00-test2");
+			setParams.put("name", "aaa00-test2");
 			setParams.put("password", "test123");
 			setParams.put("quota", "128");
 			setParams.put("quotalimit", "192");
@@ -74,8 +74,8 @@
 			Object execute = client.execute(MODULE + ".add", params);
 			if (execute instanceof Map<?, ?>) {
 				Map<?, ?> entry = (Map<?, ?>) execute;
-				assertEquals("peh00-test2", entry.get("name"));
-				assertEquals("peh00", entry.get("pac"));
+				assertEquals("aaa00-test2", entry.get("name"));
+				assertEquals("aaa00", entry.get("pac"));
 				assertEquals(null, entry.get("password"));
 			} else {
 				fail("map expected");
@@ -90,7 +90,7 @@
 	public void testAddAsPacAdminFail() {
 		int count = getObjectCount();
 		try {
-			String user = "peh00";
+			String user = "aaa00";
 			String grantingTicketURL = cas.getGrantingTicketURL(user);
 			Map<String, String> setParams = new HashMap<String, String>();
 			setParams.put("name", "peh01-testfail");
@@ -111,10 +111,10 @@
 	public void testAddWithFalseName() {
 		int count = getObjectCount();
 		try {
-			String user = "peh00";
+			String user = "aaa00";
 			String grantingTicketURL = cas.getGrantingTicketURL(user);
 			Map<String, String> setParams = new HashMap<String, String>();
-			setParams.put("name", "peh00-langer-name");
+			setParams.put("name", "aaa00-langer-name");
 			setParams.put("password", "test123");
 			Object[] params = new Object[] { user, 
 					cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
@@ -132,11 +132,11 @@
 	public void testUpdateAsPacAdmin() {
 		int count = getObjectCount();
 		try {
-			String user = "peh00";
+			String user = "aaa00";
 			String grantingTicketURL = cas.getGrantingTicketURL(user);
 			Map<String, String> whereParams = new HashMap<String, String>();
 			Map<String, String> setParams = new HashMap<String, String>();
-			whereParams.put("name", "peh00-test2");
+			whereParams.put("name", "aaa00-test2");
 			setParams.put("password", "test1234");
 			Object[] params = new Object[] { user, 
 					cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
@@ -148,7 +148,7 @@
 					if (o instanceof Map<?, ?>) {
 						Map<?, ?> entry = (Map<?, ?>) o;
 						assertNull(entry.get("password"));
-						assertEquals("peh00-test2", entry.get("name"));
+						assertEquals("aaa00-test2", entry.get("name"));
 					} else {
 						fail("map expected");
 					}
@@ -166,10 +166,10 @@
 	public void testDeleteWithLongName() {
 		int count = getObjectCount();
 		try {
-			String user = "peh00";
+			String user = "aaa00";
 			String grantingTicketURL = cas.getGrantingTicketURL(user);
 			Map<String, String> whereParams = new HashMap<String, String>();
-			whereParams.put("name", "peh00-langer-name");
+			whereParams.put("name", "aaa00-langer-name");
 			Object[] params = new Object[] { user, 
 					cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 					whereParams };
@@ -181,33 +181,33 @@
 		assertEquals(count, getObjectCount());
 	}
 
-	@Test
-	public void testDeleteAsPacAdminFail() {
-		int count = getObjectCount();
-		try {
-			String user = "peh01";
-			String grantingTicketURL = cas.getGrantingTicketURL(user);
-			Map<String, String> whereParams = new HashMap<String, String>();
-			whereParams.put("name", "peh00-test2");
-			Object[] params = new Object[] { user, 
-					cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
-					whereParams };
-			Object execute = client.execute(MODULE + ".delete", params);
-			assertNull(execute);
-		} catch (XmlRpcException e) {
-			fail(e.getMessage());
-		}
-		assertEquals(count, getObjectCount());
-	}
+//	@Test
+//	public void testDeleteAsPacAdminFail() {
+//		int count = getObjectCount();
+//		try {
+//			String user = "aaa01";
+//			String grantingTicketURL = cas.getGrantingTicketURL(user);
+//			Map<String, String> whereParams = new HashMap<String, String>();
+//			whereParams.put("name", "aaa00-test2");
+//			Object[] params = new Object[] { user, 
+//					cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
+//					whereParams };
+//			Object execute = client.execute(MODULE + ".delete", params);
+//			assertNull(execute);
+//		} catch (XmlRpcException e) {
+//			fail(e.getMessage());
+//		}
+//		assertEquals(count, getObjectCount());
+//	}
 
 	@Test
 	public void testDeleteAsPacAdmin() {
 		int count = getObjectCount();
 		try {
-			String user = "peh00";
+			String user = "aaa00";
 			String grantingTicketURL = cas.getGrantingTicketURL(user);
 			Map<String, String> whereParams = new HashMap<String, String>();
-			whereParams.put("name", "peh00-test2");
+			whereParams.put("name", "aaa00-test2");
 			Object[] params = new Object[] { user, 
 					cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), 
 					whereParams };
@@ -222,7 +222,7 @@
 	private int getObjectCount() {
 		int count = -1;
 		try {
-			String user = "peh00";
+			String user = "aaa00";
 			String grantingTicketURL = cas.getGrantingTicketURL(user);
 			Map<String, String> whereParams = new HashMap<String, String>();
 			Object[] params = new Object[] { user, 
diff --git a/hsarweb/WebContent/WEB-INF/web.xml b/hsarweb/WebContent/WEB-INF/web.xml
index 90ed4dd..8a1cc6f 100644
--- a/hsarweb/WebContent/WEB-INF/web.xml
+++ b/hsarweb/WebContent/WEB-INF/web.xml
@@ -11,11 +11,11 @@
 	</context-param>
 	<context-param>
 		<param-name>backendURL</param-name>
-		<param-value>https://agnes.ostwall195.de:9443/hsar/backend</param-value>
+		<param-value>https://config-dev.hostsharing.net:443/hsar/backend</param-value>
 	</context-param>
 	<context-param>
 		<param-name>xmlrpcURL</param-name>
-		<param-value>https://agnes.ostwall195.de:9443/hsar/xmlrpc/hsadmin</param-value>
+		<param-value>https://config-dev.hostsharing.net:443/hsar/xmlrpc/hsadmin</param-value>
 	</context-param>
 	<context-param>
 		<description>Vaadin production mode</description>
@@ -33,7 +33,7 @@
 		<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
 		<init-param>
 			<param-name>casServerLoginUrl</param-name>
-			<param-value>https://agnes.ostwall195.de:9443/cas/login</param-value>
+			<param-value>https://login-dev.hostsharing.net:443/cas/login</param-value>
 		</init-param>
 		<init-param>
 			<param-name>service</param-name>
@@ -46,7 +46,7 @@
 		<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
 		<init-param>
 			<param-name>casServerUrlPrefix</param-name>
-			<param-value>https://agnes.ostwall195.de:9443/cas</param-value>
+			<param-value>https://login-dev.hostsharing.net:443/cas</param-value>
 		</init-param>
 		<init-param>
         	<param-name>proxyReceptorUrl</param-name>
diff --git a/hsarweb/src/de/hsadmin/web/DomainModule.java b/hsarweb/src/de/hsadmin/web/DomainModule.java
index 4083317..9361c76 100644
--- a/hsarweb/src/de/hsadmin/web/DomainModule.java
+++ b/hsarweb/src/de/hsadmin/web/DomainModule.java
@@ -20,8 +20,9 @@
 
 	@Override
 	protected void initModule() {
-		moduleConfig = new ModuleConfig("domain");
-		String login = getApplication().getLogin();
+		MainApplication application = getApplication();
+		moduleConfig = new ModuleConfig("domain", application.getLocale());
+		String login = application.getLogin();
 		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 e52bd84..75fecc4 100644
--- a/hsarweb/src/de/hsadmin/web/EMailAddressModule.java
+++ b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java
@@ -20,8 +20,9 @@
 
 	@Override
 	protected void initModule() {
-		moduleConfig = new ModuleConfig("emailaddress");
-		String login = getApplication().getLogin();
+		MainApplication application = getApplication();
+		moduleConfig = new ModuleConfig("emailaddress", application.getLocale());
+		String login = application.getLogin();
 		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 d893e48..ab9b162 100644
--- a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java
+++ b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java
@@ -20,8 +20,9 @@
 
 	@Override
 	protected void initModule() {
-		moduleConfig = new ModuleConfig("emailalias");
-		String login = getApplication().getLogin();
+		MainApplication application = getApplication();
+		moduleConfig = new ModuleConfig("emailalias", application.getLocale());
+		String login = application.getLogin();
 		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/MainApplication.java b/hsarweb/src/de/hsadmin/web/MainApplication.java
index 1d160ed..aaf201d 100644
--- a/hsarweb/src/de/hsadmin/web/MainApplication.java
+++ b/hsarweb/src/de/hsadmin/web/MainApplication.java
@@ -38,11 +38,16 @@
 	private LocaleConfig localeConfig;
 	private Remote remote;
 	private Map<String, Module> modules;
+	private Locale requestLocale;
 
 
 	@Override
 	public void init() {
-		localeConfig = new LocaleConfig(Locale.getDefault(), "main");
+		Locale locale = requestLocale;
+		if (locale == null) {
+			locale = Locale.getDefault();
+		}
+		localeConfig = new LocaleConfig(locale, "main");
 		remote = new Remote(this);
 		Window mainWindow = new Window(localeConfig.getText("applicationtitle"));
 		VerticalLayout verticalLayout = new VerticalLayout();
@@ -105,9 +110,14 @@
 		return localeConfig;
 	}
 
+	public Locale getRequestLocale() {
+		return requestLocale;
+	}
+
 	@Override
 	public void onRequestStart(HttpServletRequest request,
 			HttpServletResponse response) {
+		requestLocale = request.getLocale();
 		httpSession = request.getSession();
 		servletContext = httpSession.getServletContext();
 		userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal();
diff --git a/hsarweb/src/de/hsadmin/web/QueueTaskModule.java b/hsarweb/src/de/hsadmin/web/QueueTaskModule.java
index 36a326f..e393ee0 100644
--- a/hsarweb/src/de/hsadmin/web/QueueTaskModule.java
+++ b/hsarweb/src/de/hsadmin/web/QueueTaskModule.java
@@ -14,7 +14,7 @@
 
 	@Override
 	protected void initModule() {
-		moduleConfig = new ModuleConfig("q");
+		moduleConfig = new ModuleConfig("q", getApplication().getLocale());
 		moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY));
 		moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class));
 		moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class));
diff --git a/hsarweb/src/de/hsadmin/web/UnixUserModule.java b/hsarweb/src/de/hsadmin/web/UnixUserModule.java
index ec66927..3549cd8 100644
--- a/hsarweb/src/de/hsadmin/web/UnixUserModule.java
+++ b/hsarweb/src/de/hsadmin/web/UnixUserModule.java
@@ -20,8 +20,9 @@
 
 	@Override
 	protected void initModule() {
-		moduleConfig = new ModuleConfig("user");
-		String login = getApplication().getLogin();
+		MainApplication application = getApplication();
+		moduleConfig = new ModuleConfig("user", application.getLocale());
+		String login = application.getLogin();
 		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/config/ModuleConfig.java b/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java
index acf8bb6..776afd8 100644
--- a/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java
+++ b/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java
@@ -16,11 +16,11 @@
 	private Map<String, PropertyConfig> propertyMap;
 	private LocaleConfig localeConfig;
 
-	public ModuleConfig(String name) {
+	public ModuleConfig(String name, Locale locale) {
 		this.name = name;
 		propertyList = new ArrayList<PropertyConfig>();
 		propertyMap = new HashMap<String, PropertyConfig>();
-		localeConfig = new LocaleConfig(Locale.getDefault(), name);
+		localeConfig = new LocaleConfig(locale, name);
 	}
 	
 	public String getName() {

--
Gitblit v1.9.3