Locale aus Request

RoleRemote
This commit is contained in:
Peter Hormanns 2011-03-30 16:26:43 +00:00
parent f9c969cb92
commit 1d5797d81d
22 changed files with 353 additions and 83 deletions

View File

@ -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

View File

@ -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

Binary file not shown.

View File

@ -23,6 +23,7 @@ import de.hsadmin.cliClientConnector.TechnicalException;
import de.hsadmin.core.model.onetier.PersistenceManager; import de.hsadmin.core.model.onetier.PersistenceManager;
import de.hsadmin.core.qserv.QueueClient; import de.hsadmin.core.qserv.QueueClient;
import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
public class Transaction { public class Transaction {
@ -181,7 +182,10 @@ public class Transaction {
public UnixUser getLoginUser() { public UnixUser getLoginUser() {
String loginName = getLoginName(); String loginName = getLoginName();
if (loginName != null && loginName.length() == 2) { 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"); Query userQuery = getEntityManager().createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username");
userQuery.setParameter("username", loginName); userQuery.setParameter("username", loginName);

View File

@ -45,6 +45,8 @@ public class TicketValidator {
(runAsUser.equals(ticketUser) // user himself (runAsUser.equals(ticketUser) // user himself
|| (ticketUser.length() == 5 && runAsUser.startsWith(ticketUser)) || (ticketUser.length() == 5 && runAsUser.startsWith(ticketUser))
// pac-admin // pac-admin
|| (ticketUser.length() == 3 && runAsUser.startsWith(ticketUser))
// member
|| ticketUser.length() == 2) // hostmaster || ticketUser.length() == 2) // hostmaster
// TODO: add test for member-account // 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) { if (proxyServiceURL == null || proxyServiceURL == null) {
log.fatal("TicketValidator is not initialized."); log.fatal("TicketValidator is not initialized.");
throw new RuntimeException("TicketValidator is not initialized."); throw new RuntimeException("TicketValidator is not initialized.");

View File

@ -268,6 +268,7 @@ public class Pac extends AbstractEntity implements Serializable {
public boolean isReadAllowedFor(UnixUser loginUser) { public boolean isReadAllowedFor(UnixUser loginUser) {
return getName().equals(loginUser.getName()) return getName().equals(loginUser.getName())
|| getCustomer().getName().equals(loginUser.getName())
|| super.isReadAllowedFor(loginUser); || super.isReadAllowedFor(loginUser);
} }

View File

@ -19,6 +19,7 @@ import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.EntityInfo; import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.FieldValidation; import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
@Entity(name = "UnixUsers") @Entity(name = "UnixUsers")
@ -271,7 +272,7 @@ public class UnixUser extends AbstractEntity implements Serializable {
public boolean hasHostmasterRole() { public boolean hasHostmasterRole() {
// TODO: hardcoded Hostsharing conventions // TODO: hardcoded Hostsharing conventions
String login = getName(); 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));
} }
/** /**

View File

@ -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");
}
}

View File

@ -5,3 +5,4 @@ domain=de.hsadmin.remote.DomainRemote
emailalias=de.hsadmin.remote.EMailAliasRemote emailalias=de.hsadmin.remote.EMailAliasRemote
emailaddress=de.hsadmin.remote.EMailAddressRemote emailaddress=de.hsadmin.remote.EMailAddressRemote
q=de.hsadmin.remote.QueueTaskRemote q=de.hsadmin.remote.QueueTaskRemote
role=de.hsadmin.remote.RoleRemote

View File

@ -37,14 +37,10 @@ public class InitDataTest {
public void testAddMember() { public void testAddMember() {
String user = "pe"; String user = "pe";
int membersCount = -9999; int membersCount = -9999;
try { membersCount = getMembersCount();
membersCount = getMembersCount(user);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
setParams.put("membercode", "hsh00-aaa"); setParams.put("membercode", "hsh90-aaa");
setParams.put("password", "geheimnIs"); setParams.put("password", "geheimnIs");
setParams.put("memberno", "20001"); setParams.put("memberno", "20001");
setParams.put("membersince", "01.10.2010"); setParams.put("membersince", "01.10.2010");
@ -64,10 +60,10 @@ public class InitDataTest {
setParams }; setParams };
try { try {
client.execute(CUST_MODULE + ".add", params); 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; // Map<?, ?> result = (Map<?, ?>) execute;
// System.out.println(result); // System.out.println(result);
assertEquals(membersCount + 1, getMembersCount(user)); assertEquals(membersCount + 1, getMembersCount());
} catch (XmlRpcException e) { } catch (XmlRpcException e) {
fail(e.getMessage()); fail(e.getMessage());
} }
@ -80,10 +76,10 @@ public class InitDataTest {
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "aaa00"); setParams.put("name", "aaa00");
setParams.put("hive", "h81"); setParams.put("hive", "h90");
setParams.put("customer", "hsh00-aaa"); setParams.put("customer", "hsh90-aaa");
setParams.put("basepac", "DW/B"); setParams.put("basepac", "DW/B");
setParams.put("curinetaddr", "192.168.108.203"); setParams.put("curinetaddr", "83.223.95.132");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams }; setParams };
@ -96,15 +92,59 @@ public class InitDataTest {
assertEquals(count + 1, getPacsCount()); 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); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams }; whereParams };
Object execute = client.execute(CUST_MODULE + ".search", params); Object execute;
Object[] result = (Object[]) execute; try {
return result.length; 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() { private int getPacsCount() {
@ -112,7 +152,7 @@ public class InitDataTest {
String user = "pe"; String user = "pe";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("customer", "hsh00-aaa"); whereParams.put("customer", "hsh90-aaa");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams }; whereParams };

View File

@ -15,17 +15,21 @@ import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import de.hsadmin.core.util.Config;
public class PacTest { public class PacTest {
private static final String MODULE = "pac"; private static final String MODULE = "pac";
private XmlRpcClient client; private XmlRpcClient client;
private RemoteCASHelper cas; private RemoteCASHelper cas;
private Config config;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
client = RemoteTestHelper.getClient(); client = RemoteTestHelper.getClient();
cas = new RemoteCASHelper(); cas = new RemoteCASHelper();
config = Config.getInstance();
} }
@After @After
@ -36,7 +40,7 @@ public class PacTest {
@Test @Test
public void testSearchAllAsPacAdmin() { public void testSearchAllAsPacAdmin() {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
@ -49,7 +53,7 @@ public class PacTest {
for (Object o : result) { for (Object o : result) {
if (o instanceof Map<?, ?>) { if (o instanceof Map<?, ?>) {
Map<?, ?> row = (Map<?, ?>) o; Map<?, ?> row = (Map<?, ?>) o;
assertEquals("hsh00-peh", row.get("customer")); assertEquals(config.getProperty("accountprefix.customer") + "-aaa", row.get("customer"));
} else { } else {
fail("map expected"); fail("map expected");
} }
@ -61,12 +65,12 @@ public class PacTest {
@Test @Test
public void testUpdate() { public void testUpdate() {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
setParams.put("curinetaddr", "192.168.10.2"); setParams.put("curinetaddr", "192.168.10.2");
whereParams.put("name", "peh00"); whereParams.put("name", "aaa00");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams, whereParams }; setParams, whereParams };
@ -85,11 +89,11 @@ public class PacTest {
String user = "pe"; String user = "pe";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "peh07"); setParams.put("name", "aaa01");
setParams.put("hive", "h05"); setParams.put("hive", "h90");
setParams.put("customer", "hsh00-peh"); setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", "DW/S"); setParams.put("basepac", "DW/B");
setParams.put("curinetaddr", "212.42.230.178"); setParams.put("curinetaddr", "83.223.95.133");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams }; setParams };
@ -108,7 +112,7 @@ public class PacTest {
String user = "pe"; String user = "pe";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "peh07"); whereParams.put("name", "aaa01");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams }; whereParams };
@ -123,10 +127,10 @@ public class PacTest {
private int getPacsCount() { private int getPacsCount() {
int count = 0; int count = 0;
String user = "pe"; String user = "hsh90-aaa";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); 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, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams }; whereParams };

View File

@ -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());
}
}
}

View File

@ -34,7 +34,7 @@ public class UnixUserTest {
@Test @Test
public void testSearchAsPacAdmin() { public void testSearchAsPacAdmin() {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
@ -43,11 +43,11 @@ public class UnixUserTest {
try { try {
Object execute = client.execute(MODULE + ".search", params); Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute; Object[] result = (Object[]) execute;
assertEquals(21, result.length); assertEquals(1, result.length);
for (Object o : result) { for (Object o : result) {
if (o instanceof Map<?, ?>) { if (o instanceof Map<?, ?>) {
Map<?, ?> row = (Map<?, ?>) o; Map<?, ?> row = (Map<?, ?>) o;
assertEquals("peh00", row.get("pac")); assertEquals("aaa00", row.get("pac"));
} else { } else {
fail("map expected"); fail("map expected");
} }
@ -61,10 +61,10 @@ public class UnixUserTest {
public void testAddAsPacAdmin() { public void testAddAsPacAdmin() {
int count = getObjectCount(); int count = getObjectCount();
try { try {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "peh00-test2"); setParams.put("name", "aaa00-test2");
setParams.put("password", "test123"); setParams.put("password", "test123");
setParams.put("quota", "128"); setParams.put("quota", "128");
setParams.put("quotalimit", "192"); setParams.put("quotalimit", "192");
@ -74,8 +74,8 @@ public class UnixUserTest {
Object execute = client.execute(MODULE + ".add", params); Object execute = client.execute(MODULE + ".add", params);
if (execute instanceof Map<?, ?>) { if (execute instanceof Map<?, ?>) {
Map<?, ?> entry = (Map<?, ?>) execute; Map<?, ?> entry = (Map<?, ?>) execute;
assertEquals("peh00-test2", entry.get("name")); assertEquals("aaa00-test2", entry.get("name"));
assertEquals("peh00", entry.get("pac")); assertEquals("aaa00", entry.get("pac"));
assertEquals(null, entry.get("password")); assertEquals(null, entry.get("password"));
} else { } else {
fail("map expected"); fail("map expected");
@ -90,7 +90,7 @@ public class UnixUserTest {
public void testAddAsPacAdminFail() { public void testAddAsPacAdminFail() {
int count = getObjectCount(); int count = getObjectCount();
try { try {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "peh01-testfail"); setParams.put("name", "peh01-testfail");
@ -111,10 +111,10 @@ public class UnixUserTest {
public void testAddWithFalseName() { public void testAddWithFalseName() {
int count = getObjectCount(); int count = getObjectCount();
try { try {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "peh00-langer-name"); setParams.put("name", "aaa00-langer-name");
setParams.put("password", "test123"); setParams.put("password", "test123");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
@ -132,11 +132,11 @@ public class UnixUserTest {
public void testUpdateAsPacAdmin() { public void testUpdateAsPacAdmin() {
int count = getObjectCount(); int count = getObjectCount();
try { try {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
Map<String, String> setParams = 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"); setParams.put("password", "test1234");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
@ -148,7 +148,7 @@ public class UnixUserTest {
if (o instanceof Map<?, ?>) { if (o instanceof Map<?, ?>) {
Map<?, ?> entry = (Map<?, ?>) o; Map<?, ?> entry = (Map<?, ?>) o;
assertNull(entry.get("password")); assertNull(entry.get("password"));
assertEquals("peh00-test2", entry.get("name")); assertEquals("aaa00-test2", entry.get("name"));
} else { } else {
fail("map expected"); fail("map expected");
} }
@ -166,10 +166,10 @@ public class UnixUserTest {
public void testDeleteWithLongName() { public void testDeleteWithLongName() {
int count = getObjectCount(); int count = getObjectCount();
try { try {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); 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, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams }; whereParams };
@ -181,33 +181,33 @@ public class UnixUserTest {
assertEquals(count, getObjectCount()); assertEquals(count, getObjectCount());
} }
@Test // @Test
public void testDeleteAsPacAdminFail() { // public void testDeleteAsPacAdminFail() {
int count = getObjectCount(); // int count = getObjectCount();
try { // try {
String user = "peh01"; // String user = "aaa01";
String grantingTicketURL = cas.getGrantingTicketURL(user); // String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); // Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "peh00-test2"); // whereParams.put("name", "aaa00-test2");
Object[] params = new Object[] { user, // Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), // cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams }; // whereParams };
Object execute = client.execute(MODULE + ".delete", params); // Object execute = client.execute(MODULE + ".delete", params);
assertNull(execute); // assertNull(execute);
} catch (XmlRpcException e) { // } catch (XmlRpcException e) {
fail(e.getMessage()); // fail(e.getMessage());
} // }
assertEquals(count, getObjectCount()); // assertEquals(count, getObjectCount());
} // }
@Test @Test
public void testDeleteAsPacAdmin() { public void testDeleteAsPacAdmin() {
int count = getObjectCount(); int count = getObjectCount();
try { try {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "peh00-test2"); whereParams.put("name", "aaa00-test2");
Object[] params = new Object[] { user, Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()), cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams }; whereParams };
@ -222,7 +222,7 @@ public class UnixUserTest {
private int getObjectCount() { private int getObjectCount() {
int count = -1; int count = -1;
try { try {
String user = "peh00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user, Object[] params = new Object[] { user,

View File

@ -11,11 +11,11 @@
</context-param> </context-param>
<context-param> <context-param>
<param-name>backendURL</param-name> <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>
<context-param> <context-param>
<param-name>xmlrpcURL</param-name> <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>
<context-param> <context-param>
<description>Vaadin production mode</description> <description>Vaadin production mode</description>
@ -33,7 +33,7 @@
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class> <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
<init-param> <init-param>
<param-name>casServerLoginUrl</param-name> <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>
<init-param> <init-param>
<param-name>service</param-name> <param-name>service</param-name>
@ -46,7 +46,7 @@
<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class> <filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
<init-param> <init-param>
<param-name>casServerUrlPrefix</param-name> <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>
<init-param> <init-param>
<param-name>proxyReceptorUrl</param-name> <param-name>proxyReceptorUrl</param-name>

View File

@ -20,8 +20,9 @@ public class DomainModule extends GenericModule {
@Override @Override
protected void initModule() { protected void initModule() {
moduleConfig = new ModuleConfig("domain"); MainApplication application = getApplication();
String login = getApplication().getLogin(); moduleConfig = new ModuleConfig("domain", application.getLocale());
String login = application.getLogin();
final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true); idProp.setReadOnly(true);

View File

@ -20,8 +20,9 @@ public class EMailAddressModule extends GenericModule {
@Override @Override
protected void initModule() { protected void initModule() {
moduleConfig = new ModuleConfig("emailaddress"); MainApplication application = getApplication();
String login = getApplication().getLogin(); moduleConfig = new ModuleConfig("emailaddress", application.getLocale());
String login = application.getLogin();
final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true); idProp.setReadOnly(true);

View File

@ -20,8 +20,9 @@ public class EMailAliasModule extends GenericModule {
@Override @Override
protected void initModule() { protected void initModule() {
moduleConfig = new ModuleConfig("emailalias"); MainApplication application = getApplication();
String login = getApplication().getLogin(); moduleConfig = new ModuleConfig("emailalias", application.getLocale());
String login = application.getLogin();
final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true); idProp.setReadOnly(true);

View File

@ -38,11 +38,16 @@ public class MainApplication extends Application implements HttpServletRequestLi
private LocaleConfig localeConfig; private LocaleConfig localeConfig;
private Remote remote; private Remote remote;
private Map<String, Module> modules; private Map<String, Module> modules;
private Locale requestLocale;
@Override @Override
public void init() { 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); remote = new Remote(this);
Window mainWindow = new Window(localeConfig.getText("applicationtitle")); Window mainWindow = new Window(localeConfig.getText("applicationtitle"));
VerticalLayout verticalLayout = new VerticalLayout(); VerticalLayout verticalLayout = new VerticalLayout();
@ -105,9 +110,14 @@ public class MainApplication extends Application implements HttpServletRequestLi
return localeConfig; return localeConfig;
} }
public Locale getRequestLocale() {
return requestLocale;
}
@Override @Override
public void onRequestStart(HttpServletRequest request, public void onRequestStart(HttpServletRequest request,
HttpServletResponse response) { HttpServletResponse response) {
requestLocale = request.getLocale();
httpSession = request.getSession(); httpSession = request.getSession();
servletContext = httpSession.getServletContext(); servletContext = httpSession.getServletContext();
userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal(); userPrincipal = ((Assertion) httpSession.getAttribute(AuthenticationFilter.CONST_CAS_ASSERTION)).getPrincipal();

View File

@ -14,7 +14,7 @@ public class QueueTaskModule extends AbstractModule {
@Override @Override
protected void initModule() { 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, "id", Long.class, PropertyTableColumn.INTERNAL_KEY));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class));

View File

@ -20,8 +20,9 @@ public class UnixUserModule extends GenericModule {
@Override @Override
protected void initModule() { protected void initModule() {
moduleConfig = new ModuleConfig("user"); MainApplication application = getApplication();
String login = getApplication().getLogin(); moduleConfig = new ModuleConfig("user", application.getLocale());
String login = application.getLogin();
final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory()); PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
pacProp.setSelectValues(new PropertySelectValues() { pacProp.setSelectValues(new PropertySelectValues() {

View File

@ -16,11 +16,11 @@ public class ModuleConfig implements Serializable {
private Map<String, PropertyConfig> propertyMap; private Map<String, PropertyConfig> propertyMap;
private LocaleConfig localeConfig; private LocaleConfig localeConfig;
public ModuleConfig(String name) { public ModuleConfig(String name, Locale locale) {
this.name = name; this.name = name;
propertyList = new ArrayList<PropertyConfig>(); propertyList = new ArrayList<PropertyConfig>();
propertyMap = new HashMap<String, PropertyConfig>(); propertyMap = new HashMap<String, PropertyConfig>();
localeConfig = new LocaleConfig(Locale.getDefault(), name); localeConfig = new LocaleConfig(locale, name);
} }
public String getName() { public String getName() {