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 Binary files /dev/null and b/hsarback/lib/activemq-all-5.4.2.jar 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 Binary files a/hsarback/lib/commons-logging-1.0.4.jar and /dev/null 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.cliClientConnector.TechnicalException; 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 class Transaction { 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 @@ public class TicketValidator { (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 class TicketValidator { } } - 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 class Pac extends AbstractEntity implements Serializable { 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 javax.persistence.Transient; 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 class UnixUser extends AbstractEntity implements Serializable { 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> search(String runAsUser, String ticket, + Map 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 list = module.search(Domain.class, "obj.user.name = '" + user + "'", null); + if (list != null && list.size() > 0) { + role = "DOM_ADMIN"; + } + } + List> result = new ArrayList>(); + Map record = new HashMap(); + record.put("role", role); + result.add(record); + transaction.close(); + return result; + } else { + transaction.close(); + throw new AuthenticationException("authentication failed"); + } + } + + @Override + public Map add(String runAsUser, String ticket, + Map setParams) throws HSAdminException { + throw new HSAdminException("not implemented"); + } + + @Override + public List> update(String runAsUser, String ticket, + Map setParams, Map whereParams) + throws HSAdminException { + throw new HSAdminException("not implemented"); + } + + @Override + public void delete(String runAsUser, String ticket, + Map 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 @@ domain=de.hsadmin.remote.DomainRemote 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 class InitDataTest { 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 setParams = new HashMap(); - 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 @@ public class InitDataTest { 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 @@ public class InitDataTest { String grantingTicketURL = cas.getGrantingTicketURL(user); Map setParams = new HashMap(); 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 @@ public class InitDataTest { 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 whereParams = new HashMap(); + 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 whereParams = new HashMap(); + 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 whereParams = new HashMap(); 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 @@ public class InitDataTest { String user = "pe"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); - 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.After; 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 @@ public class PacTest { @Test public void testSearchAllAsPacAdmin() { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); Object[] params = new Object[] { user, @@ -49,7 +53,7 @@ public class PacTest { 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 @@ public class PacTest { @Test public void testUpdate() { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map setParams = new HashMap(); Map whereParams = new HashMap(); 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 @@ public class PacTest { String user = "pe"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map setParams = new HashMap(); - 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 @@ public class PacTest { String user = "pe"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); - whereParams.put("name", "peh07"); + whereParams.put("name", "aaa01"); Object[] params = new Object[] { user, cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), whereParams }; @@ -123,10 +127,10 @@ public class PacTest { private int getPacsCount() { int count = 0; - String user = "pe"; + String user = "hsh90-aaa"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); - 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 whereParams = new HashMap(); + 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 whereParams = new HashMap(); + 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 whereParams = new HashMap(); + 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 whereParams = new HashMap(); + 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 @@ public class UnixUserTest { @Test public void testSearchAsPacAdmin() { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); Object[] params = new Object[] { user, @@ -43,11 +43,11 @@ public class UnixUserTest { 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 class UnixUserTest { public void testAddAsPacAdmin() { int count = getObjectCount(); try { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map setParams = new HashMap(); - 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 @@ public class UnixUserTest { 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 class UnixUserTest { public void testAddAsPacAdminFail() { int count = getObjectCount(); try { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map setParams = new HashMap(); setParams.put("name", "peh01-testfail"); @@ -111,10 +111,10 @@ public class UnixUserTest { public void testAddWithFalseName() { int count = getObjectCount(); try { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map setParams = new HashMap(); - 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 class UnixUserTest { public void testUpdateAsPacAdmin() { int count = getObjectCount(); try { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); Map setParams = new HashMap(); - 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 @@ public class UnixUserTest { 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 class UnixUserTest { public void testDeleteWithLongName() { int count = getObjectCount(); try { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); - 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 @@ public class UnixUserTest { assertEquals(count, getObjectCount()); } - @Test - public void testDeleteAsPacAdminFail() { - int count = getObjectCount(); - try { - String user = "peh01"; - String grantingTicketURL = cas.getGrantingTicketURL(user); - Map whereParams = new HashMap(); - 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 whereParams = new HashMap(); +// 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 whereParams = new HashMap(); - 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 @@ public class UnixUserTest { private int getObjectCount() { int count = -1; try { - String user = "peh00"; + String user = "aaa00"; String grantingTicketURL = cas.getGrantingTicketURL(user); Map whereParams = new HashMap(); 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 @@ backendURL - https://agnes.ostwall195.de:9443/hsar/backend + https://config-dev.hostsharing.net:443/hsar/backend xmlrpcURL - https://agnes.ostwall195.de:9443/hsar/xmlrpc/hsadmin + https://config-dev.hostsharing.net:443/hsar/xmlrpc/hsadmin Vaadin production mode @@ -33,7 +33,7 @@ org.jasig.cas.client.authentication.AuthenticationFilter casServerLoginUrl - https://agnes.ostwall195.de:9443/cas/login + https://login-dev.hostsharing.net:443/cas/login service @@ -46,7 +46,7 @@ org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter casServerUrlPrefix - https://agnes.ostwall195.de:9443/cas + https://login-dev.hostsharing.net:443/cas proxyReceptorUrl 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 @@ public class DomainModule extends GenericModule { @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 @@ public class EMailAddressModule extends GenericModule { @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 @@ public class EMailAliasModule extends GenericModule { @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 @@ public class MainApplication extends Application implements HttpServletRequestLi private LocaleConfig localeConfig; private Remote remote; private Map 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 @@ public class MainApplication extends Application implements HttpServletRequestLi 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 @@ public class QueueTaskModule extends AbstractModule { @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 @@ public class UnixUserModule extends GenericModule { @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 @@ public class ModuleConfig implements Serializable { private Map propertyMap; private LocaleConfig localeConfig; - public ModuleConfig(String name) { + public ModuleConfig(String name, Locale locale) { this.name = name; propertyList = new ArrayList(); propertyMap = new HashMap(); - localeConfig = new LocaleConfig(Locale.getDefault(), name); + localeConfig = new LocaleConfig(locale, name); } public String getName() {