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.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);

View File

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

View File

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

View File

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

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
emailaddress=de.hsadmin.remote.EMailAddressRemote
q=de.hsadmin.remote.QueueTaskRemote
role=de.hsadmin.remote.RoleRemote

View File

@ -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<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 @@ 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<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 @@ 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<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 @@ public class InitDataTest {
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 };

View File

@ -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<String, String> whereParams = new HashMap<String, String>();
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<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 @@ public class PacTest {
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 @@ public class PacTest {
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 @@ public class PacTest {
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 };

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
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 @@ 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<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 @@ 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<String, String> setParams = new HashMap<String, String>();
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<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 class UnixUserTest {
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 @@ 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<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 @@ public class UnixUserTest {
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 @@ public class UnixUserTest {
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,

View File

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

View File

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

View File

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

View File

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

View File

@ -38,11 +38,16 @@ public class MainApplication extends Application implements HttpServletRequestLi
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 @@ 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();

View File

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

View File

@ -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() {

View File

@ -16,11 +16,11 @@ public class ModuleConfig implements Serializable {
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() {