Schlankes Backend ohne JSF-Code
This commit is contained in:
parent
67eb44cd49
commit
19ea388bf1
76
hsarback/build.xml
Normal file
76
hsarback/build.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="hsarweb" default="war">
|
||||
|
||||
<property name="build.home" value="${basedir}/build" />
|
||||
<property name="lib.home" value="${basedir}/lib" />
|
||||
<property name="conf.home" value="${basedir}/conf" />
|
||||
<property name="src.home" value="${basedir}/src" />
|
||||
<property name="dist.home" value="${basedir}/dist" />
|
||||
|
||||
<!-- Optionen für Java-Compiler-->
|
||||
<property name="compile.debug" value="true" />
|
||||
<property name="compile.deprecation" value="true" />
|
||||
<property name="compile.optimize" value="true" />
|
||||
|
||||
<path id="compile.classpath">
|
||||
<fileset dir="lib">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<path id="enhance.classpath">
|
||||
<fileset dir="lib">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
<dirset dir="conf"/>
|
||||
<dirset dir="${build.home}"/>
|
||||
</path>
|
||||
|
||||
<target name="clean" description="aufräumen">
|
||||
<delete dir="${build.home}" />
|
||||
<delete dir="${dist.home}" />
|
||||
</target>
|
||||
|
||||
<target name="war" depends="enhance">
|
||||
<war destfile="build/hsar.war" basedir="webapp">
|
||||
<lib dir="lib">
|
||||
<include name="**/*.jar"/>
|
||||
<exclude name="**/servlet*.jar"/>
|
||||
<exclude name="**/geronimo-jms*.jar"/>
|
||||
</lib>
|
||||
<classes dir="build/cls" />
|
||||
<classes dir="src">
|
||||
<include name="**/*.properties"/>
|
||||
</classes>
|
||||
<classes dir="conf">
|
||||
<include name="**/*.xml"/>
|
||||
</classes>
|
||||
</war>
|
||||
</target>
|
||||
|
||||
<target name="compile" description="compilieren">
|
||||
<mkdir dir="${build.home}" />
|
||||
<mkdir dir="${build.home}/cls" />
|
||||
<javac srcdir="${src.home}" destdir="${build.home}/cls" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}">
|
||||
<classpath refid="compile.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="enhance" description="openjpa enhancer" depends="compile">
|
||||
<taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask">
|
||||
<classpath refid="enhance.classpath"/>
|
||||
</taskdef>
|
||||
<taskdef name="mappingtool" classname="org.apache.openjpa.jdbc.ant.MappingToolTask">
|
||||
<classpath refid="enhance.classpath"/>
|
||||
</taskdef>
|
||||
<openjpac>
|
||||
<classpath refid="enhance.classpath"/>
|
||||
</openjpac>
|
||||
<!--
|
||||
<mappingtool action="buildSchema">
|
||||
<classpath refid="enhance.classpath"/>
|
||||
</mappingtool> -->
|
||||
<echo message="Enhancing complete."/>
|
||||
</target>
|
||||
|
||||
</project>
|
26
hsarback/conf/META-INF/persistence.xml
Normal file
26
hsarback/conf/META-INF/persistence.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
|
||||
<persistence-unit name="hsadmin" transaction-type="RESOURCE_LOCAL">
|
||||
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
|
||||
<non-jta-data-source>java:/comp/env/jdbc/HSAdminDB</non-jta-data-source>
|
||||
<class>de.hsadmin.core.qserv.QueueTask</class>
|
||||
<class>de.hsadmin.mods.cust.Customer</class>
|
||||
<class>de.hsadmin.mods.cust.Contact</class>
|
||||
<class>de.hsadmin.mods.cust.BankAccount</class>
|
||||
<class>de.hsadmin.mods.cust.CustomersTariff</class>
|
||||
<class>de.hsadmin.mods.pac.Pac</class>
|
||||
<class>de.hsadmin.mods.pac.BasePac</class>
|
||||
<class>de.hsadmin.mods.pac.BaseComponent</class>
|
||||
<class>de.hsadmin.mods.pac.Component</class>
|
||||
<class>de.hsadmin.mods.pac.PacComponent</class>
|
||||
<class>de.hsadmin.mods.pac.Hive</class>
|
||||
<class>de.hsadmin.mods.pac.INetAddress</class>
|
||||
<class>de.hsadmin.mods.user.UnixUser</class>
|
||||
<properties>
|
||||
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/>
|
||||
<!--
|
||||
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
|
||||
<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/> -->
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
BIN
hsarback/lib/commons-codec-1.3.jar
Normal file
BIN
hsarback/lib/commons-codec-1.3.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/commons-collections-3.2.1.jar
Normal file
BIN
hsarback/lib/commons-collections-3.2.1.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/commons-httpclient-3.1.jar
Normal file
BIN
hsarback/lib/commons-httpclient-3.1.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/commons-lang-2.1.jar
Normal file
BIN
hsarback/lib/commons-lang-2.1.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/commons-logging-1.1.1.jar
Normal file
BIN
hsarback/lib/commons-logging-1.1.1.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/commons-pool-1.5.3.jar
Normal file
BIN
hsarback/lib/commons-pool-1.5.3.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/geronimo-jms_1.1_spec-1.1.1.jar
Normal file
BIN
hsarback/lib/geronimo-jms_1.1_spec-1.1.1.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/geronimo-jpa_2.0_spec-1.0.jar
Normal file
BIN
hsarback/lib/geronimo-jpa_2.0_spec-1.0.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/geronimo-jta_1.1_spec-1.1.1.jar
Normal file
BIN
hsarback/lib/geronimo-jta_1.1_spec-1.1.1.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/mail.jar
Normal file
BIN
hsarback/lib/mail.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/openjpa-2.0.0.jar
Normal file
BIN
hsarback/lib/openjpa-2.0.0.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/serp-1.13.1.jar
Normal file
BIN
hsarback/lib/serp-1.13.1.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/servlet-api-2.4.jar
Normal file
BIN
hsarback/lib/servlet-api-2.4.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/ws-commons-util-1.0.2.jar
Normal file
BIN
hsarback/lib/ws-commons-util-1.0.2.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/xmlrpc-client-3.1.3.jar
Normal file
BIN
hsarback/lib/xmlrpc-client-3.1.3.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/xmlrpc-common-3.1.3.jar
Normal file
BIN
hsarback/lib/xmlrpc-common-3.1.3.jar
Normal file
Binary file not shown.
BIN
hsarback/lib/xmlrpc-server-3.1.3.jar
Normal file
BIN
hsarback/lib/xmlrpc-server-3.1.3.jar
Normal file
Binary file not shown.
125
hsarback/test/de/hsadmin/remote/QueueTaskTest.java
Normal file
125
hsarback/test/de/hsadmin/remote/QueueTaskTest.java
Normal file
@ -0,0 +1,125 @@
|
||||
package de.hsadmin.remote;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
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 QueueTaskTest {
|
||||
|
||||
private static final String MODULE = "q";
|
||||
|
||||
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 testSearchAllAsPacAdmin() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
assertTrue(result.length > 100);
|
||||
for (Object o : result) {
|
||||
if (o instanceof Map<?, ?>) {
|
||||
Map<?, ?> row = (Map<?, ?>) o;
|
||||
assertEquals("peh00", ((String) row.get("user")).substring(0, 5));
|
||||
} else {
|
||||
fail("map expected");
|
||||
}
|
||||
}
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
setParams.put("details", "Test");
|
||||
whereParams.put("user", "peh00");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
setParams, whereParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".update", params);
|
||||
assertNotNull(execute);
|
||||
fail("exception expected");
|
||||
} catch (XmlRpcException e) {
|
||||
// System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateFails() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("status", "done");
|
||||
setParams.put("title", "Test");
|
||||
setParams.put("user", "peh00");
|
||||
setParams.put("hive", "h05");
|
||||
setParams.put("started", "03.03.2010");
|
||||
setParams.put("finished", "03.03.2010");
|
||||
setParams.put("details", "Blupp");
|
||||
setParams.put("exception", "f6n");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
setParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".add", params);
|
||||
assertTrue(execute instanceof Map<?, ?>);
|
||||
fail("exception expected");
|
||||
} catch (XmlRpcException e) {
|
||||
// System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAsPacAdminFails() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("user", "peh00");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".delete", params);
|
||||
assertTrue(execute instanceof Map<?, ?>);
|
||||
fail("exception expected");
|
||||
} catch (XmlRpcException e) {
|
||||
// System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
105
hsarback/test/de/hsadmin/remote/RemoteCASHelper.java
Normal file
105
hsarback/test/de/hsadmin/remote/RemoteCASHelper.java
Normal file
@ -0,0 +1,105 @@
|
||||
package de.hsadmin.remote;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
public class RemoteCASHelper {
|
||||
|
||||
private static String LOGIN_URL = "https://login.hostsharing.net:443/cas/v1/tickets";
|
||||
|
||||
private String loginURL;
|
||||
private Properties config;
|
||||
|
||||
public RemoteCASHelper() {
|
||||
initConfig();
|
||||
}
|
||||
|
||||
private void initConfig() {
|
||||
config = new Properties();
|
||||
try {
|
||||
config.load(new FileInputStream( new File(System.getProperty("user.home"), ".hsadmin.conf")));
|
||||
} catch (IOException e) {
|
||||
}
|
||||
loginURL = config.getProperty("loginURL", LOGIN_URL);
|
||||
}
|
||||
|
||||
public String getGrantingTicketURL(String user, String pw) {
|
||||
if ("peh00".equals(pw)) {
|
||||
pw = config.getProperty("peh00.passWord", "-");
|
||||
}
|
||||
if ("peh01".equals(pw)) {
|
||||
pw = config.getProperty("peh01.passWord", "-");
|
||||
}
|
||||
if ("pe".equals(pw)) {
|
||||
pw = config.getProperty("pe.passWord", "-");
|
||||
}
|
||||
if (user.equals(pw)) {
|
||||
System.err.println("Unknown Password for: " + pw);
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String encodedParams = URLEncoder.encode("username", "UTF-8")
|
||||
+ "=" + URLEncoder.encode(user, "UTF-8")
|
||||
+ "&" + URLEncoder.encode("password", "UTF-8")
|
||||
+ "=" + URLEncoder.encode(pw, "UTF-8");
|
||||
return doHttpPost(loginURL, encodedParams);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
System.err.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getServiceTicket(String location, String service) {
|
||||
try {
|
||||
String encodedParams = URLEncoder.encode("service", "UTF-8")
|
||||
+ "=" + URLEncoder.encode(service, "UTF-8");
|
||||
return doHttpPost(location, encodedParams);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
System.err.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String doHttpPost(String urlString, String encodedParams) {
|
||||
String result = null;
|
||||
try {
|
||||
URL url = new URL(urlString);
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setAllowUserInteraction(false);
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connection.getOutputStream()));
|
||||
writer.write(encodedParams);
|
||||
writer.close();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String ticket = reader.readLine();
|
||||
String readLine = null;
|
||||
do {
|
||||
readLine = reader.readLine();
|
||||
} while (readLine != null);
|
||||
result = connection.getHeaderField("Location");
|
||||
if (ticket != null && ticket.startsWith("ST-")) {
|
||||
result = ticket;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
20
hsarback/test/de/hsadmin/remote/RemoteTest.java
Normal file
20
hsarback/test/de/hsadmin/remote/RemoteTest.java
Normal file
@ -0,0 +1,20 @@
|
||||
package de.hsadmin.remote;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
UnixUserTest.class,
|
||||
// MySqlDatabaseTest.class,
|
||||
// MySqlUserTest.class,
|
||||
// PgSqlUserTest.class,
|
||||
// EMailAddressTest.class,
|
||||
// DomainTest.class,
|
||||
// HostmasterTest.class,
|
||||
QueueTaskTest.class
|
||||
})
|
||||
|
||||
public class RemoteTest {
|
||||
|
||||
}
|
25
hsarback/test/de/hsadmin/remote/RemoteTestHelper.java
Normal file
25
hsarback/test/de/hsadmin/remote/RemoteTestHelper.java
Normal file
@ -0,0 +1,25 @@
|
||||
package de.hsadmin.remote;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.xmlrpc.client.XmlRpcClient;
|
||||
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
|
||||
|
||||
public class RemoteTestHelper {
|
||||
|
||||
public static String BACKEND_URL = "https://agnes.ostwall195.de:9443/hsar/backend";
|
||||
|
||||
private static XmlRpcClient client;
|
||||
|
||||
public static XmlRpcClient getClient() throws Exception {
|
||||
if (client == null) {
|
||||
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
|
||||
config.setServerURL(new URL("https://agnes.ostwall195.de:9443/hsar/xmlrpc/hsadmin"));
|
||||
config.setEnabledForExtensions(true);
|
||||
client = new XmlRpcClient();
|
||||
client.setConfig(config);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
}
|
240
hsarback/test/de/hsadmin/remote/UnixUserTest.java
Normal file
240
hsarback/test/de/hsadmin/remote/UnixUserTest.java
Normal file
@ -0,0 +1,240 @@
|
||||
package de.hsadmin.remote;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
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 UnixUserTest {
|
||||
|
||||
private static final String MODULE = "user";
|
||||
|
||||
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 testSearchAsPacAdmin() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
assertEquals(23, result.length);
|
||||
for (Object o : result) {
|
||||
if (o instanceof Map<?, ?>) {
|
||||
Map<?, ?> row = (Map<?, ?>) o;
|
||||
assertEquals("peh00", row.get("pac"));
|
||||
} else {
|
||||
fail("map expected");
|
||||
}
|
||||
}
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAsPacAdmin() {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("name", "peh00-test2");
|
||||
setParams.put("password", "test123");
|
||||
setParams.put("quota", "128");
|
||||
setParams.put("quotalimit", "192");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
setParams };
|
||||
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(null, entry.get("password"));
|
||||
} else {
|
||||
fail("map expected");
|
||||
}
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
assertEquals(count + 1, getObjectCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAsPacAdminFail() {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("name", "peh01-testfail");
|
||||
setParams.put("password", "test123");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
setParams };
|
||||
Object execute = client.execute(MODULE + ".add", params);
|
||||
assertNull(execute);
|
||||
fail("should fail");
|
||||
} catch (XmlRpcException e) {
|
||||
|
||||
}
|
||||
assertEquals(count, getObjectCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddWithFalseName() {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("name", "peh00-langer-name");
|
||||
setParams.put("password", "test123");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
setParams };
|
||||
Object execute = client.execute(MODULE + ".add", params);
|
||||
assertNull(execute);
|
||||
fail("exception expected");
|
||||
} catch (XmlRpcException e) {
|
||||
|
||||
}
|
||||
assertEquals(count, getObjectCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAsPacAdmin() {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
whereParams.put("name", "peh00-test2");
|
||||
setParams.put("password", "test1234");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
setParams, whereParams };
|
||||
Object execute = client.execute(MODULE + ".update", params);
|
||||
if (execute instanceof Object[]) {
|
||||
Object[] a = (Object[]) execute;
|
||||
for (Object o : a) {
|
||||
if (o instanceof Map<?, ?>) {
|
||||
Map<?, ?> entry = (Map<?, ?>) o;
|
||||
assertNull(entry.get("password"));
|
||||
assertEquals("peh00-test2", entry.get("name"));
|
||||
} else {
|
||||
fail("map expected");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fail("Object[] axpected");
|
||||
}
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
assertEquals(count, getObjectCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteWithLongName() {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("name", "peh00-langer-name");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
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 = "peh01";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("name", "peh00-test2");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
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 grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("name", "peh00-test2");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
Object execute = client.execute(MODULE + ".delete", params);
|
||||
assertNull(execute);
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
assertEquals(count - 1, getObjectCount());
|
||||
}
|
||||
|
||||
private int getObjectCount() {
|
||||
int count = -1;
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
count = result.length;
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
289
hsarback/webapp/WEB-INF/web.xml
Normal file
289
hsarback/webapp/WEB-INF/web.xml
Normal file
@ -0,0 +1,289 @@
|
||||
<?xml version="1.0"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Queue Status Servlet</servlet-name>
|
||||
<servlet-class>de.hsadmin.core.qserv.QueueStatusReceiverServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>CLI Client Connector</servlet-name>
|
||||
<servlet-class>de.hsadmin.cliClientConnector.CLIClientConnectorServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>proxyValidateUrl</param-name>
|
||||
<param-value>https://agnes.ostwall195.de:9443/cas/proxyValidate</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>proxyServiceUrl</param-name>
|
||||
<param-value>https://agnes.ostwall195.de:9443/hsar/backend</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>Components</param-name>
|
||||
<param-value>user,member,contact,bankaccount,pac,paccomponent,hive,ipaddr,basepac,basecomponent,component,q</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_user</param-name>
|
||||
<param-value>de.hsadmin.mods.user.UnixUser</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_user</param-name>
|
||||
<param-value>Unix User</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_member</param-name>
|
||||
<param-value>de.hsadmin.mods.cust.Customer</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_member</param-name>
|
||||
<param-value>Mitglieder</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_contact</param-name>
|
||||
<param-value>de.hsadmin.mods.cust.Contact</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_contact</param-name>
|
||||
<param-value>Kontaktdaten zu Mitgliedern</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_bankaccount</param-name>
|
||||
<param-value>de.hsadmin.mods.cust.BankAccount</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_bankaccount</param-name>
|
||||
<param-value>Bankverbindungen</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_pac</param-name>
|
||||
<param-value>de.hsadmin.mods.pac.Pac</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_pac</param-name>
|
||||
<param-value>Pakete</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_paccomponent</param-name>
|
||||
<param-value>de.hsadmin.mods.pac.PacComponent</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_paccomponent</param-name>
|
||||
<param-value>Optionen der Pakete</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_hive</param-name>
|
||||
<param-value>de.hsadmin.mods.pac.Hive</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_hive</param-name>
|
||||
<param-value>Hives</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_ipaddr</param-name>
|
||||
<param-value>de.hsadmin.mods.pac.INetAddress</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_ipaddr</param-name>
|
||||
<param-value>IP Adressen</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_basepac</param-name>
|
||||
<param-value>de.hsadmin.mods.pac.BasePac</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_basepac</param-name>
|
||||
<param-value>bestellbare Pakete</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_basecomponent</param-name>
|
||||
<param-value>de.hsadmin.mods.pac.BaseComponent</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_basecomponent</param-name>
|
||||
<param-value>Zusammenstellung bestellbarer Pakete</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_component</param-name>
|
||||
<param-value>de.hsadmin.mods.pac.Component</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_component</param-name>
|
||||
<param-value>bestellbare Optionen</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentClass_q</param-name>
|
||||
<param-value>de.hsadmin.core.qserv.QueueTask</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ComponentDescription_q</param-name>
|
||||
<param-value>offene Aktionen</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>XmlRpcServlet</servlet-name>
|
||||
<servlet-class>org.apache.xmlrpc.webserver.XmlRpcServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>enabledForExtensions</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>Queue Status Servlet</servlet-name>
|
||||
<url-pattern>/queueStatus</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>CLI Client Connector</servlet-name>
|
||||
<url-pattern>/hsadmin/cli-interface/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>XmlRpcServlet</servlet-name>
|
||||
<url-pattern>/xmlrpc/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<resource-ref>
|
||||
<res-ref-name>jdbc/HSAdminDB</res-ref-name>
|
||||
<res-type>javax.sql.DataSource</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
</resource-ref>
|
||||
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/QueueCF</res-ref-name>
|
||||
<res-type>javax.jms.QueueConnectionFactory</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h01</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h02</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h03</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h04</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h05</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h50</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h51</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h52</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h53</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h54</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-h90</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-dns1</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-dns2</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-dns3</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-mail1</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-mail2</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-mail3</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminSystem-backupmx</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/hsadminStatus</res-ref-name>
|
||||
<res-type>javax.jms.Queue</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
|
||||
<security-constraint>
|
||||
<web-resource-collection>
|
||||
<web-resource-name>Hostsharing Administrative Area</web-resource-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</web-resource-collection>
|
||||
<user-data-constraint>
|
||||
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
|
||||
</user-data-constraint>
|
||||
</security-constraint>
|
||||
|
||||
</web-app>
|
Loading…
Reference in New Issue
Block a user