From ece7d18cf35374bf4e26d041799cda8f791c89f8 Mon Sep 17 00:00:00 2001
From: gregor
Date: Mon, 7 Jul 2003 10:58:37 +0000
Subject: Initial commit
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@2 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/logging/LogMsg.java | 43 ++
.../src/at/gv/egovernment/moa/logging/Logger.java | 175 +++++
.../gv/egovernment/moa/logging/LoggingContext.java | 46 ++
.../moa/logging/LoggingContextManager.java | 56 ++
.../at/gv/egovernment/moa/util/Base64Utils.java | 109 +++
.../src/at/gv/egovernment/moa/util/BoolUtils.java | 24 +
.../gv/egovernment/moa/util/CollectionUtils.java | 36 +
.../src/at/gv/egovernment/moa/util/Constants.java | 218 ++++++
.../src/at/gv/egovernment/moa/util/DOMUtils.java | 806 +++++++++++++++++++++
.../at/gv/egovernment/moa/util/DateTimeUtils.java | 326 +++++++++
.../egovernment/moa/util/EntityResolverChain.java | 52 ++
.../src/at/gv/egovernment/moa/util/FileUtils.java | 87 +++
.../at/gv/egovernment/moa/util/KeyStoreUtils.java | 134 ++++
.../gv/egovernment/moa/util/MOADefaultHandler.java | 82 +++
.../gv/egovernment/moa/util/MOAEntityResolver.java | 103 +++
.../gv/egovernment/moa/util/MOAErrorHandler.java | 85 +++
.../src/at/gv/egovernment/moa/util/MOATimer.java | 110 +++
.../gv/egovernment/moa/util/MessageProvider.java | 63 ++
.../src/at/gv/egovernment/moa/util/Messages.java | 117 +++
.../egovernment/moa/util/NodeIteratorAdapter.java | 87 +++
.../gv/egovernment/moa/util/NodeListAdapter.java | 44 ++
.../egovernment/moa/util/ResourceBundleChain.java | 66 ++
.../src/at/gv/egovernment/moa/util/SSLUtils.java | 222 ++++++
.../egovernment/moa/util/StreamEntityResolver.java | 64 ++
.../at/gv/egovernment/moa/util/StreamUtils.java | 116 +++
.../src/at/gv/egovernment/moa/util/URLDecoder.java | 60 ++
.../src/at/gv/egovernment/moa/util/URLEncoder.java | 63 ++
.../at/gv/egovernment/moa/util/XPathException.java | 58 ++
.../src/at/gv/egovernment/moa/util/XPathUtils.java | 415 +++++++++++
.../src/test/at/gv/egovernment/moa/AllTests.java | 38 +
.../test/at/gv/egovernment/moa/MOATestCase.java | 75 ++
.../at/gv/egovernment/moa/util/DOMUtilsTest.java | 137 ++++
.../gv/egovernment/moa/util/DateTimeUtilsTest.java | 104 +++
.../gv/egovernment/moa/util/KeyStoreUtilsTest.java | 90 +++
.../at/gv/egovernment/moa/util/SSLUtilsTest.java | 160 ++++
.../at/gv/egovernment/moa/util/URLDecoderTest.java | 29 +
.../at/gv/egovernment/moa/util/URLEncoderTest.java | 43 ++
.../moa/util/XMLGrammarBuilderTest.java | 99 +++
.../at/gv/egovernment/moa/util/XPathUtilsTest.java | 51 ++
39 files changed, 4693 insertions(+)
create mode 100644 common/src/at/gv/egovernment/moa/logging/LogMsg.java
create mode 100644 common/src/at/gv/egovernment/moa/logging/Logger.java
create mode 100644 common/src/at/gv/egovernment/moa/logging/LoggingContext.java
create mode 100644 common/src/at/gv/egovernment/moa/logging/LoggingContextManager.java
create mode 100644 common/src/at/gv/egovernment/moa/util/Base64Utils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/BoolUtils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/CollectionUtils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/Constants.java
create mode 100644 common/src/at/gv/egovernment/moa/util/DOMUtils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/DateTimeUtils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/EntityResolverChain.java
create mode 100644 common/src/at/gv/egovernment/moa/util/FileUtils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/KeyStoreUtils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/MOADefaultHandler.java
create mode 100644 common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java
create mode 100644 common/src/at/gv/egovernment/moa/util/MOAErrorHandler.java
create mode 100644 common/src/at/gv/egovernment/moa/util/MOATimer.java
create mode 100644 common/src/at/gv/egovernment/moa/util/MessageProvider.java
create mode 100644 common/src/at/gv/egovernment/moa/util/Messages.java
create mode 100644 common/src/at/gv/egovernment/moa/util/NodeIteratorAdapter.java
create mode 100644 common/src/at/gv/egovernment/moa/util/NodeListAdapter.java
create mode 100644 common/src/at/gv/egovernment/moa/util/ResourceBundleChain.java
create mode 100644 common/src/at/gv/egovernment/moa/util/SSLUtils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/StreamEntityResolver.java
create mode 100644 common/src/at/gv/egovernment/moa/util/StreamUtils.java
create mode 100644 common/src/at/gv/egovernment/moa/util/URLDecoder.java
create mode 100644 common/src/at/gv/egovernment/moa/util/URLEncoder.java
create mode 100644 common/src/at/gv/egovernment/moa/util/XPathException.java
create mode 100644 common/src/at/gv/egovernment/moa/util/XPathUtils.java
create mode 100644 common/src/test/at/gv/egovernment/moa/AllTests.java
create mode 100644 common/src/test/at/gv/egovernment/moa/MOATestCase.java
create mode 100644 common/src/test/at/gv/egovernment/moa/util/DOMUtilsTest.java
create mode 100644 common/src/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java
create mode 100644 common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java
create mode 100644 common/src/test/at/gv/egovernment/moa/util/SSLUtilsTest.java
create mode 100644 common/src/test/at/gv/egovernment/moa/util/URLDecoderTest.java
create mode 100644 common/src/test/at/gv/egovernment/moa/util/URLEncoderTest.java
create mode 100644 common/src/test/at/gv/egovernment/moa/util/XMLGrammarBuilderTest.java
create mode 100644 common/src/test/at/gv/egovernment/moa/util/XPathUtilsTest.java
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/logging/LogMsg.java b/common/src/at/gv/egovernment/moa/logging/LogMsg.java
new file mode 100644
index 000000000..4d04fc72d
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/logging/LogMsg.java
@@ -0,0 +1,43 @@
+package at.gv.egovernment.moa.logging;
+
+/**
+ * A unified message type to log messages from inside the MOA subsystem.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class LogMsg {
+ /** The message to log. */
+ private Object message;
+
+ /**
+ * Create a LogMsg object.
+ *
+ * @param message The actual message to log. May be null.
+ */
+ public LogMsg(Object message) {
+ this.message = message;
+ }
+
+ /**
+ * Convert this log message to a String.
+ *
+ * @return The String representation of this log message.
+ */
+ public String toString() {
+ StringBuffer msg = new StringBuffer();
+ LoggingContext ctx =
+ LoggingContextManager.getInstance().getLoggingContext();
+ String tid = ctx != null ? ctx.getTransactionID() : null;
+ String nodeId = ctx != null ? ctx.getNodeID() : null;
+
+ msg.append("TID=");
+ msg.append(tid != null ? tid : "");
+ msg.append(" NID=");
+ msg.append(nodeId != null ? nodeId : "");
+ msg.append(" MSG=");
+ msg.append(message != null ? message.toString() : "");
+
+ return msg.toString();
+ }
+}
diff --git a/common/src/at/gv/egovernment/moa/logging/Logger.java b/common/src/at/gv/egovernment/moa/logging/Logger.java
new file mode 100644
index 000000000..eb7aa5634
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/logging/Logger.java
@@ -0,0 +1,175 @@
+package at.gv.egovernment.moa.logging;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A utility class acting as a facade to the logging subsystem.
+ *
+ * Configure the logging defaultHierarchy that the Logger uses by
+ * calling setHierarchy once before calling any of the logging
+ * output functions.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class Logger {
+
+ /** The default logging hierarchy. */
+ private static String defaultHierarchy = "";
+
+ /**
+ * Get the Log object for the default hierarchy.
+ *
+ * @return The Log object to write log messages to.
+ */
+ private static Log getLog() {
+ return LogFactory.getLog(defaultHierarchy);
+ }
+
+ /**
+ * Get the Log object for a given hierarchy.
+ *
+ * @param hierarchy The logging hierarchy for which to return the logger.
+ * @return The Log object to write log messages to.
+ */
+ private static Log getLog(String hierarchy) {
+ return LogFactory.getLog(hierarchy);
+ }
+
+ /**
+ * Set the default hierarchy to which the Logger should send its
+ * logging output.
+ * @param hierarchy The logging defaultHierarchy.
+ */
+ public static void setHierarchy(String hierarchy) {
+ defaultHierarchy = hierarchy;
+ }
+
+ /**
+ * Test, if the trace log level is enabled.
+ *
+ * @return boolean true, if tracing output is enabled
+ * false otherwise.
+ */
+ public static boolean isTraceEnabled() {
+ return getLog().isTraceEnabled();
+ }
+
+ /**
+ * Test, if the trace log level is enabled for a given hierarchy.
+ *
+ * @param hierarchy requested log hierarchy
+ * @return boolean true, if tracing output is enabled
+ * false otherwise.
+ */
+ public static boolean isTraceEnabled(String hierarchy) {
+ return getLog(hierarchy).isTraceEnabled();
+ }
+
+ /**
+ * Trace a message.
+ *
+ * @param message The message to trace.
+ */
+ public static void trace(Object message) {
+ getLog().trace(message);
+ }
+
+ /**
+ * Test, if the debug log level is enabled.
+ *
+ * @return boolean true, if debug output is enabled
+ * false otherwise.
+ */
+ public static boolean isDebugEnabled() {
+ return getLog().isDebugEnabled();
+ }
+
+ /**
+ * Test, if the debug log level is enabled for a given hierarchy.
+ *
+ * @param hierarchy requested log hierarchy
+ * @return boolean true, if debug output is enabled
+ * false otherwise.
+ */
+ public static boolean isDebugEnabled(String hierarchy) {
+ return getLog(hierarchy).isDebugEnabled();
+ }
+
+ /**
+ * Log a debug message.
+ *
+ * @param message The message to log.
+ */
+ public static void debug(Object message) {
+ getLog().debug(message);
+ }
+
+ /**
+ * Log an info message.
+ *
+ * @param message The message to log.
+ */
+ public static void info(Object message) {
+ getLog().info(message);
+ }
+
+ /**
+ * Log a warning message.
+ *
+ * @param message The message to log.
+ */
+ public static void warn(Object message) {
+ getLog().warn(message);
+ }
+
+ /**
+ * Log a warning message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the warning.
+ */
+ public static void warn(Object message, Throwable t) {
+ getLog().warn(message, t);
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param message The message to log.
+ */
+ public static void error(Object message) {
+ getLog().error(message);
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the error.
+ */
+ public static void error(Object message, Throwable t) {
+ getLog().error(message, t);
+ }
+
+ /**
+ * Log a fatal error message.
+ *
+ * @param message The message to log.
+ */
+ public static void fatal(Object message) {
+ getLog().fatal(message);
+ }
+
+ /**
+ * Log a fatal error message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the error.
+ */
+ public static void fatal(Object message, Throwable t) {
+ getLog().fatal(message, t);
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/logging/LoggingContext.java b/common/src/at/gv/egovernment/moa/logging/LoggingContext.java
new file mode 100644
index 000000000..42d8db06e
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/logging/LoggingContext.java
@@ -0,0 +1,46 @@
+package at.gv.egovernment.moa.logging;
+
+/**
+ * Encapsulates contextual information (i.e. per request information) for
+ * logging purposes.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class LoggingContext {
+ /** The name of the node ID system property. */
+ public static final String NODE_ID_PROPERTY = "moa.node-id";
+
+ /** The current transaction ID. */
+ private String transactionID;
+ /** The node ID. */
+ private String nodeID;
+
+ /**
+ * Create a new LoggingContext.
+ *
+ * @param transactionID The transaction ID. May be null.
+ */
+ public LoggingContext(String transactionID) {
+ this.transactionID = transactionID;
+ this.nodeID = System.getProperty(NODE_ID_PROPERTY);
+ }
+
+ /**
+ * Return the transaction ID.
+ *
+ * @return The transaction ID.
+ */
+ public String getTransactionID() {
+ return transactionID;
+ }
+
+ /**
+ * Return the node ID.
+ *
+ * @return The node ID.
+ */
+ public String getNodeID() {
+ return nodeID;
+ }
+}
diff --git a/common/src/at/gv/egovernment/moa/logging/LoggingContextManager.java b/common/src/at/gv/egovernment/moa/logging/LoggingContextManager.java
new file mode 100644
index 000000000..2bbe6caa1
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/logging/LoggingContextManager.java
@@ -0,0 +1,56 @@
+package at.gv.egovernment.moa.logging;
+
+/**
+ * Provides each thread with a single instance of LoggingContext.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class LoggingContextManager {
+ /** The single instance of this class. */
+ private static LoggingContextManager instance = null;
+
+ /** The LoggingContext for each thread. */
+ private ThreadLocal context;
+
+ /**
+ * Get the single instance of the LoggingContextManager class.
+ *
+ * @return LoggingContextManager The single instance.
+ */
+ public static synchronized LoggingContextManager getInstance() {
+ if (instance == null) {
+ instance = new LoggingContextManager();
+ }
+ return instance;
+ }
+
+ /**
+ * Creates a new LoggingContextManager.
+ *
+ * Protected to disallow direct instantiation.
+ */
+ protected LoggingContextManager() {
+ context = new ThreadLocal();
+ }
+
+ /**
+ * Set the LoggingContext context for the current thread.
+ *
+ * @param ctx The LoggingContext for the current thread.
+ */
+ public void setLoggingContext(LoggingContext ctx) {
+ context.set(ctx);
+ }
+
+ /**
+ * Return the LoggingContext for the current thread.
+ *
+ * @return LoggingContext The LoggingContext for the current
+ * thread, or null if none has been set.
+ */
+ public LoggingContext getLoggingContext() {
+ return (LoggingContext) context.get();
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/Base64Utils.java b/common/src/at/gv/egovernment/moa/util/Base64Utils.java
new file mode 100644
index 000000000..ba2c4fb0e
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/Base64Utils.java
@@ -0,0 +1,109 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import iaik.utils.Base64InputStream;
+import iaik.utils.Base64OutputStream;
+
+/**
+ * Utitility functions for encoding/decoding Base64 strings.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class Base64Utils {
+
+ /**
+ * Read the bytes encoded in a Base64 encoded String.
+ *
+ * @param base64String The String containing the Base64 encoded
+ * bytes.
+ * @param ignoreInvalidChars Whether to ignore invalid Base64 characters.
+ * @return byte[] The raw bytes contained in the base64String.
+ * @throws IOException Failed to read the Base64 data.
+ */
+ public static byte[] decode(String base64String, boolean ignoreInvalidChars)
+ throws IOException {
+
+ Base64InputStream in =
+ new Base64InputStream(
+ new ByteArrayInputStream(base64String.getBytes("UTF-8")),
+ ignoreInvalidChars);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ byte[] bytes = new byte[256];
+ int bytesRead;
+
+ while ((bytesRead = in.read(bytes)) > 0) {
+ out.write(bytes, 0, bytesRead);
+ }
+
+ return out.toByteArray();
+ }
+
+ /**
+ * Read the bytes encoded in a Base64 encoded String and provide
+ * them via an InputStream.
+ *
+ * @param base64String The String containing the Base64 encoded
+ * bytes.
+ * @param ignoreInvalidChars Whether to ignore invalid Base64 characters.
+ * @return The InputStream from which the binary content of the
+ * base64String can be read.
+ */
+ public static InputStream decodeToStream(
+ String base64String,
+ boolean ignoreInvalidChars) {
+
+ try {
+ ByteArrayInputStream bin =
+ new ByteArrayInputStream(base64String.getBytes("UTF-8"));
+ Base64InputStream in = new Base64InputStream(bin, ignoreInvalidChars);
+
+ return in;
+ } catch (UnsupportedEncodingException e) {
+ // cannot occur, since UTF-8 is required to be supported by every JRE
+ return null;
+ }
+ }
+
+ /**
+ * Convert a byte array to a Base64 encoded String.
+ *
+ * @param bytes The bytes to encode.
+ * @return String The Base64 encoded representation of the bytes.
+ * @throws IOException Failed to write the bytes as Base64 data.
+ */
+ public static String encode(byte[] bytes) throws IOException {
+ return encode(new ByteArrayInputStream(bytes));
+ }
+
+ /**
+ * Convert the data contained in the given stream to a Base64 encoded
+ * String.
+ *
+ * @param inputStream The stream containing the data to encode.
+ * @return The Base64 encoded data of inputStream, as a
+ * String.
+ * @throws IOException Failed to convert the data in the stream.
+ */
+ public static String encode(InputStream inputStream) throws IOException {
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ Base64OutputStream base64Stream = new Base64OutputStream(byteStream);
+ byte[] bytes = new byte[256];
+ int bytesRead;
+
+ while ((bytesRead = inputStream.read(bytes)) > 0) {
+ base64Stream.write(bytes, 0, bytesRead);
+ }
+ base64Stream.flush();
+ base64Stream.close();
+ inputStream.close();
+
+ return byteStream.toString("UTF-8");
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/BoolUtils.java b/common/src/at/gv/egovernment/moa/util/BoolUtils.java
new file mode 100644
index 000000000..fcd39b4dd
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/BoolUtils.java
@@ -0,0 +1,24 @@
+package at.gv.egovernment.moa.util;
+
+/**
+ * Utility class for parsing XML schema boolean values.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class BoolUtils {
+
+ /**
+ * Return the boolean value of an xsd:boolean type of DOM
+ * element/attribute.
+ *
+ * @param boolStr The value of the xsd:boolean element/attribute.
+ * @return true, if boolStr equals
+ * "true" or "1;". Otherwise,
+ * false is returned.
+ */
+ public static boolean valueOf(String boolStr) {
+ return "true".equals(boolStr) || "1".equals(boolStr);
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/CollectionUtils.java b/common/src/at/gv/egovernment/moa/util/CollectionUtils.java
new file mode 100644
index 000000000..5329dcbd2
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/CollectionUtils.java
@@ -0,0 +1,36 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Various utility methods for dealing with java.util.Collection
+ * classes.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class CollectionUtils {
+
+ /**
+ * Convert a List of Number objects to an
+ * int array.
+ *
+ * @param nums The List containing the numbers whose integer
+ * value to put into the result.
+ * @return The int values of the Numbers contained
+ * in nums.
+ */
+ public static int[] toIntArray(List nums) {
+ int[] result = new int[nums.size()];
+ Iterator iter;
+ int i;
+
+ for (i = 0, iter = nums.iterator(); iter.hasNext(); i++) {
+ Number num = (Number) iter.next();
+ result[i] = num.intValue();
+ }
+
+ return result;
+ }
+}
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
new file mode 100644
index 000000000..681bed55b
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -0,0 +1,218 @@
+package at.gv.egovernment.moa.util;
+
+/**
+ * Contains various constants used throughout the system.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public interface Constants {
+ /** Root location of the schema files. */
+ public static final String SCHEMA_ROOT = "/resources/schemas/";
+
+ /** URI of the MOA XML namespace. */
+ public static final String MOA_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moa/20020822#";
+
+ /** Prefix used for the MOA XML namespace */
+ public static final String MOA_PREFIX = "moa";
+
+ /** Local location of the MOA XML schema definition. */
+ public static final String MOA_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-SPSS-1.1.xsd";
+
+ /** URI of the MOA configuration XML namespace. */
+ public static final String MOA_CONFIG_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moaconfig/20021122#";
+
+ /** URI of the MOA ID configuration XML namespace. */
+ public static final String MOA_ID_CONFIG_NS_URI =
+ "http://www.buergerkarte.at/namespaces/moaconfig#";
+
+ /** Prefix used for the MOA configuration XML namespace */
+ public static final String MOA_CONFIG_PREFIX = "conf";
+
+ /** Prefix used for the MOA configuration XML namespace */
+ public static final String MOA_ID_CONFIG_PREFIX = "confID";
+
+ /** Local location of the MOA configuration XML schema definition. */
+ public static final String MOA_CONFIG_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-SPSS-Configuration-1.0.xsd";
+
+ /** Local location of the MOA ID configuration XML schema definition. */
+ public static final String MOA_ID_CONFIG_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-ID-Configuration-1.1.xsd";
+
+ /** URI of the Security Layer 1.0 namespace. */
+ public static final String SL10_NS_URI =
+ "http://www.buergerkarte.at/namespaces/securitylayer/20020225#";
+
+ /** Prefix used for the Security Layer 1.0 XML namespace */
+ public static final String SL10_PREFIX = "sl10";
+
+ /** Local location of the Security Layer 1.0 XML schema definition */
+ public static final String SL10_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "Core.20020225.xsd";
+
+ /** URI of the Security Layer 1.1 XML namespace */
+ public static final String SL11_NS_URI =
+ "http://www.buergerkarte.at/namespaces/securitylayer/20020831#";
+
+ /** Prefix used for the Security Layer 1.1 XML namespace */
+ public static final String SL11_PREFIX = "sl11";
+
+ /** Local location of the Security Layer 1.1 XML schema definition */
+ public static final String SL11_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "Core.20020831.xsd";
+
+ /** URI of the ECDSA XML namespace */
+ public static final String ECDSA_NS_URI =
+ "http://www.buergerkarte.at/namespaces/ecdsa/200206030#";
+
+ /** Prefix used for ECDSA namespace */
+ public static final String ECDSA_PREFIX = "ecdsa";
+
+ /** Local location of ECDSA XML schema definition */
+ public static final String ECDSA_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "ECDSAKeyValue.xsd";
+
+ /** URI of the PersonData XML namespace. */
+ public static final String PD_NS_URI =
+ "http://reference.e-government.gv.at/namespace/persondata/20020228#";
+
+ /** Prefix used for the PersonData XML namespace */
+ public static final String PD_PREFIX = "pr";
+
+ /** Local location of the PersonData XML schema definition */
+ public static final String PD_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "PersonData.xsd";
+
+ /** URI of the SAML namespace. */
+ public static final String SAML_NS_URI =
+ "urn:oasis:names:tc:SAML:1.0:assertion";
+
+ /** Prefix used for the SAML XML namespace */
+ public static final String SAML_PREFIX = "saml";
+
+ /** Local location of the SAML XML schema definition. */
+ public static final String SAML_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "cs-sstc-schema-assertion-01.xsd";
+
+ /** URI of the SAML request-response protocol namespace. */
+ public static final String SAMLP_NS_URI =
+ "urn:oasis:names:tc:SAML:1.0:protocol";
+
+ /** Prefix used for the SAML request-response protocol namespace */
+ public static final String SAMLP_PREFIX = "samlp";
+
+ /** Local location of the SAML request-response protocol schema definition. */
+ public static final String SAMLP_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "cs-sstc-schema-protocol-01.xsd";
+
+ /** URI of the XML namespace. */
+ public static final String XML_NS_URI =
+ "http://www.w3.org/XML/1998/namespace";
+
+ /** Prefix used for the XML namespace */
+ public static final String XML_PREFIX = "xml";
+
+ /** Local location of the XML schema definition. */
+ public static final String XML_SCHEMA_LOCATION = SCHEMA_ROOT + "xml.xsd";
+
+ /** URI of the XMLNS namespace */
+ public static final String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/";
+
+ /** Prefix used for the XSI namespace */
+ public static final String XSI_PREFIX = "xsi";
+
+ /** Local location of the XSI schema definition. */
+ public static final String XSI_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "XMLSchema-instance.xsd";
+
+ /** URI of the XSI XMLNS namespace */
+ public static final String XSI_NS_URI =
+ "http://www.w3.org/2001/XMLSchema-instance";
+
+ /** URI of the XSLT XML namespace */
+ public static final String XSLT_NS_URI =
+ "http://www.w3.org/1999/XSL/Transform";
+
+ /** Prefix used for the XSLT XML namespace */
+ public static final String XSLT_PREFIX = "xsl";
+
+ /** URI of the XMLDSig XML namespace. */
+ public static final String DSIG_NS_URI = "http://www.w3.org/2000/09/xmldsig#";
+
+ /** Prefix used for the XMLDSig XML namespace */
+ public static final String DSIG_PREFIX = "dsig";
+
+ /** Local location of the XMLDSig XML schema. */
+ public static final String DSIG_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "xmldsig-core-schema.xsd";
+
+ /** URI of the XMLDSig XPath Filter XML namespace. */
+ public static final String DSIG_FILTER2_NS_URI =
+ "http://www.w3.org/2002/06/xmldsig-filter2";
+
+ /** Prefix used for the XMLDSig XPath Filter XML namespace */
+ public static final String DSIG_FILTER2_PREFIX = "dsig-filter2";
+
+ /** Local location of the XMLDSig XPath Filter XML schema definition. */
+ public static final String DSIG_FILTER2_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "xmldsig-filter2.xsd";
+
+ /** URI of the Exclusive Canonicalization XML namespace */
+ public static final String DSIG_EC_NS_URI =
+ "http://www.w3.org/2001/10/xml-exc-c14n#";
+
+ /** Prefix used for the Exclusive Canonicalization XML namespace */
+ public static final String DSIG_EC_PREFIX = "ec";
+
+ /** Local location of the Exclusive Canonicalizaion XML schema definition */
+ public static final String DSIG_EC_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "exclusive-canonicalization.xsd";
+
+ /**
+ * Contains all namespaces and local schema locations for XML schema
+ * definitions relevant for MOA. For use in validating XML parsers.
+ */
+ public static final String ALL_SCHEMA_LOCATIONS =
+ (MOA_NS_URI + " " + MOA_SCHEMA_LOCATION + " ")
+ + (MOA_CONFIG_NS_URI + " " + MOA_CONFIG_SCHEMA_LOCATION + " ")
+ + (MOA_ID_CONFIG_NS_URI + " " + MOA_ID_CONFIG_SCHEMA_LOCATION + " ")
+ + (SL10_NS_URI + " " + SL10_SCHEMA_LOCATION + " ")
+ + (SL11_NS_URI + " " + SL11_SCHEMA_LOCATION + " ")
+ + (ECDSA_NS_URI + " " + ECDSA_SCHEMA_LOCATION + " ")
+ + (PD_NS_URI + " " + PD_SCHEMA_LOCATION + " ")
+ + (SAML_NS_URI + " " + SAML_SCHEMA_LOCATION + " ")
+ + (SAMLP_NS_URI + " " + SAMLP_SCHEMA_LOCATION + " ")
+ + (XML_NS_URI + " " + XML_SCHEMA_LOCATION + " ")
+ + (XSI_NS_URI + " " + XSI_SCHEMA_LOCATION + " ")
+ + (DSIG_NS_URI + " " + DSIG_SCHEMA_LOCATION + " ")
+ + (DSIG_FILTER2_NS_URI + " " + DSIG_FILTER2_SCHEMA_LOCATION + " ")
+ + (DSIG_EC_NS_URI + " " + DSIG_EC_SCHEMA_LOCATION);
+
+ /** Security Layer manifest type URI. */
+ public static final String SL_MANIFEST_TYPE_URI =
+ "http://www.buergerkarte.at/specifications/Security-Layer/20020225#SignatureManifest";
+
+ /** URI of the SHA1 digest algorithm */
+ public static final String SHA1_URI =
+ "http://www.w3.org/2000/09/xmldsig#sha1";
+
+ /** URI of the Canonical XML algorithm */
+ public static final String C14N_URI =
+ "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
+
+ /** URI of the Canoncial XML with comments algorithm */
+ public static final String C14N_WITH_COMMENTS_URI =
+ "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
+
+ /** URI of the Exclusive Canonical XML algorithm */
+ public static final String EXC_C14N_URI =
+ "http://www.w3.org/2001/10/xml-exc-c14n#";
+
+ /** URI of the Exclusive Canonical XML with commments algorithm */
+ public static final String EXC_C14N_WITH_COMMENTS_URI =
+ "http://www.w3.org/2001/10/xml-exc-c14n#WithComments";
+}
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
new file mode 100644
index 000000000..6da99037e
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -0,0 +1,806 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.xerces.parsers.DOMParser;
+import org.apache.xerces.parsers.SAXParser;
+import org.apache.xerces.parsers.XMLGrammarPreparser;
+import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.util.XMLGrammarPoolImpl;
+import org.apache.xerces.xni.grammars.XMLGrammarDescription;
+import org.apache.xerces.xni.grammars.XMLGrammarPool;
+import org.apache.xerces.xni.parser.XMLInputSource;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Various utility functions for handling XML DOM trees.
+ *
+ * The parsing methods in this class make use of some features internal to the
+ * Xerces DOM parser, mainly for performance reasons. As soon as JAXP
+ * (currently at version 1.2) is better at schema handling, it should be used as
+ * the parser interface.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class DOMUtils {
+
+ /** Feature URI for namespace aware parsing. */
+ private static final String NAMESPACES_FEATURE =
+ "http://xml.org/sax/features/namespaces";
+ /** Feature URI for validating parsing. */
+ private static final String VALIDATION_FEATURE =
+ "http://xml.org/sax/features/validation";
+ /** Feature URI for schema validating parsing. */
+ private static final String SCHEMA_VALIDATION_FEATURE =
+ "http://apache.org/xml/features/validation/schema";
+ /** Feature URI for normalization of element/attribute values. */
+ private static final String NORMALIZED_VALUE_FEATURE =
+ "http://apache.org/xml/features/validation/schema/normalized-value";
+ /** Feature URI for parsing ignorable whitespace. */
+ private static final String INCLUDE_IGNORABLE_WHITESPACE_FEATURE =
+ "http://apache.org/xml/features/dom/include-ignorable-whitespace";
+ /** Feature URI for creating EntityReference nodes in the DOM tree. */
+ private static final String CREATE_ENTITY_REF_NODES_FEATURE =
+ "http://apache.org/xml/features/dom/create-entity-ref-nodes";
+ /** Property URI for providing external schema locations. */
+ private static final String EXTERNAL_SCHEMA_LOCATION_PROPERTY =
+ "http://apache.org/xml/properties/schema/external-schemaLocation";
+ /** Property URI for providing the external schema location for elements
+ * without a namespace. */
+ private static final String EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY =
+ "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
+ /** Property URI for the Xerces grammar pool. */
+ private static final String GRAMMAR_POOL =
+ org.apache.xerces.impl.Constants.XERCES_PROPERTY_PREFIX
+ + org.apache.xerces.impl.Constants.XMLGRAMMAR_POOL_PROPERTY;
+ /** A prime number for initializing the symbol table. */
+ private static final int BIG_PRIME = 2039;
+ /** Symbol table for the grammar pool. */
+ private static SymbolTable symbolTable = new SymbolTable(BIG_PRIME);
+ /** Xerces schema grammar pool. */
+ private static XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
+
+ /**
+ * Preparse a schema and add it to the schema pool.
+ *
+ * @param inputStream An InputStream providing the contents of
+ * the schema.
+ * @param systemId The systemId to use for the schema.
+ * @throws IOException An error occurred reading the schema.
+ */
+ public static void addSchemaToPool(InputStream inputStream, String systemId)
+ throws IOException {
+ XMLGrammarPreparser preparser;
+
+ // unlock the pool so that we can add another grammar
+ grammarPool.unlockPool();
+
+ // prepare the preparser
+ preparser = new XMLGrammarPreparser(symbolTable);
+ preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
+ preparser.setProperty(GRAMMAR_POOL, grammarPool);
+ preparser.setFeature(NAMESPACES_FEATURE, true);
+ preparser.setFeature(VALIDATION_FEATURE, true);
+
+ // add the grammar to the pool
+ preparser.preparseGrammar(
+ XMLGrammarDescription.XML_SCHEMA,
+ new XMLInputSource(null, systemId, null, inputStream, null));
+
+ // lock the pool again so that schemas are not added automatically
+ grammarPool.lockPool();
+ }
+
+ /**
+ * Parse an XML document from an InputStream.
+ *
+ * @param inputStream The InputStream containing the XML
+ * document.
+ * @param validating If true, parse validating.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @param entityResolver An EntityResolver to resolve external
+ * entities (schemas and DTDs). If null, it will not be set.
+ * @param errorHandler An ErrorHandler to decide what to do
+ * with parsing errors. If null, it will not be set.
+ * @return The parsed XML document as a DOM tree.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Document parseDocument(
+ InputStream inputStream,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation,
+ EntityResolver entityResolver,
+ ErrorHandler errorHandler)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ DOMParser parser;
+
+ // create the DOM parser
+ if (symbolTable != null) {
+ parser = new DOMParser(symbolTable, grammarPool);
+ } else {
+ parser = new DOMParser();
+ }
+
+ // set parser features and properties
+ parser.setFeature(NAMESPACES_FEATURE, true);
+ parser.setFeature(VALIDATION_FEATURE, validating);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE, validating);
+ parser.setFeature(NORMALIZED_VALUE_FEATURE, false);
+ parser.setFeature(INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true);
+ parser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE, false);
+
+ if (validating) {
+ if (externalSchemaLocations != null) {
+ parser.setProperty(
+ EXTERNAL_SCHEMA_LOCATION_PROPERTY,
+ externalSchemaLocations);
+ }
+ if (externalNoNamespaceSchemaLocation != null) {
+ parser.setProperty(
+ EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
+ externalNoNamespaceSchemaLocation);
+ }
+ }
+
+ // set entity resolver and error handler
+ if (entityResolver != null) {
+ parser.setEntityResolver(entityResolver);
+ }
+ if (errorHandler != null) {
+ parser.setErrorHandler(errorHandler);
+ }
+
+ // parse the document and return it
+ parser.parse(new InputSource(inputStream));
+
+ return parser.getDocument();
+ }
+
+ /**
+ * Parse an XML document from an InputStream.
+ *
+ * It uses a MOAEntityResolver as the EntityResolver
+ * and a MOAErrorHandler as the ErrorHandler.
+ *
+ * @param inputStream The InputStream containing the XML
+ * document.
+ * @param validating If true, parse validating.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @return The parsed XML document as a DOM tree.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Document parseDocument(
+ InputStream inputStream,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ return parseDocument(
+ inputStream,
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation,
+ new MOAEntityResolver(),
+ new MOAErrorHandler());
+ }
+
+ /**
+ * Parse an XML document from a String.
+ *
+ * It uses a MOAEntityResolver as the EntityResolver
+ * and a MOAErrorHandler as the ErrorHandler.
+ *
+ * @param xmlString The String containing the XML document.
+ * @param encoding The encoding of the XML document.
+ * @param validating If true, parse validating.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @return The parsed XML document as a DOM tree.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Document parseDocument(
+ String xmlString,
+ String encoding,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ InputStream in = new ByteArrayInputStream(xmlString.getBytes(encoding));
+ return parseDocument(
+ in,
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation);
+ }
+
+ /**
+ * Parse an UTF-8 encoded XML document from a String.
+ *
+ * @param xmlString The String containing the XML document.
+ * @param validating If true, parse validating.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @return The parsed XML document as a DOM tree.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Document parseDocument(
+ String xmlString,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ return parseDocument(
+ xmlString,
+ "UTF-8",
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation);
+ }
+
+ /**
+ * A convenience method to parse an XML document validating.
+ *
+ * @param inputStream The InputStream containing the XML
+ * document.
+ * @return The root element of the parsed XML document.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Element parseXmlValidating(InputStream inputStream)
+ throws ParserConfigurationException, SAXException, IOException {
+ return DOMUtils
+ .parseDocument(inputStream, true, Constants.ALL_SCHEMA_LOCATIONS, null)
+ .getDocumentElement();
+ }
+
+ /**
+ * Schema validate a given DOM element.
+ *
+ * @param element The element to validate.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @return true, if the element validates against
+ * the schemas declared in it.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document from its
+ * serialized representation.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * @throws TransformerException An error occurred serializing the element.
+ */
+ public static boolean validateElement(
+ Element element,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws
+ ParserConfigurationException,
+ IOException,
+ SAXException,
+ TransformerException {
+
+ byte[] docBytes;
+ SAXParser parser;
+
+ // create the SAX parser
+ if (symbolTable != null) {
+ parser = new SAXParser(symbolTable, grammarPool);
+ } else {
+ parser = new SAXParser();
+ }
+
+ // serialize the document
+ docBytes = serializeNode(element, "UTF-8");
+
+ // set up parser features and attributes
+ parser.setFeature(NAMESPACES_FEATURE, true);
+ parser.setFeature(VALIDATION_FEATURE, true);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE, true);
+ if (externalSchemaLocations != null) {
+ parser.setProperty(
+ EXTERNAL_SCHEMA_LOCATION_PROPERTY,
+ externalSchemaLocations);
+ }
+ if (externalNoNamespaceSchemaLocation != null) {
+ parser.setProperty(
+ EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
+ "externalNoNamespaceSchemaLocation");
+ }
+
+ // set up entity resolver and error handler
+ parser.setEntityResolver(new MOAEntityResolver());
+ parser.setErrorHandler(new MOAErrorHandler());
+
+ // parse validating
+ parser.parse(new InputSource(new ByteArrayInputStream(docBytes)));
+ return true;
+ }
+
+ /**
+ * Serialize the given DOM node.
+ *
+ * The node will be serialized using the UTF-8 encoding.
+ *
+ * @param node The node to serialize.
+ * @return String The String representation of the given DOM
+ * node.
+ * @throws TransformerException An error occurred transforming the
+ * node to a String.
+ * @throws IOException An IO error occurred writing the node to a byte array.
+ */
+ public static String serializeNode(Node node)
+ throws TransformerException, IOException {
+ return new String(serializeNode(node, "UTF-8"), "UTF-8");
+ }
+
+ /**
+ * Serialize the given DOM node to a byte array.
+ *
+ * @param node The node to serialize.
+ * @param xmlEncoding The XML encoding to use.
+ * @return The serialized node, as a byte array. Using a compatible encoding
+ * this can easily be converted into a String.
+ * @throws TransformerException An error occurred transforming the node to a
+ * byte array.
+ * @throws IOException An IO error occurred writing the node to a byte array.
+ */
+ public static byte[] serializeNode(Node node, String xmlEncoding)
+ throws TransformerException, IOException {
+
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(16384);
+
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.ENCODING, xmlEncoding);
+ transformer.transform(new DOMSource(node), new StreamResult(bos));
+
+ bos.flush();
+ bos.close();
+
+ return bos.toByteArray();
+ }
+
+ /**
+ * Return the text that a node contains.
+ *
+ * This routine:
+ *
+ *
Ignores comments and processing instructions.
+ *
Concatenates TEXT nodes, CDATA nodes, and the results recursively
+ * processing EntityRef nodes.
+ *
Ignores any element nodes in the sublist. (Other possible options are
+ * to recurse into element sublists or throw an exception.)
+ *
+ *
+ * @param node A DOM node from which to extract text.
+ * @return A String representing its contents.
+ */
+ public static String getText(Node node) {
+ if (!node.hasChildNodes()) {
+ return "";
+ }
+
+ StringBuffer result = new StringBuffer();
+ NodeList list = node.getChildNodes();
+
+ for (int i = 0; i < list.getLength(); i++) {
+ Node subnode = list.item(i);
+ if (subnode.getNodeType() == Node.TEXT_NODE) {
+ result.append(subnode.getNodeValue());
+ } else if (subnode.getNodeType() == Node.CDATA_SECTION_NODE) {
+ result.append(subnode.getNodeValue());
+ } else if (subnode.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
+ // Recurse into the subtree for text
+ // (and ignore comments)
+ result.append(getText(subnode));
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Build the namespace prefix to namespace URL mapping in effect for a given
+ * node.
+ *
+ * @param node The context node for which build the map.
+ * @return The namespace prefix to namespace URL mapping (
+ * a String value to String value mapping).
+ */
+ public static Map getNamespaceDeclarations(Node node) {
+ Map nsDecls = new HashMap();
+ int i;
+
+ do {
+ if (node.hasAttributes()) {
+ NamedNodeMap attrs = node.getAttributes();
+
+ for (i = 0; i < attrs.getLength(); i++) {
+ Attr attr = (Attr) attrs.item(i);
+
+ // add prefix mapping if none exists
+ if ("xmlns".equals(attr.getPrefix())
+ || "xmlns".equals(attr.getName())) {
+
+ String nsPrefix =
+ attr.getPrefix() != null ? attr.getLocalName() : "";
+
+ if (nsDecls.get(nsPrefix) == null) {
+ nsDecls.put(nsPrefix, attr.getValue());
+ }
+ }
+ }
+ }
+ } while ((node = node.getParentNode()) != null);
+
+ return nsDecls;
+ }
+
+ /**
+ * Add all namespace declarations declared in the parent(s) of a given
+ * element and used in the subtree of the given element to the given element.
+ *
+ * @param context The element to which to add the namespaces.
+ */
+ public static void localizeNamespaceDeclarations(Element context) {
+ Node parent = context.getParentNode();
+
+ if (parent != null) {
+ Map namespaces = getNamespaceDeclarations(context.getParentNode());
+ Set nsUris = collectNamespaceURIs(context);
+ Iterator iter;
+
+ for (iter = namespaces.entrySet().iterator(); iter.hasNext();) {
+ Map.Entry e = (Map.Entry) iter.next();
+
+ if (nsUris.contains(e.getValue())) {
+ String prefix = (String) e.getKey();
+ String nsUri = (String) e.getValue();
+ String nsAttrName = "".equals(prefix) ? "xmlns" : "xmlns:" + prefix;
+
+ context.setAttributeNS(Constants.XMLNS_NS_URI, nsAttrName, nsUri);
+ }
+ }
+ }
+ }
+
+ /**
+ * Collect all the namespace URIs used in the subtree of a given element.
+ *
+ * @param context The element that should be searched for namespace URIs.
+ * @return All namespace URIs used in the subtree of context,
+ * including the ones used in context itself.
+ */
+ public static Set collectNamespaceURIs(Element context) {
+ Set result = new HashSet();
+
+ collectNamespaceURIsImpl(context, result);
+ return result;
+ }
+
+ /**
+ * A recursive method to do the work of collectNamespaceURIs.
+ *
+ * @param context The context element to evaluate.
+ * @param result The result, passed as a parameter to avoid unnecessary
+ * instantiations of Set.
+ */
+ private static void collectNamespaceURIsImpl(Element context, Set result) {
+ NamedNodeMap attrs = context.getAttributes();
+ NodeList childNodes = context.getChildNodes();
+ String nsUri;
+ int i;
+
+ // add the namespace of the context element
+ nsUri = context.getNamespaceURI();
+ if (nsUri != null && nsUri != Constants.XMLNS_NS_URI) {
+ result.add(nsUri);
+ }
+
+ // add all namespace URIs from attributes
+ for (i = 0; i < attrs.getLength(); i++) {
+ nsUri = attrs.item(i).getNamespaceURI();
+ if (nsUri != null && nsUri != Constants.XMLNS_NS_URI) {
+ result.add(nsUri);
+ }
+ }
+
+ // add all namespaces from subelements
+ for (i = 0; i < childNodes.getLength(); i++) {
+ Node node = childNodes.item(i);
+
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ collectNamespaceURIsImpl((Element) node, result);
+ }
+ }
+ }
+
+ /**
+ * Check, that each attribute node in the given NodeList has its
+ * parent in the NodeList as well.
+ *
+ * @param nodes The NodeList to check.
+ * @return true, if each attribute node in nodes
+ * has its parent in nodes as well.
+ */
+ public static boolean checkAttributeParentsInNodeList(NodeList nodes) {
+ Set nodeSet = new HashSet();
+ int i;
+
+ // put the nodes into the nodeSet
+ for (i = 0; i < nodes.getLength(); i++) {
+ nodeSet.add(nodes.item(i));
+ }
+
+ // check that each attribute node's parent is in the node list
+ for (i = 0; i < nodes.getLength(); i++) {
+ Node n = nodes.item(i);
+
+ if (n.getNodeType() == Node.ATTRIBUTE_NODE) {
+ Attr attr = (Attr) n;
+ Element owner = attr.getOwnerElement();
+
+ if (owner == null) {
+ if (!isNamespaceDeclaration(attr)) {
+ return false;
+ }
+ }
+
+ if (!nodeSet.contains(owner) && !isNamespaceDeclaration(attr)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Convert an unstructured NodeList into a
+ * DocumentFragment.
+ *
+ * @param nodeList Contains the node list to be converted into a DOM
+ * DocumentFragment.
+ * @return the resulting DocumentFragment. The DocumentFragment will be
+ * backed by a new DOM Document, i.e. all noded of the node list will be
+ * cloned.
+ * @throws ParserConfigurationException An error occurred creating the
+ * DocumentFragment.
+ * @precondition The nodes in the node list appear in document order.
+ * @precondition For each Attr node in the node list, the owning Element is
+ * in the node list as well.
+ * @precondition Each Element or Attr node in the node list is namespace
+ * aware.
+ */
+ public static DocumentFragment nodeList2DocumentFragment(NodeList nodeList)
+ throws ParserConfigurationException {
+
+ DocumentBuilder builder =
+ DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = builder.newDocument();
+ DocumentFragment result = doc.createDocumentFragment();
+
+ if (null == nodeList || nodeList.getLength() == 0) {
+ return result;
+ }
+
+ int currPos = 0;
+ currPos =
+ nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
+
+ while (currPos < nodeList.getLength()) {
+ currPos =
+ nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
+ }
+ return result;
+ }
+
+ /**
+ * Helper method for the nodeList2DocumentFragment.
+ *
+ * @param nodeList The NodeList to convert.
+ * @param currPos The current position in the nodeList.
+ * @param result The resulting DocumentFragment.
+ * @param currOrgElem The current original element.
+ * @param currClonedElem The current cloned element.
+ * @return The current position.
+ */
+ private static int nodeList2DocumentFragment(
+ NodeList nodeList,
+ int currPos,
+ DocumentFragment result,
+ Element currOrgElem,
+ Element currClonedElem) {
+
+ while (currPos < nodeList.getLength()) {
+ Node currentNode = nodeList.item(currPos);
+ switch (currentNode.getNodeType()) {
+ case Node.COMMENT_NODE :
+ case Node.PROCESSING_INSTRUCTION_NODE :
+ case Node.TEXT_NODE :
+ {
+ // Append current node either to resulting DocumentFragment or to
+ // current cloned Element
+ if (null == currClonedElem) {
+ result.appendChild(
+ result.getOwnerDocument().importNode(currentNode, false));
+ } else {
+ // Stop processing if current Node is not a descendant of
+ // current Element
+ if (!isAncestor(currOrgElem, currentNode)) {
+ return --currPos;
+ }
+
+ currClonedElem.appendChild(
+ result.getOwnerDocument().importNode(currentNode, false));
+ }
+ break;
+ }
+
+ case Node.ELEMENT_NODE :
+ {
+ Element nextCurrOrgElem = (Element) currentNode;
+ Element nextCurrClonedElem =
+ result.getOwnerDocument().createElementNS(
+ nextCurrOrgElem.getNamespaceURI(),
+ nextCurrOrgElem.getNodeName());
+
+ // Append current Node either to resulting DocumentFragment or to
+ // current cloned Element
+ if (null == currClonedElem) {
+ result.appendChild(nextCurrClonedElem);
+ currOrgElem = nextCurrOrgElem;
+ currClonedElem = nextCurrClonedElem;
+ } else {
+ // Stop processing if current Node is not a descendant of
+ // current Element
+ if (!isAncestor(currOrgElem, currentNode)) {
+ return --currPos;
+ }
+
+ currClonedElem.appendChild(nextCurrClonedElem);
+ }
+
+ // Process current Node (of type Element) recursively
+ currPos =
+ nodeList2DocumentFragment(
+ nodeList,
+ ++currPos,
+ result,
+ nextCurrOrgElem,
+ nextCurrClonedElem);
+
+ break;
+ }
+
+ case Node.ATTRIBUTE_NODE :
+ {
+ Attr currAttr = (Attr) currentNode;
+
+ // GK 20030411: Hack to overcome problems with IAIK IXSIL
+ if (currAttr.getOwnerElement() == null)
+ break;
+ if (currClonedElem == null)
+ break;
+
+ // currClonedElem must be the owner Element of currAttr if
+ // preconditions are met
+ currClonedElem.setAttributeNS(
+ currAttr.getNamespaceURI(),
+ currAttr.getNodeName(),
+ currAttr.getValue());
+ break;
+ }
+
+ default :
+ {
+ // All other nodes will be ignored
+ }
+ }
+
+ currPos++;
+ }
+
+ return currPos;
+ }
+
+ /**
+ * Check, if the given attribute is a namespace declaration.
+ *
+ * @param attr The attribute to check.
+ * @return true, if the attribute is a namespace declaration,
+ * false otherwise.
+ */
+ private static boolean isNamespaceDeclaration(Attr attr) {
+ return Constants.XMLNS_NS_URI.equals(attr.getNamespaceURI());
+ }
+
+ /**
+ * Check, if a given DOM element is an ancestor of a given node.
+ *
+ * @param candAnc The DOM element to check for being the ancestor.
+ * @param cand The node to check for being the child.
+ * @return true, if candAnc is an (indirect)
+ * ancestor of cand; false otherwise.
+ */
+ public static boolean isAncestor(Element candAnc, Node cand) {
+ Node currPar = cand.getParentNode();
+
+ while (currPar != null) {
+ if (candAnc == currPar)
+ return true;
+ currPar = currPar.getParentNode();
+ }
+ return false;
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/DateTimeUtils.java b/common/src/at/gv/egovernment/moa/util/DateTimeUtils.java
new file mode 100644
index 000000000..58cc04c4c
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/DateTimeUtils.java
@@ -0,0 +1,326 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.StringWriter;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+/**
+ * Utility for parsing and building XML type dateTime,
+ * according to ISO 8601.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ * @see http://www.w3.org/2001/XMLSchema-datatypes"
+ */
+public class DateTimeUtils {
+ /** Error messages. */
+ private static MessageProvider msg = MessageProvider.getInstance();
+
+ /**
+ * Builds a dateTime value from a Calendar value.
+ * @param cal the Calendar value
+ * @return the dateTime value
+ */
+ public static String buildDateTime(Calendar cal) {
+ StringWriter out = new StringWriter();
+ out.write("" + cal.get(Calendar.YEAR));
+ out.write("-");
+ out.write(to2DigitString(cal.get(Calendar.MONTH) + 1));
+ out.write("-");
+ out.write(to2DigitString(cal.get(Calendar.DAY_OF_MONTH)));
+ out.write("T");
+ out.write(to2DigitString(cal.get(Calendar.HOUR_OF_DAY)));
+ out.write(":");
+ out.write(to2DigitString(cal.get(Calendar.MINUTE)));
+ out.write(":");
+ out.write(to2DigitString(cal.get(Calendar.SECOND)));
+ int tzOffsetMilliseconds =
+ cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
+ if (tzOffsetMilliseconds != 0) {
+ int tzOffsetMinutes = tzOffsetMilliseconds / (1000 * 60);
+ int tzOffsetHours = tzOffsetMinutes / 60;
+ tzOffsetMinutes -= tzOffsetHours * 60;
+ if (tzOffsetMilliseconds > 0) {
+ out.write("+");
+ out.write(to2DigitString(tzOffsetHours));
+ out.write(":");
+ out.write(to2DigitString(tzOffsetMinutes));
+ } else {
+ out.write("-");
+ out.write(to2DigitString(-tzOffsetHours));
+ out.write(":");
+ out.write(to2DigitString(-tzOffsetMinutes));
+ }
+ }
+ return out.toString();
+ }
+
+ /**
+ * Converts month, day, hour, minute, or second value
+ * to a 2 digit String.
+ * @param number the month, day, hour, minute, or second value
+ * @return 2 digit String
+ */
+ private static String to2DigitString(int number) {
+ if (number < 10)
+ return "0" + number;
+ else
+ return "" + number;
+ }
+
+ /**
+ * Parse a String containing a date and time instant, given in
+ * ISO 8601 format.
+ *
+ * @param dateTime The String to parse.
+ * @return The Date representation of the contents of
+ * dateTime.
+ * @throws ParseException Parsing the dateTime failed.
+ */
+ public static Date parseDateTime(String dateTime) throws ParseException {
+ GregorianCalendar calendar;
+ long time;
+ int yearSign = 1, year, month, day;
+ int hour, minute, second;
+ double fraction = 0.0;
+ int tzSign = 1, tzHour = 0, tzMinute = 0;
+ int curPos = 0;
+ String fractStr;
+ boolean localTime = false;
+ char c;
+
+ // parse year sign
+ ensureChars(dateTime, curPos, 1);
+ c = dateTime.charAt(curPos);
+ if (c == '+' || c == '-') {
+ yearSign = c == '+' ? 1 : -1;
+ curPos++;
+ }
+
+ // parse year
+ year = parseInt(dateTime, curPos, 4);
+ curPos += 4;
+
+ // parse '-'
+ ensureChar(dateTime, curPos, '-');
+ curPos++;
+
+ // parse month
+ month = parseInt(dateTime, curPos, 2);
+ ensureValue(month, 1, 12, curPos);
+ curPos += 2;
+
+ // parse '-'
+ ensureChar(dateTime, curPos, '-');
+ curPos++;
+
+ // parse day
+ day = parseInt(dateTime, curPos, 2);
+ ensureValue(day, 1, 31, curPos);
+ curPos += 2;
+
+ // parse 'T'
+ ensureChar(dateTime, curPos, 'T');
+ curPos++;
+
+ // parse hour
+ hour = parseInt(dateTime, curPos, 2);
+ ensureValue(hour, 0, 23, curPos);
+ curPos += 2;
+
+ // parse ':'
+ ensureChar(dateTime, curPos, ':');
+ curPos++;
+
+ // parse minute
+ minute = parseInt(dateTime, curPos, 2);
+ ensureValue(minute, 0, 59, curPos);
+ curPos += 2;
+
+ // parse ':'
+ ensureChar(dateTime, curPos, ':');
+ curPos++;
+
+ // parse second
+ second = parseInt(dateTime, curPos, 2);
+ ensureValue(second, 0, 59, curPos);
+ curPos += 2;
+
+ // parse a fraction
+ if (dateTime.length() > curPos && dateTime.charAt(curPos) == '.') {
+ curPos++;
+ ensureDigits(dateTime, curPos, 1);
+ fractStr = "0.";
+ fractStr
+ += dateTime.substring(curPos, curPos + countDigits(dateTime, curPos));
+ fraction = Double.parseDouble(fractStr);
+ curPos += countDigits(dateTime, curPos);
+ }
+
+ // parse a time zone
+ if (dateTime.length() > curPos) {
+ c = dateTime.charAt(curPos);
+ if (c == 'Z') {
+ curPos++;
+ } else if (c == '+' || c == '-') {
+ // parse time zone sign
+ tzSign = c == '+' ? 1 : -1;
+ curPos++;
+
+ // parse time zone hour
+ tzHour = parseInt(dateTime, curPos, 2);
+ ensureValue(tzHour, 0, 14, curPos);
+ curPos += 2;
+
+ // parse ':'
+ ensureChar(dateTime, curPos, ':');
+ curPos++;
+
+ // parse time zone minute
+ tzMinute = parseInt(dateTime, curPos, 2);
+ ensureValue(tzMinute, 0, 59, curPos);
+ curPos += 2;
+ }
+ } else {
+ localTime = true;
+ }
+
+ // if we have characters left, it's an error
+ if (dateTime.length() != curPos) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+
+ // build the Date object
+ year = year * yearSign;
+ try {
+ calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+ calendar.set(year, month - 1, day, hour, minute, second);
+ calendar.set(Calendar.MILLISECOND, 0);
+ time = calendar.getTime().getTime();
+ time += (long) (fraction * 1000.0);
+ time -= tzSign * ((tzHour * 60) + tzMinute) * 60 * 1000;
+ if (localTime) {
+ time -= TimeZone.getDefault().getRawOffset();
+ }
+ return new Date(time);
+ } catch (IllegalArgumentException e) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+
+ }
+
+ /**
+ * Parse an integer value.
+ *
+ * @param str The String containing the digits.
+ * @param curPos The starting position.
+ * @param digits The number of digist making up the integer value.
+ * @return int The integer representation of the digits contained in
+ * str.
+ * @throws ParseException Parsing the integer value failed.
+ */
+ private static int parseInt(String str, int curPos, int digits)
+ throws ParseException {
+
+ ensureDigits(str, curPos, digits);
+ return Integer.parseInt(str.substring(curPos, curPos + digits));
+ }
+
+ /**
+ * Count the number of digits following curPos.
+ *
+ * @param str The String in which to count digits.
+ * @param curPos The starting position.
+ * @return int The number of digits.
+ */
+ private static int countDigits(String str, int curPos) {
+ int i;
+
+ for (i = curPos; i < str.length() && Character.isDigit(str.charAt(i)); i++);
+ return i - curPos;
+ }
+
+ /**
+ * Ensure that a value falls in a given min/max range.
+ *
+ * @param value The value to check.
+ * @param min The minimum allowed value.
+ * @param max The maximum allowed value.
+ * @param curPos To indicate the parsing position in the
+ * ParseException.
+ * @throws ParseException Thrown, if value < min || value >
+ * max
+ */
+ private static void ensureValue(int value, int min, int max, int curPos)
+ throws ParseException {
+
+ if (value < min || value > max) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+ }
+
+ /**
+ * Ensure that the given String has a number of characters left.
+ *
+ * @param str The String to check for its length.
+ * @param curPos The starting position.
+ * @param count The minimum number of characters that str must
+ * contain, starting at from curPos.
+ * @throws ParseException Thrown, if
+ * curPos + count > str.length().
+ */
+ private static void ensureChars(String str, int curPos, int count)
+ throws ParseException {
+ if (curPos + count > str.length()) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+ }
+
+ /**
+ * Ensure that a given String contains a certain character at a
+ * certain position.
+ *
+ * @param str The String in which to look up the character.
+ * @param curPos The position in str that must contain the
+ * character.
+ * @param c The character value that must be contained at position
+ * curPos.
+ * @throws ParseException Thrown, if the characters do not match or
+ * curPos is out of range.
+ */
+ private static void ensureChar(String str, int curPos, char c)
+ throws ParseException {
+
+ ensureChars(str, curPos, 1);
+ if (str.charAt(curPos) != c) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+ }
+
+ /**
+ * Ensure that a given String contains a number of digits,
+ * starting at a given position.
+ *
+ * @param str The String to scan for digits.
+ * @param curPos The starting postion.
+ * @param count The number of digits that must be contained in
+ * str, starting at curPos.
+ * @throws ParseException Thrown, if str is not long enough, or
+ * one of the characters following curPos in str is
+ * not a digit.
+ */
+ private static void ensureDigits(String str, int curPos, int count)
+ throws ParseException {
+
+ ensureChars(str, curPos, count);
+ for (int i = curPos; i < curPos + count; i++) {
+ if (!Character.isDigit(str.charAt(i))) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+ }
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/EntityResolverChain.java b/common/src/at/gv/egovernment/moa/util/EntityResolverChain.java
new file mode 100644
index 000000000..e7008a701
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/EntityResolverChain.java
@@ -0,0 +1,52 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Implementation of the org.xml.sax.EntityResolver,
+ * for use by a org.apache.xerces.parsers.DOMParser.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class EntityResolverChain implements EntityResolver {
+ /** The EntityResolvers in the chain. */
+ private List resolvers = new ArrayList();
+
+ /**
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+
+ Iterator iter;
+
+ for (iter = resolvers.iterator(); iter.hasNext(); ) {
+ EntityResolver resolver = (EntityResolver) iter.next();
+ InputSource is = resolver.resolveEntity(publicId, systemId);
+
+ if (is != null) {
+ return is;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Add an EntityResolver to the chain.
+ *
+ * @param entityResolver The EntityResolver to add.
+ */
+ public void addEntityResolver(EntityResolver entityResolver) {
+ resolvers.add(entityResolver);
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/FileUtils.java b/common/src/at/gv/egovernment/moa/util/FileUtils.java
new file mode 100644
index 000000000..f8941568d
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/FileUtils.java
@@ -0,0 +1,87 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Utility for accessing files on the file system, and for reading from input streams.
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class FileUtils {
+
+ /**
+ * Reads a file, given by URL, into a byte array.
+ * @param urlString file URL
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static byte[] readURL(String urlString) throws IOException {
+ URL url = new URL(urlString);
+ InputStream in = new BufferedInputStream(url.openStream());
+ byte[] content = StreamUtils.readStream(in);
+ in.close();
+ return content;
+ }
+ /**
+ * Reads a file, given by URL, into a String.
+ * @param urlString file URL
+ * @param encoding character encoding
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static String readURL(String urlString, String encoding) throws IOException {
+ byte[] content = readURL(urlString);
+ return new String(content, encoding);
+ }
+ /**
+ * Reads a file, given by filename, into a byte array.
+ * @param filename filename
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static byte[] readFile(String filename) throws IOException {
+ BufferedInputStream in = new BufferedInputStream(new FileInputStream(filename));
+ byte[] content = StreamUtils.readStream(in);
+ in.close();
+ return content;
+ }
+ /**
+ * Reads a file, given by filename, into a String.
+ * @param filename filename
+ * @param encoding character encoding
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static String readFile(String filename, String encoding) throws IOException {
+ byte[] content = readFile(filename);
+ return new String(content, encoding);
+ }
+ /**
+ * Reads a file from a resource.
+ * @param name resource name
+ * @return file content as a byte array
+ * @throws IOException on any exception thrown
+ */
+ public static byte[] readResource(String name) throws IOException {
+ ClassLoader cl = FileUtils.class.getClassLoader();
+ BufferedInputStream in = new BufferedInputStream(cl.getResourceAsStream(name));
+ byte[] content = StreamUtils.readStream(in);
+ in.close();
+ return content;
+ }
+ /**
+ * Reads a file from a resource.
+ * @param name filename
+ * @param encoding character encoding
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static String readResource(String name, String encoding) throws IOException {
+ byte[] content = readResource(name);
+ return new String(content, encoding);
+ }
+}
diff --git a/common/src/at/gv/egovernment/moa/util/KeyStoreUtils.java b/common/src/at/gv/egovernment/moa/util/KeyStoreUtils.java
new file mode 100644
index 000000000..d6a34a7b2
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/KeyStoreUtils.java
@@ -0,0 +1,134 @@
+package at.gv.egovernment.moa.util;
+
+import iaik.x509.X509Certificate;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+
+/**
+ * Utility for creating and loading key stores.
+ *
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class KeyStoreUtils {
+
+ /**
+ * Loads a key store from file.
+ *
+ * @param keystoreType key store type
+ * @param urlString URL of key store
+ * @param password password protecting the key store
+ * @return key store loaded
+ * @throws IOException thrown while reading the key store from file
+ * @throws GeneralSecurityException thrown while creating the key store
+ */
+ public static KeyStore loadKeyStore(
+ String keystoreType,
+ String urlString,
+ String password)
+ throws IOException, GeneralSecurityException {
+
+ URL keystoreURL = new URL(urlString);
+ InputStream in = keystoreURL.openStream();
+ return loadKeyStore(keystoreType, in, password);
+ }
+ /**
+ * Loads a key store from an InputStream, and
+ * closes the InputStream.
+ *
+ * @param keystoreType key store type
+ * @param in input stream
+ * @param password password protecting the key store
+ * @return key store loaded
+ * @throws IOException thrown while reading the key store from the stream
+ * @throws GeneralSecurityException thrown while creating the key store
+ */
+ public static KeyStore loadKeyStore(
+ String keystoreType,
+ InputStream in,
+ String password)
+ throws IOException, GeneralSecurityException {
+
+ char[] chPassword = null;
+ if (password != null)
+ chPassword = password.toCharArray();
+ KeyStore ks = KeyStore.getInstance(keystoreType);
+ ks.load(in, chPassword);
+ in.close();
+ return ks;
+ }
+ /**
+ * Creates a key store from X509 certificate files, aliasing them with
+ * the index in the String[], starting with "0".
+ *
+ * @param keyStoreType key store type
+ * @param certFilenames certificate filenames
+ * @return key store created
+ * @throws IOException thrown while reading the certificates from file
+ * @throws GeneralSecurityException thrown while creating the key store
+ */
+ public static KeyStore createKeyStore(
+ String keyStoreType,
+ String[] certFilenames)
+ throws IOException, GeneralSecurityException {
+
+ KeyStore ks = KeyStore.getInstance(keyStoreType);
+ ks.load(null, null);
+ for (int i = 0; i < certFilenames.length; i++) {
+ Certificate cert = loadCertificate(certFilenames[i]);
+ ks.setCertificateEntry("" + i, cert);
+ }
+ return ks;
+ }
+ /**
+ * Creates a key store from a directory containg X509 certificate files,
+ * aliasing them with the index in the String[], starting with "0".
+ * All the files in the directory are considered to be certificates.
+ *
+ * @param keyStoreType key store type
+ * @param certDirURLString file URL of directory containing certificate filenames
+ * @return key store created
+ * @throws IOException thrown while reading the certificates from file
+ * @throws GeneralSecurityException thrown while creating the key store
+ */
+ public static KeyStore createKeyStoreFromCertificateDirectory(
+ String keyStoreType,
+ String certDirURLString)
+ throws IOException, GeneralSecurityException {
+
+ URL certDirURL = new URL(certDirURLString);
+ String certDirname = certDirURL.getFile();
+ File certDir = new File(certDirname);
+ String[] certFilenames = certDir.list();
+ String separator =
+ (certDirname.endsWith(File.separator) ? "" : File.separator);
+ for (int i = 0; i < certFilenames.length; i++) {
+ certFilenames[i] = certDirname + separator + certFilenames[i];
+ }
+ return createKeyStore(keyStoreType, certFilenames);
+ }
+
+ /**
+ * Loads an X509 certificate from file.
+ * @param certFilename filename
+ * @return the certificate loaded
+ * @throws IOException thrown while reading the certificate from file
+ * @throws GeneralSecurityException thrown while creating the certificate
+ */
+ private static Certificate loadCertificate(String certFilename)
+ throws IOException, GeneralSecurityException {
+
+ FileInputStream in = new FileInputStream(certFilename);
+ Certificate cert = new X509Certificate(in);
+ in.close();
+ return cert;
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/MOADefaultHandler.java b/common/src/at/gv/egovernment/moa/util/MOADefaultHandler.java
new file mode 100644
index 000000000..0474d92cd
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/MOADefaultHandler.java
@@ -0,0 +1,82 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.IOException;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A DefaultHandler that uses a MOAEntityResolver and
+ * a MOAErrorHandler.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class MOADefaultHandler extends DefaultHandler {
+ /** The EntityResolver to use. */
+ private EntityResolver entityResolver;
+ /** The ErrorHandler to use. */
+ private ErrorHandler errorHandler;
+
+ /**
+ * Create a new MOADefaultHandler.
+ */
+ public MOADefaultHandler() {
+ entityResolver = new MOAEntityResolver();
+ errorHandler = new MOAErrorHandler();
+ }
+
+ /**
+ * Create a new MOADefaultHandler.
+ *
+ * @param entityResolver The EntityResolver to use for resolving
+ * external entities.
+ * @param errorHandler The ErrorHandler to use for reporting
+ * parsing errors.
+ */
+ public MOADefaultHandler(
+ EntityResolver entityResolver,
+ ErrorHandler errorHandler) {
+
+ this.entityResolver = entityResolver;
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException {
+ try {
+ return entityResolver.resolveEntity(publicId, systemId);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ /**
+ * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
+ */
+ public void warning(SAXParseException exception) throws SAXException {
+ errorHandler.warning(exception);
+ }
+
+ /**
+ * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
+ */
+ public void error(SAXParseException exception) throws SAXException {
+ errorHandler.error(exception);
+ }
+
+ /**
+ * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
+ */
+ public void fatalError(SAXParseException exception) throws SAXException {
+ errorHandler.fatalError(exception);
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java b/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java
new file mode 100644
index 000000000..9406612e2
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java
@@ -0,0 +1,103 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.InputStream;
+
+import org.apache.xerces.util.URI;
+import org.apache.xerces.util.URI.MalformedURIException;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+import at.gv.egovernment.moa.logging.LogMsg;
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * An EntityResolver that looks up entities stored as
+ * local resources.
+ *
+ *
The following DTDs are mapped to local resources:
+ *
+ *
The XMLSchema.dtd
+ *
The datatypes.dtd
+ *
+ *
+ *
For all other resources, an attempt is made to resolve them as resources,
+ * either absolute or relative to Constants.SCHEMA_ROOT.
+ *
+ * @author Patrick Peck
+ * @author Sven Aigner
+ */
+public class MOAEntityResolver implements EntityResolver {
+
+ /**
+ * Resolve an entity.
+ *
+ * The systemId parameter is used to perform the lookup of the
+ * entity as a resource, either by interpreting the systemId as
+ * an absolute resource path, or by appending the last path component of
+ * systemId to Constants.SCHEMA_ROOT.
+ *
+ * @param publicId The public ID of the resource.
+ * @param systemId The system ID of the resource.
+ * @return An InputSource from which the entity can be read, or
+ * null, if the entity could not be found.
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId) {
+ InputStream stream;
+ int slashPos;
+
+ if (Logger.isDebugEnabled()) {
+ Logger.debug(
+ new LogMsg("resolveEntity: p=" + publicId + " s=" + systemId));
+ }
+
+ if (publicId != null) {
+ // check if we can resolve some standard dtd's
+ if (publicId.equalsIgnoreCase("-//W3C//DTD XMLSchema 200102//EN")) {
+ return new InputSource(
+ getClass().getResourceAsStream(
+ Constants.SCHEMA_ROOT + "XMLSchema.dtd"));
+ } else if (publicId.equalsIgnoreCase("datatypes")) {
+ return new InputSource(
+ getClass().getResourceAsStream(
+ Constants.SCHEMA_ROOT + "datatypes.dtd"));
+ }
+ } else if (systemId != null) {
+ // get the URI path
+ try {
+ URI uri = new URI(systemId);
+ systemId = uri.getPath();
+ if (!"file".equals(uri.getScheme()) || "".equals(systemId.trim())) {
+ return null;
+ }
+ } catch (MalformedURIException e) {
+ return null;
+ }
+
+ // try to get the resource from the full path
+ stream = getClass().getResourceAsStream(systemId);
+ if (stream != null) {
+ InputSource source = new InputSource(stream);
+
+ source.setSystemId(systemId);
+ return source;
+ }
+
+ // try to get the resource from the last path component
+ slashPos = systemId.lastIndexOf('/');
+ if (slashPos >= 0 && systemId.length() > slashPos) {
+ systemId = systemId.substring(slashPos + 1, systemId.length());
+ stream =
+ getClass().getResourceAsStream(Constants.SCHEMA_ROOT + systemId);
+ if (stream != null) {
+ InputSource source = new InputSource(stream);
+
+ source.setSystemId(systemId);
+ return source;
+ }
+ }
+ }
+
+ return null; // nothing found - let the parser handle the entity
+ }
+}
\ No newline at end of file
diff --git a/common/src/at/gv/egovernment/moa/util/MOAErrorHandler.java b/common/src/at/gv/egovernment/moa/util/MOAErrorHandler.java
new file mode 100644
index 000000000..1f7757c8f
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/MOAErrorHandler.java
@@ -0,0 +1,85 @@
+package at.gv.egovernment.moa.util;
+
+import org.apache.xml.utils.DefaultErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import at.gv.egovernment.moa.logging.LogMsg;
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * An ErrorHandler that logs a message and throws a
+ * SAXException upon error and fatal
+ * parsing errors.
+ *
+ * @author Patrick Peck
+ * @author Sven Aigner
+ */
+public class MOAErrorHandler extends DefaultErrorHandler {
+
+ /**
+ * Logs a warning message.
+ *
+ * @see org.xml.sax.ErrorHandler#warning(SAXParseException)
+ */
+ public void warning(SAXParseException exception) throws SAXException {
+ warn("parser.00", messageParams(exception), null);
+ }
+
+ /**
+ * Logs a warning and rethrows the exception.
+ *
+ * @see org.xml.sax.ErrorHandler#error(SAXParseException)
+ */
+ public void error(SAXParseException exception) throws SAXException {
+ warn("parser.01", messageParams(exception), null);
+ throw exception;
+ }
+
+ /**
+ * Logs a warning and rethrows the exception.
+ *
+ * @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
+ */
+ public void fatalError(SAXParseException exception) throws SAXException {
+ warn("parser.02", messageParams(exception), null);
+ throw exception;
+ }
+
+ /**
+ * Log a warning message.
+ *
+ * @param messageId The message ID to log.
+ * @param parameters Additional message parameters.
+ * @param t The Throwable to log; usually the cause of this
+ * warning.
+ */
+ private static void warn(
+ String messageId,
+ Object[] parameters,
+ Throwable t) {
+
+ MessageProvider msg = MessageProvider.getInstance();
+ Logger.warn(new LogMsg(msg.getMessage(messageId, parameters)), t);
+ }
+
+ /**
+ * Put the system id, line and column number information from the exception
+ * into an Object array, to provide it as a
+ * MessageFormat parameter.
+ *
+ * @param e The SAXParseException containing the
+ * source system id and line/column numbers.
+ * @return An array containing the system id (a String) as well
+ * as line/column numbers (2 Integer objects) from the
+ * SAXParseException.
+ */
+ private static Object[] messageParams(SAXParseException e) {
+ return new Object[] {
+ e.getMessage(),
+ e.getSystemId(),
+ new Integer(e.getLineNumber()),
+ new Integer(e.getColumnNumber())};
+ }
+
+}
\ No newline at end of file
diff --git a/common/src/at/gv/egovernment/moa/util/MOATimer.java b/common/src/at/gv/egovernment/moa/util/MOATimer.java
new file mode 100644
index 000000000..d8bf64fc3
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/MOATimer.java
@@ -0,0 +1,110 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * A timer utility for named timers.
+ *
+ * @author Sven Aigner
+ */
+public class MOATimer {
+
+ /** The single instance of this class. */
+ private static MOATimer instance = null;
+ /** The starting points of single timings. */
+ private static Map timemapstart = new WeakHashMap();
+ /** The end points of single timings. */
+ private static Map timemapend = new WeakHashMap();
+
+ /**
+ * Return the single instance of this class.
+ *
+ * @return The single instance of this class.
+ */
+ public static MOATimer getInstance() {
+ if (instance == null) {
+ instance = new MOATimer();
+ }
+ return instance;
+ }
+
+ /**
+ * Create a new MOATimer.
+ *
+ * Protected to disallow multiple instances.
+ */
+ protected MOATimer() {
+ super();
+ }
+
+ /**
+ * Start timing a certain action.
+ *
+ * The timing belonging to the action ID is garbage collected as soon as there
+ * exists no other reference to the action ID.
+ *
+ * @param id The action ID.
+ */
+ public void startTiming(Object id) {
+ timemapstart.put(id, new Long(System.currentTimeMillis()));
+ }
+
+ /**
+ * Stop timing an action.
+ *
+ * @param id The action ID.
+ */
+ public void stopTiming(Object id) {
+ timemapend.put(id, new Long(System.currentTimeMillis()));
+ }
+
+ /**
+ * Get the duration of an action.
+ *
+ * @param id The action ID for which to compute the duration.
+ * @return long The duration in milliseconds between calls to
+ * startTiming() and stopTiming(). If
+ * only startTiming() has been called for the action, then
+ * current difference to the system time is returned. If no timing exists for
+ * the action, - 1 is returned.
+ */
+ public long duration(Object id) {
+ if (timemapstart.containsKey(id)) {
+ long start = ((Long) timemapstart.get(id)).longValue();
+ if (timemapend.containsKey(id)) {
+ long end = ((Long) timemapend.get(id)).longValue();
+ return end - start;
+ } else {
+ return System.currentTimeMillis() - start;
+ }
+ } else
+ return -1;
+ }
+
+ /**
+ * Get the duration of an action, as a nicely formatted String.
+ *
+ * @param id The action ID.
+ * @return String The duration() as a String.
+ */
+ public String durationAsString(Object id) {
+ long dur = duration(id);
+ long second = dur / 1000;
+ long mil = (dur) - (second * 1000);
+ return "Duration: " + second + "." + mil + " seconds";
+ }
+
+ /**
+ * Remove a timing.
+ *
+ * @param id The action ID.
+ */
+ public void clearTiming(String id) {
+ if (timemapstart.containsKey(id))
+ timemapstart.remove(id);
+ if (timemapend.containsKey(id))
+ timemapend.remove(id);
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/MessageProvider.java b/common/src/at/gv/egovernment/moa/util/MessageProvider.java
new file mode 100644
index 000000000..f5117e390
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/MessageProvider.java
@@ -0,0 +1,63 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.Locale;
+
+/**
+ * A singleton wrapper around a Message object.
+ *
+ * Provides the messages used in the common project.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class MessageProvider {
+ /** The location of the default message resources. */
+ private static final String[] DEFAULT_MESSAGE_RESOURCES =
+ { "resources/properties/common_messages" };
+ /** The locale of the default message resources. */
+ private static final Locale[] DEFAULT_MESSAGE_LOCALES =
+ new Locale[] { new Locale("de", "AT") };
+ /** The single instance of this class. */
+ private static MessageProvider instance;
+
+ /** The messages provided by this MessageProvider. */
+ private Messages messages;
+
+ /**
+ * Return the single instance of the MessageProvider.
+ *
+ * Intialilizes the MessageProvider with the default message
+ * locations: /resources/properties/common_messages.
+ *
+ * @return The single MessageProvider.
+ */
+ public static synchronized MessageProvider getInstance() {
+ if (instance == null) {
+ instance =
+ new MessageProvider(DEFAULT_MESSAGE_RESOURCES, DEFAULT_MESSAGE_LOCALES);
+ }
+ return instance;
+ }
+
+ /**
+ * Create a MessageProvider.
+ *
+ * @param resourceNames The names of the resources containing the messages.
+ * @param locales The corresponding locales.
+ */
+ protected MessageProvider(String[] resourceNames, Locale[] locales) {
+ this.messages = new Messages(resourceNames, locales);
+ }
+
+ /**
+ * Get the message corresponding to a given message ID.
+ *
+ * @param messageId The ID of the message.
+ * @param parameters The parameters to fill in into the message arguments.
+ * @return The formatted message.
+ */
+ public String getMessage(String messageId, Object[] parameters) {
+ return messages.getMessage(messageId, parameters);
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/Messages.java b/common/src/at/gv/egovernment/moa/util/Messages.java
new file mode 100644
index 000000000..a0139ae93
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/Messages.java
@@ -0,0 +1,117 @@
+package at.gv.egovernment.moa.util;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * Provides access to the system messages resource used for exception handling
+ * and logging messages.
+ *
+ * Messages must be provided as a resource bundle at the path.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class Messages {
+ /** Error message indicating that no messages are avaiable. */
+ private static final String ERROR_MESSAGES_UNAVAILABLE =
+ "Fehler in der Server-Konfiguration. "
+ + "Die Fehlertexte konnten nicht geladen werden.";
+ /** Error message indicating that the message is not available. */
+ private static final String ERROR_NO_MESSAGE =
+ "Keine Fehlermeldung für Fehler-Nr.={0}";
+
+ /** The names of the resources containing the messages. */
+ private String[] resourceNames;
+ /** The corresponding Locales of the resources. */
+ private Locale[] locales;
+ /** The ResourceBundles containing the messages. */
+ private ResourceBundleChain messages;
+
+ /**
+ * Create a new Message object containing the messages
+ * in the given resources.
+ *
+ * @param resourceNames The names of the resources containing the messages.
+ * @param locales The corresponding locales.
+ */
+ public Messages(String[] resourceNames, Locale[] locales) {
+ this.resourceNames = resourceNames;
+ this.locales = locales;
+ this.messages = null;
+ }
+
+ /**
+ * Get the message corresponding to a given message ID.
+ *
+ * @param messageId The ID of the message.
+ * @param parameters The parameters to fill in into the message arguments.
+ * @return The formatted message.
+ */
+ public String getMessage(String messageId, Object[] parameters) {
+ // initialize messages
+ if (messages == null) {
+ initMessages();
+ }
+
+ // create the message
+ if (messages == null) {
+ return ERROR_MESSAGES_UNAVAILABLE;
+ } else {
+ try {
+ String rawMessage = messages.getString(messageId);
+ return MessageFormat.format(rawMessage, parameters);
+ } catch (MissingResourceException e2) {
+ // couldn't find any message -> set to default error message
+ return MessageFormat.format(
+ ERROR_NO_MESSAGE,
+ new Object[] { messageId });
+ }
+ }
+ }
+
+ /**
+ * Return the names of the resources containing the messages.
+ *
+ * @return String[] The names of the resource bundles containing the messages.
+ */
+ private String[] getResourceNames() {
+ return resourceNames;
+ }
+
+ /**
+ * Return the Locales of the resources containing the messages.
+ *
+ * @return Locale[] The Locales of the resource bundles
+ * containing the messages.
+ */
+ private Locale[] getLocales() {
+ return locales;
+ }
+
+ /**
+ * Initialize the messagesResourceBundle containing
+ * the MOA error messages.
+ */
+ private void initMessages() {
+ messages = new ResourceBundleChain();
+ int i;
+
+ // initialize the message resources
+ for (i = 0; i < resourceNames.length; i++) {
+ try {
+ messages.addResourceBundle(
+ PropertyResourceBundle.getBundle(
+ getResourceNames()[i],
+ getLocales()[i]));
+ } catch (MissingResourceException e) {
+ Logger.error(ERROR_MESSAGES_UNAVAILABLE, e);
+ }
+ }
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/NodeIteratorAdapter.java b/common/src/at/gv/egovernment/moa/util/NodeIteratorAdapter.java
new file mode 100644
index 000000000..f71aa472d
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/NodeIteratorAdapter.java
@@ -0,0 +1,87 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.ListIterator;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.traversal.NodeIterator;
+
+/**
+ * A NodeIterator implementation based on a
+ * ListIterator.
+ *
+ * @see java.util.ListIterator
+ * @see org.w3c.dom.traversal.NodeIterator
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class NodeIteratorAdapter implements NodeIterator {
+
+ /** The ListIterator to wrap. */
+ private ListIterator nodeIterator;
+
+ /**
+ * Create a new NodeIteratorAdapter.
+ * @param nodeIterator The ListIterator to iterate over.
+ */
+ public NodeIteratorAdapter(ListIterator nodeIterator) {
+ this.nodeIterator = nodeIterator;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#getRoot()
+ */
+ public Node getRoot() {
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#getWhatToShow()
+ */
+ public int getWhatToShow() {
+ return NodeFilter.SHOW_ALL;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#getFilter()
+ */
+ public NodeFilter getFilter() {
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#getExpandEntityReferences()
+ */
+ public boolean getExpandEntityReferences() {
+ return false;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#nextNode()
+ */
+ public Node nextNode() throws DOMException {
+ if (nodeIterator.hasNext()) {
+ return (Node) nodeIterator.next();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#previousNode()
+ */
+ public Node previousNode() throws DOMException {
+ if (nodeIterator.hasPrevious()) {
+ return (Node) nodeIterator.previous();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#detach()
+ */
+ public void detach() {
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/NodeListAdapter.java b/common/src/at/gv/egovernment/moa/util/NodeListAdapter.java
new file mode 100644
index 000000000..7102cadca
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/NodeListAdapter.java
@@ -0,0 +1,44 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.List;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A NodeList implementation based on a List.
+ *
+ * @see java.util.List
+ * @see org.w3c.dom.NodeList
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class NodeListAdapter implements NodeList {
+ /** The List to wrap. */
+ private List nodeList;
+
+ /**
+ * Create a new NodeListAdapter.
+ *
+ * @param nodeList The List containing the nodes.
+ */
+ public NodeListAdapter(List nodeList) {
+ this.nodeList = nodeList;
+ }
+
+ /**
+ * @see org.w3c.dom.NodeList#item(int)
+ */
+ public Node item(int index) {
+ return (Node) nodeList.get(index);
+ }
+
+ /**
+ * @see org.w3c.dom.NodeList#getLength()
+ */
+ public int getLength() {
+ return nodeList.size();
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/ResourceBundleChain.java b/common/src/at/gv/egovernment/moa/util/ResourceBundleChain.java
new file mode 100644
index 000000000..90b28548a
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/ResourceBundleChain.java
@@ -0,0 +1,66 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * A class to chain ResourceBundles.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class ResourceBundleChain {
+ /** Error message indicating the resource is not available. */
+ private static final String ERROR_MISSING_RESOURCE = "Missing resource";
+ /** The ResourceBundles contained in this chain. */
+ private List resourceBundles = new ArrayList();
+
+ /**
+ * Add a ResourceBundle to the chain.
+ *
+ * @param resourceBundle The ResourceBundle to add.
+ */
+ public void addResourceBundle(ResourceBundle resourceBundle) {
+ resourceBundles.add(resourceBundle);
+ }
+
+ /**
+ * Return the value of the resource.
+ *
+ * @param key The key to access the String resource.
+ * @return The resource value. All the registered ResourceBundles
+ * are searched in the order in which they have previously been added to this
+ * ResourceBundleChain.
+ * @throws MissingResourceException The resource coult not be found in any of
+ * the bundles.
+ */
+ public String getString(String key) throws MissingResourceException {
+ MissingResourceException lastException = null;
+ Iterator iter;
+
+ // handle case where no resource bundles have been added
+ if (resourceBundles.size() == 0) {
+ throw new MissingResourceException(
+ ERROR_MISSING_RESOURCE,
+ this.getClass().getName(),
+ key);
+ }
+
+ // try to find the resource in one of the bundles; if it cannot be found,
+ // return the exception thrown by the last bundle in the list
+ for (iter = resourceBundles.iterator(); iter.hasNext();) {
+ ResourceBundle resourceBundle = (ResourceBundle) iter.next();
+ try {
+ String value = resourceBundle.getString(key);
+ return value;
+ } catch (MissingResourceException e) {
+ lastException = e;
+ }
+ }
+ throw lastException;
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/SSLUtils.java b/common/src/at/gv/egovernment/moa/util/SSLUtils.java
new file mode 100644
index 000000000..621562e2d
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/SSLUtils.java
@@ -0,0 +1,222 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import javax.net.ssl.SSLSocketFactory;
+
+import com.sun.net.ssl.KeyManager;
+import com.sun.net.ssl.KeyManagerFactory;
+import com.sun.net.ssl.SSLContext;
+import com.sun.net.ssl.TrustManager;
+import com.sun.net.ssl.TrustManagerFactory;
+
+/**
+ * Utility for connecting to server applications via SSL.
+ *
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class SSLUtils {
+
+ /**
+ * Creates an SSLSocketFactory which utilizes the given trust store.
+ *
+ * @param trustStoreType key store type of trust store
+ * @param trustStoreInputStream input stream for reading JKS trust store containing
+ * trusted server certificates; if null, the default
+ * trust store will be utilized
+ * @param trustStorePassword if provided, it will be used to check
+ * the integrity of the trust store; if omitted, it will not be checked
+ * @return SSLSocketFactory to be used by an HttpsURLConnection
+ * @throws IOException thrown while reading from the input stream
+ * @throws GeneralSecurityException thrown while creating the socket factory
+ */
+ public static SSLSocketFactory getSSLSocketFactory(
+ String trustStoreType,
+ InputStream trustStoreInputStream,
+ String trustStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ TrustManager[] tms = getTrustManagers(trustStoreType, trustStoreInputStream, trustStorePassword);
+ SSLContext ctx = SSLContext.getInstance("TLS");
+ ctx.init(null, tms, null);
+
+ SSLSocketFactory sf = ctx.getSocketFactory();
+ return sf;
+ }
+ /**
+ * Creates an SSLSocketFactory which utilizes the
+ * given trust store and keystore.
+ *
+ * @param trustStore trust store containing trusted server certificates;
+ * if null, the default trust store will be utilized
+ * @param clientKeyStoreType key store type of clientKeyStore
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if null, the default key store will be utilized
+ * @param clientKeyStorePassword if provided, it will be used to check
+ * the integrity of the client key store; if omitted, it will not be checked
+ * @return SSLSocketFactory to be used by an HttpsURLConnection
+ * @throws IOException thrown while reading key store file
+ * @throws GeneralSecurityException thrown while creating the socket factory
+ */
+ public static SSLSocketFactory getSSLSocketFactory(
+ KeyStore trustStore,
+ String clientKeyStoreType,
+ String clientKeyStoreURL,
+ String clientKeyStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ SSLContext ctx = getSSLContext(
+ trustStore, clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ SSLSocketFactory sf = ctx.getSocketFactory();
+ return sf;
+ }
+ /**
+ * Creates an SSLContext initialized for the
+ * given trust store and keystore.
+ *
+ * @param trustStore trust store containing trusted server certificates;
+ * if null, the default trust store will be utilized
+ * @param clientKeyStoreType key store type of clientKeyStore
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if null, the default key store will be utilized
+ * @param clientKeyStorePassword if provided, it will be used to check
+ * the integrity of the client key store; if omitted, it will not be checked
+ * @return SSLContext to be used for creating an SSLSocketFactory
+ * @throws IOException thrown while reading key store file
+ * @throws GeneralSecurityException thrown while creating the SSL context
+ */
+ public static SSLContext getSSLContext(
+ KeyStore trustStore,
+ String clientKeyStoreType,
+ String clientKeyStoreURL,
+ String clientKeyStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ //System.setProperty("javax.net.debug", "all");
+ TrustManager[] tms = getTrustManagers(trustStore);
+ KeyManager[] kms = getKeyManagers(clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ SSLContext ctx = SSLContext.getInstance("TLS");
+ ctx.init(kms, tms, null);
+ return ctx;
+ }
+ /**
+ * Loads the trust store from an input stream and gets the
+ * TrustManagers from a default TrustManagerFactory,
+ * initialized from the given trust store.
+ * @param trustStoreType key store type of trust store
+ * @param trustStoreInputStream input stream for reading JKS trust store containing
+ * trusted server certificates; if null, the default
+ * trust store will be utilized
+ * @param trustStorePassword if provided, it will be used to check
+ * the integrity of the trust store; if omitted, it will not be checked
+ * @return TrustManagers to be used for creating an
+ * SSLSocketFactory utilizing the given trust store
+ * @throws IOException thrown while reading from the input stream
+ * @throws GeneralSecurityException thrown while initializing the
+ * default TrustManagerFactory
+ */
+ protected static TrustManager[] getTrustManagers(
+ String trustStoreType,
+ InputStream trustStoreInputStream,
+ String trustStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ if (trustStoreInputStream == null)
+ return null;
+
+ // Set up the TrustStore to use. We need to load the file into
+ // a KeyStore instance.
+ KeyStore trustStore = KeyStoreUtils.loadKeyStore(trustStoreType, trustStoreInputStream, trustStorePassword);
+ return getTrustManagers(trustStore);
+ }
+ /**
+ * Gets the TrustManagers from a default TrustManagerFactory,
+ * initialized from the given trust store.
+ *
+ * @param trustStore the trust store to use
+ * @param trustStorePassword password protecting the given trust store
+ * @return TrustManagers to be used for creating an
+ * SSLSocketFactory utilizing the given trust store
+ * @throws GeneralSecurityException thrown while initializing the
+ * default TrustManagerFactory
+ */
+ protected static TrustManager[] getTrustManagers(KeyStore trustStore)
+ throws GeneralSecurityException {
+
+ if (trustStore == null)
+ return null;
+
+ // Initialize the default TrustManagerFactory with this KeyStore
+ String alg=TrustManagerFactory.getDefaultAlgorithm();
+ TrustManagerFactory tmFact=TrustManagerFactory.getInstance(alg);
+ tmFact.init(trustStore);
+
+ // And now get the TrustManagers
+ TrustManager[] tms=tmFact.getTrustManagers();
+ return tms;
+ }
+ /**
+ * Loads the client key store from file and gets the
+ * KeyManagers from a default KeyManagerFactory,
+ * initialized from the given client key store.
+ * @param clientKeyStoreType key store type of clientKeyStore
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if null, the default key store will be utilized
+ * @param clientKeyStorePassword password used to check the integrity of the client key store;
+ * if null, it will not be checked
+ * @return KeyManagers to be used for creating an
+ * SSLSocketFactory utilizing the given client key store
+ * @throws IOException thrown while reading from the key store file
+ * @throws GeneralSecurityException thrown while initializing the
+ * default KeyManagerFactory
+ */
+ public static KeyManager[] getKeyManagers (
+ String clientKeyStoreType,
+ String clientKeyStoreURL,
+ String clientKeyStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ if (clientKeyStoreURL == null)
+ return null;
+
+ // Set up the KeyStore to use. We need to load the file into
+ // a KeyStore instance.
+ KeyStore clientKeyStore = KeyStoreUtils.loadKeyStore(
+ clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ return getKeyManagers(clientKeyStore, clientKeyStorePassword);
+ }
+ /**
+ * Gets the KeyManagers from a default KeyManagerFactory,
+ * initialized from the given client key store.
+ * @param clientKeyStore client key store
+ * @param clientKeyStorePassword if provided, it will be used to check
+ * the integrity of the client key store; if omitted, it will not be checked
+ * @return KeyManagers to be used for creating an
+ * SSLSocketFactory utilizing the given client key store
+ * @throws GeneralSecurityException thrown while initializing the
+ * default KeyManagerFactory
+ */
+ public static KeyManager[] getKeyManagers (
+ KeyStore clientKeyStore,
+ String clientKeyStorePassword)
+ throws GeneralSecurityException {
+
+ if (clientKeyStore == null)
+ return null;
+
+ // Now we initialize the default KeyManagerFactory with this KeyStore
+ String alg=KeyManagerFactory.getDefaultAlgorithm();
+ KeyManagerFactory kmFact=KeyManagerFactory.getInstance(alg);
+ char[] password = null;
+ if (clientKeyStorePassword != null)
+ password = clientKeyStorePassword.toCharArray();
+ kmFact.init(clientKeyStore, password);
+
+ // And now get the KeyManagers
+ KeyManager[] kms=kmFact.getKeyManagers();
+ return kms;
+ }
+}
diff --git a/common/src/at/gv/egovernment/moa/util/StreamEntityResolver.java b/common/src/at/gv/egovernment/moa/util/StreamEntityResolver.java
new file mode 100644
index 000000000..38c4e863c
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/StreamEntityResolver.java
@@ -0,0 +1,64 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * An EntityResolver that maps system IDs to
+ * InputStreams.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class StreamEntityResolver implements EntityResolver {
+
+ /** A mapping from Public ID or System ID to an InputStream
+ * containing the entity. */
+ private Map mappedEntities;
+
+ /**
+ * Create a StreamEntityResolver.
+ *
+ * @param mappedEntities A mapping from public or system IDs
+ * (String objects) to InputStreams.
+ */
+ public StreamEntityResolver(Map mappedEntities) {
+ this.mappedEntities = mappedEntities;
+ }
+
+ /**
+ * Resolve an entity by looking it up in the mapped entities.
+ *
+ * First, the public ID is looked up in the mapping, then the system ID.
+ *
+ * @param publicId The public ID of the entity.
+ * @param systemId The system ID of the entity.
+ * @return An InputStream containing the entity or
+ * null if no entity could be found.
+ * @throws SAXException Signalling a parsing exception.
+ * @throws IOException Error reading the entity.
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+
+ InputSource src = null;
+
+ if (publicId != null && mappedEntities.get(publicId) != null) {
+ src = new InputSource((InputStream) mappedEntities.get(publicId));
+ } else if (systemId != null && mappedEntities.get(systemId) != null) {
+ src = new InputSource((InputStream) mappedEntities.get(systemId));
+ }
+
+ if (src != null) {
+ src.setPublicId(publicId);
+ src.setSystemId(systemId);
+ }
+
+ return src;
+ }
+}
diff --git a/common/src/at/gv/egovernment/moa/util/StreamUtils.java b/common/src/at/gv/egovernment/moa/util/StreamUtils.java
new file mode 100644
index 000000000..88db24504
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/StreamUtils.java
@@ -0,0 +1,116 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Utility methods for streams.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class StreamUtils {
+
+ /**
+ * Compare the contents of two InputStreams.
+ *
+ * @param is1 The 1st InputStream to compare.
+ * @param is2 The 2nd InputStream to compare.
+ * @return boolean true, if both streams contain the exactly the
+ * same content, false otherwise.
+ * @throws IOException An error occurred reading one of the streams.
+ */
+ public static boolean compareStreams(InputStream is1, InputStream is2)
+ throws IOException {
+
+ byte[] buf1 = new byte[256];
+ byte[] buf2 = new byte[256];
+ int length1;
+ int length2;
+
+ try {
+ while (true) {
+ length1 = is1.read(buf1);
+ length2 = is2.read(buf2);
+
+ if (length1 != length2) {
+ return false;
+ }
+ if (length1 <= 0) {
+ return true;
+ }
+ if (!compareBytes(buf1, buf2, length1)) {
+ return false;
+ }
+ }
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ // close both streams
+ try {
+ is1.close();
+ is2.close();
+ } catch (IOException e) {
+ // ignore this
+ }
+ }
+ }
+
+ /**
+ * Compare two byte arrays, up to a given maximum length.
+ *
+ * @param b1 1st byte array to compare.
+ * @param b2 2nd byte array to compare.
+ * @param length The maximum number of bytes to compare.
+ * @return true, if the byte arrays are equal, false
+ * otherwise.
+ */
+ private static boolean compareBytes(byte[] b1, byte[] b2, int length) {
+ if (b1.length != b2.length) {
+ return false;
+ }
+
+ for (int i = 0; i < b1.length && i < length; i++) {
+ if (b1[i] != b2[i]) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Reads a byte array from a stream.
+ * @param in The InputStream to read.
+ * @return The bytes contained in the given InputStream.
+ * @throws IOException on any exception thrown
+ */
+ public static byte[] readStream(InputStream in) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int b;
+ while ((b = in.read()) >= 0)
+ out.write(b);
+ in.close();
+ return out.toByteArray();
+ }
+
+ /**
+ * Reads a String from a stream, using given encoding.
+ * @param in The InputStream to read.
+ * @param encoding The character encoding to use for converting the bytes
+ * of the InputStream into a String.
+ * @return The content of the given InputStream converted into
+ * a String.
+ * @throws IOException on any exception thrown
+ */
+ public static String readStream(InputStream in, String encoding) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int b;
+ while ((b = in.read()) >= 0)
+ out.write(b);
+ in.close();
+ return out.toString(encoding);
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/URLDecoder.java b/common/src/at/gv/egovernment/moa/util/URLDecoder.java
new file mode 100644
index 000000000..a20820f7e
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/URLDecoder.java
@@ -0,0 +1,60 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Decodes an URL encoded String using a specified character encoding.
+ * Provides a function missing in JDK 1.3.
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class URLDecoder {
+
+ /**
+ * Decodes an application/x-www-form-urlencoded string using a specific encoding scheme.
+ * @param s the string to decode
+ * @param encoding name of character encoding
+ * @return the newly decoded string
+ * @throws UnsupportedEncodingException if the encoding is not supported
+ */
+ public static String decode(String s, String encoding) throws UnsupportedEncodingException {
+ StringReader in = new StringReader(s);
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ for (int b = read(in); b >= 0; b = read(in))
+ bout.write(b);
+ return bout.toString(encoding);
+ }
+ /**
+ * Decodes the next byte from the string reader.
+ * @param in string reader
+ * @return the next byte decoded;
+ * -1 upon end of string, on erroneous data, and on any exception caught
+ * @todo syntax check on string
+ */
+ private static int read(StringReader in) {
+ try {
+ int b = in.read();
+ if (b == '+')
+ return ' ';
+ if (b == '%') {
+ char[] hex = new char[2];
+ if (in.read(hex, 0, 2) >= 0) {
+ String hexString = new String(hex);
+ return Integer.valueOf(hexString, 16).intValue();
+ }
+ else
+ return -1;
+ }
+ return b;
+ }
+ catch (IOException ex) {
+ return -1;
+ }
+ catch (NumberFormatException ex) {
+ return -1;
+ }
+ }
+}
diff --git a/common/src/at/gv/egovernment/moa/util/URLEncoder.java b/common/src/at/gv/egovernment/moa/util/URLEncoder.java
new file mode 100644
index 000000000..840c0c3bc
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/URLEncoder.java
@@ -0,0 +1,63 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Translates a string into mime format "x-www-form-urlencoded".
+ * Provides a function missing in JDK 1.3.
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class URLEncoder {
+
+ /**
+ * Translates a string into x-www-form-urlencoded format.
+ * @param s the string to be translated
+ * @param encoding the encoding to use
+ * @return the translated string
+ * @throws UnsupportedEncodingException when the desired encoding is not supported
+ */
+ public static String encode(String s, String encoding) throws UnsupportedEncodingException {
+ byte[] barr = s.getBytes(encoding);
+ ByteArrayInputStream bin = new ByteArrayInputStream(barr);
+ StringWriter out = new StringWriter();
+ for (int b = bin.read(); b >= 0; b = bin.read())
+ encode(b, out);
+ return out.toString();
+ }
+
+ /**
+ * Encode a character.
+ * @param ch The character to encode.
+ * @param out The StringWriter containing the result.
+ */
+ private static void encode(int ch, StringWriter out) {
+ if ((ch >= 'a' && ch <= 'z')
+ || (ch >= 'A' && ch <= 'Z')
+ || (ch >= '0' && ch <= '9')
+ || ch == '.' || ch == '-' || ch == '*' || ch == '_')
+ out.write(ch);
+ else if (ch == ' ')
+ out.write('+');
+ else
+ encodeHex(ch, out);
+ }
+
+ /**
+ * Encode a character as an escaped hex value.
+ * @param ch The character to encode.
+ * @param out The StringWriter containing the result.
+ */
+ private static void encodeHex(int ch, StringWriter out) {
+ out.write('%');
+ String hex = Integer.toHexString(ch).toUpperCase();
+ if (hex.length() < 2)
+ out.write('0');
+ else
+ out.write(hex.charAt(hex.length() - 2));
+ out.write(hex.charAt(hex.length() - 1));
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/XPathException.java b/common/src/at/gv/egovernment/moa/util/XPathException.java
new file mode 100644
index 000000000..e10c882e5
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/XPathException.java
@@ -0,0 +1,58 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * An exception occurred evaluating an XPath.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class XPathException extends RuntimeException {
+ /** The wrapped exception. */
+ private Throwable wrapped;
+
+ /**
+ * Create a XPathException.
+ *
+ * @param message The exception message.
+ * @param wrapped The exception being the likely cause of this exception.
+ */
+ public XPathException(String message, Throwable wrapped) {
+ super(message);
+ this.wrapped = wrapped;
+ }
+
+ /**
+ * Return the wrapped exception.
+ *
+ * @return The wrapped exception being the likely cause of this exception.
+ */
+ public Throwable getWrapped() {
+ return wrapped;
+ }
+
+ /**
+ * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
+ */
+ public void printStackTrace(PrintStream s) {
+ super.printStackTrace(s);
+ if (getWrapped() != null) {
+ s.print("Caused by: ");
+ getWrapped().printStackTrace(s);
+ }
+ }
+
+ /**
+ * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+ */
+ public void printStackTrace(PrintWriter s) {
+ super.printStackTrace(s);
+ if (getWrapped() != null) {
+ s.print("Caused by: ");
+ getWrapped().printStackTrace(s);
+ }
+ }
+
+}
diff --git a/common/src/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
new file mode 100644
index 000000000..0ed4fcda3
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
@@ -0,0 +1,415 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.traversal.NodeIterator;
+
+import org.jaxen.JaxenException;
+import org.jaxen.NamespaceContext;
+import org.jaxen.SimpleNamespaceContext;
+import org.jaxen.dom.DOMXPath;
+import org.jaxen.dom.DocumentNavigator;
+
+/**
+ * Utility methods to evaluate XPath expressions on DOM nodes.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class XPathUtils {
+
+ /**
+ * The XPath expression selecting all nodes under a given root (including the
+ * root node itself).
+ */
+ public static final String ALL_NODES_XPATH =
+ "(.//. | .//@* | .//namespace::*)";
+
+ /** The DocumentNavigator to use for navigating the document. */
+ private static DocumentNavigator documentNavigator =
+ DocumentNavigator.getInstance();
+ /** The default namespace prefix to namespace URI mappings. */
+ private static NamespaceContext NS_CONTEXT;
+
+ static {
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ ctx.addNamespace(Constants.MOA_PREFIX, Constants.MOA_NS_URI);
+ ctx.addNamespace(Constants.MOA_CONFIG_PREFIX, Constants.MOA_CONFIG_NS_URI);
+ ctx.addNamespace(
+ Constants.MOA_ID_CONFIG_PREFIX,
+ Constants.MOA_ID_CONFIG_NS_URI);
+ ctx.addNamespace(Constants.SL10_PREFIX, Constants.SL10_NS_URI);
+ ctx.addNamespace(Constants.SL11_PREFIX, Constants.SL11_NS_URI);
+ ctx.addNamespace(Constants.ECDSA_PREFIX, Constants.ECDSA_NS_URI);
+ ctx.addNamespace(Constants.PD_PREFIX, Constants.PD_NS_URI);
+ ctx.addNamespace(Constants.SAML_PREFIX, Constants.SAML_NS_URI);
+ ctx.addNamespace(Constants.SAMLP_PREFIX, Constants.SAMLP_NS_URI);
+ ctx.addNamespace(Constants.DSIG_PREFIX, Constants.DSIG_NS_URI);
+ ctx.addNamespace(Constants.XSLT_PREFIX, Constants.XSLT_NS_URI);
+ ctx.addNamespace(Constants.XSI_PREFIX, Constants.XSI_NS_URI);
+ ctx.addNamespace(
+ Constants.DSIG_FILTER2_PREFIX,
+ Constants.DSIG_FILTER2_NS_URI);
+ ctx.addNamespace(Constants.DSIG_EC_PREFIX, Constants.DSIG_EC_NS_URI);
+ NS_CONTEXT = ctx;
+ }
+
+ /**
+ * Return a NodeIterator over the nodes matching the XPath
+ * expression.
+ *
+ * All namespace URIs and prefixes declared in the Constants
+ * interface are used for resolving namespaces.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return An iterator over the resulting nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeIterator selectNodeIterator(Node contextNode, String exp)
+ throws XPathException {
+
+ return selectNodeIterator(contextNode, NS_CONTEXT, exp);
+ }
+
+ /**
+ * Return a NodeIterator over the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceElement An element from which to build the
+ * namespace mapping for evaluating the XPath expression
+ * @param exp The XPath expression to evaluate.
+ * @return An iterator over the resulting nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeIterator selectNodeIterator(
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
+
+ try {
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ ctx.addElementNamespaces(documentNavigator, namespaceElement);
+ return selectNodeIterator(contextNode, ctx, exp);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Return a NodeIterator over the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceMapping A namespace prefix to namespace URI mapping
+ * (String to String) for evaluating the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return An iterator over the resulting nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeIterator selectNodeIterator(
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
+
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+
+ return selectNodeIterator(contextNode, ctx, exp);
+ }
+
+ /**
+ * Return a NodeIterator over the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param nsContext The NamespaceContext for resolving namespace
+ * prefixes to namespace URIs for evaluating the XPath expression.
+ * @param exp The XPath expression to evaluate.
+ * @return An iterator over the resulting nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ private static NodeIterator selectNodeIterator(
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
+
+ try {
+ DOMXPath xpath = new DOMXPath(exp);
+ List nodes;
+
+ xpath.setNamespaceContext(nsContext);
+ nodes = xpath.selectNodes(contextNode);
+ return new NodeIteratorAdapter(nodes.listIterator());
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Return a NodeList of all the nodes matching the XPath
+ * expression.
+ *
+ * All namespace URIs and prefixes declared in the Constants
+ * interface are used for resolving namespaces.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return A NodeList containing the matching nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeList selectNodeList(Node contextNode, String exp)
+ throws XPathException {
+
+ return selectNodeList(contextNode, NS_CONTEXT, exp);
+ }
+
+ /**
+ * Return a NodeList of all the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceElement An element from which to build the
+ * namespace mapping for evaluating the XPath expression
+ * @param exp The XPath expression to evaluate.
+ * @return A NodeList containing the matching nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeList selectNodeList(
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
+
+ try {
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+
+ ctx.addElementNamespaces(documentNavigator, namespaceElement);
+ return selectNodeList(contextNode, ctx, exp);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Return a NodeList of all the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceMapping A namespace prefix to namespace URI mapping
+ * (String to String) for evaluating the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return A NodeList containing the matching nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeList selectNodeList(
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
+
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+
+ return selectNodeList(contextNode, ctx, exp);
+ }
+
+ /**
+ * Return a NodeList of all the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param nsContext The NamespaceContext for resolving namespace
+ * prefixes to namespace URIs for evaluating the XPath expression.
+ * @param exp The XPath expression to evaluate.
+ * @return A NodeList containing the matching nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ private static NodeList selectNodeList(
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
+
+ try {
+ DOMXPath xpath = new DOMXPath(exp);
+ List nodes;
+
+ xpath.setNamespaceContext(nsContext);
+ nodes = xpath.selectNodes(contextNode);
+ return new NodeListAdapter(nodes);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Select the first node matching an XPath expression.
+ *
+ * All namespace URIs and prefixes declared in the Constants
+ * interface are used for resolving namespaces.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return Node The first node matching the XPath expression, or
+ * null, if no node matched.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static Node selectSingleNode(Node contextNode, String exp)
+ throws XPathException {
+
+ return selectSingleNode(contextNode, NS_CONTEXT, exp);
+ }
+
+ /**
+ * Select the first node matching an XPath expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceElement An element from which to build the
+ * namespace mapping for evaluating the XPath expression
+ * @param exp The XPath expression to evaluate.
+ * @return Node The first node matching the XPath expression, or
+ * null, if no node matched.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static Node selectSingleNode(
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
+
+ try {
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ ctx.addElementNamespaces(documentNavigator, namespaceElement);
+
+ return selectSingleNode(contextNode, ctx, exp);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Select the first node matching an XPath expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceMapping A namespace prefix to namespace URI mapping
+ * (String to String) for evaluating the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return Node The first node matching the XPath expression, or
+ * null, if no node matched.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static Node selectSingleNode(
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
+
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+
+ return selectSingleNode(contextNode, ctx, exp);
+ }
+
+ /**
+ * Select the first node matching an XPath expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param nsContext The NamespaceContext for resolving namespace
+ * prefixes to namespace URIs for evaluating the XPath expression.
+ * @param exp The XPath expression to evaluate.
+ * @return Node The first node matching the XPath expression, or
+ * null, if no node matched.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ private static Node selectSingleNode(
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
+
+ try {
+ DOMXPath xpath = new DOMXPath(exp);
+ xpath.setNamespaceContext(nsContext);
+ return (Node) xpath.selectSingleNode(contextNode);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Return the value of a DOM element whose location is given by an XPath
+ * expression.
+ *
+ * @param root The root element from which to evaluate the XPath.
+ * @param xpath The XPath expression pointing to the element whose value
+ * to return.
+ * @param def The default value to return, if no element can be found using
+ * the given xpath.
+ * @return The element value, if it can be located using the
+ * xpath. Otherwise, def is returned.
+ */
+ public static String getElementValue(
+ Element root,
+ String xpath,
+ String def) {
+
+ Element elem = (Element) XPathUtils.selectSingleNode(root, xpath);
+ return elem != null ? DOMUtils.getText(elem) : def;
+ }
+
+ /**
+ * Return the value of a DOM attribute whose location is given by an XPath
+ * expression.
+ *
+ * @param root The root element from which to evaluate the XPath.
+ * @param xpath The XPath expression pointing to the attribute whose value to
+ * return.
+ * @param def The default value to return, if no attribute can be found using
+ * the given xpath.
+ * @return The element value, if it can be located using the
+ * xpath. Otherwise, def is returned.
+ */
+ public static String getAttributeValue(
+ Element root,
+ String xpath,
+ String def) {
+
+ Attr attr = (Attr) XPathUtils.selectSingleNode(root, xpath);
+ return attr != null ? attr.getValue() : def;
+ }
+
+}
diff --git a/common/src/test/at/gv/egovernment/moa/AllTests.java b/common/src/test/at/gv/egovernment/moa/AllTests.java
new file mode 100644
index 000000000..00e2c505f
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/AllTests.java
@@ -0,0 +1,38 @@
+package test.at.gv.egovernment.moa;
+
+import test.at.gv.egovernment.moa.util.DOMUtilsTest;
+import test.at.gv.egovernment.moa.util.DateTimeUtilsTest;
+import test.at.gv.egovernment.moa.util.KeyStoreUtilsTest;
+import test.at.gv.egovernment.moa.util.SSLUtilsTest;
+import test.at.gv.egovernment.moa.util.XPathUtilsTest;
+
+import junit.awtui.TestRunner;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author patrick
+ * @version $Id$
+ */
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+
+ suite.addTestSuite(DOMUtilsTest.class);
+ suite.addTestSuite(DateTimeUtilsTest.class);
+ suite.addTestSuite(XPathUtilsTest.class);
+ suite.addTestSuite(KeyStoreUtilsTest.class);
+ suite.addTestSuite(SSLUtilsTest.class);
+
+ return suite;
+ }
+
+ public static void main(String[] args) {
+ try {
+ TestRunner.run(AllTests.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/common/src/test/at/gv/egovernment/moa/MOATestCase.java b/common/src/test/at/gv/egovernment/moa/MOATestCase.java
new file mode 100644
index 000000000..86ea2ee6c
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/MOATestCase.java
@@ -0,0 +1,75 @@
+package test.at.gv.egovernment.moa;
+
+import java.io.FileInputStream;
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
+import org.xml.sax.InputSource;
+
+import junit.framework.TestCase;
+
+import at.gv.egovernment.moa.util.Constants;
+import at.gv.egovernment.moa.util.DOMUtils;
+
+/**
+ * Base class for MOA test cases.
+ *
+ * Provides some utility functions.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class MOATestCase extends TestCase {
+
+ protected static final String TESTDATA_ROOT = "data/test/";
+
+ /**
+ * Constructor for MOATestCase.
+ * @param arg0
+ */
+ public MOATestCase(String name) {
+ super(name);
+ }
+
+ /**
+ * Parse an XML file non-validating.
+ */
+ public static Document parseXml(String fileName) throws Exception {
+ return DOMUtils.parseDocument(
+ new FileInputStream(fileName),
+ false,
+ null,
+ null);
+ }
+
+ /**
+ * Parse an XML validating with a given file name.
+ *
+ * Uses the local schema resources.
+ */
+ public static Document parseXmlValidating(String fileName) throws Exception {
+ return DOMUtils.parseDocument(
+ new FileInputStream(fileName),
+ true,
+ Constants.ALL_SCHEMA_LOCATIONS,
+ null);
+ }
+
+ /**
+ * Parse an XML from a String.
+ */
+ public static Document parseXmlString(String xml) throws Exception {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder;
+
+ factory.setNamespaceAware(true);
+ builder = factory.newDocumentBuilder();
+
+ return builder.parse(new InputSource(new StringReader(xml)));
+ }
+
+}
diff --git a/common/src/test/at/gv/egovernment/moa/util/DOMUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/DOMUtilsTest.java
new file mode 100644
index 000000000..eb3ad1a5c
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/util/DOMUtilsTest.java
@@ -0,0 +1,137 @@
+package test.at.gv.egovernment.moa.util;
+import java.io.FileInputStream;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import test.at.gv.egovernment.moa.*;
+
+import at.gv.egovernment.moa.util.Constants;
+import at.gv.egovernment.moa.util.DOMUtils;
+
+/**
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class DOMUtilsTest extends MOATestCase {
+ private static final String TESTDATA_BASE = TESTDATA_ROOT + "xml/";
+ private static boolean grammarsInitialized = false;
+
+ /**
+ * Constructor for DOMUtilsTest.
+ * @param name
+ */
+ public DOMUtilsTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ if (!grammarsInitialized) {
+ // preparse XML schema
+ DOMUtils.addSchemaToPool(
+ getClass().getResourceAsStream(Constants.XML_SCHEMA_LOCATION),
+ Constants.XML_NS_URI);
+ // preparse XMLDsig Filter2 schema
+ DOMUtils.addSchemaToPool(
+ getClass().getResourceAsStream(Constants.DSIG_FILTER2_SCHEMA_LOCATION),
+ Constants.DSIG_FILTER2_NS_URI);
+ // preparse XMLDsig schema
+ DOMUtils.addSchemaToPool(
+ getClass().getResourceAsStream(Constants.DSIG_SCHEMA_LOCATION),
+ Constants.DSIG_NS_URI);
+ // preparse MOA schema
+ DOMUtils.addSchemaToPool(
+ getClass().getResourceAsStream(Constants.MOA_SCHEMA_LOCATION),
+ Constants.MOA_NS_URI);
+ grammarsInitialized = true;
+ }
+ }
+
+ private Document parse(String fileName) throws Exception {
+ return DOMUtils.parseDocument(
+ new FileInputStream(fileName),
+ true,
+ Constants.ALL_SCHEMA_LOCATIONS,
+ null);
+ }
+
+ public void testParseCreateXMLSignature() throws Exception {
+ parse(TESTDATA_BASE + "CreateXMLSignature/TestGeneratorCX2.005.Req.xml");
+ parse(TESTDATA_BASE + "CreateXMLSignature/Req000.xml");
+ parse(TESTDATA_BASE + "CreateXMLSignature/Req001.xml");
+ parse(TESTDATA_BASE + "CreateXMLSignature/Req002.xml");
+ parse(TESTDATA_BASE + "CreateXMLSignature/Req004.xml");
+ }
+
+ public void testParseVerifyCMSSignature() throws Exception {
+ parse(TESTDATA_BASE + "VerifyCMSSignature/Req000.xml");
+ }
+
+ public void testParseVerifyXMLSignature() throws Exception {
+ parse(TESTDATA_BASE + "VerifyXMLSignature/Req000.xml");
+ parse(TESTDATA_BASE + "VerifyXMLSignature/Req001.xml");
+ parse(TESTDATA_BASE + "VerifyXMLSignature/Req002.xml");
+ parse(TESTDATA_BASE + "VerifyXMLSignature/TestGeneratorVX.002.Req.xml");
+ //parse(TESTDATA_BASE + "VerifyXMLSignature/TestGeneratorVX.006.Req.xml");
+ parse(TESTDATA_BASE + "VerifyXMLSignature/VerifySAMLRequest.xml");
+ }
+
+ public void testParseInfobox() throws Exception {
+ parse(TESTDATA_BASE + "Infobox/InfoboxReadResponseMOA4.xml");
+ parse(TESTDATA_BASE + "Infobox/InfoboxReadResponse.xml");
+ }
+
+
+ private Document parsePlain(String fileName) throws Exception {
+ return DOMUtils.parseDocument(
+ new FileInputStream(fileName),
+ false,
+ null,
+ null);
+ }
+
+ public void testValidateCreateXMLSignature() throws Exception {
+ Document doc;
+ boolean valid;
+
+ // test a valid request
+ doc = parsePlain(TESTDATA_BASE + "CreateXMLSignature/Req000.xml");
+ valid =
+ DOMUtils.validateElement(
+ doc.getDocumentElement(),
+ Constants.ALL_SCHEMA_LOCATIONS,
+ null);
+ assertTrue(valid);
+
+ // test an invalid request
+ doc = parsePlain(TESTDATA_BASE + "CreateXMLSignature/invalid.xml");
+ try {
+ valid =
+ DOMUtils.validateElement(
+ doc.getDocumentElement(),
+ Constants.ALL_SCHEMA_LOCATIONS,
+ null);
+ fail();
+ } catch (Exception e) {
+ }
+ }
+
+ public void testGetNamespaceDeclarations() throws Exception {
+ Document doc;
+ NodeList nl;
+ Element elem;
+ Map nsDecls;
+
+ doc = parse(TESTDATA_BASE + "VerifyXMLSignature/Req002.xml");
+ nl = doc.getElementsByTagNameNS(Constants.DSIG_NS_URI, "Reference");
+ elem = (Element) nl.item(0);
+ nsDecls = DOMUtils.getNamespaceDeclarations(elem);
+
+ assertEquals(2, nsDecls.size());
+ assertEquals(Constants.DSIG_NS_URI, nsDecls.get("dsig"));
+ assertEquals(Constants.MOA_NS_URI, nsDecls.get(""));
+ }
+
+}
diff --git a/common/src/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java
new file mode 100644
index 000000000..da6b29b1c
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java
@@ -0,0 +1,104 @@
+package test.at.gv.egovernment.moa.util;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+import junit.framework.TestCase;
+
+import at.gv.egovernment.moa.util.DateTimeUtils;
+
+/**
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class DateTimeUtilsTest extends TestCase {
+
+ /**
+ * Constructor for DateTimeUtilsTest.
+ * @param arg0
+ */
+ public DateTimeUtilsTest(String arg0) {
+ super(arg0);
+ }
+
+ public void testParseDateTimeValid() throws Exception {
+ Date date;
+ DateFormat format = SimpleDateFormat.getDateTimeInstance();
+ String dateStr;
+
+ format.setTimeZone(TimeZone.getTimeZone("GMT"));
+ date = DateTimeUtils.parseDateTime("+1971-12-12T06:30:15");
+ date.setTime(date.getTime() + TimeZone.getDefault().getRawOffset());
+ dateStr = format.format(date);
+ assertEquals("12.12.1971 06:30:15", dateStr);
+
+ date = DateTimeUtils.parseDateTime("2000-01-01T23:59:59.012Z");
+ dateStr = format.format(date);
+ assertEquals("01.01.2000 23:59:59", dateStr);
+
+ date = DateTimeUtils.parseDateTime("2003-05-20T12:17:30-05:00");
+ dateStr = format.format(date);
+ assertEquals("20.05.2003 17:17:30", dateStr);
+
+
+ date = DateTimeUtils.parseDateTime("2002-02-02T02:02:02.33+04:30");
+ dateStr = format.format(date);
+ assertEquals("01.02.2002 21:32:02", dateStr);
+ }
+
+ public void testParseDateTimeInvalid() {
+ try {
+ DateTimeUtils.parseDateTime("+1971-12-12T6:30:15");
+ fail();
+ } catch (ParseException e) {
+ }
+
+ try {
+ DateTimeUtils.parseDateTime("2000-01-0123:59:59.999999Z");
+ fail();
+ } catch (ParseException e) {
+ }
+
+ try {
+ DateTimeUtils.parseDateTime("2003-05-20T12:17:3005:00");
+ fail();
+ } catch (ParseException e) {
+ }
+
+ try {
+ DateTimeUtils.parseDateTime(" 2002-02-02T02:02:02.33+04:00");
+ fail();
+ } catch (ParseException e) {
+ }
+
+ }
+
+ public void testBuildDateTimeGMTMinus3() {
+ String should = "2002-01-01T01:01:01-03:00";
+ doTestBuildDateTime(2002, 1, 1, 1, 1, 1, "GMT-03:00", should);
+ }
+ public void testBuildDateTimeMEZSommerzeit() {
+ String should = "2002-07-31T23:59:59+02:00";
+ doTestBuildDateTime(2002, 7, 31, 23, 59, 59, "GMT+01:00", should);
+ }
+ public void testBuildDateTimeGMT() {
+ String should = "2002-01-01T01:01:01";
+ doTestBuildDateTime(2002, 1, 1, 1, 1, 1, "GMT+00:00", should);
+ }
+ private void doTestBuildDateTime(
+ int year, int month, int day,
+ int hour, int min, int sec,
+ String timeZone, String dateTimeShould) {
+
+ Calendar cal = new GregorianCalendar(TimeZone.getTimeZone(timeZone));
+ cal.set(year,month, day, hour, min, sec);
+ cal.set(Calendar.MILLISECOND, 0);
+ String dateTimeBuilt = DateTimeUtils.buildDateTime(cal);
+ assertEquals(dateTimeShould, dateTimeBuilt);
+ }
+
+}
diff --git a/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java
new file mode 100644
index 000000000..06a72c570
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java
@@ -0,0 +1,90 @@
+package test.at.gv.egovernment.moa.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.KeyStore;
+import java.security.Security;
+import java.security.cert.X509Certificate;
+import java.util.Enumeration;
+
+import at.gv.egovernment.moa.util.KeyStoreUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class KeyStoreUtilsTest extends TestCase {
+ private String tmpDir = "tmp/KeyStoreUtilsTest";
+ private String tmpDirURL = "file:" + tmpDir;
+
+ public KeyStoreUtilsTest(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
+ new File(tmpDir).mkdirs();
+ }
+ protected void tearDown() throws Exception {
+ new File(tmpDir).delete();
+ }
+ public void testCreateKeyStoreJKS() throws Exception {
+ String[] certFilenames = new String[] {
+ "data/test/security/server-certs/baltimore.cer"
+ };
+ KeyStore ks = KeyStoreUtils.createKeyStore("jks", certFilenames);
+ assertEquals(1, ks.size());
+ X509Certificate cert = (X509Certificate)ks.getCertificate("0");
+ assertEquals(3424, cert.getSerialNumber().intValue());
+ }
+ public void testCreateKeyStorePKCS12() throws Exception {
+ String[] certFilenames = new String[] {
+ "data/test/security/server-certs/baltimore.cer"
+ };
+ KeyStore ks = KeyStoreUtils.createKeyStore("pkcs12", certFilenames);
+ assertEquals(1, ks.size());
+ X509Certificate cert = (X509Certificate)ks.getCertificate("0");
+ assertEquals(3424, cert.getSerialNumber().intValue());
+ }
+ public void testCreateKeyStoreFromCertificateDirectory() throws Exception {
+ // copy certificate files to a temporary directory,
+ // omitting the "CVS" directory in the source directory
+ copyCertificates("data/test/security/server-certs", tmpDir);
+ KeyStore ks = KeyStoreUtils.createKeyStoreFromCertificateDirectory("jks", tmpDirURL);
+ assertEquals(2, ks.size());
+ X509Certificate cert0 = (X509Certificate)ks.getCertificate("0");
+ X509Certificate cert1 = (X509Certificate)ks.getCertificate("1");
+ assertTrue(3424 == cert0.getSerialNumber().intValue() || 3424 == cert1.getSerialNumber().intValue());
+ }
+ private void copyCertificates(String from, String to) throws IOException {
+ String[] fromList = new File(from).list();
+ for (int i = 0; i < fromList.length; i++) {
+ File fromFile = new File(from + File.separator + fromList[i]);
+ if (fromFile.isFile()) {
+ String toFile = to + "/" + fromList[i];
+ FileInputStream in = new FileInputStream(fromFile);
+ FileOutputStream out = new FileOutputStream(toFile);
+ for (int ch = in.read(); ch >= 0; ch = in.read())
+ out.write(ch);
+ out.close();
+ in.close();
+ }
+ }
+
+ }
+ public void testLoadKeyStore() throws Exception {
+ String keyStoreURL = "file:data/test/security/client-certs/sicher-demo(buergerkarte).p12";
+ KeyStore ks = KeyStoreUtils.loadKeyStore("pkcs12", keyStoreURL, "buergerkarte");
+ assertEquals(1, ks.size());
+ Enumeration enum = ks.aliases();
+ String alias = (String)enum.nextElement();
+ X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
+ assertEquals(new BigInteger("1044289238331").intValue(), cert.getSerialNumber().intValue());
+ }
+
+}
diff --git a/common/src/test/at/gv/egovernment/moa/util/SSLUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/SSLUtilsTest.java
new file mode 100644
index 000000000..7e55cb7d0
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/util/SSLUtilsTest.java
@@ -0,0 +1,160 @@
+package test.at.gv.egovernment.moa.util;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.security.KeyStore;
+import java.security.Security;
+
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLSocketFactory;
+
+import com.sun.net.ssl.HostnameVerifier;
+import com.sun.net.ssl.HttpsURLConnection;
+
+import at.gv.egovernment.moa.util.KeyStoreUtils;
+import at.gv.egovernment.moa.util.SSLUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class SSLUtilsTest extends TestCase {
+
+ public SSLUtilsTest(String arg0) {
+ super(arg0);
+ }
+
+
+ protected void setUp() throws Exception {
+ //System.setProperty("javax.net.debug", "all");
+ Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
+ System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
+ System.setProperty("https.cipherSuites", "SSL_DHE_DSS_WITH_DES_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA,SSL_RSA_WITH_DES_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_EXPORT_WITH_RC4_40_MD5");
+ }
+
+ public void testGetSSLSocketFactoryBaltimoreOK() throws Exception {
+ doTestGetSSLSocketFactory(
+ "GET",
+ "https://www.baltimore.com/",
+ false,
+ "file:data/test/security/cacerts+gt_cybertrust_root",
+ "changeit",
+ true);
+ }
+ public void testGetSSLSocketFactoryBaltimoreNOK() throws Exception {
+ doTestGetSSLSocketFactory(
+ "GET",
+ "https://www.baltimore.com/",
+ false,
+ "file:data/test/security/cacerts",
+ "changeit",
+ false);
+ }
+ public void testGetSSLSocketFactoryVerisignOK() throws Exception {
+ doTestGetSSLSocketFactory(
+ "GET",
+ "https://www.verisign.com/",
+ false,
+ "file:data/test/security/cacerts",
+ "changeit",
+ true);
+ }
+ public void testGetSSLSocketFactoryVerisignNoTruststoreOK() throws Exception {
+ doTestGetSSLSocketFactory(
+ "GET",
+ "https://www.verisign.com/",
+ false,
+ null,
+ null,
+ true);
+ }
+ public void testGetSSLSocketFactoryLocalhostOK() throws Exception {
+ String urlString = "https://localhost:8443/moa-id-auth/index.jsp";
+ doTestGetSSLSocketFactory(
+ "GET",
+ urlString,
+ true,
+ "file:data/test/security/server.keystore.tomcat",
+ "changeit",
+ true);
+ }
+ public void testGetSSLSocketFactoryLocalhostNOK() throws Exception {
+ String urlString = "https://localhost:8443/moa-id-auth/index.jsp";
+ doTestGetSSLSocketFactory(
+ "GET",
+ urlString,
+ true,
+ null,
+ null,
+ false);
+ }
+
+ public void doTestGetSSLSocketFactory(
+ String requestMethod,
+ String urlString,
+ boolean useHostnameVerifierHack,
+ String truststoreurl,
+ String trustpassword,
+ boolean shouldOk
+ ) throws Exception {
+
+ doTestGetSSLSocketFactory(
+ requestMethod, urlString, useHostnameVerifierHack, truststoreurl, trustpassword, null, null, null, shouldOk);
+ }
+ public void doTestGetSSLSocketFactory(
+ String requestMethod,
+ String urlString,
+ boolean useHostnameVerifierHack,
+ String truststoreurl,
+ String trustpassword,
+ String keystoretype,
+ String keystoreurl,
+ String keypassword,
+ boolean shouldOk
+ ) throws Exception {
+
+ KeyStore truststore = null;
+ if (truststoreurl != null)
+ truststore = KeyStoreUtils.loadKeyStore("jks", truststoreurl, trustpassword);
+ SSLSocketFactory sf = SSLUtils.getSSLSocketFactory(
+ truststore, keystoretype, keystoreurl, keypassword);
+ System.out.println(requestMethod + " " + urlString);
+
+ URL url = new URL(urlString);
+ HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
+ conn.setRequestMethod(requestMethod);
+ conn.setDoInput(true);
+ conn.setDoOutput(true);
+ conn.setUseCaches(false);
+ conn.setAllowUserInteraction(false);
+ conn.setSSLSocketFactory(sf);
+ if (useHostnameVerifierHack)
+ conn.setHostnameVerifier(new HostnameVerifierHack());
+ try {
+ conn.connect();
+ assertTrue(shouldOk);
+ assertEquals(200, conn.getResponseCode());
+ conn.disconnect();
+ }
+ catch (SSLException ex) {
+ assertFalse(shouldOk);
+ }
+ }
+ private byte[] readTruststore(String filename) throws IOException {
+ if (filename == null)
+ return null;
+ FileInputStream in = new FileInputStream(filename);
+ byte[] buffer = new byte[in.available()];
+ in.read(buffer);
+ in.close();
+ return buffer;
+ }
+ private class HostnameVerifierHack implements HostnameVerifier {
+ public boolean verify(String arg0, String arg1) {
+ return true;
+ }
+ }
+}
diff --git a/common/src/test/at/gv/egovernment/moa/util/URLDecoderTest.java b/common/src/test/at/gv/egovernment/moa/util/URLDecoderTest.java
new file mode 100644
index 000000000..b6ea0e152
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/util/URLDecoderTest.java
@@ -0,0 +1,29 @@
+package test.at.gv.egovernment.moa.util;
+
+import java.net.URLEncoder;
+
+import at.gv.egovernment.moa.util.FileUtils;
+import at.gv.egovernment.moa.util.URLDecoder;
+
+import junit.framework.TestCase;
+
+/*
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class URLDecoderTest extends TestCase {
+
+ public void test() throws Exception {
+ String s = "immerZUA0129<>%==$$%&/()@?{()=} \\\"äöüÄÖÜ?§";
+ String senc = URLEncoder.encode(s);
+ String sdec = URLDecoder.decode(senc, "ISO-8859-1");
+ assertEquals(s, sdec);
+ }
+ public void testUTF8() throws Exception {
+ String s = new String(FileUtils.readFile("data/test/xml/CreateXMLSignature/CreateXMLSignatureResponse.xml"));
+ String senc = URLEncoder.encode(s);
+ String sdec = URLDecoder.decode(senc, "UTF-8");
+ String sutf8 = FileUtils.readFile("data/test/xml/CreateXMLSignature/CreateXMLSignatureResponse.xml", "UTF-8");
+ assertEquals(sutf8, sdec);
+ }
+}
diff --git a/common/src/test/at/gv/egovernment/moa/util/URLEncoderTest.java b/common/src/test/at/gv/egovernment/moa/util/URLEncoderTest.java
new file mode 100644
index 000000000..43238c51f
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/util/URLEncoderTest.java
@@ -0,0 +1,43 @@
+package test.at.gv.egovernment.moa.util;
+
+import at.gv.egovernment.moa.util.FileUtils;
+import at.gv.egovernment.moa.util.URLDecoder;
+import at.gv.egovernment.moa.util.URLEncoder;
+import junit.framework.TestCase;
+
+/*
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class URLEncoderTest extends TestCase {
+
+ public void testUnchangedString() throws Exception {
+ String s = "AZaz0123456789.-*_";
+ String senc = URLEncoder.encode(s, "UTF-8");
+ assertEquals(s, senc);
+ }
+ public void testAumlUTF8() throws Exception {
+ String s = "ä";
+ String senc = URLEncoder.encode(s, "UTF-8");
+ assertEquals("%C3%A4", senc);
+ }
+ public void testEncodeDecode() throws Exception {
+ String s = "AZaz09.-*_ <>%=$%&/()@?{}[]\\\"'äöüÄÖÜß§";
+ String senc = URLEncoder.encode(s, "UTF-8");
+ String sdec = URLDecoder.decode(senc, "UTF-8");
+ assertEquals(s, sdec);
+ }
+ public void testCertInfo() throws Exception {
+ String s = new String(FileUtils.readFile("data/test/xml/VerifyXMLSignature/CertInfoVerifyXMLSignatureRequest.xml", "UTF-8"));
+ String senc = URLEncoder.encode(s, "UTF-8");
+ String sdec = URLDecoder.decode(senc, "UTF-8");
+ assertEquals(s, sdec);
+ }
+ /*public void testJDK14() throws Exception {
+ String s = new String(FileUtils.readFile("data/test/xml/VerifyXMLSignature/CertInfoVerifyXMLSignatureRequest.xml", "UTF-8"));
+ String senc = URLEncoder.encode(s, "UTF-8");
+ String senc14 = java.net.URLEncoder.encode(s, "UTF-8");
+ assertEquals(senc, senc14);
+ }*/
+
+}
diff --git a/common/src/test/at/gv/egovernment/moa/util/XMLGrammarBuilderTest.java b/common/src/test/at/gv/egovernment/moa/util/XMLGrammarBuilderTest.java
new file mode 100644
index 000000000..7986fe540
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/util/XMLGrammarBuilderTest.java
@@ -0,0 +1,99 @@
+package test.at.gv.egovernment.moa.util;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.xerces.parsers.DOMParser;
+import org.apache.xerces.parsers.XMLGrammarPreparser;
+import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.util.XMLGrammarPoolImpl;
+import org.apache.xerces.xni.grammars.Grammar;
+import org.apache.xerces.xni.grammars.XMLGrammarDescription;
+import org.apache.xerces.xni.parser.XMLInputSource;
+import org.xml.sax.InputSource;
+
+import test.at.gv.egovernment.moa.MOATestCase;
+
+import at.gv.egovernment.moa.util.Constants;
+
+
+/**
+ * Experimentation with Xerces grammar caching.
+ *
+ * Used the Xerces sample 'XMLGrammarBuilder' as a starting point.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class XMLGrammarBuilderTest extends MOATestCase {
+
+ private static final String GRAMMAR_POOL =
+ org.apache.xerces.impl.Constants.XERCES_PROPERTY_PREFIX
+ + org.apache.xerces.impl.Constants.XMLGRAMMAR_POOL_PROPERTY;
+
+ protected static final String NAMESPACES_FEATURE_ID =
+ "http://xml.org/sax/features/namespaces";
+ protected static final String VALIDATION_FEATURE_ID =
+ "http://xml.org/sax/features/validation";
+ protected static final String SCHEMA_VALIDATION_FEATURE_ID =
+ "http://apache.org/xml/features/validation/schema";
+ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
+ "http://apache.org/xml/features/validation/schema-full-checking";
+
+ private static final int BIG_PRIME = 2039;
+ private SymbolTable symbolTable;
+ private XMLGrammarPoolImpl grammarPool;
+
+ /**
+ * Constructor for XMLGrammarBuilderTest.
+ * @param name
+ */
+ public XMLGrammarBuilderTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ XMLGrammarPreparser preparser;
+
+ // set up symbol table and grammar pool
+ symbolTable = new SymbolTable(BIG_PRIME);
+ grammarPool = new XMLGrammarPoolImpl();
+ preparser = new XMLGrammarPreparser(symbolTable);
+ preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
+ preparser.setProperty(GRAMMAR_POOL, grammarPool);
+ preparser.setFeature(NAMESPACES_FEATURE_ID, true);
+ preparser.setFeature(VALIDATION_FEATURE_ID, true);
+ // now we can still do schema features just in case,
+ // so long as it's our configuraiton......
+ preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
+ preparseSchemaResource(
+ preparser,
+ Constants.DSIG_SCHEMA_LOCATION,
+ "/resources/schemas/xmldsig-core-schema.xsd");
+ }
+
+ private static Grammar preparseSchemaResource(
+ XMLGrammarPreparser preparser,
+ String systemId,
+ String resource)
+ throws Exception {
+
+ InputStream is = XMLGrammarBuilderTest.class.getResourceAsStream(resource);
+ return preparser.preparseGrammar(
+ XMLGrammarDescription.XML_SCHEMA,
+ new XMLInputSource(null, systemId, null, is, null));
+ }
+
+ public void testParseValidating() throws Exception {
+ DOMParser parser = new DOMParser(symbolTable, grammarPool);
+
+ parser.setFeature(NAMESPACES_FEATURE_ID, true);
+ parser.setFeature(VALIDATION_FEATURE_ID, true);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
+
+ parser.parse(
+ new InputSource(
+ new FileInputStream(TESTDATA_ROOT + "xml/dsigTransform/base64.xml")));
+ parser.getDocument();
+ }
+
+}
diff --git a/common/src/test/at/gv/egovernment/moa/util/XPathUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/XPathUtilsTest.java
new file mode 100644
index 000000000..559494300
--- /dev/null
+++ b/common/src/test/at/gv/egovernment/moa/util/XPathUtilsTest.java
@@ -0,0 +1,51 @@
+package test.at.gv.egovernment.moa.util;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+import test.at.gv.egovernment.moa.MOATestCase;
+
+import at.gv.egovernment.moa.util.XPathUtils;
+
+
+/**
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class XPathUtilsTest extends MOATestCase {
+
+ private Document doc1;
+
+ /**
+ * Constructor for XPathUtilsTest.
+ * @param name
+ */
+ public XPathUtilsTest(String name) {
+ super(name);
+ }
+
+ /**
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ doc1 =
+ parseXml(TESTDATA_ROOT + "xml/VerifyXMLSignature/Req000.xml");
+ }
+
+ public void testSelectNodeList() throws Exception {
+ NodeList nodes;
+
+ nodes =
+ XPathUtils.selectNodeList(
+ doc1.getDocumentElement(),
+ doc1.getDocumentElement(),
+ "/VerifyXMLSignatureRequest");
+ assertEquals(1, nodes.getLength());
+ nodes =
+ XPathUtils.selectNodeList(
+ doc1.getDocumentElement(),
+ "//dsig:Signature");
+ assertEquals(1, nodes.getLength());
+ }
+
+}
--
cgit v1.2.3
From b1f795dce3d7a371e018c4933423ccd00ef74eab Mon Sep 17 00:00:00 2001
From: rudolf
Date: Mon, 20 Oct 2003 14:46:06 +0000
Subject: added lockPool method
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@16 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/DOMUtils.java | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
index 6da99037e..8e6394445 100644
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -89,6 +89,10 @@ public class DOMUtils {
private static SymbolTable symbolTable = new SymbolTable(BIG_PRIME);
/** Xerces schema grammar pool. */
private static XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
+
+ static {
+ grammarPool.lockPool();
+ }
/**
* Preparse a schema and add it to the schema pool.
--
cgit v1.2.3
From 69561539a64141e5ed23c4d042fc0c00a17c2bef Mon Sep 17 00:00:00 2001
From: gregor
Date: Fri, 7 Nov 2003 17:58:36 +0000
Subject: Bug 19 behoben.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@41 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/Constants.java | 15 +++++++++++++++
.../moa/spss/server/service/SignatureCreationService.java | 7 +++++--
2 files changed, 20 insertions(+), 2 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index 681bed55b..df7c843d1 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -215,4 +215,19 @@ public interface Constants {
/** URI of the Exclusive Canonical XML with commments algorithm */
public static final String EXC_C14N_WITH_COMMENTS_URI =
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments";
+
+ //
+ // Local names for elements of the MOA SPSS schema
+ //
+
+ /**
+ * Local name of request for creating an XML signature.
+ */
+ public static final String MOA_SPSS_CREATE_XML_REQUEST = "CreateXMLSignatureRequest";
+
+ /**
+ * Local name of request for verifying an XML signature.
+ */
+ public static final String MOA_SPSS_VERIFY_XML_REQUEST = "VerifiyXMLSignatureRequest";
+
}
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/service/SignatureCreationService.java b/spss.server/src/at/gv/egovernment/moa/spss/server/service/SignatureCreationService.java
index 07d7ab371..271d85f6d 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/service/SignatureCreationService.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/server/service/SignatureCreationService.java
@@ -16,6 +16,7 @@ import at.gv.egovernment.moa.spss.api.xmlbind.CreateXMLSignatureResponseBuilder;
import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest;
import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureResponse;
import at.gv.egovernment.moa.spss.server.invoke.XMLSignatureCreationInvoker;
+import at.gv.egovernment.moa.util.Constants;
/**
* The service endpoint for the SignatureCreation web service.
@@ -42,9 +43,11 @@ public class SignatureCreationService {
// check that we have a CreateXMLSignatureRequest; if not, create an
// AxisFault, just like the org.apache.axis.providers.java.MsgProvider
- if (request[0].getNodeName() != "CreateXMLSignatureRequest") {
+ if (!Constants.MOA_SPSS_CREATE_XML_REQUEST.equals(request[0].getLocalName()) ||
+ !Constants.MOA_NS_URI.equals(request[0].getNamespaceURI()))
+ {
QName qname =
- new QName(request[0].getNamespaceURI(), request[0].getNodeName());
+ new QName(request[0].getNamespaceURI(), request[0].getLocalName());
throw new AxisFault(
Messages.getMessage("noOperationForQName", qname.toString()));
}
--
cgit v1.2.3
From bc620256eb9b4dc6a33244b1105e58773358dbe6 Mon Sep 17 00:00:00 2001
From: gregor
Date: Tue, 11 Nov 2003 22:12:44 +0000
Subject: Feature 41 implementiert.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@50 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/res/resources/schemas/MOA-SPSS-1.2.xsd | 444 +++++++++++++++++++++
.../src/at/gv/egovernment/moa/util/Constants.java | 2 +-
spss.server/.cvsignore | 1 +
spss.server/build.xml | 4 +-
spss.server/doc/moa_spss/MOA-SPSS-1.2.xsd | 444 +++++++++++++++++++++
.../properties/spss_messages_de.properties | 5 +
spss.server/res/resources/wsdl/MOA-SPSS-1.2.wsdl | 105 +++++
spss.server/res/resources/wsdl/MOA-SPSS-1.2.xsd | 444 +++++++++++++++++++++
spss.server/server-config.wsdd | 7 +-
.../gv/egovernment/moa/spss/api/SPSSFactory.java | 17 +
.../egovernment/moa/spss/api/common/Content.java | 14 +-
.../moa/spss/api/common/ContentLocRef.java | 17 +
.../moa/spss/api/impl/ContentLocRefImpl.java | 44 ++
.../moa/spss/api/impl/SPSSFactoryImpl.java | 7 +
.../moa/spss/api/xmlbind/RequestParserUtils.java | 11 +-
.../moa/spss/server/invoke/DataObjectFactory.java | 146 +++++--
.../moa/spss/server/service/AxisHandler.java | 2 +-
17 files changed, 1671 insertions(+), 43 deletions(-)
create mode 100644 common/res/resources/schemas/MOA-SPSS-1.2.xsd
create mode 100644 spss.server/doc/moa_spss/MOA-SPSS-1.2.xsd
create mode 100644 spss.server/res/resources/wsdl/MOA-SPSS-1.2.wsdl
create mode 100644 spss.server/res/resources/wsdl/MOA-SPSS-1.2.xsd
create mode 100644 spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentLocRef.java
create mode 100644 spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentLocRefImpl.java
(limited to 'common/src')
diff --git a/common/res/resources/schemas/MOA-SPSS-1.2.xsd b/common/res/resources/schemas/MOA-SPSS-1.2.xsd
new file mode 100644
index 000000000..b1b89bc30
--- /dev/null
+++ b/common/res/resources/schemas/MOA-SPSS-1.2.xsd
@@ -0,0 +1,444 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ermöglichung der Stapelsignatur durch wiederholte Angabe dieses Elements
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Auswahl: Entweder explizite Angabe des Signaturorts sowie ggf. sinnvoller Supplements im Zshg. mit der Signaturumgebung, oder Verweis auf ein benanntes Profil
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Kardinalität 1..oo erlaubt die Antwort auf eine Stapelsignatur-Anfrage
+
+
+
+ Resultat, falls die Signaturerstellung erfolgreich war
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ mit diesem Profil wird eine Menge von vertrauenswürdigen Wurzelzertifikaten spezifiziert
+
+
+
+
+
+
+
+
+
+
+ only ds:X509Data and RetrievalMethod is supported; QualifiedCertificate is included as X509Data/any;publicAuthority is included as X509Data/any
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Pro dsig:Reference-Element in der zu überprüfenden XML-Signatur muss hier ein ReferenceInfo-Element erscheinen. Die Reihenfolge der einzelnen ReferenceInfo Elemente entspricht jener der dsig:Reference Elemente in der XML-Signatur.
+
+
+
+
+
+
+
+
+
+ mit diesem Profil wird eine Menge von vertrauenswürdigen Wurzelzertifikaten spezifiziert
+
+
+
+
+
+
+
+
+
+
+ only ds:X509Data and ds:RetrievalMethod is supported; QualifiedCertificate is included as X509Data/any; PublicAuthority is included as X509Data/any
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Auswahl: Entweder explizite Angabe EINER Transformationskette inklusive ggf. sinnvoller Supplements oder Verweis auf ein benanntes Profil
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Resultat, falls die Signaturerstellung gescheitert ist
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ein oder mehrere Transformationswege können von der Applikation an MOA mitgeteilt werden. Die zu prüfende Signatur hat zumindest einem dieser Transformationswege zu entsprechen. Die Angabe kann explizit oder als Profilbezeichner erfolgen.
+
+
+
+
+ Profilbezeichner für einen Transformationsweg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Die Angabe des Transformationsparameters (explizit oder als Hashwert) kann unterlassen werden, wenn die Applikation von der Unveränderlichkeit des Inhalts der in "Transformationsparamter", Attribut "URI" angegebenen URI ausgehen kann.
+
+
+
+ Der Transformationsparameter explizit angegeben.
+
+
+
+
+ Der Hashwert des Transformationsparameters.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Explizite Angabe des Transformationswegs
+
+
+
+
+
+
+ Alle impliziten Transformationsparameter, die zum Durchlaufen der oben angeführten Transformationskette bekannt sein müssen, müssen hier angeführt werden. Das Attribut "URI" bezeichnet den Transformationsparameter in exakt jener Weise, wie er in der zu überprüfenden Signatur gebraucht wird.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index df7c843d1..77a830c76 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -19,7 +19,7 @@ public interface Constants {
/** Local location of the MOA XML schema definition. */
public static final String MOA_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-SPSS-1.1.xsd";
+ SCHEMA_ROOT + "MOA-SPSS-1.2.xsd";
/** URI of the MOA configuration XML namespace. */
public static final String MOA_CONFIG_NS_URI =
diff --git a/spss.server/.cvsignore b/spss.server/.cvsignore
index 7c18d5ded..795bc497e 100644
--- a/spss.server/.cvsignore
+++ b/spss.server/.cvsignore
@@ -1,2 +1,3 @@
bin
tmp
+releases
diff --git a/spss.server/build.xml b/spss.server/build.xml
index 17408cb10..c0021a96d 100644
--- a/spss.server/build.xml
+++ b/spss.server/build.xml
@@ -11,7 +11,7 @@
-
+
@@ -118,7 +118,7 @@
-
+
diff --git a/spss.server/doc/moa_spss/MOA-SPSS-1.2.xsd b/spss.server/doc/moa_spss/MOA-SPSS-1.2.xsd
new file mode 100644
index 000000000..b1b89bc30
--- /dev/null
+++ b/spss.server/doc/moa_spss/MOA-SPSS-1.2.xsd
@@ -0,0 +1,444 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ermöglichung der Stapelsignatur durch wiederholte Angabe dieses Elements
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Auswahl: Entweder explizite Angabe des Signaturorts sowie ggf. sinnvoller Supplements im Zshg. mit der Signaturumgebung, oder Verweis auf ein benanntes Profil
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Kardinalität 1..oo erlaubt die Antwort auf eine Stapelsignatur-Anfrage
+
+
+
+ Resultat, falls die Signaturerstellung erfolgreich war
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ mit diesem Profil wird eine Menge von vertrauenswürdigen Wurzelzertifikaten spezifiziert
+
+
+
+
+
+
+
+
+
+
+ only ds:X509Data and RetrievalMethod is supported; QualifiedCertificate is included as X509Data/any;publicAuthority is included as X509Data/any
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Pro dsig:Reference-Element in der zu überprüfenden XML-Signatur muss hier ein ReferenceInfo-Element erscheinen. Die Reihenfolge der einzelnen ReferenceInfo Elemente entspricht jener der dsig:Reference Elemente in der XML-Signatur.
+
+
+
+
+
+
+
+
+
+ mit diesem Profil wird eine Menge von vertrauenswürdigen Wurzelzertifikaten spezifiziert
+
+
+
+
+
+
+
+
+
+
+ only ds:X509Data and ds:RetrievalMethod is supported; QualifiedCertificate is included as X509Data/any; PublicAuthority is included as X509Data/any
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Auswahl: Entweder explizite Angabe EINER Transformationskette inklusive ggf. sinnvoller Supplements oder Verweis auf ein benanntes Profil
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Resultat, falls die Signaturerstellung gescheitert ist
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ein oder mehrere Transformationswege können von der Applikation an MOA mitgeteilt werden. Die zu prüfende Signatur hat zumindest einem dieser Transformationswege zu entsprechen. Die Angabe kann explizit oder als Profilbezeichner erfolgen.
+
+
+
+
+ Profilbezeichner für einen Transformationsweg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Die Angabe des Transformationsparameters (explizit oder als Hashwert) kann unterlassen werden, wenn die Applikation von der Unveränderlichkeit des Inhalts der in "Transformationsparamter", Attribut "URI" angegebenen URI ausgehen kann.
+
+
+
+ Der Transformationsparameter explizit angegeben.
+
+
+
+
+ Der Hashwert des Transformationsparameters.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Explizite Angabe des Transformationswegs
+
+
+
+
+
+
+ Alle impliziten Transformationsparameter, die zum Durchlaufen der oben angeführten Transformationskette bekannt sein müssen, müssen hier angeführt werden. Das Attribut "URI" bezeichnet den Transformationsparameter in exakt jener Weise, wie er in der zu überprüfenden Signatur gebraucht wird.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spss.server/res/resources/properties/spss_messages_de.properties b/spss.server/res/resources/properties/spss_messages_de.properties
index cab226a82..f98a6f84c 100644
--- a/spss.server/res/resources/properties/spss_messages_de.properties
+++ b/spss.server/res/resources/properties/spss_messages_de.properties
@@ -77,9 +77,14 @@
2270=Fehler beim Decodieren des Hash-Wertes
2271=Falsche Anzahl an ReferenceInfo Elementen in SignatureManfestCheckParams
2280=Die Angabe XMLContent wird derzeit nicht unterstützt
+2281=XML-Supplement kann nicht serialisiert werden (Reference="{0}")
2900=Interner Server-Fehler
+3201=Objekt kann nicht geladen werden (Reference="{0}", LocRef-URI="{0}")
+3202=Supplement für Signaturumgebung kann nicht geladen werden (Reference="{0}", LocRef-URI="{0}")
+3203=Signaturumgebung kann nicht geladen werden (Reference="{0}", LocRef-URI="{0}")
+
9900=Nicht klassifizierter Fehler in Subsystem
9901=Nicht klassifizierter Laufzeitfehler in Subsystem
9999=Nicht klassifizierter Fehler
diff --git a/spss.server/res/resources/wsdl/MOA-SPSS-1.2.wsdl b/spss.server/res/resources/wsdl/MOA-SPSS-1.2.wsdl
new file mode 100644
index 000000000..b3f252562
--- /dev/null
+++ b/spss.server/res/resources/wsdl/MOA-SPSS-1.2.wsdl
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spss.server/res/resources/wsdl/MOA-SPSS-1.2.xsd b/spss.server/res/resources/wsdl/MOA-SPSS-1.2.xsd
new file mode 100644
index 000000000..b1b89bc30
--- /dev/null
+++ b/spss.server/res/resources/wsdl/MOA-SPSS-1.2.xsd
@@ -0,0 +1,444 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ermöglichung der Stapelsignatur durch wiederholte Angabe dieses Elements
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Auswahl: Entweder explizite Angabe des Signaturorts sowie ggf. sinnvoller Supplements im Zshg. mit der Signaturumgebung, oder Verweis auf ein benanntes Profil
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Kardinalität 1..oo erlaubt die Antwort auf eine Stapelsignatur-Anfrage
+
+
+
+ Resultat, falls die Signaturerstellung erfolgreich war
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ mit diesem Profil wird eine Menge von vertrauenswürdigen Wurzelzertifikaten spezifiziert
+
+
+
+
+
+
+
+
+
+
+ only ds:X509Data and RetrievalMethod is supported; QualifiedCertificate is included as X509Data/any;publicAuthority is included as X509Data/any
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Pro dsig:Reference-Element in der zu überprüfenden XML-Signatur muss hier ein ReferenceInfo-Element erscheinen. Die Reihenfolge der einzelnen ReferenceInfo Elemente entspricht jener der dsig:Reference Elemente in der XML-Signatur.
+
+
+
+
+
+
+
+
+
+ mit diesem Profil wird eine Menge von vertrauenswürdigen Wurzelzertifikaten spezifiziert
+
+
+
+
+
+
+
+
+
+
+ only ds:X509Data and ds:RetrievalMethod is supported; QualifiedCertificate is included as X509Data/any; PublicAuthority is included as X509Data/any
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Auswahl: Entweder explizite Angabe EINER Transformationskette inklusive ggf. sinnvoller Supplements oder Verweis auf ein benanntes Profil
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Resultat, falls die Signaturerstellung gescheitert ist
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ein oder mehrere Transformationswege können von der Applikation an MOA mitgeteilt werden. Die zu prüfende Signatur hat zumindest einem dieser Transformationswege zu entsprechen. Die Angabe kann explizit oder als Profilbezeichner erfolgen.
+
+
+
+
+ Profilbezeichner für einen Transformationsweg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Die Angabe des Transformationsparameters (explizit oder als Hashwert) kann unterlassen werden, wenn die Applikation von der Unveränderlichkeit des Inhalts der in "Transformationsparamter", Attribut "URI" angegebenen URI ausgehen kann.
+
+
+
+ Der Transformationsparameter explizit angegeben.
+
+
+
+
+ Der Hashwert des Transformationsparameters.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Explizite Angabe des Transformationswegs
+
+
+
+
+
+
+ Alle impliziten Transformationsparameter, die zum Durchlaufen der oben angeführten Transformationskette bekannt sein müssen, müssen hier angeführt werden. Das Attribut "URI" bezeichnet den Transformationsparameter in exakt jener Weise, wie er in der zu überprüfenden Signatur gebraucht wird.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spss.server/server-config.wsdd b/spss.server/server-config.wsdd
index 1f5f83ae5..fee506cb2 100644
--- a/spss.server/server-config.wsdd
+++ b/spss.server/server-config.wsdd
@@ -1,4 +1,7 @@
+
@@ -29,7 +32,7 @@
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/SPSSFactory.java b/spss.server/src/at/gv/egovernment/moa/spss/api/SPSSFactory.java
index 178a45273..dfa8927e1 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/api/SPSSFactory.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/api/SPSSFactory.java
@@ -57,6 +57,7 @@ import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse;
* this instance, concrete MOA SP/SS API object can be created.
*
* @author Patrick Peck
+ * @author Gregor Karlinger
* @version $Id$
*/
public abstract class SPSSFactory {
@@ -778,6 +779,22 @@ public abstract class SPSSFactory {
InputStream binaryData,
String referenceURI);
+ /**
+ * Create a new Content object containing location reference data.
+ *
+ * @param locationReferenceURI a URI pointing to the actual remote location of the content.
+ *
+ * @param referenceURI An URI identifying the data. May be null.
+ *
+ * @return The Content object containing the data.
+ *
+ * @pre locationReferenceURI != null
+ * @post return != null
+ */
+ public abstract Content createContent(
+ String locationReferenceURI,
+ String referenceURI);
+
/**
* Create a new Content object containing XML data.
*
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/Content.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/Content.java
index 173e9d395..0777c3d65 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/api/common/Content.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/Content.java
@@ -5,29 +5,39 @@ package at.gv.egovernment.moa.spss.api.common;
*
* @author Patrick Peck
* @author Stephan Grill
+ * @author Gregor Karlinger
* @version $Id$
*/
public interface Content {
+
/**
* Indicates that this object contains a URI reference to some content.
*/
public static final int REFERENCE_CONTENT = 0;
+
/**
* Indicates that this object contains binary content.
*/
public static final int BINARY_CONTENT = 1;
+
/**
* Indicates that this object contains XML content.
*/
public static final int XML_CONTENT = 2;
+
+ /**
+ * Indicates that this object contains a location reference content.
+ */
+ public static final int LOCREF_CONTENT = 3;
/**
* Gets the type of content contained in this object.
*
- * @return The type of content, either BINARY_CONTENT or
- * XML_CONTENT
+ * @return The type of content, one of BINARY_CONTENT, XML_CONTENT,
+ * REFERENCE_CONTENT or LOCREF_CONTENT.
*/
public int getContentType();
+
/**
* Gets the reference to the content data (a URI).
*
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentLocRef.java b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentLocRef.java
new file mode 100644
index 000000000..f640f2b92
--- /dev/null
+++ b/spss.server/src/at/gv/egovernment/moa/spss/api/common/ContentLocRef.java
@@ -0,0 +1,17 @@
+package at.gv.egovernment.moa.spss.api.common;
+
+/**
+ * Encapsulates location reference content.
+ *
+ * @author Gregor Karlinger
+ * @version $Id$
+ */
+public interface ContentLocRef extends Content
+{
+ /**
+ * Gets the location reference URI pointing to the actual remote location of the content.
+ *
+ * @return the location reference URI.
+ */
+ public String getLocationReferenceURI();
+}
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentLocRefImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentLocRefImpl.java
new file mode 100644
index 000000000..902f7bd72
--- /dev/null
+++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/ContentLocRefImpl.java
@@ -0,0 +1,44 @@
+package at.gv.egovernment.moa.spss.api.impl;
+
+import at.gv.egovernment.moa.spss.api.common.ContentLocRef;
+
+/**
+ * Default implementation of ContentLocRef.
+ *
+ * @author Gregor Karlinger
+ * @version $Id$
+ */
+public class ContentLocRefImpl extends ContentImpl implements ContentLocRef
+{
+ /**
+ * The location reference URI pointing to the actual remote location of the content.
+ */
+ private String locationReferenceURI_;
+
+ /**
+ * @see at.gv.egovernment.moa.spss.api.common.ContentLocRef#getLocationReference()
+ */
+ public String getLocationReferenceURI()
+ {
+ return locationReferenceURI_;
+ }
+
+ /**
+ * Sets the location reference URI pointing to the actual remote location of the content.
+ *
+ * @param locationReferenceURI the location reference URI.
+ */
+ public void setLocationReferenceURI(String locationReferenceURI)
+ {
+ locationReferenceURI_ = locationReferenceURI;
+ }
+
+ /**
+ * Gets the type of content.
+ *
+ * @return LOCREF_CONTENT.
+ */
+ public int getContentType() {
+ return LOCREF_CONTENT;
+ }
+}
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SPSSFactoryImpl.java b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SPSSFactoryImpl.java
index ab6240f79..a953c2af3 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SPSSFactoryImpl.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/api/impl/SPSSFactoryImpl.java
@@ -439,6 +439,13 @@ public class SPSSFactoryImpl extends SPSSFactory {
return content;
}
+ public Content createContent(String locationReferenceURI, String referenceURI) {
+ ContentLocRefImpl content = new ContentLocRefImpl();
+ content.setLocationReferenceURI(locationReferenceURI);
+ content.setReference(referenceURI);
+ return content;
+ }
+
public Content createContent(String referenceURI) {
ContentReferenceImpl content = new ContentReferenceImpl();
content.setReference(referenceURI);
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java
index 0fff949b1..a41b14df0 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java
@@ -34,7 +34,7 @@ public class RequestParserUtils {
private static final String DESCRIPTION_XPATH = MOA + "Description";
private static final String XML_ASSOC_CONTENT_XPATH = MOA + "Content";
private static final String CONTENT_XPATH =
- MOA + "Base64Content | " + MOA + "XMLContent";
+ MOA + "Base64Content | " + MOA + "XMLContent |" + MOA + "LocRefContent";
private static final String ANY_OTHER_XPATH =
"*[namespace-uri() != \"" + Constants.MOA_NS_URI + "\"]";
@@ -101,8 +101,15 @@ public class RequestParserUtils {
return factory.createContent(
Base64Utils.decodeToStream(base64String, true),
referenceURI);
+ } else if ("LocRefContent".equals(contentElem.getLocalName())) {
+ String locationReferenceURI = DOMUtils.getText(contentElem);
+ return factory.createContent(
+ locationReferenceURI,
+ referenceURI);
} else { // "XMLContent".equals(contentElem.getLocalName())
- return factory.createContent(contentElem.getChildNodes(), referenceURI);
+ return factory.createContent(
+ contentElem.getChildNodes(),
+ referenceURI);
}
}
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java
index 32c81dc07..6f541ed42 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java
@@ -37,6 +37,7 @@ import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOASystemException;
import at.gv.egovernment.moa.spss.api.common.Content;
import at.gv.egovernment.moa.spss.api.common.ContentBinary;
+import at.gv.egovernment.moa.spss.api.common.ContentLocRef;
import at.gv.egovernment.moa.spss.api.common.ContentXML;
import at.gv.egovernment.moa.spss.api.common.MetaInfo;
import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation;
@@ -54,6 +55,7 @@ import at.gv.egovernment.moa.spss.util.MessageProvider;
* locations of the MOA XML request format.
*
* @author Patrick Peck
+ * @author Gregor Karlinger
* @version $Id$
*/
public class DataObjectFactory {
@@ -128,6 +130,21 @@ public class DataObjectFactory {
contentBytes = StreamUtils.readStream(is);
break;
}
+ case Content.LOCREF_CONTENT:
+ {
+ ExternalURIResolver uriResolver = new ExternalURIResolver();
+ String locRefURI = ((ContentLocRef) content).getLocationReferenceURI();
+ try
+ {
+ InputStream is = uriResolver.resolve(locRefURI);
+ contentBytes = StreamUtils.readStream(is);
+ }
+ catch (MOAApplicationException e)
+ {
+ throw new MOAApplicationException("3203", new Object[]{reference, locRefURI}, e);
+ }
+ break;
+ }
case Content.REFERENCE_CONTENT :
{
ExternalURIResolver uriResolver = new ExternalURIResolver();
@@ -245,7 +262,9 @@ public class DataObjectFactory {
* their reference URI to an InputStream of their respective
* content.
*/
- private static StreamEntityResolver buildSupplementEntityResolver(List supplements) {
+ private static StreamEntityResolver buildSupplementEntityResolver(List supplements)
+ throws MOAApplicationException
+ {
Map entities = new HashMap();
Iterator iter;
@@ -257,31 +276,52 @@ public class DataObjectFactory {
switch (content.getContentType()) {
case Content.BINARY_CONTENT :
- entities.put(reference, ((ContentBinary) content).getBinaryContent());
- break;
+ {
+ entities.put(reference, ((ContentBinary) content).getBinaryContent());
+ break;
+ }
+ case Content.LOCREF_CONTENT:
+ {
+ ExternalURIResolver uriResolver = new ExternalURIResolver();
+ String locRefURI = ((ContentLocRef) content).getLocationReferenceURI();
+ InputStream contentIS = null;
+ try
+ {
+ contentIS = uriResolver.resolve(locRefURI);
+ }
+ catch (MOAApplicationException e)
+ {
+ throw new MOAApplicationException("3202", new Object[]{reference, locRefURI}, e);
+ }
+ entities.put(reference, contentIS);
+ break;
+ }
case Content.XML_CONTENT :
- // serialize the first element node that is found in the supplement
- // and make it available as a stream
- NodeList nodes = ((ContentXML) content).getXMLContent();
- int i = 0;
-
- // find the first element node
- while (i < nodes.getLength()
- && nodes.item(i).getNodeType() != Node.ELEMENT_NODE)
- i++;
-
- // serialize the node
- if (i < nodes.getLength()) {
- try {
- byte[] serialized =
- DOMUtils.serializeNode(nodes.item(i), "UTF-8");
- entities.put(reference, new ByteArrayInputStream(serialized));
- } catch (Exception e) {
- // serializing the element failed - just don't put it in the map
+ {
+ // serialize the first element node that is found in the supplement
+ // and make it available as a stream
+ NodeList nodes = ((ContentXML) content).getXMLContent();
+ int i = 0;
+
+ // find the first element node
+ while (i < nodes.getLength()
+ && nodes.item(i).getNodeType() != Node.ELEMENT_NODE)
+ i++;
+
+ // serialize the node
+ if (i < nodes.getLength()) {
+ try
+ {
+ byte[] serialized = DOMUtils.serializeNode(nodes.item(i), "UTF-8");
+ entities.put(reference, new ByteArrayInputStream(serialized));
+ }
+ catch (Exception e)
+ {
+ throw new MOAApplicationException("2282", new Object[]{reference}, e);
+ }
}
+ break;
}
-
- break;
}
}
@@ -336,22 +376,42 @@ public class DataObjectFactory {
checkAllowContentAndReference(content, allowContentAndReference);
// ok, build the data object; use content first, if available
- switch (content.getContentType()) {
+ switch (content.getContentType())
+ {
case Content.XML_CONTENT :
+ {
ContentXML contentXml = (ContentXML) content;
dataObject = createFromXmlContent(contentXml, xmlAsNodeList);
break;
+ }
case Content.BINARY_CONTENT :
+ {
ContentBinary contentBinary = (ContentBinary) content;
dataObject = createFromBinaryContent(contentBinary, binaryAsXml, false);
break;
+ }
+ case Content.LOCREF_CONTENT :
+ {
+ String locRefURI = ((ContentLocRef) content).getLocationReferenceURI();
+ try
+ {
+ dataObject = createFromURIImpl(locRefURI, referenceAsXml);
+ }
+ catch (MOAApplicationException e)
+ {
+ throw new MOAApplicationException("3201", new Object[]{reference, locRefURI}, e);
+ }
+ break;
+ }
case Content.REFERENCE_CONTENT :
+ {
dataObject = createFromURIImpl(reference, referenceAsXml);
break;
+ }
}
// set URI and reference ID
- dataObject.setURI(content.getReference());
+ dataObject.setURI(reference);
dataObject.setReferenceID(referenceID);
return dataObject;
@@ -417,21 +477,41 @@ public class DataObjectFactory {
String mimeType = metaInfo != null ? metaInfo.getMimeType() : null;
DataObjectImpl dataObject = null;
- switch (content.getContentType()) {
+ switch (content.getContentType())
+ {
case Content.XML_CONTENT :
- if (xmlContentAllowed) {
+ {
+ if (xmlContentAllowed)
+ {
dataObject = createFromXmlContent((ContentXML) content, true);
- } else {
+ }
+ else
+ {
throw new MOAApplicationException("2280", null);
}
break;
+ }
case Content.BINARY_CONTENT :
- dataObject =
- createFromBinaryContent(
- (ContentBinary) content,
- false,
- binaryContentRepeatable);
+ {
+ dataObject = createFromBinaryContent(
+ (ContentBinary) content,
+ false,
+ binaryContentRepeatable);
+ break;
+ }
+ case Content.LOCREF_CONTENT :
+ {
+ String locRefURI = ((ContentLocRef) content).getLocationReferenceURI();
+ try
+ {
+ dataObject = createFromURIImpl(locRefURI, false);
+ }
+ catch (MOAApplicationException e)
+ {
+ throw new MOAApplicationException("3201", new Object[]{content.getReference(), locRefURI}, e);
+ }
break;
+ }
}
dataObject.setURI(content.getReference());
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/service/AxisHandler.java b/spss.server/src/at/gv/egovernment/moa/spss/server/service/AxisHandler.java
index 19e5aa9fa..64bbb8dbe 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/service/AxisHandler.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/server/service/AxisHandler.java
@@ -44,7 +44,7 @@ import at.gv.egovernment.moa.spss.util.MessageProvider;
public class AxisHandler extends BasicHandler {
/** The resource names of the messages to load. */
- private static final String MOA_SPSS_WSDL_RESOURCE_ = "/resources/wsdl/MOA-SPSS-1.1.wsdl";
+ private static final String MOA_SPSS_WSDL_RESOURCE_ = "/resources/wsdl/MOA-SPSS-1.2.wsdl";
/** The property name for accessing the HTTP request. */
private static final String REQUEST_PROPERTY = HTTPConstants.MC_HTTP_SERVLETREQUEST;
--
cgit v1.2.3
From 55e33b147723d68223f31994125b6364cb808bb1 Mon Sep 17 00:00:00 2001
From: rudolf
Date: Mon, 1 Dec 2003 10:42:06 +0000
Subject: added makeAbsoluteURI (RSCH)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@66 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/FileUtils.java | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/FileUtils.java b/common/src/at/gv/egovernment/moa/util/FileUtils.java
index f8941568d..bb21f4ca0 100644
--- a/common/src/at/gv/egovernment/moa/util/FileUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/FileUtils.java
@@ -4,6 +4,8 @@ import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
/**
@@ -84,4 +86,26 @@ public class FileUtils {
byte[] content = readResource(name);
return new String(content, encoding);
}
+
+ /**
+ * Returns the absolute URL of a given url which is relative to the parameter root
+ * @param url
+ * @param root
+ * @return String
+ */
+ public static String makeAbsoluteURL(String url, String root) {
+ //if url is relative to rootConfigFileDirName make it absolute
+ try {
+ if(null == url) return null;
+ URI uri = new URI(url);
+ if (!uri.isAbsolute()) { // make it absolute to the config file
+ uri = new URI(root + url);
+ }
+ return uri.toString();
+ } catch (URISyntaxException e) {
+ //if url string could not be converted to absolute URL return source url
+ return url;
+ }
+ }
+
}
--
cgit v1.2.3
From 98bbfa11070a62956d7e2663a82f19fd048d1d5e Mon Sep 17 00:00:00 2001
From: rudolf
Date: Thu, 18 Dec 2003 19:19:09 +0000
Subject: MOAIdentities wird von XMLLoginParameterResolver verwendet
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@77 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../resources/schemas/MOA-ID-Configuration-1.1.xsd | 110 ++++++++++++++-------
common/res/resources/schemas/MOAIdentities.xsd | 46 +++++++++
.../src/at/gv/egovernment/moa/util/FileUtils.java | 27 ++---
3 files changed, 136 insertions(+), 47 deletions(-)
create mode 100644 common/res/resources/schemas/MOAIdentities.xsd
(limited to 'common/src')
diff --git a/common/res/resources/schemas/MOA-ID-Configuration-1.1.xsd b/common/res/resources/schemas/MOA-ID-Configuration-1.1.xsd
index 52d0add45..59bd6562f 100644
--- a/common/res/resources/schemas/MOA-ID-Configuration-1.1.xsd
+++ b/common/res/resources/schemas/MOA-ID-Configuration-1.1.xsd
@@ -1,8 +1,14 @@
-
-
-
-
+
+
+
+
@@ -74,24 +80,30 @@
- enthält Parameter der Authentisierungs-Komponente
+ enthält Parameter der
+ Authentisierungs-Komponente
- enthält Konfigurationsparameter der Proxy-Komponente
+ enthält Konfigurationsparameter der
+ Proxy-Komponente
- enthält Parameter für die Kommunikation zw. Proxykomponente und Authenttisierungskomponente
+ enthält Parameter für die Kommunikation zw.
+ Proxykomponente und Authenttisierungskomponente
-
+
- enthält Parameter für die SOAP-Verbindung von der Proxy-Komponente zur Auth-Komponente (vgl. AuthComponent/MOA-SP/ConnectionParameter)
+ enthält Parameter für die SOAP-Verbindung von der
+ Proxy-Komponente zur Auth-Komponente (vgl.
+ AuthComponent/MOA-SP/ConnectionParameter)
@@ -114,13 +126,15 @@
- spezifiziert den Algorithmus ("pkix" oder "chaining") für die Zertifikatspfadvalidierung
+ spezifiziert den Algorithmus ("pkix" oder "chaining") für die
+ Zertifikatspfadvalidierung
- ein vom SystemDefaultMode abweichender ChiningMode kann für jeden TrustAnchor gesetzt werden
+ ein vom SystemDefaultMode abweichender ChiningMode kann
+ für jeden TrustAnchor gesetzt werden
@@ -131,12 +145,14 @@
-
+
- verweist auf ein Verzeichnis, das vertrauenswürdige CA (Zwischen-CA, Wurzel-CA) Zertifikate enthält.
+ verweist auf ein Verzeichnis, das vertrauenswürdige CA
+ (Zwischen-CA, Wurzel-CA) Zertifikate enthält.
@@ -155,18 +171,23 @@
-
+
- enthält Parameter für die Kommunikation mit dem Security-Layer
+ enthält Parameter für die Kommunikation mit dem
+ Security-Layer
- das Attribut filename verweist auf eine Datei mit globalem Element TransformsInfo vom Typ sl10:TransformsInfo; diese TransformsInfo werden in den CreateXMLSignatureRequest für die Signatur des AUTH-Blocks inkludiert
+ das Attribut filename verweist auf eine Datei mit globalem
+ Element TransformsInfo vom Typ sl10:TransformsInfo; diese TransformsInfo
+ werden in den CreateXMLSignatureRequest für die Signatur des AUTH-Blocks
+ inkludiert
@@ -177,18 +198,26 @@
- enthält Konfiguratiosnparameter für die Kommunikation mit dem MOA SP Modul
+ enthält Konfiguratiosnparameter für die Kommunikation mit dem MOA
+ SP Modul
-
+
- enthält Parameter für die SOAP-Verbindung von der AUTH-Komponente zu MOA-SP; das Attribut URL enthält den Endpunkt des Server; wird das Schema "https" verwendet müssen die Kind-Elemente angegeben werden; wird das Schema "http" verwendet dürfen keine Kind-Elemente angegeben werden; wird das Element nicht verwendet dann wird MOA-SP über das API aufgerufen
+ enthält Parameter für die SOAP-Verbindung von der
+ AUTH-Komponente zu MOA-SP; das Attribut URL enthält den Endpunkt des Server;
+ wird das Schema "https" verwendet müssen die Kind-Elemente angegeben werden;
+ wird das Schema "http" verwendet dürfen keine Kind-Elemente angegeben
+ werden; wird das Element nicht verwendet dann wird MOA-SP über das API
+ aufgerufen
- enthält Parameter für die Überprüfung der Personenbindung
+ enthält Parameter für die Überprüfung der
+ Personenbindung
@@ -198,12 +227,14 @@
- enthält Parameter für die Überprüfung des AUTH-Blocks
+ enthält Parameter für die Überprüfung des
+ AUTH-Blocks
-
+
@@ -212,13 +243,15 @@
- enthält Informationen über akzeptierte Signers des IdentityLinks
+ enthält Informationen über akzeptierte Signers des
+ IdentityLinks
- akzeptierte Signer des IdentityLinks werden per X509SubjectName (Kodierung nach RFC 2253) identifiziert
+ akzeptierte Signer des IdentityLinks werden per
+ X509SubjectName (Kodierung nach RFC 2253) identifiziert
@@ -231,31 +264,38 @@
- enthält Parameter über die OA, die die Authentisierungs-Komponente betreffen
+ enthält Parameter über die OA, die die
+ Authentisierungs-Komponente betreffen
-
-
-
+
+
+
- enthält Parameter über die OA, die die Proxy-Komponente betreffen
+ enthält Parameter über die OA, die die Proxy-Komponente
+ betreffen
- enthält Parameter über die OA, die die Proxy-Komponente betreffen
+ enthält Parameter über die OA, die die Proxy-Komponente
+ betreffen
+
-
@@ -264,7 +304,8 @@
- URL zu einem Verzeichnis, das akzeptierte Server-Zertifikate der TLS-Verbindung enthält (keine CA-Zertifikate)
+ URL zu einem Verzeichnis, das akzeptierte Server-Zertifikate der
+ TLS-Verbindung enthält (keine CA-Zertifikate)
@@ -276,7 +317,8 @@
- URL zu einem KeyStore, der den privaten Schlüssel, der für die TLS-Client-Authentisierung verwendetwird, enthält
+ URL zu einem KeyStore, der den privaten Schlüssel, der für
+ die TLS-Client-Authentisierung verwendetwird, enthält
@@ -303,4 +345,4 @@
-
+
\ No newline at end of file
diff --git a/common/res/resources/schemas/MOAIdentities.xsd b/common/res/resources/schemas/MOAIdentities.xsd
new file mode 100644
index 000000000..f2aa8f8e0
--- /dev/null
+++ b/common/res/resources/schemas/MOAIdentities.xsd
@@ -0,0 +1,46 @@
+
+
+
+
+ MOAIdentities provides a mapping from identities to parameters used in the XMLLoginParameterResolver of MOA-ID
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/common/src/at/gv/egovernment/moa/util/FileUtils.java b/common/src/at/gv/egovernment/moa/util/FileUtils.java
index bb21f4ca0..ae8d83834 100644
--- a/common/src/at/gv/egovernment/moa/util/FileUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/FileUtils.java
@@ -1,11 +1,10 @@
package at.gv.egovernment.moa.util;
import java.io.BufferedInputStream;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
/**
@@ -95,17 +94,19 @@ public class FileUtils {
*/
public static String makeAbsoluteURL(String url, String root) {
//if url is relative to rootConfigFileDirName make it absolute
- try {
- if(null == url) return null;
- URI uri = new URI(url);
- if (!uri.isAbsolute()) { // make it absolute to the config file
- uri = new URI(root + url);
- }
- return uri.toString();
- } catch (URISyntaxException e) {
- //if url string could not be converted to absolute URL return source url
- return url;
- }
+
+ File keyFile;
+ String newURL = url;
+
+ if(null == url) return null;
+
+ // check if absolute - if not make it absolute
+ keyFile = new File(url);
+ if (!keyFile.isAbsolute()) {
+ keyFile = new File(root, url);
+ newURL = keyFile.getPath();
+ }
+ return newURL;
}
}
--
cgit v1.2.3
From 658ddc1007c023784353ee97cfc21fb886b00979 Mon Sep 17 00:00:00 2001
From: rudolf
Date: Tue, 16 Mar 2004 11:24:11 +0000
Subject: update to v 1.2 of schema of MOA-ID-Configuration
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@102 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/Constants.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index 77a830c76..cf703eb7c 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -41,7 +41,7 @@ public interface Constants {
/** Local location of the MOA ID configuration XML schema definition. */
public static final String MOA_ID_CONFIG_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-ID-Configuration-1.1.xsd";
+ SCHEMA_ROOT + "MOA-ID-Configuration-1.2.xsd";
/** URI of the Security Layer 1.0 namespace. */
public static final String SL10_NS_URI =
--
cgit v1.2.3
From 86b51fd16f65996db588ee4a20bfda177b2dcd2e Mon Sep 17 00:00:00 2001
From: rudolf
Date: Mon, 26 Apr 2004 12:45:31 +0000
Subject: Namensraum für XMLLoginParameterResolver hinzugefügt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@105 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/Constants.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index cf703eb7c..e63dbf015 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -164,7 +164,7 @@ public interface Constants {
/** URI of the Exclusive Canonicalization XML namespace */
public static final String DSIG_EC_NS_URI =
"http://www.w3.org/2001/10/xml-exc-c14n#";
-
+
/** Prefix used for the Exclusive Canonicalization XML namespace */
public static final String DSIG_EC_PREFIX = "ec";
@@ -172,6 +172,14 @@ public interface Constants {
public static final String DSIG_EC_SCHEMA_LOCATION =
SCHEMA_ROOT + "exclusive-canonicalization.xsd";
+ /** URI of the XMLLoginParameterResolver Configuration XML namespace */
+ public static final String XMLLPR_NS_URI="http://reference.e-government.gv.at/namespace/moa/20020822#/xmllpr20030814";
+
+ /** Local location of the XMLLoginParameterResolver Configuration XML schema definition */
+ public static final String XMLLPR_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOAIdentities.xsd";
+
+
/**
* Contains all namespaces and local schema locations for XML schema
* definitions relevant for MOA. For use in validating XML parsers.
@@ -190,7 +198,8 @@ public interface Constants {
+ (XSI_NS_URI + " " + XSI_SCHEMA_LOCATION + " ")
+ (DSIG_NS_URI + " " + DSIG_SCHEMA_LOCATION + " ")
+ (DSIG_FILTER2_NS_URI + " " + DSIG_FILTER2_SCHEMA_LOCATION + " ")
- + (DSIG_EC_NS_URI + " " + DSIG_EC_SCHEMA_LOCATION);
+ + (DSIG_EC_NS_URI + " " + DSIG_EC_SCHEMA_LOCATION + " ")
+ + (XMLLPR_NS_URI + " " + XMLLPR_SCHEMA_LOCATION);
/** Security Layer manifest type URI. */
public static final String SL_MANIFEST_TYPE_URI =
--
cgit v1.2.3
From 6f2b4760a460ad3eeedbd5b475d7ecbfdc77179c Mon Sep 17 00:00:00 2001
From: rudolf
Date: Mon, 26 Apr 2004 12:47:06 +0000
Subject: Debug logging des Dokuments im Falle einer SAXException wurde
hinzugefügt (RSCH)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@106 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/DOMUtils.java | 82 ++++++++++++++--------
1 file changed, 52 insertions(+), 30 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
index 8e6394445..f44804927 100644
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -41,6 +41,8 @@ import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import at.gv.egovernment.moa.logging.Logger;
+
/**
* Various utility functions for handling XML DOM trees.
*
@@ -154,10 +156,22 @@ public class DOMUtils {
String externalNoNamespaceSchemaLocation,
EntityResolver entityResolver,
ErrorHandler errorHandler)
- throws SAXException, IOException, ParserConfigurationException {
+ throws SAXException, IOException, ParserConfigurationException {
DOMParser parser;
+
+
+ //if Debug is enabled make a copy of inputStream to enable debug output in case of SAXException
+ byte buffer [] = null;
+ ByteArrayInputStream baStream = null;
+ if(true == Logger.isDebugEnabled()) {
+ int len = inputStream.available();
+ buffer = new byte[len];
+ inputStream.read(buffer);
+ baStream = new ByteArrayInputStream(buffer);
+ }
+
// create the DOM parser
if (symbolTable != null) {
parser = new DOMParser(symbolTable, grammarPool);
@@ -166,36 +180,44 @@ public class DOMUtils {
}
// set parser features and properties
- parser.setFeature(NAMESPACES_FEATURE, true);
- parser.setFeature(VALIDATION_FEATURE, validating);
- parser.setFeature(SCHEMA_VALIDATION_FEATURE, validating);
- parser.setFeature(NORMALIZED_VALUE_FEATURE, false);
- parser.setFeature(INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true);
- parser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE, false);
-
- if (validating) {
- if (externalSchemaLocations != null) {
- parser.setProperty(
- EXTERNAL_SCHEMA_LOCATION_PROPERTY,
- externalSchemaLocations);
- }
- if (externalNoNamespaceSchemaLocation != null) {
- parser.setProperty(
- EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
- externalNoNamespaceSchemaLocation);
- }
- }
-
- // set entity resolver and error handler
- if (entityResolver != null) {
- parser.setEntityResolver(entityResolver);
+ try {
+ parser.setFeature(NAMESPACES_FEATURE, true);
+ parser.setFeature(VALIDATION_FEATURE, validating);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE, validating);
+ parser.setFeature(NORMALIZED_VALUE_FEATURE, false);
+ parser.setFeature(INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true);
+ parser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE, false);
+
+ if (validating) {
+ if (externalSchemaLocations != null) {
+ parser.setProperty(
+ EXTERNAL_SCHEMA_LOCATION_PROPERTY,
+ externalSchemaLocations);
+ }
+ if (externalNoNamespaceSchemaLocation != null) {
+ parser.setProperty(
+ EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
+ externalNoNamespaceSchemaLocation);
+ }
+ }
+
+ // set entity resolver and error handler
+ if (entityResolver != null) {
+ parser.setEntityResolver(entityResolver);
+ }
+ if (errorHandler != null) {
+ parser.setErrorHandler(errorHandler);
+ }
+
+ // parse the document and return it
+ parser.parse(new InputSource(baStream));
+ } catch(SAXException e) {
+ if(true == Logger.isDebugEnabled() && null != buffer) {
+ String xmlContent = new String(buffer);
+ Logger.debug("SAXException in:\n" + xmlContent);
+ throw(e);
+ }
}
- if (errorHandler != null) {
- parser.setErrorHandler(errorHandler);
- }
-
- // parse the document and return it
- parser.parse(new InputSource(inputStream));
return parser.getDocument();
}
--
cgit v1.2.3
From 77f701b92244538afafc4a2df77169ee07b61388 Mon Sep 17 00:00:00 2001
From: rudolf
Date: Mon, 26 Apr 2004 12:47:58 +0000
Subject: Diverse Utilfunktionen zur Ausgabe von XML Dokumenten in Dateien
(RSCH)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@107 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../at/gv/egovernment/moa/util/OutputXML2File.java | 78 ++++++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100644 common/src/at/gv/egovernment/moa/util/OutputXML2File.java
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/OutputXML2File.java b/common/src/at/gv/egovernment/moa/util/OutputXML2File.java
new file mode 100644
index 000000000..f9d330d41
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/OutputXML2File.java
@@ -0,0 +1,78 @@
+/*
+ * Created on 26.04.2004
+ *
+ * @author rschamberger
+ * $ID$
+ */
+package at.gv.egovernment.moa.util;
+
+import org.w3c.dom.Element;
+
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * utility functions to write XML data to files
+ * @author rschamberger
+ * @version $Id$
+ */
+public class OutputXML2File {
+
+ /**
+ * writes an XML structure to file if debug is enabled in hierarchy (Encoding: UTF-8)
+ *
+ * @param filename file name
+ * @param rootElem root element in DOM tree
+ * @param hierarchy of the Logger
+ */
+ public static void debugOutputXML2File(String filename, Element rootElem, String hierarchy) {
+ if (Logger.isDebugEnabled(hierarchy)) {
+ outputXML2File(filename, rootElem);
+ }
+ }
+
+ /**
+ * writes an XML structure to file if debug is enabled in hierarchy (Encoding: UTF-8)
+ *
+ * @param filename file name
+ * @param xmlString XML string
+ * @param hierarchy of the Logger
+ */
+ public static void debugOutputXML2File(String filename, String xmlString, String hierarchy) {
+ if (Logger.isDebugEnabled(hierarchy)) {
+ outputXML2File(filename, xmlString);
+ }
+ }
+
+ /**
+ * writes an XML structure to file (Encoding: UTF-8)
+ *
+ * @param filename file name
+ * @param rootElem root element in DOM tree
+ */
+ public static void outputXML2File(String filename, Element rootElem) {
+ try {
+ String xmlString = new String(DOMUtils.serializeNode(rootElem));
+ outputXML2File(filename, xmlString);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * writes an XML structure to file (Encoding: UTF-8)
+ *
+ * @param filename file name
+ * @param xmlString XML string
+ */
+ public static void outputXML2File(String filename, String xmlString) {
+ try {
+ java.io.OutputStream fout = new java.io.FileOutputStream(filename);
+ byte[] xmlData = xmlString.getBytes("UTF-8");
+ fout.write(xmlData);
+ fout.close();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+}
--
cgit v1.2.3
From 2c72f5741e7b2a5338b41a40ee42d05ffe63f3e3 Mon Sep 17 00:00:00 2001
From: rudolf
Date: Thu, 24 Jun 2004 18:31:51 +0000
Subject: fixed MalformedURLException (RSCH)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@134 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/DOMUtils.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
index f44804927..f0e7768be 100644
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -210,7 +210,11 @@ public class DOMUtils {
}
// parse the document and return it
- parser.parse(new InputSource(baStream));
+ // if debug is enabled: use copy of strem (baStream) else use orig stream
+ if(null != baStream)
+ parser.parse(new InputSource(baStream));
+ else
+ parser.parse(new InputSource(inputStream));
} catch(SAXException e) {
if(true == Logger.isDebugEnabled() && null != buffer) {
String xmlContent = new String(buffer);
--
cgit v1.2.3
From 8620f68d1d5f60b97b961f8e1691bd33e3ce0c5b Mon Sep 17 00:00:00 2001
From: gregor
Date: Thu, 1 Jul 2004 13:20:12 +0000
Subject: Methode getStackTraceAsString hinzugefügt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@148 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/StreamUtils.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/StreamUtils.java b/common/src/at/gv/egovernment/moa/util/StreamUtils.java
index 88db24504..a22f1c2a8 100644
--- a/common/src/at/gv/egovernment/moa/util/StreamUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/StreamUtils.java
@@ -3,6 +3,7 @@ package at.gv.egovernment.moa.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintStream;
/**
* Utility methods for streams.
@@ -112,5 +113,16 @@ public class StreamUtils {
in.close();
return out.toString(encoding);
}
-
+
+ /**
+ * Gets the stack trace of the Throwable passed in as a string.
+ * @param t The Throwable.
+ * @return a String representing the stack trace of the Throwable.
+ */
+ public static String getStackTraceAsString(Throwable t)
+ {
+ ByteArrayOutputStream stackTraceBIS = new ByteArrayOutputStream();
+ t.printStackTrace(new PrintStream(stackTraceBIS));
+ return new String(stackTraceBIS.toByteArray());
+ }
}
--
cgit v1.2.3
From ca508dd0091a1e3736a6b98543996a47cc6a1835 Mon Sep 17 00:00:00 2001
From: gregor
Date: Tue, 18 Jan 2005 11:06:28 +0000
Subject: Unterstützung des aktuellen NS für ECDSA-XML-Strukturen (dsig-more
statt buergerkarte).
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@220 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/.classpath | 38 +++----
common/build.xml | 4 +-
.../resources/schemas/ECDSAKeyValue.ancient.xsd | 122 +++++++++++++++++++++
.../res/resources/schemas/ECDSAKeyValue.wrong.xsd | 122 +++++++++++++++++++++
common/res/resources/schemas/ECDSAKeyValue.xsd | 2 +-
.../src/at/gv/egovernment/moa/util/Constants.java | 16 +++
6 files changed, 282 insertions(+), 22 deletions(-)
create mode 100644 common/res/resources/schemas/ECDSAKeyValue.ancient.xsd
create mode 100644 common/res/resources/schemas/ECDSAKeyValue.wrong.xsd
(limited to 'common/src')
diff --git a/common/.classpath b/common/.classpath
index 614f844f4..6534e6c4e 100644
--- a/common/.classpath
+++ b/common/.classpath
@@ -1,22 +1,22 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/common/build.xml b/common/build.xml
index 20ac141ad..c118f86de 100644
--- a/common/build.xml
+++ b/common/build.xml
@@ -16,8 +16,8 @@
-
-
+
+
diff --git a/common/res/resources/schemas/ECDSAKeyValue.ancient.xsd b/common/res/resources/schemas/ECDSAKeyValue.ancient.xsd
new file mode 100644
index 000000000..833d327f2
--- /dev/null
+++ b/common/res/resources/schemas/ECDSAKeyValue.ancient.xsd
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/common/res/resources/schemas/ECDSAKeyValue.wrong.xsd b/common/res/resources/schemas/ECDSAKeyValue.wrong.xsd
new file mode 100644
index 000000000..db83c9df5
--- /dev/null
+++ b/common/res/resources/schemas/ECDSAKeyValue.wrong.xsd
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/common/res/resources/schemas/ECDSAKeyValue.xsd b/common/res/resources/schemas/ECDSAKeyValue.xsd
index 833d327f2..7a01b23d1 100644
--- a/common/res/resources/schemas/ECDSAKeyValue.xsd
+++ b/common/res/resources/schemas/ECDSAKeyValue.xsd
@@ -1,5 +1,5 @@
-
+
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index e63dbf015..0d8f19064 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -67,7 +67,15 @@ public interface Constants {
/** URI of the ECDSA XML namespace */
public static final String ECDSA_NS_URI =
+ "http://www.w3.org/2001/04/xmldsig-more#";
+
+ /** Ancient URI for the ECDSA XML namespace **/
+ public static final String ECDSA_NS_URI_ANCIENT =
"http://www.buergerkarte.at/namespaces/ecdsa/200206030#";
+
+ /** Wrong URI for the ECDSA XML namespace, used by the ZMR **/
+ public static final String ECDSA_NS_URI_WRONG = // TODO Entfernen, sobald ZMR umgestellt hat
+ "http://www.w3.org/2004/01/xmldsig-more#";
/** Prefix used for ECDSA namespace */
public static final String ECDSA_PREFIX = "ecdsa";
@@ -76,6 +84,14 @@ public interface Constants {
public static final String ECDSA_SCHEMA_LOCATION =
SCHEMA_ROOT + "ECDSAKeyValue.xsd";
+ /** Local location of ECDSA XML schema definition (ancient version) */
+ public static final String ECDSA_SCHEMA_LOCATION_ANCIENT =
+ SCHEMA_ROOT + "ECDSAKeyValue.ancient.xsd";
+
+ /** Local location of ECDSA XML schema definition (wrong ZMR version) */
+ public static final String ECDSA_SCHEMA_LOCATION_WRONG =
+ SCHEMA_ROOT + "ECDSAKeyValue.wrong.xsd";
+
/** URI of the PersonData XML namespace. */
public static final String PD_NS_URI =
"http://reference.e-government.gv.at/namespace/persondata/20020228#";
--
cgit v1.2.3
From fcbbccd3c79d31bc853918353c5dc156bc5370bc Mon Sep 17 00:00:00 2001
From: gregor
Date: Tue, 18 Jan 2005 14:34:37 +0000
Subject: Unterstützung des aktuellen, des historischen, sowie des falschen
ZMR-NS für ECDSA XML eingebaut.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@225 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/Constants.java | 2 ++
1 file changed, 2 insertions(+)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index 0d8f19064..edab2b41e 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -207,6 +207,8 @@ public interface Constants {
+ (SL10_NS_URI + " " + SL10_SCHEMA_LOCATION + " ")
+ (SL11_NS_URI + " " + SL11_SCHEMA_LOCATION + " ")
+ (ECDSA_NS_URI + " " + ECDSA_SCHEMA_LOCATION + " ")
+ + (ECDSA_NS_URI_ANCIENT + " " + ECDSA_SCHEMA_LOCATION_ANCIENT + " ")
+ + (ECDSA_NS_URI_WRONG + " " + ECDSA_SCHEMA_LOCATION_WRONG + " ") // TODO Entfernen, sobald ZMR umgestellt hat
+ (PD_NS_URI + " " + PD_SCHEMA_LOCATION + " ")
+ (SAML_NS_URI + " " + SAML_SCHEMA_LOCATION + " ")
+ (SAMLP_NS_URI + " " + SAMLP_SCHEMA_LOCATION + " ")
--
cgit v1.2.3
From ea8c4f9b5564ac201fffc8f3e0b0c6b71defa6ed Mon Sep 17 00:00:00 2001
From: rudolf
Date: Fri, 21 Jan 2005 17:56:18 +0000
Subject: Inserted HashMap used for namespace prefix to NS mapping
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@234 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/Constants.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index edab2b41e..48b633b94 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -1,5 +1,7 @@
package at.gv.egovernment.moa.util;
+import java.util.HashMap;
+
/**
* Contains various constants used throughout the system.
*
@@ -256,5 +258,10 @@ public interface Constants {
* Local name of request for verifying an XML signature.
*/
public static final String MOA_SPSS_VERIFY_XML_REQUEST = "VerifiyXMLSignatureRequest";
-
+
+ /**
+ * A map used to map namespace prefixes to namespace URIs
+ */
+ public static HashMap nSMap = new HashMap(5);
+
}
--
cgit v1.2.3
From fa8fbee356922b9445c2773b011e141bad7ea4ad Mon Sep 17 00:00:00 2001
From: gregor
Date: Thu, 3 Feb 2005 09:15:45 +0000
Subject: Bug 220 korrigiert.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@271 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/DOMUtils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
index f0e7768be..53b1a0e48 100644
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -219,8 +219,8 @@ public class DOMUtils {
if(true == Logger.isDebugEnabled() && null != buffer) {
String xmlContent = new String(buffer);
Logger.debug("SAXException in:\n" + xmlContent);
- throw(e);
}
+ throw(e);
}
return parser.getDocument();
--
cgit v1.2.3
From d040b091d0e8556a536978fe830e5db7695e5bef Mon Sep 17 00:00:00 2001
From: "harald.bratko"
Date: Fri, 22 Jul 2005 16:07:10 +0000
Subject: updated for MAO WID (wbPK)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@400 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/Constants.java | 35 ++++++++++++++++++++--
.../src/at/gv/egovernment/moa/util/DOMUtils.java | 22 ++++++++++++++
.../src/at/gv/egovernment/moa/util/XPathUtils.java | 1 +
3 files changed, 56 insertions(+), 2 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index 48b633b94..99fe81065 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -43,7 +43,7 @@ public interface Constants {
/** Local location of the MOA ID configuration XML schema definition. */
public static final String MOA_ID_CONFIG_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-ID-Configuration-1.2.xsd";
+ SCHEMA_ROOT + "MOA-ID-Configuration-1.3.xsd";
/** URI of the Security Layer 1.0 namespace. */
public static final String SL10_NS_URI =
@@ -66,7 +66,18 @@ public interface Constants {
/** Local location of the Security Layer 1.1 XML schema definition */
public static final String SL11_SCHEMA_LOCATION =
SCHEMA_ROOT + "Core.20020831.xsd";
+
+ /** URI of the Security Layer 1.2 XML namespace */
+ public static final String SL12_NS_URI =
+ "http://www.buergerkarte.at/namespaces/securitylayer/1.2#";
+
+ /** Prefix used for the Security Layer 1.2 XML namespace */
+ public static final String SL12_PREFIX = "sl";
+ /** Local location of the Security Layer 1.2 XML schema definition */
+ public static final String SL12_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "Core-1.2.xsd";
+
/** URI of the ECDSA XML namespace */
public static final String ECDSA_NS_URI =
"http://www.w3.org/2001/04/xmldsig-more#";
@@ -101,9 +112,13 @@ public interface Constants {
/** Prefix used for the PersonData XML namespace */
public static final String PD_PREFIX = "pr";
+// /** Local location of the PersonData XML schema definition */
+// public static final String PD_SCHEMA_LOCATION =
+// SCHEMA_ROOT + "PersonData.xsd";
+
/** Local location of the PersonData XML schema definition */
public static final String PD_SCHEMA_LOCATION =
- SCHEMA_ROOT + "PersonData.xsd";
+ SCHEMA_ROOT + "PersonData_20_en.xsd";
/** URI of the SAML namespace. */
public static final String SAML_NS_URI =
@@ -208,6 +223,7 @@ public interface Constants {
+ (MOA_ID_CONFIG_NS_URI + " " + MOA_ID_CONFIG_SCHEMA_LOCATION + " ")
+ (SL10_NS_URI + " " + SL10_SCHEMA_LOCATION + " ")
+ (SL11_NS_URI + " " + SL11_SCHEMA_LOCATION + " ")
+ + (SL12_NS_URI + " " + SL12_SCHEMA_LOCATION + " ")
+ (ECDSA_NS_URI + " " + ECDSA_SCHEMA_LOCATION + " ")
+ (ECDSA_NS_URI_ANCIENT + " " + ECDSA_SCHEMA_LOCATION_ANCIENT + " ")
+ (ECDSA_NS_URI_WRONG + " " + ECDSA_SCHEMA_LOCATION_WRONG + " ") // TODO Entfernen, sobald ZMR umgestellt hat
@@ -221,6 +237,21 @@ public interface Constants {
+ (DSIG_EC_NS_URI + " " + DSIG_EC_SCHEMA_LOCATION + " ")
+ (XMLLPR_NS_URI + " " + XMLLPR_SCHEMA_LOCATION);
+ /** URN prefix for bPK and wbPK. */
+ public static final String URN_PREFIX = "urn:publicid:gv.at";
+
+ /** URN prefix for context dependent id. */
+ public static final String URN_PREFIX_CDID = URN_PREFIX + ":cdid";
+
+ /** URN prefix for context dependent id (bPK). */
+ public static final String URN_PREFIX_BPK = URN_PREFIX_CDID + "+bpk";
+
+ /** URN prefix for context dependent id (wbPK). */
+ public static final String URN_PREFIX_WBPK = URN_PREFIX + ":wbpk";
+
+ /** URN prefix for context dependent id. */
+ public static final String URN_PREFIX_BASEID = URN_PREFIX + ":baseid";
+
/** Security Layer manifest type URI. */
public static final String SL_MANIFEST_TYPE_URI =
"http://www.buergerkarte.at/specifications/Security-Layer/20020225#SignatureManifest";
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
index 53b1a0e48..52f6554d5 100644
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -41,6 +41,7 @@ import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+
import at.gv.egovernment.moa.logging.Logger;
/**
@@ -832,5 +833,26 @@ public class DOMUtils {
}
return false;
}
+
+ /**
+ * Selects the (first) element from a node list and returns it.
+ *
+ * @param nl The NodeList to get the element from.
+ * @return The (first) element included in the node list or null
+ * if the node list is null or empty or no element is
+ * included in the list.
+ */
+ public static Element getElementFromNodeList (NodeList nl) {
+ if ((nl == null) || (nl.getLength() == 0)) {
+ return null;
+ }
+ for (int i=0; i
Date: Fri, 22 Jul 2005 16:07:32 +0000
Subject: added for MOA-WID (wbPK)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@401 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../at/gv/egovernment/moa/util/StringUtils.java | 148 +++++++++++++++++++++
1 file changed, 148 insertions(+)
create mode 100644 common/src/at/gv/egovernment/moa/util/StringUtils.java
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/StringUtils.java b/common/src/at/gv/egovernment/moa/util/StringUtils.java
new file mode 100644
index 000000000..0ad5c515c
--- /dev/null
+++ b/common/src/at/gv/egovernment/moa/util/StringUtils.java
@@ -0,0 +1,148 @@
+// Copyright (C) 2002 IAIK
+// email: jce-info@iaik.tu-graz.ac.at
+//
+// All rights reserved.
+//
+// This source is provided for inspection purposes and recompilation only,
+// unless specified differently in a contract with IAIK. This source has to
+// be kept in strict confidence and must not be disclosed to any third party
+// under any circumstances. Redistribution in source and binary forms, with
+// or without modification, are permitted in any case!
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+//
+
+package at.gv.egovernment.moa.util;
+
+import java.util.StringTokenizer;
+
+/**
+ * Utitility functions for string manipulations.
+ *
+ * @author Harald Bratko
+ */
+public class StringUtils {
+
+ /**
+ * Removes all blanks and tabs from the given string.
+ *
+ * @param s The string to remove all blanks and tabs from.
+ * @return The input string with all blanks and tabs removed from.
+ */
+ public static String removeBlanks(String s) {
+ StringTokenizer st = new StringTokenizer(s);
+ StringBuffer sb = new StringBuffer(s.length());
+ while (st.hasMoreTokens()) {
+ sb.append(st.nextToken());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Removes all occurences of the specified token from the the given string.
+ *
+ * @param s The string to remove all occurences of the specified token from.
+ * @return The input string with all occurences of the specified token removed from.
+ */
+ public static String removeToken(String s, String token) {
+ StringTokenizer st = new StringTokenizer(s, token);
+ StringBuffer sb = new StringBuffer(s.length());
+ while (st.hasMoreTokens()) {
+ sb.append(st.nextToken());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Removes all leading zeros from the input string.
+ *
+ * @param s The string remove the leading zeros from.
+ * @return The input string with the leading zeros removed from.
+ */
+ public static String deleteLeadingZeros(String s) {
+ StringBuffer sb = new StringBuffer(s);
+ int l = sb.length();
+ int j = 0;
+ for (int i=0; is that matches the given
+ * search string by the given replace string.
+ *
+ * @param s The string where the replacment should take place.
+ * @param search The pattern that should be replaced.
+ * @param replace The string that should replace all each search
+ * string within s.
+ * @return A string whrer all occurrence of search are
+ * replaced with replace.
+ */
+ public static String replaceAll (String s, String search, String replace)
+ {
+ StringBuffer sb = new StringBuffer();
+ int i = 0, j = 0;
+ int len = search.length();
+ while (j > -1)
+ {
+ j = s.indexOf(search, i);
+
+ if (j > -1)
+ {
+ sb.append(s.substring(i,j));
+ sb.append(replace);
+ i = j + len;
+ }
+ }
+
+ sb.append(s.substring(i, s.length()));
+
+ return sb.toString();
+ }
+
+ /**
+ * Changes the SecurityLayer version in the given string.
+ * This method usually takes as input an XML structure represented in a string
+ * format and changes the SecurityLayer namespaces prefixes and URIs from
+ * one SecurityLayer version to another.
+ * e.g.: code>sl10 to sl and
+ * http://www.buergerkarte.at/namespaces/securitylayer/20020225#
+ * to
+ * http://www.buergerkarte.at/namespaces/securitylayer/1.2#
+ *
+ * @param s The string (usally an XML structure) where the
+ * SecurityLayer version should be changed.
+ * @param slPrefixOld The SecurityLayer namespace prefix that should be
+ * replaced by the new one.
+ * @param slPrefixNew The new SecurityLayer namespace prefix that should
+ * replace the old one.
+ * @param slNSUriOld The SecurityLayer namespace URI that should be
+ * replaced by the new one.
+ * @param slNSUriNew The new SecurityLayer namespace URI that should
+ * replace the old one.
+ * @return A string where the SecurityLayer namespace prefixes
+ * and URIs are replaced by new ones.
+ */
+ public static String changeSLVersion(String s, String slPrefixOld, String slPrefixNew, String slNSUriOld, String slNSUriNew) {
+ String retString = replaceAll(s, slPrefixOld, slPrefixNew);
+ retString = replaceAll(retString, slNSUriOld, slNSUriNew);
+ return retString ;
+ }
+
+}
--
cgit v1.2.3
From 4246bab1caa15f15929fc36983641024dd9417fc Mon Sep 17 00:00:00 2001
From: gregor
Date: Tue, 26 Jul 2005 20:18:41 +0000
Subject: Neue Namen der Schemata für Konfiguration und XML-Schnittstelle
berücksichtigt.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@410 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/Constants.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index 99fe81065..c3379ae0e 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -21,7 +21,7 @@ public interface Constants {
/** Local location of the MOA XML schema definition. */
public static final String MOA_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-SPSS-1.2.xsd";
+ SCHEMA_ROOT + "MOA-SPSS-1.3.xsd";
/** URI of the MOA configuration XML namespace. */
public static final String MOA_CONFIG_NS_URI =
@@ -39,7 +39,7 @@ public interface Constants {
/** Local location of the MOA configuration XML schema definition. */
public static final String MOA_CONFIG_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-SPSS-Configuration-1.0.xsd";
+ SCHEMA_ROOT + "MOA-SPSS-config-1.3.xsd";
/** Local location of the MOA ID configuration XML schema definition. */
public static final String MOA_ID_CONFIG_SCHEMA_LOCATION =
--
cgit v1.2.3
From 17f18fc9749c4f3a4b74a2103500bbd549de1160 Mon Sep 17 00:00:00 2001
From: rudolf
Date: Thu, 11 Aug 2005 08:30:11 +0000
Subject: WRONG and ANCIENT ECDSA Schema NS wurde entfernt
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@431 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/Constants.java | 18 ------------------
1 file changed, 18 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index c3379ae0e..bae811c41 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -82,14 +82,6 @@ public interface Constants {
public static final String ECDSA_NS_URI =
"http://www.w3.org/2001/04/xmldsig-more#";
- /** Ancient URI for the ECDSA XML namespace **/
- public static final String ECDSA_NS_URI_ANCIENT =
- "http://www.buergerkarte.at/namespaces/ecdsa/200206030#";
-
- /** Wrong URI for the ECDSA XML namespace, used by the ZMR **/
- public static final String ECDSA_NS_URI_WRONG = // TODO Entfernen, sobald ZMR umgestellt hat
- "http://www.w3.org/2004/01/xmldsig-more#";
-
/** Prefix used for ECDSA namespace */
public static final String ECDSA_PREFIX = "ecdsa";
@@ -97,14 +89,6 @@ public interface Constants {
public static final String ECDSA_SCHEMA_LOCATION =
SCHEMA_ROOT + "ECDSAKeyValue.xsd";
- /** Local location of ECDSA XML schema definition (ancient version) */
- public static final String ECDSA_SCHEMA_LOCATION_ANCIENT =
- SCHEMA_ROOT + "ECDSAKeyValue.ancient.xsd";
-
- /** Local location of ECDSA XML schema definition (wrong ZMR version) */
- public static final String ECDSA_SCHEMA_LOCATION_WRONG =
- SCHEMA_ROOT + "ECDSAKeyValue.wrong.xsd";
-
/** URI of the PersonData XML namespace. */
public static final String PD_NS_URI =
"http://reference.e-government.gv.at/namespace/persondata/20020228#";
@@ -225,8 +209,6 @@ public interface Constants {
+ (SL11_NS_URI + " " + SL11_SCHEMA_LOCATION + " ")
+ (SL12_NS_URI + " " + SL12_SCHEMA_LOCATION + " ")
+ (ECDSA_NS_URI + " " + ECDSA_SCHEMA_LOCATION + " ")
- + (ECDSA_NS_URI_ANCIENT + " " + ECDSA_SCHEMA_LOCATION_ANCIENT + " ")
- + (ECDSA_NS_URI_WRONG + " " + ECDSA_SCHEMA_LOCATION_WRONG + " ") // TODO Entfernen, sobald ZMR umgestellt hat
+ (PD_NS_URI + " " + PD_SCHEMA_LOCATION + " ")
+ (SAML_NS_URI + " " + SAML_SCHEMA_LOCATION + " ")
+ (SAMLP_NS_URI + " " + SAMLP_SCHEMA_LOCATION + " ")
--
cgit v1.2.3
From 9c5b6686313cdaffa018f8048f0d751f11fc8c26 Mon Sep 17 00:00:00 2001
From: "harald.bratko"
Date: Fri, 12 Aug 2005 13:00:53 +0000
Subject: Added methods for retrieving SecurityLayer prefixes.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@440 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/XPathUtils.java | 105 +++++++++++++++++++++
1 file changed, 105 insertions(+)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
index 4ee160476..aa5a4fec5 100644
--- a/common/src/at/gv/egovernment/moa/util/XPathUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
@@ -412,5 +412,110 @@ public class XPathUtils {
Attr attr = (Attr) XPathUtils.selectSingleNode(root, xpath);
return attr != null ? attr.getValue() : def;
}
+
+ /**
+ * Return the SecurityLayer namespace prefix of the context element.
+ * If the context element has no prefix explicitely set (i.e. is specified
+ * within the default namespace), the method sets the prefix
+ * according to the value of the xmlns attribute of the context
+ * element.
+ * The returned prefix is needed for evaluating XPATH expressions.
+ *
+ * @param contextElement The element to get a prefix from.
+ *
+ * @return The string sl10, sl11 or sl,
+ * depending on the SecurityLayer namespace of the contextElement.
+ *
+ * throws XpathException If the element has no prefix or no valid SecurityLayer
+ * namespace is used as default namespace.
+ */
+ public static String getSlPrefix (Element contextElement) throws XPathException {
+ String slPrefix = contextElement.getPrefix();
+ if (slPrefix != null) {
+ return slPrefix;
+ } else {
+ String nameSpace = contextElement.getAttribute("xmlns");
+
+ if (nameSpace.equals(Constants.SL10_NS_URI)) {
+ slPrefix = Constants.SL10_PREFIX;
+ } else if (nameSpace.equals(Constants.SL12_NS_URI)) {
+ slPrefix = Constants.SL12_PREFIX;
+ } else if (nameSpace.equals(Constants.SL11_NS_URI)) {
+ slPrefix = Constants.SL11_PREFIX;
+ } else {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
+ throw new XPathException(message, null);
+
+ }
+
+ return slPrefix;
+ }
+ }
+
+
+ /**
+ * Return the SecurityLayer namespace prefix of the context element.
+ * If the context element is not the element that lies within the
+ * SecurityLayer namespace. The Securitylayer namespace is derived from
+ * the xmlns:sl10, sl11 or sl
+ * attribute of the context element.
+ *
+ * The returned prefix is needed for evaluating XPATH expressions.
+ *
+ * @param contextElement The element to get a prefix for the Securitylayer namespace,
+ * that is used within the corresponding document.
+ *
+ * @return The string sl10, sl11 or sl,
+ * depending on the SecurityLayer namespace of the contextElement.
+ *
+ * throws XPathException If no (vlalid) SecurityLayer namespace prefix or namespace
+ * is defined.
+ */
+ public static String getSlPrefixFromNoRoot (Element contextElement) throws XPathException {
+
+ String slPrefix = checkSLnsDeclaration(contextElement, Constants.SL10_PREFIX, Constants.SL10_NS_URI);
+ if (slPrefix == null) {
+ slPrefix = checkSLnsDeclaration(contextElement, Constants.SL11_PREFIX, Constants.SL11_NS_URI);
+ }
+ if (slPrefix == null) {
+ slPrefix = checkSLnsDeclaration(contextElement, Constants.SL12_PREFIX, Constants.SL12_NS_URI);
+ }
+
+ return slPrefix;
+
+ }
+
+ /**
+ * Checks if the context element has an attribute xmlns:slPrefix and
+ * if the prefix of that attribute corresponds with a valid SecurityLayer namespace.
+ *
+ * @param contextElement The element to be checked.
+ * @param slPrefix The prefix which should be checked. Must be a valid SecurityLayer
+ * namespace prefix.
+ * @param slNameSpace The SecurityLayer namespace that corresponds to the specified prefix.
+ *
+ * @return The valid SecurityLayer prefix or null if this prefix is
+ * not used.
+ * @throws XPathException
+ */
+ private static String checkSLnsDeclaration(Element contextElement, String slPrefix, String slNameSpace)
+ throws XPathException
+ {
+ String nsAtt = "xmlns:" + slPrefix;
+ String nameSpace = contextElement.getAttribute(nsAtt);
+ if (nameSpace == "") {
+ return null;
+ } else {
+ // check if namespace is correct
+ if (nameSpace.equals(slNameSpace)) {
+ return slPrefix;
+ } else {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
+ throw new XPathException(message, null);
+ }
+ }
+ }
}
--
cgit v1.2.3
From 6fb182ea445c864219cf15aabffe9c299a9ddc4b Mon Sep 17 00:00:00 2001
From: "harald.bratko"
Date: Fri, 2 Sep 2005 10:12:25 +0000
Subject: Changed name of person data schema.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@475 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/Constants.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index bae811c41..e0c287c8d 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -102,7 +102,7 @@ public interface Constants {
/** Local location of the PersonData XML schema definition */
public static final String PD_SCHEMA_LOCATION =
- SCHEMA_ROOT + "PersonData_20_en.xsd";
+ SCHEMA_ROOT + "PersonData_20_en_moaWID.xsd";
/** URI of the SAML namespace. */
public static final String SAML_NS_URI =
--
cgit v1.2.3
From 6551ddb13f38b3d96719f5c21f10da6ff80d5d13 Mon Sep 17 00:00:00 2001
From: "harald.bratko"
Date: Fri, 2 Sep 2005 10:13:32 +0000
Subject: Added method for retrieving child elments of an element.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@476 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/DOMUtils.java | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
index 52f6554d5..fddf16944 100644
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -7,8 +7,10 @@ import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -854,5 +856,26 @@ public class DOMUtils {
}
return null;
}
+
+ /**
+ * Returns all child elements of the given element.
+ *
+ * @param parent The element to get the child elements from.
+ *
+ * @return A list including all child elements of the given element.
+ * Maybe empty if the parent element has no child elements.
+ */
+ public static List getChildElements (Element parent) {
+ Vector v = new Vector();
+ NodeList nl = parent.getChildNodes();
+ int length = nl.getLength();
+ for (int i=0; i < length; i++) {
+ Node node = nl.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ v.add((Element)node);
+ }
+ }
+ return v;
+ }
}
--
cgit v1.2.3
From d37622fc03b7be66998c8855104fe31c5b21f4a0 Mon Sep 17 00:00:00 2001
From: rudolf
Date: Thu, 22 Sep 2005 10:33:19 +0000
Subject: Mergen von MOA-VV Constants mit bisher bestehenden Constants
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@515 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/Constants.java | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
index e0c287c8d..0b441d95c 100644
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ b/common/src/at/gv/egovernment/moa/util/Constants.java
@@ -12,10 +12,45 @@ public interface Constants {
/** Root location of the schema files. */
public static final String SCHEMA_ROOT = "/resources/schemas/";
+ /** URI of the Widerrufregister XML namespace. */
+ public static final String WRR_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moavv/20041223";
+
+ /** Prefix used for the Widerrufregister XML namespace */
+ public static final String WRR_PREFIX = "wrr";
+
+ /** URI of the StandardTextBlock XML namespace. */
+ public static final String STB_NS_URI =
+ "http://reference.e-government.gv.at/namespace/standardtextblock/20041105#";
+
+ /** Prefix used for the Mandate XML namespace */
+ public static final String STB_PREFIX = "stb";
+
/** URI of the MOA XML namespace. */
public static final String MOA_NS_URI =
"http://reference.e-government.gv.at/namespace/moa/20020822#";
+ /** Prefix used for the Mandate XML namespace */
+ public static final String MD_PREFIX = "md";
+
+ /** URI of the Mandate XML namespace. */
+ public static final String MD_NS_URI =
+ "http://reference.e-government.gv.at/namespace/mandates/20040701#";
+
+ /** Prefix used for the Mandate XML namespace */
+ public static final String MVV_PREFIX = "mvv";
+
+ /** URI of the Mandate XML namespace. */
+ public static final String MVV_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moavv/app2mvv/20041125";
+
+ /** Prefix used for the MandateCheckProfile XML namespace */
+ public static final String MDP_PREFIX = "mdp";
+
+ /** URI of the Mandate XML namespace. */
+ public static final String MDP_NS_URI =
+ "http://reference.e-government.gv.at/namespace/mandateprofile/20041105#";
+
/** Prefix used for the MOA XML namespace */
public static final String MOA_PREFIX = "moa";
--
cgit v1.2.3
From be0e139b0e57606477ffe09b4e8169c65e3a3701 Mon Sep 17 00:00:00 2001
From: rudolf
Date: Thu, 22 Sep 2005 10:41:49 +0000
Subject: Mergen von MOA-VV Code mit bisher bestehendem Code
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@516 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/XPathUtils.java | 111 +--------------------
1 file changed, 5 insertions(+), 106 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
index aa5a4fec5..83000d346 100644
--- a/common/src/at/gv/egovernment/moa/util/XPathUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
@@ -45,7 +45,6 @@ public class XPathUtils {
Constants.MOA_ID_CONFIG_NS_URI);
ctx.addNamespace(Constants.SL10_PREFIX, Constants.SL10_NS_URI);
ctx.addNamespace(Constants.SL11_PREFIX, Constants.SL11_NS_URI);
- ctx.addNamespace(Constants.SL12_PREFIX, Constants.SL12_NS_URI);
ctx.addNamespace(Constants.ECDSA_PREFIX, Constants.ECDSA_NS_URI);
ctx.addNamespace(Constants.PD_PREFIX, Constants.PD_NS_URI);
ctx.addNamespace(Constants.SAML_PREFIX, Constants.SAML_NS_URI);
@@ -57,6 +56,11 @@ public class XPathUtils {
Constants.DSIG_FILTER2_PREFIX,
Constants.DSIG_FILTER2_NS_URI);
ctx.addNamespace(Constants.DSIG_EC_PREFIX, Constants.DSIG_EC_NS_URI);
+ ctx.addNamespace(Constants.MD_PREFIX, Constants.MD_NS_URI);
+ ctx.addNamespace(Constants.MDP_PREFIX, Constants.MDP_NS_URI);
+ ctx.addNamespace(Constants.MVV_PREFIX, Constants.MVV_NS_URI);
+ ctx.addNamespace(Constants.STB_PREFIX, Constants.STB_NS_URI);
+ ctx.addNamespace(Constants.WRR_PREFIX, Constants.WRR_NS_URI);
NS_CONTEXT = ctx;
}
@@ -412,110 +416,5 @@ public class XPathUtils {
Attr attr = (Attr) XPathUtils.selectSingleNode(root, xpath);
return attr != null ? attr.getValue() : def;
}
-
- /**
- * Return the SecurityLayer namespace prefix of the context element.
- * If the context element has no prefix explicitely set (i.e. is specified
- * within the default namespace), the method sets the prefix
- * according to the value of the xmlns attribute of the context
- * element.
- * The returned prefix is needed for evaluating XPATH expressions.
- *
- * @param contextElement The element to get a prefix from.
- *
- * @return The string sl10, sl11 or sl,
- * depending on the SecurityLayer namespace of the contextElement.
- *
- * throws XpathException If the element has no prefix or no valid SecurityLayer
- * namespace is used as default namespace.
- */
- public static String getSlPrefix (Element contextElement) throws XPathException {
- String slPrefix = contextElement.getPrefix();
- if (slPrefix != null) {
- return slPrefix;
- } else {
- String nameSpace = contextElement.getAttribute("xmlns");
-
- if (nameSpace.equals(Constants.SL10_NS_URI)) {
- slPrefix = Constants.SL10_PREFIX;
- } else if (nameSpace.equals(Constants.SL12_NS_URI)) {
- slPrefix = Constants.SL12_PREFIX;
- } else if (nameSpace.equals(Constants.SL11_NS_URI)) {
- slPrefix = Constants.SL11_PREFIX;
- } else {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
- throw new XPathException(message, null);
-
- }
-
- return slPrefix;
- }
- }
-
-
- /**
- * Return the SecurityLayer namespace prefix of the context element.
- * If the context element is not the element that lies within the
- * SecurityLayer namespace. The Securitylayer namespace is derived from
- * the xmlns:sl10, sl11 or sl
- * attribute of the context element.
- *
- * The returned prefix is needed for evaluating XPATH expressions.
- *
- * @param contextElement The element to get a prefix for the Securitylayer namespace,
- * that is used within the corresponding document.
- *
- * @return The string sl10, sl11 or sl,
- * depending on the SecurityLayer namespace of the contextElement.
- *
- * throws XPathException If no (vlalid) SecurityLayer namespace prefix or namespace
- * is defined.
- */
- public static String getSlPrefixFromNoRoot (Element contextElement) throws XPathException {
-
- String slPrefix = checkSLnsDeclaration(contextElement, Constants.SL10_PREFIX, Constants.SL10_NS_URI);
- if (slPrefix == null) {
- slPrefix = checkSLnsDeclaration(contextElement, Constants.SL11_PREFIX, Constants.SL11_NS_URI);
- }
- if (slPrefix == null) {
- slPrefix = checkSLnsDeclaration(contextElement, Constants.SL12_PREFIX, Constants.SL12_NS_URI);
- }
-
- return slPrefix;
-
- }
-
- /**
- * Checks if the context element has an attribute xmlns:slPrefix and
- * if the prefix of that attribute corresponds with a valid SecurityLayer namespace.
- *
- * @param contextElement The element to be checked.
- * @param slPrefix The prefix which should be checked. Must be a valid SecurityLayer
- * namespace prefix.
- * @param slNameSpace The SecurityLayer namespace that corresponds to the specified prefix.
- *
- * @return The valid SecurityLayer prefix or null if this prefix is
- * not used.
- * @throws XPathException
- */
- private static String checkSLnsDeclaration(Element contextElement, String slPrefix, String slNameSpace)
- throws XPathException
- {
- String nsAtt = "xmlns:" + slPrefix;
- String nameSpace = contextElement.getAttribute(nsAtt);
- if (nameSpace == "") {
- return null;
- } else {
- // check if namespace is correct
- if (nameSpace.equals(slNameSpace)) {
- return slPrefix;
- } else {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
- throw new XPathException(message, null);
- }
- }
- }
}
--
cgit v1.2.3
From 881ab81aad02923f57bca84dfaa4509abf706cd8 Mon Sep 17 00:00:00 2001
From: "harald.bratko"
Date: Thu, 29 Sep 2005 08:19:16 +0000
Subject: Obviously SL12-prefix and methods for selecting sl-prefix has been
removed? Added them again.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@519 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/XPathUtils.java | 106 +++++++++++++++++++++
1 file changed, 106 insertions(+)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
index 83000d346..7c412567a 100644
--- a/common/src/at/gv/egovernment/moa/util/XPathUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
@@ -45,6 +45,7 @@ public class XPathUtils {
Constants.MOA_ID_CONFIG_NS_URI);
ctx.addNamespace(Constants.SL10_PREFIX, Constants.SL10_NS_URI);
ctx.addNamespace(Constants.SL11_PREFIX, Constants.SL11_NS_URI);
+ ctx.addNamespace(Constants.SL12_PREFIX, Constants.SL12_NS_URI);
ctx.addNamespace(Constants.ECDSA_PREFIX, Constants.ECDSA_NS_URI);
ctx.addNamespace(Constants.PD_PREFIX, Constants.PD_NS_URI);
ctx.addNamespace(Constants.SAML_PREFIX, Constants.SAML_NS_URI);
@@ -416,5 +417,110 @@ public class XPathUtils {
Attr attr = (Attr) XPathUtils.selectSingleNode(root, xpath);
return attr != null ? attr.getValue() : def;
}
+
+ /**
+ * Return the SecurityLayer namespace prefix of the context element.
+ * If the context element has no prefix explicitely set (i.e. is specified
+ * within the default namespace), the method sets the prefix
+ * according to the value of the xmlns attribute of the context
+ * element.
+ * The returned prefix is needed for evaluating XPATH expressions.
+ *
+ * @param contextElement The element to get a prefix from.
+ *
+ * @return The string sl10, sl11 or sl,
+ * depending on the SecurityLayer namespace of the contextElement.
+ *
+ * throws XpathException If the element has no prefix or no valid SecurityLayer
+ * namespace is used as default namespace.
+ */
+ public static String getSlPrefix (Element contextElement) throws XPathException {
+ String slPrefix = contextElement.getPrefix();
+ if (slPrefix != null) {
+ return slPrefix;
+ } else {
+ String nameSpace = contextElement.getAttribute("xmlns");
+
+ if (nameSpace.equals(Constants.SL10_NS_URI)) {
+ slPrefix = Constants.SL10_PREFIX;
+ } else if (nameSpace.equals(Constants.SL12_NS_URI)) {
+ slPrefix = Constants.SL12_PREFIX;
+ } else if (nameSpace.equals(Constants.SL11_NS_URI)) {
+ slPrefix = Constants.SL11_PREFIX;
+ } else {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
+ throw new XPathException(message, null);
+
+ }
+
+ return slPrefix;
+ }
+ }
+
+
+ /**
+ * Return the SecurityLayer namespace prefix of the context element.
+ * If the context element is not the element that lies within the
+ * SecurityLayer namespace. The Securitylayer namespace is derived from
+ * the xmlns:sl10, sl11 or sl
+ * attribute of the context element.
+ *
+ * The returned prefix is needed for evaluating XPATH expressions.
+ *
+ * @param contextElement The element to get a prefix for the Securitylayer namespace,
+ * that is used within the corresponding document.
+ *
+ * @return The string sl10, sl11 or sl,
+ * depending on the SecurityLayer namespace of the contextElement.
+ *
+ * throws XPathException If no (vlalid) SecurityLayer namespace prefix or namespace
+ * is defined.
+ */
+ public static String getSlPrefixFromNoRoot (Element contextElement) throws XPathException {
+
+ String slPrefix = checkSLnsDeclaration(contextElement, Constants.SL10_PREFIX, Constants.SL10_NS_URI);
+ if (slPrefix == null) {
+ slPrefix = checkSLnsDeclaration(contextElement, Constants.SL11_PREFIX, Constants.SL11_NS_URI);
+ }
+ if (slPrefix == null) {
+ slPrefix = checkSLnsDeclaration(contextElement, Constants.SL12_PREFIX, Constants.SL12_NS_URI);
+ }
+
+ return slPrefix;
+
+ }
+
+ /**
+ * Checks if the context element has an attribute xmlns:slPrefix and
+ * if the prefix of that attribute corresponds with a valid SecurityLayer namespace.
+ *
+ * @param contextElement The element to be checked.
+ * @param slPrefix The prefix which should be checked. Must be a valid SecurityLayer
+ * namespace prefix.
+ * @param slNameSpace The SecurityLayer namespace that corresponds to the specified prefix.
+ *
+ * @return The valid SecurityLayer prefix or null if this prefix is
+ * not used.
+ * @throws XPathException
+ */
+ private static String checkSLnsDeclaration(Element contextElement, String slPrefix, String slNameSpace)
+ throws XPathException
+ {
+ String nsAtt = "xmlns:" + slPrefix;
+ String nameSpace = contextElement.getAttribute(nsAtt);
+ if (nameSpace == "") {
+ return null;
+ } else {
+ // check if namespace is correct
+ if (nameSpace.equals(slNameSpace)) {
+ return slPrefix;
+ } else {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
+ throw new XPathException(message, null);
+ }
+ }
+ }
}
--
cgit v1.2.3
From 38016074b0dc2c15caf1478f50c2a77d7d312534 Mon Sep 17 00:00:00 2001
From: "harald.bratko"
Date: Wed, 7 Dec 2005 14:19:06 +0000
Subject: changed "enum" varianle name, because it is a keyword since jdk1.5
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@607 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'common/src')
diff --git a/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java
index 06a72c570..a6d1847ce 100644
--- a/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java
+++ b/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java
@@ -81,8 +81,8 @@ public class KeyStoreUtilsTest extends TestCase {
String keyStoreURL = "file:data/test/security/client-certs/sicher-demo(buergerkarte).p12";
KeyStore ks = KeyStoreUtils.loadKeyStore("pkcs12", keyStoreURL, "buergerkarte");
assertEquals(1, ks.size());
- Enumeration enum = ks.aliases();
- String alias = (String)enum.nextElement();
+ Enumeration aliases = ks.aliases();
+ String alias = (String)aliases.nextElement();
X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
assertEquals(new BigInteger("1044289238331").intValue(), cert.getSerialNumber().intValue());
}
--
cgit v1.2.3
From 0eb787866e2818c65eca76dd070771e809f9bdd2 Mon Sep 17 00:00:00 2001
From: "harald.bratko"
Date: Tue, 28 Feb 2006 14:03:21 +0000
Subject: method makeAbsoluteURL does not work if URL starts with a protocol
like "http://" or "file://". Fixed this.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@632 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
common/src/at/gv/egovernment/moa/util/FileUtils.java | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/FileUtils.java b/common/src/at/gv/egovernment/moa/util/FileUtils.java
index ae8d83834..a5e777c2d 100644
--- a/common/src/at/gv/egovernment/moa/util/FileUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/FileUtils.java
@@ -99,14 +99,18 @@ public class FileUtils {
String newURL = url;
if(null == url) return null;
-
- // check if absolute - if not make it absolute
- keyFile = new File(url);
- if (!keyFile.isAbsolute()) {
- keyFile = new File(root, url);
- newURL = keyFile.getPath();
+
+ if (url.startsWith("http:/") || url.startsWith("https:/") || url.startsWith("file:/") || url.startsWith("ftp:/")) {
+ return url;
+ } else {
+ // check if absolute - if not make it absolute
+ keyFile = new File(url);
+ if (!keyFile.isAbsolute()) {
+ keyFile = new File(root, url);
+ newURL = keyFile.getPath();
+ }
+ return newURL;
}
- return newURL;
}
}
--
cgit v1.2.3
From d28ec7c9b309325d47e3cd3a99a4ae2cba269098 Mon Sep 17 00:00:00 2001
From: "harald.bratko"
Date: Thu, 27 Apr 2006 13:04:16 +0000
Subject: Changed method getSLPrefix to in all cases retrieve SecurityLayer
namespace from the namespace uri - and not use the actual prefix if present.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@705 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
.../src/at/gv/egovernment/moa/util/XPathUtils.java | 50 ++++++++++------------
1 file changed, 23 insertions(+), 27 deletions(-)
(limited to 'common/src')
diff --git a/common/src/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
index 7c412567a..dfb14697b 100644
--- a/common/src/at/gv/egovernment/moa/util/XPathUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
@@ -420,10 +420,14 @@ public class XPathUtils {
/**
* Return the SecurityLayer namespace prefix of the context element.
- * If the context element has no prefix explicitely set (i.e. is specified
- * within the default namespace), the method sets the prefix
- * according to the value of the xmlns attribute of the context
- * element.
+ * The method sets the prefix according to the value of the
+ * namespace URI of the context element:
+ *
This schema should never be used as such:
- the XML
- Schema Recommendation forbids the declaration of
- attributes in this namespace
-
-
-
-
-
-
-
-
diff --git a/common/res/resources/schemas/XMLSchema.dtd b/common/res/resources/schemas/XMLSchema.dtd
deleted file mode 100644
index e8e8f7625..000000000
--- a/common/res/resources/schemas/XMLSchema.dtd
+++ /dev/null
@@ -1,402 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-%xs-datatypes;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/common/res/resources/schemas/cs-sstc-schema-assertion-01.xsd b/common/res/resources/schemas/cs-sstc-schema-assertion-01.xsd
deleted file mode 100644
index 8bc5af147..000000000
--- a/common/res/resources/schemas/cs-sstc-schema-assertion-01.xsd
+++ /dev/null
@@ -1,194 +0,0 @@
-
-
-
-
-
-
- Document identifier: cs-sstc-schema-assertion-01
- Location: http://www.oasis-open.org/committees/security/docs/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/common/res/resources/schemas/cs-sstc-schema-protocol-01.xsd b/common/res/resources/schemas/cs-sstc-schema-protocol-01.xsd
deleted file mode 100644
index ecad05b0f..000000000
--- a/common/res/resources/schemas/cs-sstc-schema-protocol-01.xsd
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
- Document identifier: cs-sstc-schema-protocol-01
- Location: http://www.oasis-open.org/committees/security/docs/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/common/res/resources/schemas/datatypes.dtd b/common/res/resources/schemas/datatypes.dtd
deleted file mode 100644
index 8e48553be..000000000
--- a/common/res/resources/schemas/datatypes.dtd
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/common/res/resources/schemas/exclusive-canonicalization.xsd b/common/res/resources/schemas/exclusive-canonicalization.xsd
deleted file mode 100644
index d4a2d82ec..000000000
--- a/common/res/resources/schemas/exclusive-canonicalization.xsd
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/common/res/resources/schemas/xml.xsd b/common/res/resources/schemas/xml.xsd
deleted file mode 100644
index 79dbc02ba..000000000
--- a/common/res/resources/schemas/xml.xsd
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
-
- See http://www.w3.org/XML/1998/namespace.html and
- http://www.w3.org/TR/REC-xml for information about this namespace.
-
-
-
-
- This schema defines attributes and an attribute group
- suitable for use by
- schemas wishing to allow xml:base, xml:lang or xml:space attributes
- on elements they define.
-
- To enable this, such a schema must import this schema
- for the XML namespace, e.g. as follows:
- <schema . . .>
- . . .
- <import namespace="http://www.w3.org/XML/1998/namespace"
- schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
-
- Subsequently, qualified reference to any of the attributes
- or the group defined below will have the desired effect, e.g.
-
- <type . . .>
- . . .
- <attributeGroup ref="xml:specialAttrs"/>
-
- will define a type which will schema-validate an instance
- element with any of those attributes
-
-
-
- In keeping with the XML Schema WG's standard versioning
- policy, this schema document will persist at
- http://www.w3.org/2001/03/xml.xsd.
- At the date of issue it can also be found at
- http://www.w3.org/2001/xml.xsd.
- The schema document at that URI may however change in the future,
- in order to remain compatible with the latest version of XML Schema
- itself. In other words, if the XML Schema namespace changes, the version
- of this document at
- http://www.w3.org/2001/xml.xsd will change
- accordingly; the version at
- http://www.w3.org/2001/03/xml.xsd will not change.
-
-
-
-
-
- In due course, we should install the relevant ISO 2- and 3-letter
- codes as the enumerated possible values . . .
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- See http://www.w3.org/TR/xmlbase/ for
- information about this attribute.
-
-
-
-
-
-
-
-
-
-
diff --git a/common/res/resources/schemas/xmldsig-core-schema.xsd b/common/res/resources/schemas/xmldsig-core-schema.xsd
deleted file mode 100644
index a7e302373..000000000
--- a/common/res/resources/schemas/xmldsig-core-schema.xsd
+++ /dev/null
@@ -1,264 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/common/res/resources/schemas/xmldsig-filter2.xsd b/common/res/resources/schemas/xmldsig-filter2.xsd
deleted file mode 100644
index 330eafd19..000000000
--- a/common/res/resources/schemas/xmldsig-filter2.xsd
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/common/src/at/gv/egovernment/moa/logging/LogMsg.java b/common/src/at/gv/egovernment/moa/logging/LogMsg.java
deleted file mode 100644
index 4d04fc72d..000000000
--- a/common/src/at/gv/egovernment/moa/logging/LogMsg.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package at.gv.egovernment.moa.logging;
-
-/**
- * A unified message type to log messages from inside the MOA subsystem.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class LogMsg {
- /** The message to log. */
- private Object message;
-
- /**
- * Create a LogMsg object.
- *
- * @param message The actual message to log. May be null.
- */
- public LogMsg(Object message) {
- this.message = message;
- }
-
- /**
- * Convert this log message to a String.
- *
- * @return The String representation of this log message.
- */
- public String toString() {
- StringBuffer msg = new StringBuffer();
- LoggingContext ctx =
- LoggingContextManager.getInstance().getLoggingContext();
- String tid = ctx != null ? ctx.getTransactionID() : null;
- String nodeId = ctx != null ? ctx.getNodeID() : null;
-
- msg.append("TID=");
- msg.append(tid != null ? tid : "");
- msg.append(" NID=");
- msg.append(nodeId != null ? nodeId : "");
- msg.append(" MSG=");
- msg.append(message != null ? message.toString() : "");
-
- return msg.toString();
- }
-}
diff --git a/common/src/at/gv/egovernment/moa/logging/Logger.java b/common/src/at/gv/egovernment/moa/logging/Logger.java
deleted file mode 100644
index eb7aa5634..000000000
--- a/common/src/at/gv/egovernment/moa/logging/Logger.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package at.gv.egovernment.moa.logging;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * A utility class acting as a facade to the logging subsystem.
- *
- * Configure the logging defaultHierarchy that the Logger uses by
- * calling setHierarchy once before calling any of the logging
- * output functions.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class Logger {
-
- /** The default logging hierarchy. */
- private static String defaultHierarchy = "";
-
- /**
- * Get the Log object for the default hierarchy.
- *
- * @return The Log object to write log messages to.
- */
- private static Log getLog() {
- return LogFactory.getLog(defaultHierarchy);
- }
-
- /**
- * Get the Log object for a given hierarchy.
- *
- * @param hierarchy The logging hierarchy for which to return the logger.
- * @return The Log object to write log messages to.
- */
- private static Log getLog(String hierarchy) {
- return LogFactory.getLog(hierarchy);
- }
-
- /**
- * Set the default hierarchy to which the Logger should send its
- * logging output.
- * @param hierarchy The logging defaultHierarchy.
- */
- public static void setHierarchy(String hierarchy) {
- defaultHierarchy = hierarchy;
- }
-
- /**
- * Test, if the trace log level is enabled.
- *
- * @return boolean true, if tracing output is enabled
- * false otherwise.
- */
- public static boolean isTraceEnabled() {
- return getLog().isTraceEnabled();
- }
-
- /**
- * Test, if the trace log level is enabled for a given hierarchy.
- *
- * @param hierarchy requested log hierarchy
- * @return boolean true, if tracing output is enabled
- * false otherwise.
- */
- public static boolean isTraceEnabled(String hierarchy) {
- return getLog(hierarchy).isTraceEnabled();
- }
-
- /**
- * Trace a message.
- *
- * @param message The message to trace.
- */
- public static void trace(Object message) {
- getLog().trace(message);
- }
-
- /**
- * Test, if the debug log level is enabled.
- *
- * @return boolean true, if debug output is enabled
- * false otherwise.
- */
- public static boolean isDebugEnabled() {
- return getLog().isDebugEnabled();
- }
-
- /**
- * Test, if the debug log level is enabled for a given hierarchy.
- *
- * @param hierarchy requested log hierarchy
- * @return boolean true, if debug output is enabled
- * false otherwise.
- */
- public static boolean isDebugEnabled(String hierarchy) {
- return getLog(hierarchy).isDebugEnabled();
- }
-
- /**
- * Log a debug message.
- *
- * @param message The message to log.
- */
- public static void debug(Object message) {
- getLog().debug(message);
- }
-
- /**
- * Log an info message.
- *
- * @param message The message to log.
- */
- public static void info(Object message) {
- getLog().info(message);
- }
-
- /**
- * Log a warning message.
- *
- * @param message The message to log.
- */
- public static void warn(Object message) {
- getLog().warn(message);
- }
-
- /**
- * Log a warning message.
- *
- * @param message The message to log.
- * @param t An exception that may be the cause of the warning.
- */
- public static void warn(Object message, Throwable t) {
- getLog().warn(message, t);
- }
-
- /**
- * Log an error message.
- *
- * @param message The message to log.
- */
- public static void error(Object message) {
- getLog().error(message);
- }
-
- /**
- * Log an error message.
- *
- * @param message The message to log.
- * @param t An exception that may be the cause of the error.
- */
- public static void error(Object message, Throwable t) {
- getLog().error(message, t);
- }
-
- /**
- * Log a fatal error message.
- *
- * @param message The message to log.
- */
- public static void fatal(Object message) {
- getLog().fatal(message);
- }
-
- /**
- * Log a fatal error message.
- *
- * @param message The message to log.
- * @param t An exception that may be the cause of the error.
- */
- public static void fatal(Object message, Throwable t) {
- getLog().fatal(message, t);
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/logging/LoggingContext.java b/common/src/at/gv/egovernment/moa/logging/LoggingContext.java
deleted file mode 100644
index 42d8db06e..000000000
--- a/common/src/at/gv/egovernment/moa/logging/LoggingContext.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package at.gv.egovernment.moa.logging;
-
-/**
- * Encapsulates contextual information (i.e. per request information) for
- * logging purposes.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class LoggingContext {
- /** The name of the node ID system property. */
- public static final String NODE_ID_PROPERTY = "moa.node-id";
-
- /** The current transaction ID. */
- private String transactionID;
- /** The node ID. */
- private String nodeID;
-
- /**
- * Create a new LoggingContext.
- *
- * @param transactionID The transaction ID. May be null.
- */
- public LoggingContext(String transactionID) {
- this.transactionID = transactionID;
- this.nodeID = System.getProperty(NODE_ID_PROPERTY);
- }
-
- /**
- * Return the transaction ID.
- *
- * @return The transaction ID.
- */
- public String getTransactionID() {
- return transactionID;
- }
-
- /**
- * Return the node ID.
- *
- * @return The node ID.
- */
- public String getNodeID() {
- return nodeID;
- }
-}
diff --git a/common/src/at/gv/egovernment/moa/logging/LoggingContextManager.java b/common/src/at/gv/egovernment/moa/logging/LoggingContextManager.java
deleted file mode 100644
index 2bbe6caa1..000000000
--- a/common/src/at/gv/egovernment/moa/logging/LoggingContextManager.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package at.gv.egovernment.moa.logging;
-
-/**
- * Provides each thread with a single instance of LoggingContext.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class LoggingContextManager {
- /** The single instance of this class. */
- private static LoggingContextManager instance = null;
-
- /** The LoggingContext for each thread. */
- private ThreadLocal context;
-
- /**
- * Get the single instance of the LoggingContextManager class.
- *
- * @return LoggingContextManager The single instance.
- */
- public static synchronized LoggingContextManager getInstance() {
- if (instance == null) {
- instance = new LoggingContextManager();
- }
- return instance;
- }
-
- /**
- * Creates a new LoggingContextManager.
- *
- * Protected to disallow direct instantiation.
- */
- protected LoggingContextManager() {
- context = new ThreadLocal();
- }
-
- /**
- * Set the LoggingContext context for the current thread.
- *
- * @param ctx The LoggingContext for the current thread.
- */
- public void setLoggingContext(LoggingContext ctx) {
- context.set(ctx);
- }
-
- /**
- * Return the LoggingContext for the current thread.
- *
- * @return LoggingContext The LoggingContext for the current
- * thread, or null if none has been set.
- */
- public LoggingContext getLoggingContext() {
- return (LoggingContext) context.get();
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/Base64Utils.java b/common/src/at/gv/egovernment/moa/util/Base64Utils.java
deleted file mode 100644
index ad29180a6..000000000
--- a/common/src/at/gv/egovernment/moa/util/Base64Utils.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import iaik.utils.Base64InputStream;
-import iaik.utils.Base64OutputStream;
-
-/**
- * Utitility functions for encoding/decoding Base64 strings.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class Base64Utils {
-
- /**
- * Read the bytes encoded in a Base64 encoded String.
- *
- * @param base64String The String containing the Base64 encoded
- * bytes.
- * @param ignoreInvalidChars Whether to ignore invalid Base64 characters.
- * @return byte[] The raw bytes contained in the base64String.
- * @throws IOException Failed to read the Base64 data.
- */
- public static byte[] decode(String base64String, boolean ignoreInvalidChars)
- throws IOException {
-
- Base64InputStream in =
- new Base64InputStream(
- new ByteArrayInputStream(base64String.getBytes("UTF-8")),
- ignoreInvalidChars);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] bytes = new byte[256];
- int bytesRead;
-
- while ((bytesRead = in.read(bytes)) > 0) {
- out.write(bytes, 0, bytesRead);
- }
-
- return out.toByteArray();
- }
-
- /**
- * Read the bytes encoded in a Base64 encoded String and provide
- * them via an InputStream.
- *
- * @param base64String The String containing the Base64 encoded
- * bytes.
- * @param ignoreInvalidChars Whether to ignore invalid Base64 characters.
- * @return The InputStream from which the binary content of the
- * base64String can be read.
- */
- public static InputStream decodeToStream(
- String base64String,
- boolean ignoreInvalidChars) {
-
- try {
- ByteArrayInputStream bin =
- new ByteArrayInputStream(base64String.getBytes("UTF-8"));
- Base64InputStream in = new Base64InputStream(bin, ignoreInvalidChars);
-
- return in;
- } catch (UnsupportedEncodingException e) {
- // cannot occur, since UTF-8 is required to be supported by every JRE
- return null;
- }
- }
-
- /**
- * Convert a byte array to a Base64 encoded String.
- *
- * @param bytes The bytes to encode.
- * @return String The Base64 encoded representation of the bytes.
- * @throws IOException Failed to write the bytes as Base64 data.
- */
- public static String encode(byte[] bytes) throws IOException {
- return encode(new ByteArrayInputStream(bytes));
- }
-
- /**
- * Convert the data contained in the given stream to a Base64 encoded
- * String.
- *
- * @param inputStream The stream containing the data to encode.
- * @return The Base64 encoded data of inputStream, as a
- * String.
- * @throws IOException Failed to convert the data in the stream.
- */
- public static String encode(InputStream inputStream) throws IOException {
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- Base64OutputStream base64Stream = new Base64OutputStream(byteStream, "\n".getBytes());
- byte[] bytes = new byte[256];
- int bytesRead;
-
- while ((bytesRead = inputStream.read(bytes)) > 0) {
- base64Stream.write(bytes, 0, bytesRead);
- }
- base64Stream.flush();
- base64Stream.close();
- inputStream.close();
-
- return byteStream.toString("UTF-8");
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/BoolUtils.java b/common/src/at/gv/egovernment/moa/util/BoolUtils.java
deleted file mode 100644
index fcd39b4dd..000000000
--- a/common/src/at/gv/egovernment/moa/util/BoolUtils.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-/**
- * Utility class for parsing XML schema boolean values.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class BoolUtils {
-
- /**
- * Return the boolean value of an xsd:boolean type of DOM
- * element/attribute.
- *
- * @param boolStr The value of the xsd:boolean element/attribute.
- * @return true, if boolStr equals
- * "true" or "1;". Otherwise,
- * false is returned.
- */
- public static boolean valueOf(String boolStr) {
- return "true".equals(boolStr) || "1".equals(boolStr);
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/CollectionUtils.java b/common/src/at/gv/egovernment/moa/util/CollectionUtils.java
deleted file mode 100644
index 5329dcbd2..000000000
--- a/common/src/at/gv/egovernment/moa/util/CollectionUtils.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Various utility methods for dealing with java.util.Collection
- * classes.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class CollectionUtils {
-
- /**
- * Convert a List of Number objects to an
- * int array.
- *
- * @param nums The List containing the numbers whose integer
- * value to put into the result.
- * @return The int values of the Numbers contained
- * in nums.
- */
- public static int[] toIntArray(List nums) {
- int[] result = new int[nums.size()];
- Iterator iter;
- int i;
-
- for (i = 0, iter = nums.iterator(); iter.hasNext(); i++) {
- Number num = (Number) iter.next();
- result[i] = num.intValue();
- }
-
- return result;
- }
-}
diff --git a/common/src/at/gv/egovernment/moa/util/Constants.java b/common/src/at/gv/egovernment/moa/util/Constants.java
deleted file mode 100644
index 5c1314296..000000000
--- a/common/src/at/gv/egovernment/moa/util/Constants.java
+++ /dev/null
@@ -1,318 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.util.HashMap;
-
-/**
- * Contains various constants used throughout the system.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public interface Constants {
- /** Root location of the schema files. */
- public static final String SCHEMA_ROOT = "/resources/schemas/";
-
- /** URI of the Widerrufregister XML namespace. */
- public static final String WRR_NS_URI =
- "http://reference.e-government.gv.at/namespace/moavv/20041223";
-
- /** Prefix used for the Widerrufregister XML namespace */
- public static final String WRR_PREFIX = "wrr";
-
- /** URI of the StandardTextBlock XML namespace. */
- public static final String STB_NS_URI =
- "http://reference.e-government.gv.at/namespace/standardtextblock/20041105#";
-
- /** Prefix used for the Mandate XML namespace */
- public static final String STB_PREFIX = "stb";
-
- /** URI of the MOA XML namespace. */
- public static final String MOA_NS_URI =
- "http://reference.e-government.gv.at/namespace/moa/20020822#";
-
- /** Prefix used for the Mandate XML namespace */
- public static final String MD_PREFIX = "md";
-
- /** URI of the Mandate XML namespace. */
- public static final String MD_NS_URI =
- "http://reference.e-government.gv.at/namespace/mandates/20040701#";
-
- /** Prefix used for the Mandate XML namespace */
- public static final String MVV_PREFIX = "mvv";
-
- /** URI of the Mandate XML namespace. */
- public static final String MVV_NS_URI =
- "http://reference.e-government.gv.at/namespace/moavv/app2mvv/20041125";
-
- /** Prefix used for the MandateCheckProfile XML namespace */
- public static final String MDP_PREFIX = "mdp";
-
- /** URI of the Mandate XML namespace. */
- public static final String MDP_NS_URI =
- "http://reference.e-government.gv.at/namespace/mandateprofile/20041105#";
-
- /** Prefix used for the MOA XML namespace */
- public static final String MOA_PREFIX = "moa";
-
- /** Local location of the MOA XML schema definition. */
- public static final String MOA_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-SPSS-1.3.xsd";
-
- /** URI of the MOA configuration XML namespace. */
- public static final String MOA_CONFIG_NS_URI =
- "http://reference.e-government.gv.at/namespace/moaconfig/20021122#";
-
- /** URI of the MOA ID configuration XML namespace. */
- public static final String MOA_ID_CONFIG_NS_URI =
- "http://www.buergerkarte.at/namespaces/moaconfig#";
-
- /** Prefix used for the MOA configuration XML namespace */
- public static final String MOA_CONFIG_PREFIX = "conf";
-
- /** Prefix used for the MOA configuration XML namespace */
- public static final String MOA_ID_CONFIG_PREFIX = "confID";
-
- /** Local location of the MOA configuration XML schema definition. */
- public static final String MOA_CONFIG_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-SPSS-config-1.3.xsd";
-
- /** Local location of the MOA ID configuration XML schema definition. */
- public static final String MOA_ID_CONFIG_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-ID-Configuration-1.4.xsd";
-
- /** URI of the Security Layer 1.0 namespace. */
- public static final String SL10_NS_URI =
- "http://www.buergerkarte.at/namespaces/securitylayer/20020225#";
-
- /** Prefix used for the Security Layer 1.0 XML namespace */
- public static final String SL10_PREFIX = "sl10";
-
- /** Local location of the Security Layer 1.0 XML schema definition */
- public static final String SL10_SCHEMA_LOCATION =
- SCHEMA_ROOT + "Core.20020225.xsd";
-
- /** URI of the Security Layer 1.1 XML namespace */
- public static final String SL11_NS_URI =
- "http://www.buergerkarte.at/namespaces/securitylayer/20020831#";
-
- /** Prefix used for the Security Layer 1.1 XML namespace */
- public static final String SL11_PREFIX = "sl11";
-
- /** Local location of the Security Layer 1.1 XML schema definition */
- public static final String SL11_SCHEMA_LOCATION =
- SCHEMA_ROOT + "Core.20020831.xsd";
-
- /** URI of the Security Layer 1.2 XML namespace */
- public static final String SL12_NS_URI =
- "http://www.buergerkarte.at/namespaces/securitylayer/1.2#";
-
- /** Prefix used for the Security Layer 1.2 XML namespace */
- public static final String SL12_PREFIX = "sl";
-
- /** Local location of the Security Layer 1.2 XML schema definition */
- public static final String SL12_SCHEMA_LOCATION =
- SCHEMA_ROOT + "Core-1.2.xsd";
-
- /** URI of the ECDSA XML namespace */
- public static final String ECDSA_NS_URI =
- "http://www.w3.org/2001/04/xmldsig-more#";
-
- /** Prefix used for ECDSA namespace */
- public static final String ECDSA_PREFIX = "ecdsa";
-
- /** Local location of ECDSA XML schema definition */
- public static final String ECDSA_SCHEMA_LOCATION =
- SCHEMA_ROOT + "ECDSAKeyValue.xsd";
-
- /** URI of the PersonData XML namespace. */
- public static final String PD_NS_URI =
- "http://reference.e-government.gv.at/namespace/persondata/20020228#";
-
- /** Prefix used for the PersonData XML namespace */
- public static final String PD_PREFIX = "pr";
-
-// /** Local location of the PersonData XML schema definition */
-// public static final String PD_SCHEMA_LOCATION =
-// SCHEMA_ROOT + "PersonData.xsd";
-
- /** Local location of the PersonData XML schema definition */
- public static final String PD_SCHEMA_LOCATION =
- SCHEMA_ROOT + "PersonData_20_en_moaWID.xsd";
-
- /** URI of the SAML namespace. */
- public static final String SAML_NS_URI =
- "urn:oasis:names:tc:SAML:1.0:assertion";
-
- /** Prefix used for the SAML XML namespace */
- public static final String SAML_PREFIX = "saml";
-
- /** Local location of the SAML XML schema definition. */
- public static final String SAML_SCHEMA_LOCATION =
- SCHEMA_ROOT + "cs-sstc-schema-assertion-01.xsd";
-
- /** URI of the SAML request-response protocol namespace. */
- public static final String SAMLP_NS_URI =
- "urn:oasis:names:tc:SAML:1.0:protocol";
-
- /** Prefix used for the SAML request-response protocol namespace */
- public static final String SAMLP_PREFIX = "samlp";
-
- /** Local location of the SAML request-response protocol schema definition. */
- public static final String SAMLP_SCHEMA_LOCATION =
- SCHEMA_ROOT + "cs-sstc-schema-protocol-01.xsd";
-
- /** URI of the XML namespace. */
- public static final String XML_NS_URI =
- "http://www.w3.org/XML/1998/namespace";
-
- /** Prefix used for the XML namespace */
- public static final String XML_PREFIX = "xml";
-
- /** Local location of the XML schema definition. */
- public static final String XML_SCHEMA_LOCATION = SCHEMA_ROOT + "xml.xsd";
-
- /** URI of the XMLNS namespace */
- public static final String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/";
-
- /** Prefix used for the XSI namespace */
- public static final String XSI_PREFIX = "xsi";
-
- /** Local location of the XSI schema definition. */
- public static final String XSI_SCHEMA_LOCATION =
- SCHEMA_ROOT + "XMLSchema-instance.xsd";
-
- /** URI of the XSI XMLNS namespace */
- public static final String XSI_NS_URI =
- "http://www.w3.org/2001/XMLSchema-instance";
-
- /** URI of the XSLT XML namespace */
- public static final String XSLT_NS_URI =
- "http://www.w3.org/1999/XSL/Transform";
-
- /** Prefix used for the XSLT XML namespace */
- public static final String XSLT_PREFIX = "xsl";
-
- /** URI of the XMLDSig XML namespace. */
- public static final String DSIG_NS_URI = "http://www.w3.org/2000/09/xmldsig#";
-
- /** Prefix used for the XMLDSig XML namespace */
- public static final String DSIG_PREFIX = "dsig";
-
- /** Local location of the XMLDSig XML schema. */
- public static final String DSIG_SCHEMA_LOCATION =
- SCHEMA_ROOT + "xmldsig-core-schema.xsd";
-
- /** URI of the XMLDSig XPath Filter XML namespace. */
- public static final String DSIG_FILTER2_NS_URI =
- "http://www.w3.org/2002/06/xmldsig-filter2";
-
- /** Prefix used for the XMLDSig XPath Filter XML namespace */
- public static final String DSIG_FILTER2_PREFIX = "dsig-filter2";
-
- /** Local location of the XMLDSig XPath Filter XML schema definition. */
- public static final String DSIG_FILTER2_SCHEMA_LOCATION =
- SCHEMA_ROOT + "xmldsig-filter2.xsd";
-
- /** URI of the Exclusive Canonicalization XML namespace */
- public static final String DSIG_EC_NS_URI =
- "http://www.w3.org/2001/10/xml-exc-c14n#";
-
- /** Prefix used for the Exclusive Canonicalization XML namespace */
- public static final String DSIG_EC_PREFIX = "ec";
-
- /** Local location of the Exclusive Canonicalizaion XML schema definition */
- public static final String DSIG_EC_SCHEMA_LOCATION =
- SCHEMA_ROOT + "exclusive-canonicalization.xsd";
-
- /** URI of the XMLLoginParameterResolver Configuration XML namespace */
- public static final String XMLLPR_NS_URI="http://reference.e-government.gv.at/namespace/moa/20020822#/xmllpr20030814";
-
- /** Local location of the XMLLoginParameterResolver Configuration XML schema definition */
- public static final String XMLLPR_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOAIdentities.xsd";
-
-
- /**
- * Contains all namespaces and local schema locations for XML schema
- * definitions relevant for MOA. For use in validating XML parsers.
- */
- public static final String ALL_SCHEMA_LOCATIONS =
- (MOA_NS_URI + " " + MOA_SCHEMA_LOCATION + " ")
- + (MOA_CONFIG_NS_URI + " " + MOA_CONFIG_SCHEMA_LOCATION + " ")
- + (MOA_ID_CONFIG_NS_URI + " " + MOA_ID_CONFIG_SCHEMA_LOCATION + " ")
- + (SL10_NS_URI + " " + SL10_SCHEMA_LOCATION + " ")
- + (SL11_NS_URI + " " + SL11_SCHEMA_LOCATION + " ")
- + (SL12_NS_URI + " " + SL12_SCHEMA_LOCATION + " ")
- + (ECDSA_NS_URI + " " + ECDSA_SCHEMA_LOCATION + " ")
- + (PD_NS_URI + " " + PD_SCHEMA_LOCATION + " ")
- + (SAML_NS_URI + " " + SAML_SCHEMA_LOCATION + " ")
- + (SAMLP_NS_URI + " " + SAMLP_SCHEMA_LOCATION + " ")
- + (XML_NS_URI + " " + XML_SCHEMA_LOCATION + " ")
- + (XSI_NS_URI + " " + XSI_SCHEMA_LOCATION + " ")
- + (DSIG_NS_URI + " " + DSIG_SCHEMA_LOCATION + " ")
- + (DSIG_FILTER2_NS_URI + " " + DSIG_FILTER2_SCHEMA_LOCATION + " ")
- + (DSIG_EC_NS_URI + " " + DSIG_EC_SCHEMA_LOCATION + " ")
- + (XMLLPR_NS_URI + " " + XMLLPR_SCHEMA_LOCATION);
-
- /** URN prefix for bPK and wbPK. */
- public static final String URN_PREFIX = "urn:publicid:gv.at";
-
- /** URN prefix for context dependent id. */
- public static final String URN_PREFIX_CDID = URN_PREFIX + ":cdid";
-
- /** URN prefix for context dependent id (bPK). */
- public static final String URN_PREFIX_BPK = URN_PREFIX_CDID + "+bpk";
-
- /** URN prefix for context dependent id (HPI). */
- public static final String URN_PREFIX_HPI = URN_PREFIX_CDID + "+EHSP";
-
- /** URN prefix for context dependent id (wbPK). */
- public static final String URN_PREFIX_WBPK = URN_PREFIX + ":wbpk";
-
- /** URN prefix for context dependent id. */
- public static final String URN_PREFIX_BASEID = URN_PREFIX + ":baseid";
-
- /** Security Layer manifest type URI. */
- public static final String SL_MANIFEST_TYPE_URI =
- "http://www.buergerkarte.at/specifications/Security-Layer/20020225#SignatureManifest";
-
- /** URI of the SHA1 digest algorithm */
- public static final String SHA1_URI =
- "http://www.w3.org/2000/09/xmldsig#sha1";
-
- /** URI of the Canonical XML algorithm */
- public static final String C14N_URI =
- "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
-
- /** URI of the Canoncial XML with comments algorithm */
- public static final String C14N_WITH_COMMENTS_URI =
- "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
-
- /** URI of the Exclusive Canonical XML algorithm */
- public static final String EXC_C14N_URI =
- "http://www.w3.org/2001/10/xml-exc-c14n#";
-
- /** URI of the Exclusive Canonical XML with commments algorithm */
- public static final String EXC_C14N_WITH_COMMENTS_URI =
- "http://www.w3.org/2001/10/xml-exc-c14n#WithComments";
-
- //
- // Local names for elements of the MOA SPSS schema
- //
-
- /**
- * Local name of request for creating an XML signature.
- */
- public static final String MOA_SPSS_CREATE_XML_REQUEST = "CreateXMLSignatureRequest";
-
- /**
- * Local name of request for verifying an XML signature.
- */
- public static final String MOA_SPSS_VERIFY_XML_REQUEST = "VerifiyXMLSignatureRequest";
-
- /**
- * A map used to map namespace prefixes to namespace URIs
- */
- public static HashMap nSMap = new HashMap(5);
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
deleted file mode 100644
index 5be0bb500..000000000
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ /dev/null
@@ -1,971 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.apache.xerces.parsers.DOMParser;
-import org.apache.xerces.parsers.SAXParser;
-import org.apache.xerces.parsers.XMLGrammarPreparser;
-import org.apache.xerces.util.SymbolTable;
-import org.apache.xerces.util.XMLGrammarPoolImpl;
-import org.apache.xerces.xni.grammars.XMLGrammarDescription;
-import org.apache.xerces.xni.grammars.XMLGrammarPool;
-import org.apache.xerces.xni.parser.XMLInputSource;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-
-import at.gv.egovernment.moa.logging.Logger;
-
-/**
- * Various utility functions for handling XML DOM trees.
- *
- * The parsing methods in this class make use of some features internal to the
- * Xerces DOM parser, mainly for performance reasons. As soon as JAXP
- * (currently at version 1.2) is better at schema handling, it should be used as
- * the parser interface.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class DOMUtils {
-
- /** Feature URI for namespace aware parsing. */
- private static final String NAMESPACES_FEATURE =
- "http://xml.org/sax/features/namespaces";
- /** Feature URI for validating parsing. */
- private static final String VALIDATION_FEATURE =
- "http://xml.org/sax/features/validation";
- /** Feature URI for schema validating parsing. */
- private static final String SCHEMA_VALIDATION_FEATURE =
- "http://apache.org/xml/features/validation/schema";
- /** Feature URI for normalization of element/attribute values. */
- private static final String NORMALIZED_VALUE_FEATURE =
- "http://apache.org/xml/features/validation/schema/normalized-value";
- /** Feature URI for parsing ignorable whitespace. */
- private static final String INCLUDE_IGNORABLE_WHITESPACE_FEATURE =
- "http://apache.org/xml/features/dom/include-ignorable-whitespace";
- /** Feature URI for creating EntityReference nodes in the DOM tree. */
- private static final String CREATE_ENTITY_REF_NODES_FEATURE =
- "http://apache.org/xml/features/dom/create-entity-ref-nodes";
- /** Property URI for providing external schema locations. */
- private static final String EXTERNAL_SCHEMA_LOCATION_PROPERTY =
- "http://apache.org/xml/properties/schema/external-schemaLocation";
- /** Property URI for providing the external schema location for elements
- * without a namespace. */
- private static final String EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY =
- "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
- /** Property URI for the Xerces grammar pool. */
- private static final String GRAMMAR_POOL =
- org.apache.xerces.impl.Constants.XERCES_PROPERTY_PREFIX
- + org.apache.xerces.impl.Constants.XMLGRAMMAR_POOL_PROPERTY;
- /** A prime number for initializing the symbol table. */
- private static final int BIG_PRIME = 2039;
- /** Symbol table for the grammar pool. */
- private static SymbolTable symbolTable = new SymbolTable(BIG_PRIME);
- /** Xerces schema grammar pool. */
- private static XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
- /** Set holding the NamespaceURIs of the grammarPool, to prevent multiple
- * entries of same grammars to the pool */
- private static Set grammarNamespaces;
-
- static {
- grammarPool.lockPool();
- grammarNamespaces = new HashSet();
- }
-
- /**
- * Preparse a schema and add it to the schema pool.
- * The method only adds the schema to the pool if a schema having the same
- * systemId (namespace URI) is not already present in the pool.
- *
- * @param inputStream An InputStream providing the contents of
- * the schema.
- * @param systemId The systemId (namespace URI) to use for the schema.
- * @throws IOException An error occurred reading the schema.
- */
- public static void addSchemaToPool(InputStream inputStream, String systemId)
- throws IOException {
- XMLGrammarPreparser preparser;
-
- if (!grammarNamespaces.contains(systemId)) {
-
- grammarNamespaces.add(systemId);
-
- // unlock the pool so that we can add another grammar
- grammarPool.unlockPool();
-
- // prepare the preparser
- preparser = new XMLGrammarPreparser(symbolTable);
- preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
- preparser.setProperty(GRAMMAR_POOL, grammarPool);
- preparser.setFeature(NAMESPACES_FEATURE, true);
- preparser.setFeature(VALIDATION_FEATURE, true);
-
- // add the grammar to the pool
- preparser.preparseGrammar(
- XMLGrammarDescription.XML_SCHEMA,
- new XMLInputSource(null, systemId, null, inputStream, null));
-
- // lock the pool again so that schemas are not added automatically
- grammarPool.lockPool();
- }
- }
-
- /**
- * Parse an XML document from an InputStream.
- *
- * @param inputStream The InputStream containing the XML
- * document.
- * @param validating If true, parse validating.
- * @param externalSchemaLocations A String containing namespace
- * URI to schema location pairs, the same way it is accepted by the xsi:
- * schemaLocation attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * xsi:noNamespaceSchemaLocation attribute.
- * @param entityResolver An EntityResolver to resolve external
- * entities (schemas and DTDs). If null, it will not be set.
- * @param errorHandler An ErrorHandler to decide what to do
- * with parsing errors. If null, it will not be set.
- * @return The parsed XML document as a DOM tree.
- * @throws SAXException An error occurred parsing the document.
- * @throws IOException An error occurred reading the document.
- * @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
- */
- public static Document parseDocument(
- InputStream inputStream,
- boolean validating,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation,
- EntityResolver entityResolver,
- ErrorHandler errorHandler)
- throws SAXException, IOException, ParserConfigurationException {
-
- DOMParser parser;
-
-
-
- //if Debug is enabled make a copy of inputStream to enable debug output in case of SAXException
- byte buffer [] = null;
- ByteArrayInputStream baStream = null;
- if(true == Logger.isDebugEnabled()) {
- int len = inputStream.available();
- buffer = new byte[len];
- inputStream.read(buffer);
- baStream = new ByteArrayInputStream(buffer);
- }
-
- // create the DOM parser
- if (symbolTable != null) {
- parser = new DOMParser(symbolTable, grammarPool);
- } else {
- parser = new DOMParser();
- }
-
- // set parser features and properties
- try {
- parser.setFeature(NAMESPACES_FEATURE, true);
- parser.setFeature(VALIDATION_FEATURE, validating);
- parser.setFeature(SCHEMA_VALIDATION_FEATURE, validating);
- parser.setFeature(NORMALIZED_VALUE_FEATURE, false);
- parser.setFeature(INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true);
- parser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE, false);
-
- if (validating) {
- if (externalSchemaLocations != null) {
- parser.setProperty(
- EXTERNAL_SCHEMA_LOCATION_PROPERTY,
- externalSchemaLocations);
- }
- if (externalNoNamespaceSchemaLocation != null) {
- parser.setProperty(
- EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
- externalNoNamespaceSchemaLocation);
- }
- }
-
- // set entity resolver and error handler
- if (entityResolver != null) {
- parser.setEntityResolver(entityResolver);
- }
- if (errorHandler != null) {
- parser.setErrorHandler(errorHandler);
- }
-
- // parse the document and return it
- // if debug is enabled: use copy of strem (baStream) else use orig stream
- if(null != baStream)
- parser.parse(new InputSource(baStream));
- else
- parser.parse(new InputSource(inputStream));
- } catch(SAXException e) {
- if(true == Logger.isDebugEnabled() && null != buffer) {
- String xmlContent = new String(buffer);
- Logger.debug("SAXException in:\n" + xmlContent);
- }
- throw(e);
- }
-
- return parser.getDocument();
- }
-
- /**
- * Parse an XML document from an InputStream.
- *
- * It uses a MOAEntityResolver as the EntityResolver
- * and a MOAErrorHandler as the ErrorHandler.
- *
- * @param inputStream The InputStream containing the XML
- * document.
- * @param validating If true, parse validating.
- * @param externalSchemaLocations A String containing namespace
- * URI to schema location pairs, the same way it is accepted by the xsi:
- * schemaLocation attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * xsi:noNamespaceSchemaLocation attribute.
- * @return The parsed XML document as a DOM tree.
- * @throws SAXException An error occurred parsing the document.
- * @throws IOException An error occurred reading the document.
- * @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
- */
- public static Document parseDocument(
- InputStream inputStream,
- boolean validating,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation)
- throws SAXException, IOException, ParserConfigurationException {
-
- return parseDocument(
- inputStream,
- validating,
- externalSchemaLocations,
- externalNoNamespaceSchemaLocation,
- new MOAEntityResolver(),
- new MOAErrorHandler());
- }
-
- /**
- * Parse an XML document from a String.
- *
- * It uses a MOAEntityResolver as the EntityResolver
- * and a MOAErrorHandler as the ErrorHandler.
- *
- * @param xmlString The String containing the XML document.
- * @param encoding The encoding of the XML document.
- * @param validating If true, parse validating.
- * @param externalSchemaLocations A String containing namespace
- * URI to schema location pairs, the same way it is accepted by the xsi:
- * schemaLocation attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * xsi:noNamespaceSchemaLocation attribute.
- * @return The parsed XML document as a DOM tree.
- * @throws SAXException An error occurred parsing the document.
- * @throws IOException An error occurred reading the document.
- * @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
- */
- public static Document parseDocument(
- String xmlString,
- String encoding,
- boolean validating,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation)
- throws SAXException, IOException, ParserConfigurationException {
-
- InputStream in = new ByteArrayInputStream(xmlString.getBytes(encoding));
- return parseDocument(
- in,
- validating,
- externalSchemaLocations,
- externalNoNamespaceSchemaLocation);
- }
-
- /**
- * Parse an UTF-8 encoded XML document from a String.
- *
- * @param xmlString The String containing the XML document.
- * @param validating If true, parse validating.
- * @param externalSchemaLocations A String containing namespace
- * URI to schema location pairs, the same way it is accepted by the xsi:
- * schemaLocation attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * xsi:noNamespaceSchemaLocation attribute.
- * @return The parsed XML document as a DOM tree.
- * @throws SAXException An error occurred parsing the document.
- * @throws IOException An error occurred reading the document.
- * @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
- */
- public static Document parseDocument(
- String xmlString,
- boolean validating,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation)
- throws SAXException, IOException, ParserConfigurationException {
-
- return parseDocument(
- xmlString,
- "UTF-8",
- validating,
- externalSchemaLocations,
- externalNoNamespaceSchemaLocation);
- }
-
- /**
- * A convenience method to parse an XML document validating.
- *
- * @param inputStream The InputStream containing the XML
- * document.
- * @return The root element of the parsed XML document.
- * @throws SAXException An error occurred parsing the document.
- * @throws IOException An error occurred reading the document.
- * @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
- */
- public static Element parseXmlValidating(InputStream inputStream)
- throws ParserConfigurationException, SAXException, IOException {
- return DOMUtils
- .parseDocument(inputStream, true, Constants.ALL_SCHEMA_LOCATIONS, null)
- .getDocumentElement();
- }
-
- /**
- * Schema validate a given DOM element.
- *
- * @param element The element to validate.
- * @param externalSchemaLocations A String containing namespace
- * URI to schema location pairs, the same way it is accepted by the xsi:
- * schemaLocation attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * xsi:noNamespaceSchemaLocation attribute.
- * @return true, if the element validates against
- * the schemas declared in it.
- * @throws SAXException An error occurred parsing the document.
- * @throws IOException An error occurred reading the document from its
- * serialized representation.
- * @throws ParserConfigurationException An error occurred configuring the XML
- * @throws TransformerException An error occurred serializing the element.
- */
- public static boolean validateElement(
- Element element,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation)
- throws
- ParserConfigurationException,
- IOException,
- SAXException,
- TransformerException {
-
- byte[] docBytes;
- SAXParser parser;
-
- // create the SAX parser
- if (symbolTable != null) {
- parser = new SAXParser(symbolTable, grammarPool);
- } else {
- parser = new SAXParser();
- }
-
- // serialize the document
- docBytes = serializeNode(element, "UTF-8");
-
- // set up parser features and attributes
- parser.setFeature(NAMESPACES_FEATURE, true);
- parser.setFeature(VALIDATION_FEATURE, true);
- parser.setFeature(SCHEMA_VALIDATION_FEATURE, true);
- if (externalSchemaLocations != null) {
- parser.setProperty(
- EXTERNAL_SCHEMA_LOCATION_PROPERTY,
- externalSchemaLocations);
- }
- if (externalNoNamespaceSchemaLocation != null) {
- parser.setProperty(
- EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
- "externalNoNamespaceSchemaLocation");
- }
-
- // set up entity resolver and error handler
- parser.setEntityResolver(new MOAEntityResolver());
- parser.setErrorHandler(new MOAErrorHandler());
-
- // parse validating
- parser.parse(new InputSource(new ByteArrayInputStream(docBytes)));
- return true;
- }
-
- /**
- * Serialize the given DOM node.
- *
- * The node will be serialized using the UTF-8 encoding.
- *
- * @param node The node to serialize.
- * @return String The String representation of the given DOM
- * node.
- * @throws TransformerException An error occurred transforming the
- * node to a String.
- * @throws IOException An IO error occurred writing the node to a byte array.
- */
- public static String serializeNode(Node node)
- throws TransformerException, IOException {
- return new String(serializeNode(node, "UTF-8", false), "UTF-8");
- }
-
-
- /**
- * Serialize the given DOM node.
- *
- * The node will be serialized using the UTF-8 encoding.
- *
- * @param node The node to serialize.
- * @param omitXmlDeclaration The boolean value for omitting the XML Declaration.
- * @return String The String representation of the given DOM
- * node.
- * @throws TransformerException An error occurred transforming the
- * node to a String.
- * @throws IOException An IO error occurred writing the node to a byte array.
- */
- public static String serializeNode(Node node, boolean omitXmlDeclaration)
- throws TransformerException, IOException {
- return new String(serializeNode(node, "UTF-8", omitXmlDeclaration), "UTF-8");
- }
-
- /**
- * Serialize the given DOM node.
- *
- * The node will be serialized using the UTF-8 encoding.
- *
- * @param node The node to serialize.
- * @param omitXmlDeclaration The boolean value for omitting the XML Declaration.
- * @param lineSeperator Sets the line seperator String of the parser
- * @return String The String representation of the given DOM
- * node.
- * @throws TransformerException An error occurred transforming the
- * node to a String.
- * @throws IOException An IO error occurred writing the node to a byte array.
- */
- public static String serializeNode(Node node, boolean omitXmlDeclaration, String lineSeperator)
- throws TransformerException, IOException {
- return new String(serializeNode(node, "UTF-8", omitXmlDeclaration, lineSeperator), "UTF-8");
- }
-
- /**
- * Serialize the given DOM node to a byte array.
- *
- * @param node The node to serialize.
- * @param xmlEncoding The XML encoding to use.
- * @return The serialized node, as a byte array. Using a compatible encoding
- * this can easily be converted into a String.
- * @throws TransformerException An error occurred transforming the node to a
- * byte array.
- * @throws IOException An IO error occurred writing the node to a byte array.
- */
- public static byte[] serializeNode(Node node, String xmlEncoding)
- throws TransformerException, IOException {
- return serializeNode(node, xmlEncoding, false);
- }
-
- /**
- * Serialize the given DOM node to a byte array.
- *
- * @param node The node to serialize.
- * @param xmlEncoding The XML encoding to use.
- * @param omitDeclaration The boolean value for omitting the XML Declaration.
- * @return The serialized node, as a byte array. Using a compatible encoding
- * this can easily be converted into a String.
- * @throws TransformerException An error occurred transforming the node to a
- * byte array.
- * @throws IOException An IO error occurred writing the node to a byte array.
- */
- public static byte[] serializeNode(Node node, String xmlEncoding, boolean omitDeclaration)
- throws TransformerException, IOException {
- return serializeNode(node, xmlEncoding, omitDeclaration, null);
- }
-
-
- /**
- * Serialize the given DOM node to a byte array.
- *
- * @param node The node to serialize.
- * @param xmlEncoding The XML encoding to use.
- * @param omitDeclaration The boolean value for omitting the XML Declaration.
- * @param lineSeperator Sets the line seperator String of the parser
- * @return The serialized node, as a byte array. Using a compatible encoding
- * this can easily be converted into a String.
- * @throws TransformerException An error occurred transforming the node to a
- * byte array.
- * @throws IOException An IO error occurred writing the node to a byte array.
- */
- public static byte[] serializeNode(Node node, String xmlEncoding, boolean omitDeclaration, String lineSeperator)
- throws TransformerException, IOException {
-
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- ByteArrayOutputStream bos = new ByteArrayOutputStream(16384);
-
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty(OutputKeys.ENCODING, xmlEncoding);
- String omit = omitDeclaration ? "yes" : "no";
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omit);
- if (null!=lineSeperator) {
- transformer.setOutputProperty("{http://xml.apache.org/xalan}line-separator", lineSeperator);//does not work for xalan <= 2.5.1
- }
- transformer.transform(new DOMSource(node), new StreamResult(bos));
-
- bos.flush();
- bos.close();
-
- return bos.toByteArray();
- }
-
- /**
- * Return the text that a node contains.
- *
- * This routine:
- *
- *
Ignores comments and processing instructions.
- *
Concatenates TEXT nodes, CDATA nodes, and the results recursively
- * processing EntityRef nodes.
- *
Ignores any element nodes in the sublist. (Other possible options are
- * to recurse into element sublists or throw an exception.)
- *
- *
- * @param node A DOM node from which to extract text.
- * @return A String representing its contents.
- */
- public static String getText(Node node) {
- if (!node.hasChildNodes()) {
- return "";
- }
-
- StringBuffer result = new StringBuffer();
- NodeList list = node.getChildNodes();
-
- for (int i = 0; i < list.getLength(); i++) {
- Node subnode = list.item(i);
- if (subnode.getNodeType() == Node.TEXT_NODE) {
- result.append(subnode.getNodeValue());
- } else if (subnode.getNodeType() == Node.CDATA_SECTION_NODE) {
- result.append(subnode.getNodeValue());
- } else if (subnode.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
- // Recurse into the subtree for text
- // (and ignore comments)
- result.append(getText(subnode));
- }
- }
- return result.toString();
- }
-
- /**
- * Build the namespace prefix to namespace URL mapping in effect for a given
- * node.
- *
- * @param node The context node for which build the map.
- * @return The namespace prefix to namespace URL mapping (
- * a String value to String value mapping).
- */
- public static Map getNamespaceDeclarations(Node node) {
- Map nsDecls = new HashMap();
- int i;
-
- do {
- if (node.hasAttributes()) {
- NamedNodeMap attrs = node.getAttributes();
-
- for (i = 0; i < attrs.getLength(); i++) {
- Attr attr = (Attr) attrs.item(i);
-
- // add prefix mapping if none exists
- if ("xmlns".equals(attr.getPrefix())
- || "xmlns".equals(attr.getName())) {
-
- String nsPrefix =
- attr.getPrefix() != null ? attr.getLocalName() : "";
-
- if (nsDecls.get(nsPrefix) == null) {
- nsDecls.put(nsPrefix, attr.getValue());
- }
- }
- }
- }
- } while ((node = node.getParentNode()) != null);
-
- return nsDecls;
- }
-
- /**
- * Add all namespace declarations declared in the parent(s) of a given
- * element and used in the subtree of the given element to the given element.
- *
- * @param context The element to which to add the namespaces.
- */
- public static void localizeNamespaceDeclarations(Element context) {
- Node parent = context.getParentNode();
-
- if (parent != null) {
- Map namespaces = getNamespaceDeclarations(context.getParentNode());
- Set nsUris = collectNamespaceURIs(context);
- Iterator iter;
-
- for (iter = namespaces.entrySet().iterator(); iter.hasNext();) {
- Map.Entry e = (Map.Entry) iter.next();
-
- if (nsUris.contains(e.getValue())) {
- String prefix = (String) e.getKey();
- String nsUri = (String) e.getValue();
- String nsAttrName = "".equals(prefix) ? "xmlns" : "xmlns:" + prefix;
-
- context.setAttributeNS(Constants.XMLNS_NS_URI, nsAttrName, nsUri);
- }
- }
- }
- }
-
- /**
- * Collect all the namespace URIs used in the subtree of a given element.
- *
- * @param context The element that should be searched for namespace URIs.
- * @return All namespace URIs used in the subtree of context,
- * including the ones used in context itself.
- */
- public static Set collectNamespaceURIs(Element context) {
- Set result = new HashSet();
-
- collectNamespaceURIsImpl(context, result);
- return result;
- }
-
- /**
- * A recursive method to do the work of collectNamespaceURIs.
- *
- * @param context The context element to evaluate.
- * @param result The result, passed as a parameter to avoid unnecessary
- * instantiations of Set.
- */
- private static void collectNamespaceURIsImpl(Element context, Set result) {
- NamedNodeMap attrs = context.getAttributes();
- NodeList childNodes = context.getChildNodes();
- String nsUri;
- int i;
-
- // add the namespace of the context element
- nsUri = context.getNamespaceURI();
- if (nsUri != null && nsUri != Constants.XMLNS_NS_URI) {
- result.add(nsUri);
- }
-
- // add all namespace URIs from attributes
- for (i = 0; i < attrs.getLength(); i++) {
- nsUri = attrs.item(i).getNamespaceURI();
- if (nsUri != null && nsUri != Constants.XMLNS_NS_URI) {
- result.add(nsUri);
- }
- }
-
- // add all namespaces from subelements
- for (i = 0; i < childNodes.getLength(); i++) {
- Node node = childNodes.item(i);
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- collectNamespaceURIsImpl((Element) node, result);
- }
- }
- }
-
- /**
- * Check, that each attribute node in the given NodeList has its
- * parent in the NodeList as well.
- *
- * @param nodes The NodeList to check.
- * @return true, if each attribute node in nodes
- * has its parent in nodes as well.
- */
- public static boolean checkAttributeParentsInNodeList(NodeList nodes) {
- Set nodeSet = new HashSet();
- int i;
-
- // put the nodes into the nodeSet
- for (i = 0; i < nodes.getLength(); i++) {
- nodeSet.add(nodes.item(i));
- }
-
- // check that each attribute node's parent is in the node list
- for (i = 0; i < nodes.getLength(); i++) {
- Node n = nodes.item(i);
-
- if (n.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr attr = (Attr) n;
- Element owner = attr.getOwnerElement();
-
- if (owner == null) {
- if (!isNamespaceDeclaration(attr)) {
- return false;
- }
- }
-
- if (!nodeSet.contains(owner) && !isNamespaceDeclaration(attr)) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- /**
- * Convert an unstructured NodeList into a
- * DocumentFragment.
- *
- * @param nodeList Contains the node list to be converted into a DOM
- * DocumentFragment.
- * @return the resulting DocumentFragment. The DocumentFragment will be
- * backed by a new DOM Document, i.e. all noded of the node list will be
- * cloned.
- * @throws ParserConfigurationException An error occurred creating the
- * DocumentFragment.
- * @precondition The nodes in the node list appear in document order
- * @precondition for each Attr node in the node list, the owning Element is
- * in the node list as well.
- * @precondition each Element or Attr node in the node list is namespace
- * aware.
- */
- public static DocumentFragment nodeList2DocumentFragment(NodeList nodeList)
- throws ParserConfigurationException {
-
- DocumentBuilder builder =
- DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = builder.newDocument();
- DocumentFragment result = doc.createDocumentFragment();
-
- if (null == nodeList || nodeList.getLength() == 0) {
- return result;
- }
-
- int currPos = 0;
- currPos =
- nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
-
- while (currPos < nodeList.getLength()) {
- currPos =
- nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
- }
- return result;
- }
-
- /**
- * Helper method for the nodeList2DocumentFragment.
- *
- * @param nodeList The NodeList to convert.
- * @param currPos The current position in the nodeList.
- * @param result The resulting DocumentFragment.
- * @param currOrgElem The current original element.
- * @param currClonedElem The current cloned element.
- * @return The current position.
- */
- private static int nodeList2DocumentFragment(
- NodeList nodeList,
- int currPos,
- DocumentFragment result,
- Element currOrgElem,
- Element currClonedElem) {
-
- while (currPos < nodeList.getLength()) {
- Node currentNode = nodeList.item(currPos);
- switch (currentNode.getNodeType()) {
- case Node.COMMENT_NODE :
- case Node.PROCESSING_INSTRUCTION_NODE :
- case Node.TEXT_NODE :
- {
- // Append current node either to resulting DocumentFragment or to
- // current cloned Element
- if (null == currClonedElem) {
- result.appendChild(
- result.getOwnerDocument().importNode(currentNode, false));
- } else {
- // Stop processing if current Node is not a descendant of
- // current Element
- if (!isAncestor(currOrgElem, currentNode)) {
- return --currPos;
- }
-
- currClonedElem.appendChild(
- result.getOwnerDocument().importNode(currentNode, false));
- }
- break;
- }
-
- case Node.ELEMENT_NODE :
- {
- Element nextCurrOrgElem = (Element) currentNode;
- Element nextCurrClonedElem =
- result.getOwnerDocument().createElementNS(
- nextCurrOrgElem.getNamespaceURI(),
- nextCurrOrgElem.getNodeName());
-
- // Append current Node either to resulting DocumentFragment or to
- // current cloned Element
- if (null == currClonedElem) {
- result.appendChild(nextCurrClonedElem);
- currOrgElem = nextCurrOrgElem;
- currClonedElem = nextCurrClonedElem;
- } else {
- // Stop processing if current Node is not a descendant of
- // current Element
- if (!isAncestor(currOrgElem, currentNode)) {
- return --currPos;
- }
-
- currClonedElem.appendChild(nextCurrClonedElem);
- }
-
- // Process current Node (of type Element) recursively
- currPos =
- nodeList2DocumentFragment(
- nodeList,
- ++currPos,
- result,
- nextCurrOrgElem,
- nextCurrClonedElem);
-
- break;
- }
-
- case Node.ATTRIBUTE_NODE :
- {
- Attr currAttr = (Attr) currentNode;
-
- // GK 20030411: Hack to overcome problems with IAIK IXSIL
- if (currAttr.getOwnerElement() == null)
- break;
- if (currClonedElem == null)
- break;
-
- // currClonedElem must be the owner Element of currAttr if
- // preconditions are met
- currClonedElem.setAttributeNS(
- currAttr.getNamespaceURI(),
- currAttr.getNodeName(),
- currAttr.getValue());
- break;
- }
-
- default :
- {
- // All other nodes will be ignored
- }
- }
-
- currPos++;
- }
-
- return currPos;
- }
-
- /**
- * Check, if the given attribute is a namespace declaration.
- *
- * @param attr The attribute to check.
- * @return true, if the attribute is a namespace declaration,
- * false otherwise.
- */
- private static boolean isNamespaceDeclaration(Attr attr) {
- return Constants.XMLNS_NS_URI.equals(attr.getNamespaceURI());
- }
-
- /**
- * Check, if a given DOM element is an ancestor of a given node.
- *
- * @param candAnc The DOM element to check for being the ancestor.
- * @param cand The node to check for being the child.
- * @return true, if candAnc is an (indirect)
- * ancestor of cand; false otherwise.
- */
- public static boolean isAncestor(Element candAnc, Node cand) {
- Node currPar = cand.getParentNode();
-
- while (currPar != null) {
- if (candAnc == currPar)
- return true;
- currPar = currPar.getParentNode();
- }
- return false;
- }
-
- /**
- * Selects the (first) element from a node list and returns it.
- *
- * @param nl The NodeList to get the element from.
- * @return The (first) element included in the node list or null
- * if the node list is null or empty or no element is
- * included in the list.
- */
- public static Element getElementFromNodeList (NodeList nl) {
- if ((nl == null) || (nl.getLength() == 0)) {
- return null;
- }
- for (int i=0; idateTime,
- * according to ISO 8601.
- *
- * @author Patrick Peck
- * @version $Id$
- * @see http://www.w3.org/2001/XMLSchema-datatypes"
- */
-public class DateTimeUtils {
- /** Error messages. */
- private static MessageProvider msg = MessageProvider.getInstance();
-
- /**
- * Builds a dateTime value from a Calendar value.
- * @param cal the Calendar value
- * @return the dateTime value
- */
- public static String buildDateTime(Calendar cal) {
- StringWriter out = new StringWriter();
- out.write("" + cal.get(Calendar.YEAR));
- out.write("-");
- out.write(to2DigitString(cal.get(Calendar.MONTH) + 1));
- out.write("-");
- out.write(to2DigitString(cal.get(Calendar.DAY_OF_MONTH)));
- out.write("T");
- out.write(to2DigitString(cal.get(Calendar.HOUR_OF_DAY)));
- out.write(":");
- out.write(to2DigitString(cal.get(Calendar.MINUTE)));
- out.write(":");
- out.write(to2DigitString(cal.get(Calendar.SECOND)));
- int tzOffsetMilliseconds =
- cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
- if (tzOffsetMilliseconds != 0) {
- int tzOffsetMinutes = tzOffsetMilliseconds / (1000 * 60);
- int tzOffsetHours = tzOffsetMinutes / 60;
- tzOffsetMinutes -= tzOffsetHours * 60;
- if (tzOffsetMilliseconds > 0) {
- out.write("+");
- out.write(to2DigitString(tzOffsetHours));
- out.write(":");
- out.write(to2DigitString(tzOffsetMinutes));
- } else {
- out.write("-");
- out.write(to2DigitString(-tzOffsetHours));
- out.write(":");
- out.write(to2DigitString(-tzOffsetMinutes));
- }
- }
- return out.toString();
- }
-
- /**
- * Converts month, day, hour, minute, or second value
- * to a 2 digit String.
- * @param number the month, day, hour, minute, or second value
- * @return 2 digit String
- */
- private static String to2DigitString(int number) {
- if (number < 10)
- return "0" + number;
- else
- return "" + number;
- }
-
- /**
- * Parse a String containing a date and time instant, given in
- * ISO 8601 format.
- *
- * @param dateTime The String to parse.
- * @return The Date representation of the contents of
- * dateTime.
- * @throws ParseException Parsing the dateTime failed.
- */
- public static Date parseDateTime(String dateTime) throws ParseException {
- GregorianCalendar calendar;
- long time;
- int yearSign = 1, year, month, day;
- int hour, minute, second;
- double fraction = 0.0;
- int tzSign = 1, tzHour = 0, tzMinute = 0;
- int curPos = 0;
- String fractStr;
- boolean localTime = false;
- char c;
-
- // parse year sign
- ensureChars(dateTime, curPos, 1);
- c = dateTime.charAt(curPos);
- if (c == '+' || c == '-') {
- yearSign = c == '+' ? 1 : -1;
- curPos++;
- }
-
- // parse year
- year = parseInt(dateTime, curPos, 4);
- curPos += 4;
-
- // parse '-'
- ensureChar(dateTime, curPos, '-');
- curPos++;
-
- // parse month
- month = parseInt(dateTime, curPos, 2);
- ensureValue(month, 1, 12, curPos);
- curPos += 2;
-
- // parse '-'
- ensureChar(dateTime, curPos, '-');
- curPos++;
-
- // parse day
- day = parseInt(dateTime, curPos, 2);
- ensureValue(day, 1, 31, curPos);
- curPos += 2;
-
- // parse 'T'
- ensureChar(dateTime, curPos, 'T');
- curPos++;
-
- // parse hour
- hour = parseInt(dateTime, curPos, 2);
- ensureValue(hour, 0, 23, curPos);
- curPos += 2;
-
- // parse ':'
- ensureChar(dateTime, curPos, ':');
- curPos++;
-
- // parse minute
- minute = parseInt(dateTime, curPos, 2);
- ensureValue(minute, 0, 59, curPos);
- curPos += 2;
-
- // parse ':'
- ensureChar(dateTime, curPos, ':');
- curPos++;
-
- // parse second
- second = parseInt(dateTime, curPos, 2);
- ensureValue(second, 0, 59, curPos);
- curPos += 2;
-
- // parse a fraction
- if (dateTime.length() > curPos && dateTime.charAt(curPos) == '.') {
- curPos++;
- ensureDigits(dateTime, curPos, 1);
- fractStr = "0.";
- fractStr
- += dateTime.substring(curPos, curPos + countDigits(dateTime, curPos));
- fraction = Double.parseDouble(fractStr);
- curPos += countDigits(dateTime, curPos);
- }
-
- // parse a time zone
- if (dateTime.length() > curPos) {
- c = dateTime.charAt(curPos);
- if (c == 'Z') {
- curPos++;
- } else if (c == '+' || c == '-') {
- // parse time zone sign
- tzSign = c == '+' ? 1 : -1;
- curPos++;
-
- // parse time zone hour
- tzHour = parseInt(dateTime, curPos, 2);
- ensureValue(tzHour, 0, 14, curPos);
- curPos += 2;
-
- // parse ':'
- ensureChar(dateTime, curPos, ':');
- curPos++;
-
- // parse time zone minute
- tzMinute = parseInt(dateTime, curPos, 2);
- ensureValue(tzMinute, 0, 59, curPos);
- curPos += 2;
- }
- } else {
- localTime = true;
- }
-
- // if we have characters left, it's an error
- if (dateTime.length() != curPos) {
- throw new ParseException(msg.getMessage("datetime.00", null), curPos);
- }
-
- // build the Date object
- year = year * yearSign;
- try {
- calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
- calendar.set(year, month - 1, day, hour, minute, second);
- calendar.set(Calendar.MILLISECOND, 0);
- time = calendar.getTime().getTime();
- time += (long) (fraction * 1000.0);
- time -= tzSign * ((tzHour * 60) + tzMinute) * 60 * 1000;
- if (localTime) {
- time -= TimeZone.getDefault().getRawOffset();
- }
- return new Date(time);
- } catch (IllegalArgumentException e) {
- throw new ParseException(msg.getMessage("datetime.00", null), curPos);
- }
-
- }
-
- /**
- * Parse an integer value.
- *
- * @param str The String containing the digits.
- * @param curPos The starting position.
- * @param digits The number of digist making up the integer value.
- * @return int The integer representation of the digits contained in
- * str.
- * @throws ParseException Parsing the integer value failed.
- */
- private static int parseInt(String str, int curPos, int digits)
- throws ParseException {
-
- ensureDigits(str, curPos, digits);
- return Integer.parseInt(str.substring(curPos, curPos + digits));
- }
-
- /**
- * Count the number of digits following curPos.
- *
- * @param str The String in which to count digits.
- * @param curPos The starting position.
- * @return int The number of digits.
- */
- private static int countDigits(String str, int curPos) {
- int i;
-
- for (i = curPos; i < str.length() && Character.isDigit(str.charAt(i)); i++);
- return i - curPos;
- }
-
- /**
- * Ensure that a value falls in a given min/max range.
- *
- * @param value The value to check.
- * @param min The minimum allowed value.
- * @param max The maximum allowed value.
- * @param curPos To indicate the parsing position in the
- * ParseException.
- * @throws ParseException Thrown, if value < min || value >
- * max
- */
- private static void ensureValue(int value, int min, int max, int curPos)
- throws ParseException {
-
- if (value < min || value > max) {
- throw new ParseException(msg.getMessage("datetime.00", null), curPos);
- }
- }
-
- /**
- * Ensure that the given String has a number of characters left.
- *
- * @param str The String to check for its length.
- * @param curPos The starting position.
- * @param count The minimum number of characters that str must
- * contain, starting at from curPos.
- * @throws ParseException Thrown, if
- * curPos + count > str.length().
- */
- private static void ensureChars(String str, int curPos, int count)
- throws ParseException {
- if (curPos + count > str.length()) {
- throw new ParseException(msg.getMessage("datetime.00", null), curPos);
- }
- }
-
- /**
- * Ensure that a given String contains a certain character at a
- * certain position.
- *
- * @param str The String in which to look up the character.
- * @param curPos The position in str that must contain the
- * character.
- * @param c The character value that must be contained at position
- * curPos.
- * @throws ParseException Thrown, if the characters do not match or
- * curPos is out of range.
- */
- private static void ensureChar(String str, int curPos, char c)
- throws ParseException {
-
- ensureChars(str, curPos, 1);
- if (str.charAt(curPos) != c) {
- throw new ParseException(msg.getMessage("datetime.00", null), curPos);
- }
- }
-
- /**
- * Ensure that a given String contains a number of digits,
- * starting at a given position.
- *
- * @param str The String to scan for digits.
- * @param curPos The starting postion.
- * @param count The number of digits that must be contained in
- * str, starting at curPos.
- * @throws ParseException Thrown, if str is not long enough, or
- * one of the characters following curPos in str is
- * not a digit.
- */
- private static void ensureDigits(String str, int curPos, int count)
- throws ParseException {
-
- ensureChars(str, curPos, count);
- for (int i = curPos; i < curPos + count; i++) {
- if (!Character.isDigit(str.charAt(i))) {
- throw new ParseException(msg.getMessage("datetime.00", null), curPos);
- }
- }
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/EntityResolverChain.java b/common/src/at/gv/egovernment/moa/util/EntityResolverChain.java
deleted file mode 100644
index e7008a701..000000000
--- a/common/src/at/gv/egovernment/moa/util/EntityResolverChain.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Implementation of the org.xml.sax.EntityResolver,
- * for use by a org.apache.xerces.parsers.DOMParser.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class EntityResolverChain implements EntityResolver {
- /** The EntityResolvers in the chain. */
- private List resolvers = new ArrayList();
-
- /**
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
- */
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
-
- Iterator iter;
-
- for (iter = resolvers.iterator(); iter.hasNext(); ) {
- EntityResolver resolver = (EntityResolver) iter.next();
- InputSource is = resolver.resolveEntity(publicId, systemId);
-
- if (is != null) {
- return is;
- }
- }
-
- return null;
- }
-
- /**
- * Add an EntityResolver to the chain.
- *
- * @param entityResolver The EntityResolver to add.
- */
- public void addEntityResolver(EntityResolver entityResolver) {
- resolvers.add(entityResolver);
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/FileUtils.java b/common/src/at/gv/egovernment/moa/util/FileUtils.java
deleted file mode 100644
index a5e777c2d..000000000
--- a/common/src/at/gv/egovernment/moa/util/FileUtils.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * Utility for accessing files on the file system, and for reading from input streams.
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class FileUtils {
-
- /**
- * Reads a file, given by URL, into a byte array.
- * @param urlString file URL
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static byte[] readURL(String urlString) throws IOException {
- URL url = new URL(urlString);
- InputStream in = new BufferedInputStream(url.openStream());
- byte[] content = StreamUtils.readStream(in);
- in.close();
- return content;
- }
- /**
- * Reads a file, given by URL, into a String.
- * @param urlString file URL
- * @param encoding character encoding
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static String readURL(String urlString, String encoding) throws IOException {
- byte[] content = readURL(urlString);
- return new String(content, encoding);
- }
- /**
- * Reads a file, given by filename, into a byte array.
- * @param filename filename
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static byte[] readFile(String filename) throws IOException {
- BufferedInputStream in = new BufferedInputStream(new FileInputStream(filename));
- byte[] content = StreamUtils.readStream(in);
- in.close();
- return content;
- }
- /**
- * Reads a file, given by filename, into a String.
- * @param filename filename
- * @param encoding character encoding
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static String readFile(String filename, String encoding) throws IOException {
- byte[] content = readFile(filename);
- return new String(content, encoding);
- }
- /**
- * Reads a file from a resource.
- * @param name resource name
- * @return file content as a byte array
- * @throws IOException on any exception thrown
- */
- public static byte[] readResource(String name) throws IOException {
- ClassLoader cl = FileUtils.class.getClassLoader();
- BufferedInputStream in = new BufferedInputStream(cl.getResourceAsStream(name));
- byte[] content = StreamUtils.readStream(in);
- in.close();
- return content;
- }
- /**
- * Reads a file from a resource.
- * @param name filename
- * @param encoding character encoding
- * @return file content
- * @throws IOException on any exception thrown
- */
- public static String readResource(String name, String encoding) throws IOException {
- byte[] content = readResource(name);
- return new String(content, encoding);
- }
-
- /**
- * Returns the absolute URL of a given url which is relative to the parameter root
- * @param url
- * @param root
- * @return String
- */
- public static String makeAbsoluteURL(String url, String root) {
- //if url is relative to rootConfigFileDirName make it absolute
-
- File keyFile;
- String newURL = url;
-
- if(null == url) return null;
-
- if (url.startsWith("http:/") || url.startsWith("https:/") || url.startsWith("file:/") || url.startsWith("ftp:/")) {
- return url;
- } else {
- // check if absolute - if not make it absolute
- keyFile = new File(url);
- if (!keyFile.isAbsolute()) {
- keyFile = new File(root, url);
- newURL = keyFile.getPath();
- }
- return newURL;
- }
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/KeyStoreUtils.java b/common/src/at/gv/egovernment/moa/util/KeyStoreUtils.java
deleted file mode 100644
index d6a34a7b2..000000000
--- a/common/src/at/gv/egovernment/moa/util/KeyStoreUtils.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import iaik.x509.X509Certificate;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.GeneralSecurityException;
-import java.security.KeyStore;
-import java.security.cert.Certificate;
-
-/**
- * Utility for creating and loading key stores.
- *
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class KeyStoreUtils {
-
- /**
- * Loads a key store from file.
- *
- * @param keystoreType key store type
- * @param urlString URL of key store
- * @param password password protecting the key store
- * @return key store loaded
- * @throws IOException thrown while reading the key store from file
- * @throws GeneralSecurityException thrown while creating the key store
- */
- public static KeyStore loadKeyStore(
- String keystoreType,
- String urlString,
- String password)
- throws IOException, GeneralSecurityException {
-
- URL keystoreURL = new URL(urlString);
- InputStream in = keystoreURL.openStream();
- return loadKeyStore(keystoreType, in, password);
- }
- /**
- * Loads a key store from an InputStream, and
- * closes the InputStream.
- *
- * @param keystoreType key store type
- * @param in input stream
- * @param password password protecting the key store
- * @return key store loaded
- * @throws IOException thrown while reading the key store from the stream
- * @throws GeneralSecurityException thrown while creating the key store
- */
- public static KeyStore loadKeyStore(
- String keystoreType,
- InputStream in,
- String password)
- throws IOException, GeneralSecurityException {
-
- char[] chPassword = null;
- if (password != null)
- chPassword = password.toCharArray();
- KeyStore ks = KeyStore.getInstance(keystoreType);
- ks.load(in, chPassword);
- in.close();
- return ks;
- }
- /**
- * Creates a key store from X509 certificate files, aliasing them with
- * the index in the String[], starting with "0".
- *
- * @param keyStoreType key store type
- * @param certFilenames certificate filenames
- * @return key store created
- * @throws IOException thrown while reading the certificates from file
- * @throws GeneralSecurityException thrown while creating the key store
- */
- public static KeyStore createKeyStore(
- String keyStoreType,
- String[] certFilenames)
- throws IOException, GeneralSecurityException {
-
- KeyStore ks = KeyStore.getInstance(keyStoreType);
- ks.load(null, null);
- for (int i = 0; i < certFilenames.length; i++) {
- Certificate cert = loadCertificate(certFilenames[i]);
- ks.setCertificateEntry("" + i, cert);
- }
- return ks;
- }
- /**
- * Creates a key store from a directory containg X509 certificate files,
- * aliasing them with the index in the String[], starting with "0".
- * All the files in the directory are considered to be certificates.
- *
- * @param keyStoreType key store type
- * @param certDirURLString file URL of directory containing certificate filenames
- * @return key store created
- * @throws IOException thrown while reading the certificates from file
- * @throws GeneralSecurityException thrown while creating the key store
- */
- public static KeyStore createKeyStoreFromCertificateDirectory(
- String keyStoreType,
- String certDirURLString)
- throws IOException, GeneralSecurityException {
-
- URL certDirURL = new URL(certDirURLString);
- String certDirname = certDirURL.getFile();
- File certDir = new File(certDirname);
- String[] certFilenames = certDir.list();
- String separator =
- (certDirname.endsWith(File.separator) ? "" : File.separator);
- for (int i = 0; i < certFilenames.length; i++) {
- certFilenames[i] = certDirname + separator + certFilenames[i];
- }
- return createKeyStore(keyStoreType, certFilenames);
- }
-
- /**
- * Loads an X509 certificate from file.
- * @param certFilename filename
- * @return the certificate loaded
- * @throws IOException thrown while reading the certificate from file
- * @throws GeneralSecurityException thrown while creating the certificate
- */
- private static Certificate loadCertificate(String certFilename)
- throws IOException, GeneralSecurityException {
-
- FileInputStream in = new FileInputStream(certFilename);
- Certificate cert = new X509Certificate(in);
- in.close();
- return cert;
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/MOADefaultHandler.java b/common/src/at/gv/egovernment/moa/util/MOADefaultHandler.java
deleted file mode 100644
index 0474d92cd..000000000
--- a/common/src/at/gv/egovernment/moa/util/MOADefaultHandler.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.IOException;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * A DefaultHandler that uses a MOAEntityResolver and
- * a MOAErrorHandler.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class MOADefaultHandler extends DefaultHandler {
- /** The EntityResolver to use. */
- private EntityResolver entityResolver;
- /** The ErrorHandler to use. */
- private ErrorHandler errorHandler;
-
- /**
- * Create a new MOADefaultHandler.
- */
- public MOADefaultHandler() {
- entityResolver = new MOAEntityResolver();
- errorHandler = new MOAErrorHandler();
- }
-
- /**
- * Create a new MOADefaultHandler.
- *
- * @param entityResolver The EntityResolver to use for resolving
- * external entities.
- * @param errorHandler The ErrorHandler to use for reporting
- * parsing errors.
- */
- public MOADefaultHandler(
- EntityResolver entityResolver,
- ErrorHandler errorHandler) {
-
- this.entityResolver = entityResolver;
- this.errorHandler = errorHandler;
- }
-
- /**
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
- */
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException {
- try {
- return entityResolver.resolveEntity(publicId, systemId);
- } catch (IOException e) {
- return null;
- }
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
- */
- public void warning(SAXParseException exception) throws SAXException {
- errorHandler.warning(exception);
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
- */
- public void error(SAXParseException exception) throws SAXException {
- errorHandler.error(exception);
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
- */
- public void fatalError(SAXParseException exception) throws SAXException {
- errorHandler.fatalError(exception);
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java b/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java
deleted file mode 100644
index 9406612e2..000000000
--- a/common/src/at/gv/egovernment/moa/util/MOAEntityResolver.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.InputStream;
-
-import org.apache.xerces.util.URI;
-import org.apache.xerces.util.URI.MalformedURIException;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-
-import at.gv.egovernment.moa.logging.LogMsg;
-import at.gv.egovernment.moa.logging.Logger;
-
-/**
- * An EntityResolver that looks up entities stored as
- * local resources.
- *
- *
The following DTDs are mapped to local resources:
- *
- *
The XMLSchema.dtd
- *
The datatypes.dtd
- *
- *
- *
For all other resources, an attempt is made to resolve them as resources,
- * either absolute or relative to Constants.SCHEMA_ROOT.
- *
- * @author Patrick Peck
- * @author Sven Aigner
- */
-public class MOAEntityResolver implements EntityResolver {
-
- /**
- * Resolve an entity.
- *
- * The systemId parameter is used to perform the lookup of the
- * entity as a resource, either by interpreting the systemId as
- * an absolute resource path, or by appending the last path component of
- * systemId to Constants.SCHEMA_ROOT.
- *
- * @param publicId The public ID of the resource.
- * @param systemId The system ID of the resource.
- * @return An InputSource from which the entity can be read, or
- * null, if the entity could not be found.
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
- */
- public InputSource resolveEntity(String publicId, String systemId) {
- InputStream stream;
- int slashPos;
-
- if (Logger.isDebugEnabled()) {
- Logger.debug(
- new LogMsg("resolveEntity: p=" + publicId + " s=" + systemId));
- }
-
- if (publicId != null) {
- // check if we can resolve some standard dtd's
- if (publicId.equalsIgnoreCase("-//W3C//DTD XMLSchema 200102//EN")) {
- return new InputSource(
- getClass().getResourceAsStream(
- Constants.SCHEMA_ROOT + "XMLSchema.dtd"));
- } else if (publicId.equalsIgnoreCase("datatypes")) {
- return new InputSource(
- getClass().getResourceAsStream(
- Constants.SCHEMA_ROOT + "datatypes.dtd"));
- }
- } else if (systemId != null) {
- // get the URI path
- try {
- URI uri = new URI(systemId);
- systemId = uri.getPath();
- if (!"file".equals(uri.getScheme()) || "".equals(systemId.trim())) {
- return null;
- }
- } catch (MalformedURIException e) {
- return null;
- }
-
- // try to get the resource from the full path
- stream = getClass().getResourceAsStream(systemId);
- if (stream != null) {
- InputSource source = new InputSource(stream);
-
- source.setSystemId(systemId);
- return source;
- }
-
- // try to get the resource from the last path component
- slashPos = systemId.lastIndexOf('/');
- if (slashPos >= 0 && systemId.length() > slashPos) {
- systemId = systemId.substring(slashPos + 1, systemId.length());
- stream =
- getClass().getResourceAsStream(Constants.SCHEMA_ROOT + systemId);
- if (stream != null) {
- InputSource source = new InputSource(stream);
-
- source.setSystemId(systemId);
- return source;
- }
- }
- }
-
- return null; // nothing found - let the parser handle the entity
- }
-}
\ No newline at end of file
diff --git a/common/src/at/gv/egovernment/moa/util/MOAErrorHandler.java b/common/src/at/gv/egovernment/moa/util/MOAErrorHandler.java
deleted file mode 100644
index 1f7757c8f..000000000
--- a/common/src/at/gv/egovernment/moa/util/MOAErrorHandler.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import org.apache.xml.utils.DefaultErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import at.gv.egovernment.moa.logging.LogMsg;
-import at.gv.egovernment.moa.logging.Logger;
-
-/**
- * An ErrorHandler that logs a message and throws a
- * SAXException upon error and fatal
- * parsing errors.
- *
- * @author Patrick Peck
- * @author Sven Aigner
- */
-public class MOAErrorHandler extends DefaultErrorHandler {
-
- /**
- * Logs a warning message.
- *
- * @see org.xml.sax.ErrorHandler#warning(SAXParseException)
- */
- public void warning(SAXParseException exception) throws SAXException {
- warn("parser.00", messageParams(exception), null);
- }
-
- /**
- * Logs a warning and rethrows the exception.
- *
- * @see org.xml.sax.ErrorHandler#error(SAXParseException)
- */
- public void error(SAXParseException exception) throws SAXException {
- warn("parser.01", messageParams(exception), null);
- throw exception;
- }
-
- /**
- * Logs a warning and rethrows the exception.
- *
- * @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
- */
- public void fatalError(SAXParseException exception) throws SAXException {
- warn("parser.02", messageParams(exception), null);
- throw exception;
- }
-
- /**
- * Log a warning message.
- *
- * @param messageId The message ID to log.
- * @param parameters Additional message parameters.
- * @param t The Throwable to log; usually the cause of this
- * warning.
- */
- private static void warn(
- String messageId,
- Object[] parameters,
- Throwable t) {
-
- MessageProvider msg = MessageProvider.getInstance();
- Logger.warn(new LogMsg(msg.getMessage(messageId, parameters)), t);
- }
-
- /**
- * Put the system id, line and column number information from the exception
- * into an Object array, to provide it as a
- * MessageFormat parameter.
- *
- * @param e The SAXParseException containing the
- * source system id and line/column numbers.
- * @return An array containing the system id (a String) as well
- * as line/column numbers (2 Integer objects) from the
- * SAXParseException.
- */
- private static Object[] messageParams(SAXParseException e) {
- return new Object[] {
- e.getMessage(),
- e.getSystemId(),
- new Integer(e.getLineNumber()),
- new Integer(e.getColumnNumber())};
- }
-
-}
\ No newline at end of file
diff --git a/common/src/at/gv/egovernment/moa/util/MOATimer.java b/common/src/at/gv/egovernment/moa/util/MOATimer.java
deleted file mode 100644
index d8bf64fc3..000000000
--- a/common/src/at/gv/egovernment/moa/util/MOATimer.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-/**
- * A timer utility for named timers.
- *
- * @author Sven Aigner
- */
-public class MOATimer {
-
- /** The single instance of this class. */
- private static MOATimer instance = null;
- /** The starting points of single timings. */
- private static Map timemapstart = new WeakHashMap();
- /** The end points of single timings. */
- private static Map timemapend = new WeakHashMap();
-
- /**
- * Return the single instance of this class.
- *
- * @return The single instance of this class.
- */
- public static MOATimer getInstance() {
- if (instance == null) {
- instance = new MOATimer();
- }
- return instance;
- }
-
- /**
- * Create a new MOATimer.
- *
- * Protected to disallow multiple instances.
- */
- protected MOATimer() {
- super();
- }
-
- /**
- * Start timing a certain action.
- *
- * The timing belonging to the action ID is garbage collected as soon as there
- * exists no other reference to the action ID.
- *
- * @param id The action ID.
- */
- public void startTiming(Object id) {
- timemapstart.put(id, new Long(System.currentTimeMillis()));
- }
-
- /**
- * Stop timing an action.
- *
- * @param id The action ID.
- */
- public void stopTiming(Object id) {
- timemapend.put(id, new Long(System.currentTimeMillis()));
- }
-
- /**
- * Get the duration of an action.
- *
- * @param id The action ID for which to compute the duration.
- * @return long The duration in milliseconds between calls to
- * startTiming() and stopTiming(). If
- * only startTiming() has been called for the action, then
- * current difference to the system time is returned. If no timing exists for
- * the action, - 1 is returned.
- */
- public long duration(Object id) {
- if (timemapstart.containsKey(id)) {
- long start = ((Long) timemapstart.get(id)).longValue();
- if (timemapend.containsKey(id)) {
- long end = ((Long) timemapend.get(id)).longValue();
- return end - start;
- } else {
- return System.currentTimeMillis() - start;
- }
- } else
- return -1;
- }
-
- /**
- * Get the duration of an action, as a nicely formatted String.
- *
- * @param id The action ID.
- * @return String The duration() as a String.
- */
- public String durationAsString(Object id) {
- long dur = duration(id);
- long second = dur / 1000;
- long mil = (dur) - (second * 1000);
- return "Duration: " + second + "." + mil + " seconds";
- }
-
- /**
- * Remove a timing.
- *
- * @param id The action ID.
- */
- public void clearTiming(String id) {
- if (timemapstart.containsKey(id))
- timemapstart.remove(id);
- if (timemapend.containsKey(id))
- timemapend.remove(id);
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/MessageProvider.java b/common/src/at/gv/egovernment/moa/util/MessageProvider.java
deleted file mode 100644
index f5117e390..000000000
--- a/common/src/at/gv/egovernment/moa/util/MessageProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.util.Locale;
-
-/**
- * A singleton wrapper around a Message object.
- *
- * Provides the messages used in the common project.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class MessageProvider {
- /** The location of the default message resources. */
- private static final String[] DEFAULT_MESSAGE_RESOURCES =
- { "resources/properties/common_messages" };
- /** The locale of the default message resources. */
- private static final Locale[] DEFAULT_MESSAGE_LOCALES =
- new Locale[] { new Locale("de", "AT") };
- /** The single instance of this class. */
- private static MessageProvider instance;
-
- /** The messages provided by this MessageProvider. */
- private Messages messages;
-
- /**
- * Return the single instance of the MessageProvider.
- *
- * Intialilizes the MessageProvider with the default message
- * locations: /resources/properties/common_messages.
- *
- * @return The single MessageProvider.
- */
- public static synchronized MessageProvider getInstance() {
- if (instance == null) {
- instance =
- new MessageProvider(DEFAULT_MESSAGE_RESOURCES, DEFAULT_MESSAGE_LOCALES);
- }
- return instance;
- }
-
- /**
- * Create a MessageProvider.
- *
- * @param resourceNames The names of the resources containing the messages.
- * @param locales The corresponding locales.
- */
- protected MessageProvider(String[] resourceNames, Locale[] locales) {
- this.messages = new Messages(resourceNames, locales);
- }
-
- /**
- * Get the message corresponding to a given message ID.
- *
- * @param messageId The ID of the message.
- * @param parameters The parameters to fill in into the message arguments.
- * @return The formatted message.
- */
- public String getMessage(String messageId, Object[] parameters) {
- return messages.getMessage(messageId, parameters);
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/Messages.java b/common/src/at/gv/egovernment/moa/util/Messages.java
deleted file mode 100644
index a0139ae93..000000000
--- a/common/src/at/gv/egovernment/moa/util/Messages.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
-
-import at.gv.egovernment.moa.logging.Logger;
-
-/**
- * Provides access to the system messages resource used for exception handling
- * and logging messages.
- *
- * Messages must be provided as a resource bundle at the path.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class Messages {
- /** Error message indicating that no messages are avaiable. */
- private static final String ERROR_MESSAGES_UNAVAILABLE =
- "Fehler in der Server-Konfiguration. "
- + "Die Fehlertexte konnten nicht geladen werden.";
- /** Error message indicating that the message is not available. */
- private static final String ERROR_NO_MESSAGE =
- "Keine Fehlermeldung für Fehler-Nr.={0}";
-
- /** The names of the resources containing the messages. */
- private String[] resourceNames;
- /** The corresponding Locales of the resources. */
- private Locale[] locales;
- /** The ResourceBundles containing the messages. */
- private ResourceBundleChain messages;
-
- /**
- * Create a new Message object containing the messages
- * in the given resources.
- *
- * @param resourceNames The names of the resources containing the messages.
- * @param locales The corresponding locales.
- */
- public Messages(String[] resourceNames, Locale[] locales) {
- this.resourceNames = resourceNames;
- this.locales = locales;
- this.messages = null;
- }
-
- /**
- * Get the message corresponding to a given message ID.
- *
- * @param messageId The ID of the message.
- * @param parameters The parameters to fill in into the message arguments.
- * @return The formatted message.
- */
- public String getMessage(String messageId, Object[] parameters) {
- // initialize messages
- if (messages == null) {
- initMessages();
- }
-
- // create the message
- if (messages == null) {
- return ERROR_MESSAGES_UNAVAILABLE;
- } else {
- try {
- String rawMessage = messages.getString(messageId);
- return MessageFormat.format(rawMessage, parameters);
- } catch (MissingResourceException e2) {
- // couldn't find any message -> set to default error message
- return MessageFormat.format(
- ERROR_NO_MESSAGE,
- new Object[] { messageId });
- }
- }
- }
-
- /**
- * Return the names of the resources containing the messages.
- *
- * @return String[] The names of the resource bundles containing the messages.
- */
- private String[] getResourceNames() {
- return resourceNames;
- }
-
- /**
- * Return the Locales of the resources containing the messages.
- *
- * @return Locale[] The Locales of the resource bundles
- * containing the messages.
- */
- private Locale[] getLocales() {
- return locales;
- }
-
- /**
- * Initialize the messagesResourceBundle containing
- * the MOA error messages.
- */
- private void initMessages() {
- messages = new ResourceBundleChain();
- int i;
-
- // initialize the message resources
- for (i = 0; i < resourceNames.length; i++) {
- try {
- messages.addResourceBundle(
- PropertyResourceBundle.getBundle(
- getResourceNames()[i],
- getLocales()[i]));
- } catch (MissingResourceException e) {
- Logger.error(ERROR_MESSAGES_UNAVAILABLE, e);
- }
- }
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/NodeIteratorAdapter.java b/common/src/at/gv/egovernment/moa/util/NodeIteratorAdapter.java
deleted file mode 100644
index f71aa472d..000000000
--- a/common/src/at/gv/egovernment/moa/util/NodeIteratorAdapter.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.util.ListIterator;
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-
-/**
- * A NodeIterator implementation based on a
- * ListIterator.
- *
- * @see java.util.ListIterator
- * @see org.w3c.dom.traversal.NodeIterator
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class NodeIteratorAdapter implements NodeIterator {
-
- /** The ListIterator to wrap. */
- private ListIterator nodeIterator;
-
- /**
- * Create a new NodeIteratorAdapter.
- * @param nodeIterator The ListIterator to iterate over.
- */
- public NodeIteratorAdapter(ListIterator nodeIterator) {
- this.nodeIterator = nodeIterator;
- }
-
- /**
- * @see org.w3c.dom.traversal.NodeIterator#getRoot()
- */
- public Node getRoot() {
- return null;
- }
-
- /**
- * @see org.w3c.dom.traversal.NodeIterator#getWhatToShow()
- */
- public int getWhatToShow() {
- return NodeFilter.SHOW_ALL;
- }
-
- /**
- * @see org.w3c.dom.traversal.NodeIterator#getFilter()
- */
- public NodeFilter getFilter() {
- return null;
- }
-
- /**
- * @see org.w3c.dom.traversal.NodeIterator#getExpandEntityReferences()
- */
- public boolean getExpandEntityReferences() {
- return false;
- }
-
- /**
- * @see org.w3c.dom.traversal.NodeIterator#nextNode()
- */
- public Node nextNode() throws DOMException {
- if (nodeIterator.hasNext()) {
- return (Node) nodeIterator.next();
- }
- return null;
- }
-
- /**
- * @see org.w3c.dom.traversal.NodeIterator#previousNode()
- */
- public Node previousNode() throws DOMException {
- if (nodeIterator.hasPrevious()) {
- return (Node) nodeIterator.previous();
- }
- return null;
- }
-
- /**
- * @see org.w3c.dom.traversal.NodeIterator#detach()
- */
- public void detach() {
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/NodeListAdapter.java b/common/src/at/gv/egovernment/moa/util/NodeListAdapter.java
deleted file mode 100644
index 7102cadca..000000000
--- a/common/src/at/gv/egovernment/moa/util/NodeListAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.util.List;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * A NodeList implementation based on a List.
- *
- * @see java.util.List
- * @see org.w3c.dom.NodeList
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class NodeListAdapter implements NodeList {
- /** The List to wrap. */
- private List nodeList;
-
- /**
- * Create a new NodeListAdapter.
- *
- * @param nodeList The List containing the nodes.
- */
- public NodeListAdapter(List nodeList) {
- this.nodeList = nodeList;
- }
-
- /**
- * @see org.w3c.dom.NodeList#item(int)
- */
- public Node item(int index) {
- return (Node) nodeList.get(index);
- }
-
- /**
- * @see org.w3c.dom.NodeList#getLength()
- */
- public int getLength() {
- return nodeList.size();
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/OutputXML2File.java b/common/src/at/gv/egovernment/moa/util/OutputXML2File.java
deleted file mode 100644
index f9d330d41..000000000
--- a/common/src/at/gv/egovernment/moa/util/OutputXML2File.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Created on 26.04.2004
- *
- * @author rschamberger
- * $ID$
- */
-package at.gv.egovernment.moa.util;
-
-import org.w3c.dom.Element;
-
-import at.gv.egovernment.moa.logging.Logger;
-
-/**
- * utility functions to write XML data to files
- * @author rschamberger
- * @version $Id$
- */
-public class OutputXML2File {
-
- /**
- * writes an XML structure to file if debug is enabled in hierarchy (Encoding: UTF-8)
- *
- * @param filename file name
- * @param rootElem root element in DOM tree
- * @param hierarchy of the Logger
- */
- public static void debugOutputXML2File(String filename, Element rootElem, String hierarchy) {
- if (Logger.isDebugEnabled(hierarchy)) {
- outputXML2File(filename, rootElem);
- }
- }
-
- /**
- * writes an XML structure to file if debug is enabled in hierarchy (Encoding: UTF-8)
- *
- * @param filename file name
- * @param xmlString XML string
- * @param hierarchy of the Logger
- */
- public static void debugOutputXML2File(String filename, String xmlString, String hierarchy) {
- if (Logger.isDebugEnabled(hierarchy)) {
- outputXML2File(filename, xmlString);
- }
- }
-
- /**
- * writes an XML structure to file (Encoding: UTF-8)
- *
- * @param filename file name
- * @param rootElem root element in DOM tree
- */
- public static void outputXML2File(String filename, Element rootElem) {
- try {
- String xmlString = new String(DOMUtils.serializeNode(rootElem));
- outputXML2File(filename, xmlString);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * writes an XML structure to file (Encoding: UTF-8)
- *
- * @param filename file name
- * @param xmlString XML string
- */
- public static void outputXML2File(String filename, String xmlString) {
- try {
- java.io.OutputStream fout = new java.io.FileOutputStream(filename);
- byte[] xmlData = xmlString.getBytes("UTF-8");
- fout.write(xmlData);
- fout.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/ResourceBundleChain.java b/common/src/at/gv/egovernment/moa/util/ResourceBundleChain.java
deleted file mode 100644
index 90b28548a..000000000
--- a/common/src/at/gv/egovernment/moa/util/ResourceBundleChain.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * A class to chain ResourceBundles.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class ResourceBundleChain {
- /** Error message indicating the resource is not available. */
- private static final String ERROR_MISSING_RESOURCE = "Missing resource";
- /** The ResourceBundles contained in this chain. */
- private List resourceBundles = new ArrayList();
-
- /**
- * Add a ResourceBundle to the chain.
- *
- * @param resourceBundle The ResourceBundle to add.
- */
- public void addResourceBundle(ResourceBundle resourceBundle) {
- resourceBundles.add(resourceBundle);
- }
-
- /**
- * Return the value of the resource.
- *
- * @param key The key to access the String resource.
- * @return The resource value. All the registered ResourceBundles
- * are searched in the order in which they have previously been added to this
- * ResourceBundleChain.
- * @throws MissingResourceException The resource coult not be found in any of
- * the bundles.
- */
- public String getString(String key) throws MissingResourceException {
- MissingResourceException lastException = null;
- Iterator iter;
-
- // handle case where no resource bundles have been added
- if (resourceBundles.size() == 0) {
- throw new MissingResourceException(
- ERROR_MISSING_RESOURCE,
- this.getClass().getName(),
- key);
- }
-
- // try to find the resource in one of the bundles; if it cannot be found,
- // return the exception thrown by the last bundle in the list
- for (iter = resourceBundles.iterator(); iter.hasNext();) {
- ResourceBundle resourceBundle = (ResourceBundle) iter.next();
- try {
- String value = resourceBundle.getString(key);
- return value;
- } catch (MissingResourceException e) {
- lastException = e;
- }
- }
- throw lastException;
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/SSLUtils.java b/common/src/at/gv/egovernment/moa/util/SSLUtils.java
deleted file mode 100644
index ada21b412..000000000
--- a/common/src/at/gv/egovernment/moa/util/SSLUtils.java
+++ /dev/null
@@ -1,221 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.GeneralSecurityException;
-import java.security.KeyStore;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-
-/**
- * Utility for connecting to server applications via SSL.
- *
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class SSLUtils {
-
- /**
- * Creates an SSLSocketFactory which utilizes the given trust store.
- *
- * @param trustStoreType key store type of trust store
- * @param trustStoreInputStream input stream for reading JKS trust store containing
- * trusted server certificates; if null, the default
- * trust store will be utilized
- * @param trustStorePassword if provided, it will be used to check
- * the integrity of the trust store; if omitted, it will not be checked
- * @return SSLSocketFactory to be used by an HttpsURLConnection
- * @throws IOException thrown while reading from the input stream
- * @throws GeneralSecurityException thrown while creating the socket factory
- */
- public static SSLSocketFactory getSSLSocketFactory(
- String trustStoreType,
- InputStream trustStoreInputStream,
- String trustStorePassword)
- throws IOException, GeneralSecurityException {
-
- TrustManager[] tms = getTrustManagers(trustStoreType, trustStoreInputStream, trustStorePassword);
- SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(null, tms, null);
-
- SSLSocketFactory sf = ctx.getSocketFactory();
- return sf;
- }
- /**
- * Creates an SSLSocketFactory which utilizes the
- * given trust store and keystore.
- *
- * @param trustStore trust store containing trusted server certificates;
- * if null, the default trust store will be utilized
- * @param clientKeyStoreType key store type of clientKeyStore
- * @param clientKeyStoreURL URL of key store containing keys to be used for
- * client authentication; if null, the default key store will be utilized
- * @param clientKeyStorePassword if provided, it will be used to check
- * the integrity of the client key store; if omitted, it will not be checked
- * @return SSLSocketFactory to be used by an HttpsURLConnection
- * @throws IOException thrown while reading key store file
- * @throws GeneralSecurityException thrown while creating the socket factory
- */
- public static SSLSocketFactory getSSLSocketFactory(
- KeyStore trustStore,
- String clientKeyStoreType,
- String clientKeyStoreURL,
- String clientKeyStorePassword)
- throws IOException, GeneralSecurityException {
-
- SSLContext ctx = getSSLContext(
- trustStore, clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
- SSLSocketFactory sf = ctx.getSocketFactory();
- return sf;
- }
- /**
- * Creates an SSLContext initialized for the
- * given trust store and keystore.
- *
- * @param trustStore trust store containing trusted server certificates;
- * if null, the default trust store will be utilized
- * @param clientKeyStoreType key store type of clientKeyStore
- * @param clientKeyStoreURL URL of key store containing keys to be used for
- * client authentication; if null, the default key store will be utilized
- * @param clientKeyStorePassword if provided, it will be used to check
- * the integrity of the client key store; if omitted, it will not be checked
- * @return SSLContext to be used for creating an SSLSocketFactory
- * @throws IOException thrown while reading key store file
- * @throws GeneralSecurityException thrown while creating the SSL context
- */
- public static SSLContext getSSLContext(
- KeyStore trustStore,
- String clientKeyStoreType,
- String clientKeyStoreURL,
- String clientKeyStorePassword)
- throws IOException, GeneralSecurityException {
-
- //System.setProperty("javax.net.debug", "all");
- TrustManager[] tms = getTrustManagers(trustStore);
- KeyManager[] kms = getKeyManagers(clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
- SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(kms, tms, null);
- return ctx;
- }
- /**
- * Loads the trust store from an input stream and gets the
- * TrustManagers from a default TrustManagerFactory,
- * initialized from the given trust store.
- * @param trustStoreType key store type of trust store
- * @param trustStoreInputStream input stream for reading JKS trust store containing
- * trusted server certificates; if null, the default
- * trust store will be utilized
- * @param trustStorePassword if provided, it will be used to check
- * the integrity of the trust store; if omitted, it will not be checked
- * @return TrustManagers to be used for creating an
- * SSLSocketFactory utilizing the given trust store
- * @throws IOException thrown while reading from the input stream
- * @throws GeneralSecurityException thrown while initializing the
- * default TrustManagerFactory
- */
- protected static TrustManager[] getTrustManagers(
- String trustStoreType,
- InputStream trustStoreInputStream,
- String trustStorePassword)
- throws IOException, GeneralSecurityException {
-
- if (trustStoreInputStream == null)
- return null;
-
- // Set up the TrustStore to use. We need to load the file into
- // a KeyStore instance.
- KeyStore trustStore = KeyStoreUtils.loadKeyStore(trustStoreType, trustStoreInputStream, trustStorePassword);
- return getTrustManagers(trustStore);
- }
- /**
- * Gets the TrustManagers from a default TrustManagerFactory,
- * initialized from the given trust store.
- *
- * @param trustStore the trust store to use
- * @return TrustManagers to be used for creating an
- * SSLSocketFactory utilizing the given trust store
- * @throws GeneralSecurityException thrown while initializing the
- * default TrustManagerFactory
- */
- protected static TrustManager[] getTrustManagers(KeyStore trustStore)
- throws GeneralSecurityException {
-
- if (trustStore == null)
- return null;
-
- // Initialize the default TrustManagerFactory with this KeyStore
- String alg=TrustManagerFactory.getDefaultAlgorithm();
- TrustManagerFactory tmFact=TrustManagerFactory.getInstance(alg);
- tmFact.init(trustStore);
-
- // And now get the TrustManagers
- TrustManager[] tms=tmFact.getTrustManagers();
- return tms;
- }
- /**
- * Loads the client key store from file and gets the
- * KeyManagers from a default KeyManagerFactory,
- * initialized from the given client key store.
- * @param clientKeyStoreType key store type of clientKeyStore
- * @param clientKeyStoreURL URL of key store containing keys to be used for
- * client authentication; if null, the default key store will be utilized
- * @param clientKeyStorePassword password used to check the integrity of the client key store;
- * if null, it will not be checked
- * @return KeyManagers to be used for creating an
- * SSLSocketFactory utilizing the given client key store
- * @throws IOException thrown while reading from the key store file
- * @throws GeneralSecurityException thrown while initializing the
- * default KeyManagerFactory
- */
- public static KeyManager[] getKeyManagers (
- String clientKeyStoreType,
- String clientKeyStoreURL,
- String clientKeyStorePassword)
- throws IOException, GeneralSecurityException {
-
- if (clientKeyStoreURL == null)
- return null;
-
- // Set up the KeyStore to use. We need to load the file into
- // a KeyStore instance.
- KeyStore clientKeyStore = KeyStoreUtils.loadKeyStore(
- clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
- return getKeyManagers(clientKeyStore, clientKeyStorePassword);
- }
- /**
- * Gets the KeyManagers from a default KeyManagerFactory,
- * initialized from the given client key store.
- * @param clientKeyStore client key store
- * @param clientKeyStorePassword if provided, it will be used to check
- * the integrity of the client key store; if omitted, it will not be checked
- * @return KeyManagers to be used for creating an
- * SSLSocketFactory utilizing the given client key store
- * @throws GeneralSecurityException thrown while initializing the
- * default KeyManagerFactory
- */
- public static KeyManager[] getKeyManagers (
- KeyStore clientKeyStore,
- String clientKeyStorePassword)
- throws GeneralSecurityException {
-
- if (clientKeyStore == null)
- return null;
-
- // Now we initialize the default KeyManagerFactory with this KeyStore
- String alg=KeyManagerFactory.getDefaultAlgorithm();
- KeyManagerFactory kmFact=KeyManagerFactory.getInstance(alg);
- char[] password = null;
- if (clientKeyStorePassword != null)
- password = clientKeyStorePassword.toCharArray();
- kmFact.init(clientKeyStore, password);
-
- // And now get the KeyManagers
- KeyManager[] kms=kmFact.getKeyManagers();
- return kms;
- }
-}
diff --git a/common/src/at/gv/egovernment/moa/util/StreamEntityResolver.java b/common/src/at/gv/egovernment/moa/util/StreamEntityResolver.java
deleted file mode 100644
index 38c4e863c..000000000
--- a/common/src/at/gv/egovernment/moa/util/StreamEntityResolver.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * An EntityResolver that maps system IDs to
- * InputStreams.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class StreamEntityResolver implements EntityResolver {
-
- /** A mapping from Public ID or System ID to an InputStream
- * containing the entity. */
- private Map mappedEntities;
-
- /**
- * Create a StreamEntityResolver.
- *
- * @param mappedEntities A mapping from public or system IDs
- * (String objects) to InputStreams.
- */
- public StreamEntityResolver(Map mappedEntities) {
- this.mappedEntities = mappedEntities;
- }
-
- /**
- * Resolve an entity by looking it up in the mapped entities.
- *
- * First, the public ID is looked up in the mapping, then the system ID.
- *
- * @param publicId The public ID of the entity.
- * @param systemId The system ID of the entity.
- * @return An InputStream containing the entity or
- * null if no entity could be found.
- * @throws SAXException Signalling a parsing exception.
- * @throws IOException Error reading the entity.
- */
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
-
- InputSource src = null;
-
- if (publicId != null && mappedEntities.get(publicId) != null) {
- src = new InputSource((InputStream) mappedEntities.get(publicId));
- } else if (systemId != null && mappedEntities.get(systemId) != null) {
- src = new InputSource((InputStream) mappedEntities.get(systemId));
- }
-
- if (src != null) {
- src.setPublicId(publicId);
- src.setSystemId(systemId);
- }
-
- return src;
- }
-}
diff --git a/common/src/at/gv/egovernment/moa/util/StreamUtils.java b/common/src/at/gv/egovernment/moa/util/StreamUtils.java
deleted file mode 100644
index a22f1c2a8..000000000
--- a/common/src/at/gv/egovernment/moa/util/StreamUtils.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-
-/**
- * Utility methods for streams.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class StreamUtils {
-
- /**
- * Compare the contents of two InputStreams.
- *
- * @param is1 The 1st InputStream to compare.
- * @param is2 The 2nd InputStream to compare.
- * @return boolean true, if both streams contain the exactly the
- * same content, false otherwise.
- * @throws IOException An error occurred reading one of the streams.
- */
- public static boolean compareStreams(InputStream is1, InputStream is2)
- throws IOException {
-
- byte[] buf1 = new byte[256];
- byte[] buf2 = new byte[256];
- int length1;
- int length2;
-
- try {
- while (true) {
- length1 = is1.read(buf1);
- length2 = is2.read(buf2);
-
- if (length1 != length2) {
- return false;
- }
- if (length1 <= 0) {
- return true;
- }
- if (!compareBytes(buf1, buf2, length1)) {
- return false;
- }
- }
- } catch (IOException e) {
- throw e;
- } finally {
- // close both streams
- try {
- is1.close();
- is2.close();
- } catch (IOException e) {
- // ignore this
- }
- }
- }
-
- /**
- * Compare two byte arrays, up to a given maximum length.
- *
- * @param b1 1st byte array to compare.
- * @param b2 2nd byte array to compare.
- * @param length The maximum number of bytes to compare.
- * @return true, if the byte arrays are equal, false
- * otherwise.
- */
- private static boolean compareBytes(byte[] b1, byte[] b2, int length) {
- if (b1.length != b2.length) {
- return false;
- }
-
- for (int i = 0; i < b1.length && i < length; i++) {
- if (b1[i] != b2[i]) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Reads a byte array from a stream.
- * @param in The InputStream to read.
- * @return The bytes contained in the given InputStream.
- * @throws IOException on any exception thrown
- */
- public static byte[] readStream(InputStream in) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- int b;
- while ((b = in.read()) >= 0)
- out.write(b);
- in.close();
- return out.toByteArray();
- }
-
- /**
- * Reads a String from a stream, using given encoding.
- * @param in The InputStream to read.
- * @param encoding The character encoding to use for converting the bytes
- * of the InputStream into a String.
- * @return The content of the given InputStream converted into
- * a String.
- * @throws IOException on any exception thrown
- */
- public static String readStream(InputStream in, String encoding) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- int b;
- while ((b = in.read()) >= 0)
- out.write(b);
- in.close();
- return out.toString(encoding);
- }
-
- /**
- * Gets the stack trace of the Throwable passed in as a string.
- * @param t The Throwable.
- * @return a String representing the stack trace of the Throwable.
- */
- public static String getStackTraceAsString(Throwable t)
- {
- ByteArrayOutputStream stackTraceBIS = new ByteArrayOutputStream();
- t.printStackTrace(new PrintStream(stackTraceBIS));
- return new String(stackTraceBIS.toByteArray());
- }
-}
diff --git a/common/src/at/gv/egovernment/moa/util/StringUtils.java b/common/src/at/gv/egovernment/moa/util/StringUtils.java
deleted file mode 100644
index 61b1a18ea..000000000
--- a/common/src/at/gv/egovernment/moa/util/StringUtils.java
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright (C) 2002 IAIK
-// email: jce-info@iaik.tu-graz.ac.at
-//
-// All rights reserved.
-//
-// This source is provided for inspection purposes and recompilation only,
-// unless specified differently in a contract with IAIK. This source has to
-// be kept in strict confidence and must not be disclosed to any third party
-// under any circumstances. Redistribution in source and binary forms, with
-// or without modification, are permitted in any case!
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE.
-//
-
-package at.gv.egovernment.moa.util;
-
-import java.util.StringTokenizer;
-
-/**
- * Utitility functions for string manipulations.
- *
- * @author Harald Bratko
- */
-public class StringUtils {
-
- /**
- * Removes all blanks and tabs from the given string.
- *
- * @param s The string to remove all blanks and tabs from.
- * @return The input string with all blanks and tabs removed from.
- */
- public static String removeBlanks(String s) {
- StringTokenizer st = new StringTokenizer(s);
- StringBuffer sb = new StringBuffer(s.length());
- while (st.hasMoreTokens()) {
- sb.append(st.nextToken());
- }
- return sb.toString();
- }
-
- /**
- * Removes all occurences of the specified token from the the given string.
- *
- * @param s The string to remove all occurences of the specified token from.
- * @return The input string with all occurences of the specified token removed from.
- */
- public static String removeToken(String s, String token) {
- StringTokenizer st = new StringTokenizer(s, token);
- StringBuffer sb = new StringBuffer(s.length());
- while (st.hasMoreTokens()) {
- sb.append(st.nextToken());
- }
- return sb.toString();
- }
-
- /**
- * Removes all leading zeros from the input string.
- *
- * @param s The string remove the leading zeros from.
- * @return The input string with the leading zeros removed from.
- */
- public static String deleteLeadingZeros(String s) {
- StringBuffer sb = new StringBuffer(s);
- int l = sb.length();
- int j = 0;
- for (int i=0; is that matches the given
- * search string by the given replace string.
- *
- * @param s The string where the replacment should take place.
- * @param search The pattern that should be replaced.
- * @param replace The string that should replace all each search
- * string within s.
- * @return A string whrer all occurrence of search are
- * replaced with replace.
- */
- public static String replaceAll (String s, String search, String replace)
- {
- StringBuffer sb = new StringBuffer();
- int i = 0, j = 0;
- int len = search.length();
- while (j > -1)
- {
- j = s.indexOf(search, i);
-
- if (j > -1)
- {
- sb.append(s.substring(i,j));
- sb.append(replace);
- i = j + len;
- }
- }
-
- sb.append(s.substring(i, s.length()));
-
- return sb.toString();
- }
-
- /**
- * Changes the SecurityLayer version in the given string.
- * This method usually takes as input an XML structure represented in a string
- * format and changes the SecurityLayer namespaces prefixes and URIs from
- * one SecurityLayer version to another.
- * e.g.: code>sl10 to sl and
- * http://www.buergerkarte.at/namespaces/securitylayer/20020225#
- * to
- * http://www.buergerkarte.at/namespaces/securitylayer/1.2#
- *
- * @param s The string (usally an XML structure) where the
- * SecurityLayer version should be changed.
- * @param slPrefixOld The SecurityLayer namespace prefix that should be
- * replaced by the new one.
- * @param slPrefixNew The new SecurityLayer namespace prefix that should
- * replace the old one.
- * @param slNSUriOld The SecurityLayer namespace URI that should be
- * replaced by the new one.
- * @param slNSUriNew The new SecurityLayer namespace URI that should
- * replace the old one.
- * @return A string where the SecurityLayer namespace prefixes
- * and URIs are replaced by new ones.
- */
- public static String changeSLVersion(String s, String slPrefixOld, String slPrefixNew, String slNSUriOld, String slNSUriNew) {
- String retString = replaceAll(s, slPrefixOld, slPrefixNew);
- retString = replaceAll(retString, slNSUriOld, slNSUriNew);
- return retString ;
- }
-
- /**
- * Removes the XML declaration from an XML expression.
- *
- * @param xmlString XML expression as String
- *
- * @return XML expression, XML declaration removed
- */
- public static String removeXMLDeclaration(String xmlString) {
- if (xmlString.startsWith("application/x-www-form-urlencoded string using a specific encoding scheme.
- * @param s the string to decode
- * @param encoding name of character encoding
- * @return the newly decoded string
- * @throws UnsupportedEncodingException if the encoding is not supported
- */
- public static String decode(String s, String encoding) throws UnsupportedEncodingException {
- StringReader in = new StringReader(s);
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- for (int b = read(in); b >= 0; b = read(in))
- bout.write(b);
- return bout.toString(encoding);
- }
- /**
- * Decodes the next byte from the string reader.
- * @param in string reader
- * @return the next byte decoded;
- * -1 upon end of string, on erroneous data, and on any exception caught
- * @todo syntax check on string
- */
- private static int read(StringReader in) {
- try {
- int b = in.read();
- if (b == '+')
- return ' ';
- if (b == '%') {
- char[] hex = new char[2];
- if (in.read(hex, 0, 2) >= 0) {
- String hexString = new String(hex);
- return Integer.valueOf(hexString, 16).intValue();
- }
- else
- return -1;
- }
- return b;
- }
- catch (IOException ex) {
- return -1;
- }
- catch (NumberFormatException ex) {
- return -1;
- }
- }
-}
diff --git a/common/src/at/gv/egovernment/moa/util/URLEncoder.java b/common/src/at/gv/egovernment/moa/util/URLEncoder.java
deleted file mode 100644
index 840c0c3bc..000000000
--- a/common/src/at/gv/egovernment/moa/util/URLEncoder.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-
-/**
- * Translates a string into mime format "x-www-form-urlencoded".
- * Provides a function missing in JDK 1.3.
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class URLEncoder {
-
- /**
- * Translates a string into x-www-form-urlencoded format.
- * @param s the string to be translated
- * @param encoding the encoding to use
- * @return the translated string
- * @throws UnsupportedEncodingException when the desired encoding is not supported
- */
- public static String encode(String s, String encoding) throws UnsupportedEncodingException {
- byte[] barr = s.getBytes(encoding);
- ByteArrayInputStream bin = new ByteArrayInputStream(barr);
- StringWriter out = new StringWriter();
- for (int b = bin.read(); b >= 0; b = bin.read())
- encode(b, out);
- return out.toString();
- }
-
- /**
- * Encode a character.
- * @param ch The character to encode.
- * @param out The StringWriter containing the result.
- */
- private static void encode(int ch, StringWriter out) {
- if ((ch >= 'a' && ch <= 'z')
- || (ch >= 'A' && ch <= 'Z')
- || (ch >= '0' && ch <= '9')
- || ch == '.' || ch == '-' || ch == '*' || ch == '_')
- out.write(ch);
- else if (ch == ' ')
- out.write('+');
- else
- encodeHex(ch, out);
- }
-
- /**
- * Encode a character as an escaped hex value.
- * @param ch The character to encode.
- * @param out The StringWriter containing the result.
- */
- private static void encodeHex(int ch, StringWriter out) {
- out.write('%');
- String hex = Integer.toHexString(ch).toUpperCase();
- if (hex.length() < 2)
- out.write('0');
- else
- out.write(hex.charAt(hex.length() - 2));
- out.write(hex.charAt(hex.length() - 1));
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/XPathException.java b/common/src/at/gv/egovernment/moa/util/XPathException.java
deleted file mode 100644
index e10c882e5..000000000
--- a/common/src/at/gv/egovernment/moa/util/XPathException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-/**
- * An exception occurred evaluating an XPath.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class XPathException extends RuntimeException {
- /** The wrapped exception. */
- private Throwable wrapped;
-
- /**
- * Create a XPathException.
- *
- * @param message The exception message.
- * @param wrapped The exception being the likely cause of this exception.
- */
- public XPathException(String message, Throwable wrapped) {
- super(message);
- this.wrapped = wrapped;
- }
-
- /**
- * Return the wrapped exception.
- *
- * @return The wrapped exception being the likely cause of this exception.
- */
- public Throwable getWrapped() {
- return wrapped;
- }
-
- /**
- * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
- */
- public void printStackTrace(PrintStream s) {
- super.printStackTrace(s);
- if (getWrapped() != null) {
- s.print("Caused by: ");
- getWrapped().printStackTrace(s);
- }
- }
-
- /**
- * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
- */
- public void printStackTrace(PrintWriter s) {
- super.printStackTrace(s);
- if (getWrapped() != null) {
- s.print("Caused by: ");
- getWrapped().printStackTrace(s);
- }
- }
-
-}
diff --git a/common/src/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/at/gv/egovernment/moa/util/XPathUtils.java
deleted file mode 100644
index 5212ed13e..000000000
--- a/common/src/at/gv/egovernment/moa/util/XPathUtils.java
+++ /dev/null
@@ -1,526 +0,0 @@
-package at.gv.egovernment.moa.util;
-
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.traversal.NodeIterator;
-
-import org.jaxen.JaxenException;
-import org.jaxen.NamespaceContext;
-import org.jaxen.SimpleNamespaceContext;
-import org.jaxen.dom.DOMXPath;
-import org.jaxen.dom.DocumentNavigator;
-
-/**
- * Utility methods to evaluate XPath expressions on DOM nodes.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class XPathUtils {
-
- /**
- * The XPath expression selecting all nodes under a given root (including the
- * root node itself).
- */
- public static final String ALL_NODES_XPATH =
- "(.//. | .//@* | .//namespace::*)";
-
- /** The DocumentNavigator to use for navigating the document. */
- private static DocumentNavigator documentNavigator =
- DocumentNavigator.getInstance();
- /** The default namespace prefix to namespace URI mappings. */
- private static NamespaceContext NS_CONTEXT;
-
- static {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext();
- ctx.addNamespace(Constants.MOA_PREFIX, Constants.MOA_NS_URI);
- ctx.addNamespace(Constants.MOA_CONFIG_PREFIX, Constants.MOA_CONFIG_NS_URI);
- ctx.addNamespace(Constants.MOA_ID_CONFIG_PREFIX, Constants.MOA_ID_CONFIG_NS_URI);
- ctx.addNamespace(Constants.SL10_PREFIX, Constants.SL10_NS_URI);
- ctx.addNamespace(Constants.SL11_PREFIX, Constants.SL11_NS_URI);
- ctx.addNamespace(Constants.SL12_PREFIX, Constants.SL12_NS_URI);
- ctx.addNamespace(Constants.ECDSA_PREFIX, Constants.ECDSA_NS_URI);
- ctx.addNamespace(Constants.PD_PREFIX, Constants.PD_NS_URI);
- ctx.addNamespace(Constants.SAML_PREFIX, Constants.SAML_NS_URI);
- ctx.addNamespace(Constants.SAMLP_PREFIX, Constants.SAMLP_NS_URI);
- ctx.addNamespace(Constants.DSIG_PREFIX, Constants.DSIG_NS_URI);
- ctx.addNamespace(Constants.XSLT_PREFIX, Constants.XSLT_NS_URI);
- ctx.addNamespace(Constants.XSI_PREFIX, Constants.XSI_NS_URI);
- ctx.addNamespace(Constants.DSIG_FILTER2_PREFIX, Constants.DSIG_FILTER2_NS_URI);
- ctx.addNamespace(Constants.DSIG_EC_PREFIX, Constants.DSIG_EC_NS_URI);
- ctx.addNamespace(Constants.MD_PREFIX, Constants.MD_NS_URI);
- ctx.addNamespace(Constants.MDP_PREFIX, Constants.MDP_NS_URI);
- ctx.addNamespace(Constants.MVV_PREFIX, Constants.MVV_NS_URI);
- ctx.addNamespace(Constants.STB_PREFIX, Constants.STB_NS_URI);
- ctx.addNamespace(Constants.WRR_PREFIX, Constants.WRR_NS_URI);
- NS_CONTEXT = ctx;
- }
-
- /**
- * Return a NodeIterator over the nodes matching the XPath
- * expression.
- *
- * All namespace URIs and prefixes declared in the Constants
- * interface are used for resolving namespaces.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
- * @return An iterator over the resulting nodes.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static NodeIterator selectNodeIterator(Node contextNode, String exp)
- throws XPathException {
-
- return selectNodeIterator(contextNode, NS_CONTEXT, exp);
- }
-
- /**
- * Return a NodeIterator over the nodes matching the XPath
- * expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param namespaceElement An element from which to build the
- * namespace mapping for evaluating the XPath expression
- * @param exp The XPath expression to evaluate.
- * @return An iterator over the resulting nodes.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static NodeIterator selectNodeIterator(
- Node contextNode,
- Element namespaceElement,
- String exp)
- throws XPathException {
-
- try {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext();
- ctx.addElementNamespaces(documentNavigator, namespaceElement);
- return selectNodeIterator(contextNode, ctx, exp);
- } catch (JaxenException e) {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { exp });
- throw new XPathException(message, e);
- }
- }
-
- /**
- * Return a NodeIterator over the nodes matching the XPath
- * expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param namespaceMapping A namespace prefix to namespace URI mapping
- * (String to String) for evaluating the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
- * @return An iterator over the resulting nodes.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static NodeIterator selectNodeIterator(
- Node contextNode,
- Map namespaceMapping,
- String exp)
- throws XPathException {
-
- SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
-
- return selectNodeIterator(contextNode, ctx, exp);
- }
-
- /**
- * Return a NodeIterator over the nodes matching the XPath
- * expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param nsContext The NamespaceContext for resolving namespace
- * prefixes to namespace URIs for evaluating the XPath expression.
- * @param exp The XPath expression to evaluate.
- * @return An iterator over the resulting nodes.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- private static NodeIterator selectNodeIterator(
- Node contextNode,
- NamespaceContext nsContext,
- String exp)
- throws XPathException {
-
- try {
- DOMXPath xpath = new DOMXPath(exp);
- List nodes;
-
- xpath.setNamespaceContext(nsContext);
- nodes = xpath.selectNodes(contextNode);
- return new NodeIteratorAdapter(nodes.listIterator());
- } catch (JaxenException e) {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { exp });
- throw new XPathException(message, e);
- }
- }
-
- /**
- * Return a NodeList of all the nodes matching the XPath
- * expression.
- *
- * All namespace URIs and prefixes declared in the Constants
- * interface are used for resolving namespaces.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
- * @return A NodeList containing the matching nodes.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static NodeList selectNodeList(Node contextNode, String exp)
- throws XPathException {
-
- return selectNodeList(contextNode, NS_CONTEXT, exp);
- }
-
- /**
- * Return a NodeList of all the nodes matching the XPath
- * expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param namespaceElement An element from which to build the
- * namespace mapping for evaluating the XPath expression
- * @param exp The XPath expression to evaluate.
- * @return A NodeList containing the matching nodes.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static NodeList selectNodeList(
- Node contextNode,
- Element namespaceElement,
- String exp)
- throws XPathException {
-
- try {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext();
-
- ctx.addElementNamespaces(documentNavigator, namespaceElement);
- return selectNodeList(contextNode, ctx, exp);
- } catch (JaxenException e) {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { exp });
- throw new XPathException(message, e);
- }
- }
-
- /**
- * Return a NodeList of all the nodes matching the XPath
- * expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param namespaceMapping A namespace prefix to namespace URI mapping
- * (String to String) for evaluating the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
- * @return A NodeList containing the matching nodes.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static NodeList selectNodeList(
- Node contextNode,
- Map namespaceMapping,
- String exp)
- throws XPathException {
-
- SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
-
- return selectNodeList(contextNode, ctx, exp);
- }
-
- /**
- * Return a NodeList of all the nodes matching the XPath
- * expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param nsContext The NamespaceContext for resolving namespace
- * prefixes to namespace URIs for evaluating the XPath expression.
- * @param exp The XPath expression to evaluate.
- * @return A NodeList containing the matching nodes.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- private static NodeList selectNodeList(
- Node contextNode,
- NamespaceContext nsContext,
- String exp)
- throws XPathException {
-
- try {
- DOMXPath xpath = new DOMXPath(exp);
- List nodes;
-
- xpath.setNamespaceContext(nsContext);
- nodes = xpath.selectNodes(contextNode);
- return new NodeListAdapter(nodes);
- } catch (JaxenException e) {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { exp });
- throw new XPathException(message, e);
- }
- }
-
- /**
- * Select the first node matching an XPath expression.
- *
- * All namespace URIs and prefixes declared in the Constants
- * interface are used for resolving namespaces.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
- * @return Node The first node matching the XPath expression, or
- * null, if no node matched.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static Node selectSingleNode(Node contextNode, String exp)
- throws XPathException {
-
- return selectSingleNode(contextNode, NS_CONTEXT, exp);
- }
-
- /**
- * Select the first node matching an XPath expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param namespaceElement An element from which to build the
- * namespace mapping for evaluating the XPath expression
- * @param exp The XPath expression to evaluate.
- * @return Node The first node matching the XPath expression, or
- * null, if no node matched.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static Node selectSingleNode(
- Node contextNode,
- Element namespaceElement,
- String exp)
- throws XPathException {
-
- try {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext();
- ctx.addElementNamespaces(documentNavigator, namespaceElement);
-
- return selectSingleNode(contextNode, ctx, exp);
- } catch (JaxenException e) {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { exp });
- throw new XPathException(message, e);
- }
- }
-
- /**
- * Select the first node matching an XPath expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param namespaceMapping A namespace prefix to namespace URI mapping
- * (String to String) for evaluating the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
- * @return Node The first node matching the XPath expression, or
- * null, if no node matched.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- public static Node selectSingleNode(
- Node contextNode,
- Map namespaceMapping,
- String exp)
- throws XPathException {
-
- SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
-
- return selectSingleNode(contextNode, ctx, exp);
- }
-
- /**
- * Select the first node matching an XPath expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param nsContext The NamespaceContext for resolving namespace
- * prefixes to namespace URIs for evaluating the XPath expression.
- * @param exp The XPath expression to evaluate.
- * @return Node The first node matching the XPath expression, or
- * null, if no node matched.
- * @throws XPathException An error occurred evaluating the XPath expression.
- */
- private static Node selectSingleNode(
- Node contextNode,
- NamespaceContext nsContext,
- String exp)
- throws XPathException {
-
- try {
- DOMXPath xpath = new DOMXPath(exp);
- xpath.setNamespaceContext(nsContext);
- return (Node) xpath.selectSingleNode(contextNode);
- } catch (JaxenException e) {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { exp });
- throw new XPathException(message, e);
- }
- }
-
- /**
- * Return the value of a DOM element whose location is given by an XPath
- * expression.
- *
- * @param root The root element from which to evaluate the XPath.
- * @param xpath The XPath expression pointing to the element whose value
- * to return.
- * @param def The default value to return, if no element can be found using
- * the given xpath.
- * @return The element value, if it can be located using the
- * xpath. Otherwise, def is returned.
- */
- public static String getElementValue(
- Element root,
- String xpath,
- String def) {
-
- Element elem = (Element) XPathUtils.selectSingleNode(root, xpath);
- return elem != null ? DOMUtils.getText(elem) : def;
- }
-
- /**
- * Return the value of a DOM attribute whose location is given by an XPath
- * expression.
- *
- * @param root The root element from which to evaluate the XPath.
- * @param xpath The XPath expression pointing to the attribute whose value to
- * return.
- * @param def The default value to return, if no attribute can be found using
- * the given xpath.
- * @return The element value, if it can be located using the
- * xpath. Otherwise, def is returned.
- */
- public static String getAttributeValue(
- Element root,
- String xpath,
- String def) {
-
- Attr attr = (Attr) XPathUtils.selectSingleNode(root, xpath);
- return attr != null ? attr.getValue() : def;
- }
-
- /**
- * Returns the namespace prefix used within XPathUtils for referring to
- * the namespace of the specified (Security Layer command) element.
- *
- * This namespace prefix can be used in various XPath expression evaluation methods
- * within XPathUtils without explicitely binding it to the particular
- * namespace.
- *
- * @param contextElement The (Security Layer command) element.
- *
- * @return the namespace prefix used within XPathUtils for referring to
- * the namespace of the specified (Security Layer command) element.
- *
- * throws XpathException If the specified element has a namespace other than the ones
- * known by this implementation as valid Security Layer namespaces (cf.
- * @link Constants#SL10_NS_URI, @link Constants#SL11_NS_URI, @link Constants#SL12_NS_URI).
- */
- public static String getSlPrefix (Element contextElement) throws XPathException
- {
- String sLNamespace = contextElement.getNamespaceURI();
- String sLPrefix = null;
-
- if (sLNamespace.equals(Constants.SL10_NS_URI))
- {
- sLPrefix = Constants.SL10_PREFIX;
- }
- else if (sLNamespace.equals(Constants.SL12_NS_URI))
- {
- sLPrefix = Constants.SL12_PREFIX;
- }
- else if (sLNamespace.equals(Constants.SL11_NS_URI))
- {
- sLPrefix = Constants.SL11_PREFIX;
- }
- else
- {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger Security Layer Namespace: \"" + sLNamespace + "\"."});
- throw new XPathException(message, null);
- }
-
- return sLPrefix;
- }
-
-
- /**
- * Return the SecurityLayer namespace prefix of the context element.
- * If the context element is not the element that lies within the
- * SecurityLayer namespace. The Securitylayer namespace is derived from
- * the xmlns:sl10, sl11 or sl
- * attribute of the context element.
- *
- * The returned prefix is needed for evaluating XPATH expressions.
- *
- * @param contextElement The element to get a prefix for the Securitylayer namespace,
- * that is used within the corresponding document.
- *
- * @return The string sl10, sl11 or sl,
- * depending on the SecurityLayer namespace of the contextElement.
- *
- * throws XPathException If no (vlalid) SecurityLayer namespace prefix or namespace
- * is defined.
- */
- public static String getSlPrefixFromNoRoot (Element contextElement) throws XPathException {
-
- String slPrefix = checkSLnsDeclaration(contextElement, Constants.SL10_PREFIX, Constants.SL10_NS_URI);
- if (slPrefix == null) {
- slPrefix = checkSLnsDeclaration(contextElement, Constants.SL11_PREFIX, Constants.SL11_NS_URI);
- }
- if (slPrefix == null) {
- slPrefix = checkSLnsDeclaration(contextElement, Constants.SL12_PREFIX, Constants.SL12_NS_URI);
- }
-
- return slPrefix;
-
- }
-
- /**
- * Checks if the context element has an attribute xmlns:slPrefix and
- * if the prefix of that attribute corresponds with a valid SecurityLayer namespace.
- *
- * @param contextElement The element to be checked.
- * @param slPrefix The prefix which should be checked. Must be a valid SecurityLayer
- * namespace prefix.
- * @param slNameSpace The SecurityLayer namespace that corresponds to the specified prefix.
- *
- * @return The valid SecurityLayer prefix or null if this prefix is
- * not used.
- * @throws XPathException
- */
- private static String checkSLnsDeclaration(Element contextElement, String slPrefix, String slNameSpace)
- throws XPathException
- {
- String nsAtt = "xmlns:" + slPrefix;
- String nameSpace = contextElement.getAttribute(nsAtt);
- if (nameSpace == "") {
- return null;
- } else {
- // check if namespace is correct
- if (nameSpace.equals(slNameSpace)) {
- return slPrefix;
- } else {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
- throw new XPathException(message, null);
- }
- }
- }
-
-}
diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/LogMsg.java b/common/src/main/java/at/gv/egovernment/moa/logging/LogMsg.java
new file mode 100644
index 000000000..4d04fc72d
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/logging/LogMsg.java
@@ -0,0 +1,43 @@
+package at.gv.egovernment.moa.logging;
+
+/**
+ * A unified message type to log messages from inside the MOA subsystem.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class LogMsg {
+ /** The message to log. */
+ private Object message;
+
+ /**
+ * Create a LogMsg object.
+ *
+ * @param message The actual message to log. May be null.
+ */
+ public LogMsg(Object message) {
+ this.message = message;
+ }
+
+ /**
+ * Convert this log message to a String.
+ *
+ * @return The String representation of this log message.
+ */
+ public String toString() {
+ StringBuffer msg = new StringBuffer();
+ LoggingContext ctx =
+ LoggingContextManager.getInstance().getLoggingContext();
+ String tid = ctx != null ? ctx.getTransactionID() : null;
+ String nodeId = ctx != null ? ctx.getNodeID() : null;
+
+ msg.append("TID=");
+ msg.append(tid != null ? tid : "");
+ msg.append(" NID=");
+ msg.append(nodeId != null ? nodeId : "");
+ msg.append(" MSG=");
+ msg.append(message != null ? message.toString() : "");
+
+ return msg.toString();
+ }
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java
new file mode 100644
index 000000000..eb7aa5634
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java
@@ -0,0 +1,175 @@
+package at.gv.egovernment.moa.logging;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A utility class acting as a facade to the logging subsystem.
+ *
+ * Configure the logging defaultHierarchy that the Logger uses by
+ * calling setHierarchy once before calling any of the logging
+ * output functions.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class Logger {
+
+ /** The default logging hierarchy. */
+ private static String defaultHierarchy = "";
+
+ /**
+ * Get the Log object for the default hierarchy.
+ *
+ * @return The Log object to write log messages to.
+ */
+ private static Log getLog() {
+ return LogFactory.getLog(defaultHierarchy);
+ }
+
+ /**
+ * Get the Log object for a given hierarchy.
+ *
+ * @param hierarchy The logging hierarchy for which to return the logger.
+ * @return The Log object to write log messages to.
+ */
+ private static Log getLog(String hierarchy) {
+ return LogFactory.getLog(hierarchy);
+ }
+
+ /**
+ * Set the default hierarchy to which the Logger should send its
+ * logging output.
+ * @param hierarchy The logging defaultHierarchy.
+ */
+ public static void setHierarchy(String hierarchy) {
+ defaultHierarchy = hierarchy;
+ }
+
+ /**
+ * Test, if the trace log level is enabled.
+ *
+ * @return boolean true, if tracing output is enabled
+ * false otherwise.
+ */
+ public static boolean isTraceEnabled() {
+ return getLog().isTraceEnabled();
+ }
+
+ /**
+ * Test, if the trace log level is enabled for a given hierarchy.
+ *
+ * @param hierarchy requested log hierarchy
+ * @return boolean true, if tracing output is enabled
+ * false otherwise.
+ */
+ public static boolean isTraceEnabled(String hierarchy) {
+ return getLog(hierarchy).isTraceEnabled();
+ }
+
+ /**
+ * Trace a message.
+ *
+ * @param message The message to trace.
+ */
+ public static void trace(Object message) {
+ getLog().trace(message);
+ }
+
+ /**
+ * Test, if the debug log level is enabled.
+ *
+ * @return boolean true, if debug output is enabled
+ * false otherwise.
+ */
+ public static boolean isDebugEnabled() {
+ return getLog().isDebugEnabled();
+ }
+
+ /**
+ * Test, if the debug log level is enabled for a given hierarchy.
+ *
+ * @param hierarchy requested log hierarchy
+ * @return boolean true, if debug output is enabled
+ * false otherwise.
+ */
+ public static boolean isDebugEnabled(String hierarchy) {
+ return getLog(hierarchy).isDebugEnabled();
+ }
+
+ /**
+ * Log a debug message.
+ *
+ * @param message The message to log.
+ */
+ public static void debug(Object message) {
+ getLog().debug(message);
+ }
+
+ /**
+ * Log an info message.
+ *
+ * @param message The message to log.
+ */
+ public static void info(Object message) {
+ getLog().info(message);
+ }
+
+ /**
+ * Log a warning message.
+ *
+ * @param message The message to log.
+ */
+ public static void warn(Object message) {
+ getLog().warn(message);
+ }
+
+ /**
+ * Log a warning message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the warning.
+ */
+ public static void warn(Object message, Throwable t) {
+ getLog().warn(message, t);
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param message The message to log.
+ */
+ public static void error(Object message) {
+ getLog().error(message);
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the error.
+ */
+ public static void error(Object message, Throwable t) {
+ getLog().error(message, t);
+ }
+
+ /**
+ * Log a fatal error message.
+ *
+ * @param message The message to log.
+ */
+ public static void fatal(Object message) {
+ getLog().fatal(message);
+ }
+
+ /**
+ * Log a fatal error message.
+ *
+ * @param message The message to log.
+ * @param t An exception that may be the cause of the error.
+ */
+ public static void fatal(Object message, Throwable t) {
+ getLog().fatal(message, t);
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/LoggingContext.java b/common/src/main/java/at/gv/egovernment/moa/logging/LoggingContext.java
new file mode 100644
index 000000000..42d8db06e
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/logging/LoggingContext.java
@@ -0,0 +1,46 @@
+package at.gv.egovernment.moa.logging;
+
+/**
+ * Encapsulates contextual information (i.e. per request information) for
+ * logging purposes.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class LoggingContext {
+ /** The name of the node ID system property. */
+ public static final String NODE_ID_PROPERTY = "moa.node-id";
+
+ /** The current transaction ID. */
+ private String transactionID;
+ /** The node ID. */
+ private String nodeID;
+
+ /**
+ * Create a new LoggingContext.
+ *
+ * @param transactionID The transaction ID. May be null.
+ */
+ public LoggingContext(String transactionID) {
+ this.transactionID = transactionID;
+ this.nodeID = System.getProperty(NODE_ID_PROPERTY);
+ }
+
+ /**
+ * Return the transaction ID.
+ *
+ * @return The transaction ID.
+ */
+ public String getTransactionID() {
+ return transactionID;
+ }
+
+ /**
+ * Return the node ID.
+ *
+ * @return The node ID.
+ */
+ public String getNodeID() {
+ return nodeID;
+ }
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/LoggingContextManager.java b/common/src/main/java/at/gv/egovernment/moa/logging/LoggingContextManager.java
new file mode 100644
index 000000000..2bbe6caa1
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/logging/LoggingContextManager.java
@@ -0,0 +1,56 @@
+package at.gv.egovernment.moa.logging;
+
+/**
+ * Provides each thread with a single instance of LoggingContext.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class LoggingContextManager {
+ /** The single instance of this class. */
+ private static LoggingContextManager instance = null;
+
+ /** The LoggingContext for each thread. */
+ private ThreadLocal context;
+
+ /**
+ * Get the single instance of the LoggingContextManager class.
+ *
+ * @return LoggingContextManager The single instance.
+ */
+ public static synchronized LoggingContextManager getInstance() {
+ if (instance == null) {
+ instance = new LoggingContextManager();
+ }
+ return instance;
+ }
+
+ /**
+ * Creates a new LoggingContextManager.
+ *
+ * Protected to disallow direct instantiation.
+ */
+ protected LoggingContextManager() {
+ context = new ThreadLocal();
+ }
+
+ /**
+ * Set the LoggingContext context for the current thread.
+ *
+ * @param ctx The LoggingContext for the current thread.
+ */
+ public void setLoggingContext(LoggingContext ctx) {
+ context.set(ctx);
+ }
+
+ /**
+ * Return the LoggingContext for the current thread.
+ *
+ * @return LoggingContext The LoggingContext for the current
+ * thread, or null if none has been set.
+ */
+ public LoggingContext getLoggingContext() {
+ return (LoggingContext) context.get();
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/Base64Utils.java b/common/src/main/java/at/gv/egovernment/moa/util/Base64Utils.java
new file mode 100644
index 000000000..ad29180a6
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/Base64Utils.java
@@ -0,0 +1,109 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import iaik.utils.Base64InputStream;
+import iaik.utils.Base64OutputStream;
+
+/**
+ * Utitility functions for encoding/decoding Base64 strings.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class Base64Utils {
+
+ /**
+ * Read the bytes encoded in a Base64 encoded String.
+ *
+ * @param base64String The String containing the Base64 encoded
+ * bytes.
+ * @param ignoreInvalidChars Whether to ignore invalid Base64 characters.
+ * @return byte[] The raw bytes contained in the base64String.
+ * @throws IOException Failed to read the Base64 data.
+ */
+ public static byte[] decode(String base64String, boolean ignoreInvalidChars)
+ throws IOException {
+
+ Base64InputStream in =
+ new Base64InputStream(
+ new ByteArrayInputStream(base64String.getBytes("UTF-8")),
+ ignoreInvalidChars);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ byte[] bytes = new byte[256];
+ int bytesRead;
+
+ while ((bytesRead = in.read(bytes)) > 0) {
+ out.write(bytes, 0, bytesRead);
+ }
+
+ return out.toByteArray();
+ }
+
+ /**
+ * Read the bytes encoded in a Base64 encoded String and provide
+ * them via an InputStream.
+ *
+ * @param base64String The String containing the Base64 encoded
+ * bytes.
+ * @param ignoreInvalidChars Whether to ignore invalid Base64 characters.
+ * @return The InputStream from which the binary content of the
+ * base64String can be read.
+ */
+ public static InputStream decodeToStream(
+ String base64String,
+ boolean ignoreInvalidChars) {
+
+ try {
+ ByteArrayInputStream bin =
+ new ByteArrayInputStream(base64String.getBytes("UTF-8"));
+ Base64InputStream in = new Base64InputStream(bin, ignoreInvalidChars);
+
+ return in;
+ } catch (UnsupportedEncodingException e) {
+ // cannot occur, since UTF-8 is required to be supported by every JRE
+ return null;
+ }
+ }
+
+ /**
+ * Convert a byte array to a Base64 encoded String.
+ *
+ * @param bytes The bytes to encode.
+ * @return String The Base64 encoded representation of the bytes.
+ * @throws IOException Failed to write the bytes as Base64 data.
+ */
+ public static String encode(byte[] bytes) throws IOException {
+ return encode(new ByteArrayInputStream(bytes));
+ }
+
+ /**
+ * Convert the data contained in the given stream to a Base64 encoded
+ * String.
+ *
+ * @param inputStream The stream containing the data to encode.
+ * @return The Base64 encoded data of inputStream, as a
+ * String.
+ * @throws IOException Failed to convert the data in the stream.
+ */
+ public static String encode(InputStream inputStream) throws IOException {
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ Base64OutputStream base64Stream = new Base64OutputStream(byteStream, "\n".getBytes());
+ byte[] bytes = new byte[256];
+ int bytesRead;
+
+ while ((bytesRead = inputStream.read(bytes)) > 0) {
+ base64Stream.write(bytes, 0, bytesRead);
+ }
+ base64Stream.flush();
+ base64Stream.close();
+ inputStream.close();
+
+ return byteStream.toString("UTF-8");
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/BoolUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/BoolUtils.java
new file mode 100644
index 000000000..fcd39b4dd
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/BoolUtils.java
@@ -0,0 +1,24 @@
+package at.gv.egovernment.moa.util;
+
+/**
+ * Utility class for parsing XML schema boolean values.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class BoolUtils {
+
+ /**
+ * Return the boolean value of an xsd:boolean type of DOM
+ * element/attribute.
+ *
+ * @param boolStr The value of the xsd:boolean element/attribute.
+ * @return true, if boolStr equals
+ * "true" or "1;". Otherwise,
+ * false is returned.
+ */
+ public static boolean valueOf(String boolStr) {
+ return "true".equals(boolStr) || "1".equals(boolStr);
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/CollectionUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/CollectionUtils.java
new file mode 100644
index 000000000..5329dcbd2
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/CollectionUtils.java
@@ -0,0 +1,36 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Various utility methods for dealing with java.util.Collection
+ * classes.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class CollectionUtils {
+
+ /**
+ * Convert a List of Number objects to an
+ * int array.
+ *
+ * @param nums The List containing the numbers whose integer
+ * value to put into the result.
+ * @return The int values of the Numbers contained
+ * in nums.
+ */
+ public static int[] toIntArray(List nums) {
+ int[] result = new int[nums.size()];
+ Iterator iter;
+ int i;
+
+ for (i = 0, iter = nums.iterator(); iter.hasNext(); i++) {
+ Number num = (Number) iter.next();
+ result[i] = num.intValue();
+ }
+
+ return result;
+ }
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/Constants.java b/common/src/main/java/at/gv/egovernment/moa/util/Constants.java
new file mode 100644
index 000000000..5c1314296
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/Constants.java
@@ -0,0 +1,318 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.HashMap;
+
+/**
+ * Contains various constants used throughout the system.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public interface Constants {
+ /** Root location of the schema files. */
+ public static final String SCHEMA_ROOT = "/resources/schemas/";
+
+ /** URI of the Widerrufregister XML namespace. */
+ public static final String WRR_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moavv/20041223";
+
+ /** Prefix used for the Widerrufregister XML namespace */
+ public static final String WRR_PREFIX = "wrr";
+
+ /** URI of the StandardTextBlock XML namespace. */
+ public static final String STB_NS_URI =
+ "http://reference.e-government.gv.at/namespace/standardtextblock/20041105#";
+
+ /** Prefix used for the Mandate XML namespace */
+ public static final String STB_PREFIX = "stb";
+
+ /** URI of the MOA XML namespace. */
+ public static final String MOA_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moa/20020822#";
+
+ /** Prefix used for the Mandate XML namespace */
+ public static final String MD_PREFIX = "md";
+
+ /** URI of the Mandate XML namespace. */
+ public static final String MD_NS_URI =
+ "http://reference.e-government.gv.at/namespace/mandates/20040701#";
+
+ /** Prefix used for the Mandate XML namespace */
+ public static final String MVV_PREFIX = "mvv";
+
+ /** URI of the Mandate XML namespace. */
+ public static final String MVV_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moavv/app2mvv/20041125";
+
+ /** Prefix used for the MandateCheckProfile XML namespace */
+ public static final String MDP_PREFIX = "mdp";
+
+ /** URI of the Mandate XML namespace. */
+ public static final String MDP_NS_URI =
+ "http://reference.e-government.gv.at/namespace/mandateprofile/20041105#";
+
+ /** Prefix used for the MOA XML namespace */
+ public static final String MOA_PREFIX = "moa";
+
+ /** Local location of the MOA XML schema definition. */
+ public static final String MOA_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-SPSS-1.3.xsd";
+
+ /** URI of the MOA configuration XML namespace. */
+ public static final String MOA_CONFIG_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moaconfig/20021122#";
+
+ /** URI of the MOA ID configuration XML namespace. */
+ public static final String MOA_ID_CONFIG_NS_URI =
+ "http://www.buergerkarte.at/namespaces/moaconfig#";
+
+ /** Prefix used for the MOA configuration XML namespace */
+ public static final String MOA_CONFIG_PREFIX = "conf";
+
+ /** Prefix used for the MOA configuration XML namespace */
+ public static final String MOA_ID_CONFIG_PREFIX = "confID";
+
+ /** Local location of the MOA configuration XML schema definition. */
+ public static final String MOA_CONFIG_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-SPSS-config-1.3.xsd";
+
+ /** Local location of the MOA ID configuration XML schema definition. */
+ public static final String MOA_ID_CONFIG_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-ID-Configuration-1.4.xsd";
+
+ /** URI of the Security Layer 1.0 namespace. */
+ public static final String SL10_NS_URI =
+ "http://www.buergerkarte.at/namespaces/securitylayer/20020225#";
+
+ /** Prefix used for the Security Layer 1.0 XML namespace */
+ public static final String SL10_PREFIX = "sl10";
+
+ /** Local location of the Security Layer 1.0 XML schema definition */
+ public static final String SL10_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "Core.20020225.xsd";
+
+ /** URI of the Security Layer 1.1 XML namespace */
+ public static final String SL11_NS_URI =
+ "http://www.buergerkarte.at/namespaces/securitylayer/20020831#";
+
+ /** Prefix used for the Security Layer 1.1 XML namespace */
+ public static final String SL11_PREFIX = "sl11";
+
+ /** Local location of the Security Layer 1.1 XML schema definition */
+ public static final String SL11_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "Core.20020831.xsd";
+
+ /** URI of the Security Layer 1.2 XML namespace */
+ public static final String SL12_NS_URI =
+ "http://www.buergerkarte.at/namespaces/securitylayer/1.2#";
+
+ /** Prefix used for the Security Layer 1.2 XML namespace */
+ public static final String SL12_PREFIX = "sl";
+
+ /** Local location of the Security Layer 1.2 XML schema definition */
+ public static final String SL12_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "Core-1.2.xsd";
+
+ /** URI of the ECDSA XML namespace */
+ public static final String ECDSA_NS_URI =
+ "http://www.w3.org/2001/04/xmldsig-more#";
+
+ /** Prefix used for ECDSA namespace */
+ public static final String ECDSA_PREFIX = "ecdsa";
+
+ /** Local location of ECDSA XML schema definition */
+ public static final String ECDSA_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "ECDSAKeyValue.xsd";
+
+ /** URI of the PersonData XML namespace. */
+ public static final String PD_NS_URI =
+ "http://reference.e-government.gv.at/namespace/persondata/20020228#";
+
+ /** Prefix used for the PersonData XML namespace */
+ public static final String PD_PREFIX = "pr";
+
+// /** Local location of the PersonData XML schema definition */
+// public static final String PD_SCHEMA_LOCATION =
+// SCHEMA_ROOT + "PersonData.xsd";
+
+ /** Local location of the PersonData XML schema definition */
+ public static final String PD_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "PersonData_20_en_moaWID.xsd";
+
+ /** URI of the SAML namespace. */
+ public static final String SAML_NS_URI =
+ "urn:oasis:names:tc:SAML:1.0:assertion";
+
+ /** Prefix used for the SAML XML namespace */
+ public static final String SAML_PREFIX = "saml";
+
+ /** Local location of the SAML XML schema definition. */
+ public static final String SAML_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "cs-sstc-schema-assertion-01.xsd";
+
+ /** URI of the SAML request-response protocol namespace. */
+ public static final String SAMLP_NS_URI =
+ "urn:oasis:names:tc:SAML:1.0:protocol";
+
+ /** Prefix used for the SAML request-response protocol namespace */
+ public static final String SAMLP_PREFIX = "samlp";
+
+ /** Local location of the SAML request-response protocol schema definition. */
+ public static final String SAMLP_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "cs-sstc-schema-protocol-01.xsd";
+
+ /** URI of the XML namespace. */
+ public static final String XML_NS_URI =
+ "http://www.w3.org/XML/1998/namespace";
+
+ /** Prefix used for the XML namespace */
+ public static final String XML_PREFIX = "xml";
+
+ /** Local location of the XML schema definition. */
+ public static final String XML_SCHEMA_LOCATION = SCHEMA_ROOT + "xml.xsd";
+
+ /** URI of the XMLNS namespace */
+ public static final String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/";
+
+ /** Prefix used for the XSI namespace */
+ public static final String XSI_PREFIX = "xsi";
+
+ /** Local location of the XSI schema definition. */
+ public static final String XSI_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "XMLSchema-instance.xsd";
+
+ /** URI of the XSI XMLNS namespace */
+ public static final String XSI_NS_URI =
+ "http://www.w3.org/2001/XMLSchema-instance";
+
+ /** URI of the XSLT XML namespace */
+ public static final String XSLT_NS_URI =
+ "http://www.w3.org/1999/XSL/Transform";
+
+ /** Prefix used for the XSLT XML namespace */
+ public static final String XSLT_PREFIX = "xsl";
+
+ /** URI of the XMLDSig XML namespace. */
+ public static final String DSIG_NS_URI = "http://www.w3.org/2000/09/xmldsig#";
+
+ /** Prefix used for the XMLDSig XML namespace */
+ public static final String DSIG_PREFIX = "dsig";
+
+ /** Local location of the XMLDSig XML schema. */
+ public static final String DSIG_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "xmldsig-core-schema.xsd";
+
+ /** URI of the XMLDSig XPath Filter XML namespace. */
+ public static final String DSIG_FILTER2_NS_URI =
+ "http://www.w3.org/2002/06/xmldsig-filter2";
+
+ /** Prefix used for the XMLDSig XPath Filter XML namespace */
+ public static final String DSIG_FILTER2_PREFIX = "dsig-filter2";
+
+ /** Local location of the XMLDSig XPath Filter XML schema definition. */
+ public static final String DSIG_FILTER2_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "xmldsig-filter2.xsd";
+
+ /** URI of the Exclusive Canonicalization XML namespace */
+ public static final String DSIG_EC_NS_URI =
+ "http://www.w3.org/2001/10/xml-exc-c14n#";
+
+ /** Prefix used for the Exclusive Canonicalization XML namespace */
+ public static final String DSIG_EC_PREFIX = "ec";
+
+ /** Local location of the Exclusive Canonicalizaion XML schema definition */
+ public static final String DSIG_EC_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "exclusive-canonicalization.xsd";
+
+ /** URI of the XMLLoginParameterResolver Configuration XML namespace */
+ public static final String XMLLPR_NS_URI="http://reference.e-government.gv.at/namespace/moa/20020822#/xmllpr20030814";
+
+ /** Local location of the XMLLoginParameterResolver Configuration XML schema definition */
+ public static final String XMLLPR_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOAIdentities.xsd";
+
+
+ /**
+ * Contains all namespaces and local schema locations for XML schema
+ * definitions relevant for MOA. For use in validating XML parsers.
+ */
+ public static final String ALL_SCHEMA_LOCATIONS =
+ (MOA_NS_URI + " " + MOA_SCHEMA_LOCATION + " ")
+ + (MOA_CONFIG_NS_URI + " " + MOA_CONFIG_SCHEMA_LOCATION + " ")
+ + (MOA_ID_CONFIG_NS_URI + " " + MOA_ID_CONFIG_SCHEMA_LOCATION + " ")
+ + (SL10_NS_URI + " " + SL10_SCHEMA_LOCATION + " ")
+ + (SL11_NS_URI + " " + SL11_SCHEMA_LOCATION + " ")
+ + (SL12_NS_URI + " " + SL12_SCHEMA_LOCATION + " ")
+ + (ECDSA_NS_URI + " " + ECDSA_SCHEMA_LOCATION + " ")
+ + (PD_NS_URI + " " + PD_SCHEMA_LOCATION + " ")
+ + (SAML_NS_URI + " " + SAML_SCHEMA_LOCATION + " ")
+ + (SAMLP_NS_URI + " " + SAMLP_SCHEMA_LOCATION + " ")
+ + (XML_NS_URI + " " + XML_SCHEMA_LOCATION + " ")
+ + (XSI_NS_URI + " " + XSI_SCHEMA_LOCATION + " ")
+ + (DSIG_NS_URI + " " + DSIG_SCHEMA_LOCATION + " ")
+ + (DSIG_FILTER2_NS_URI + " " + DSIG_FILTER2_SCHEMA_LOCATION + " ")
+ + (DSIG_EC_NS_URI + " " + DSIG_EC_SCHEMA_LOCATION + " ")
+ + (XMLLPR_NS_URI + " " + XMLLPR_SCHEMA_LOCATION);
+
+ /** URN prefix for bPK and wbPK. */
+ public static final String URN_PREFIX = "urn:publicid:gv.at";
+
+ /** URN prefix for context dependent id. */
+ public static final String URN_PREFIX_CDID = URN_PREFIX + ":cdid";
+
+ /** URN prefix for context dependent id (bPK). */
+ public static final String URN_PREFIX_BPK = URN_PREFIX_CDID + "+bpk";
+
+ /** URN prefix for context dependent id (HPI). */
+ public static final String URN_PREFIX_HPI = URN_PREFIX_CDID + "+EHSP";
+
+ /** URN prefix for context dependent id (wbPK). */
+ public static final String URN_PREFIX_WBPK = URN_PREFIX + ":wbpk";
+
+ /** URN prefix for context dependent id. */
+ public static final String URN_PREFIX_BASEID = URN_PREFIX + ":baseid";
+
+ /** Security Layer manifest type URI. */
+ public static final String SL_MANIFEST_TYPE_URI =
+ "http://www.buergerkarte.at/specifications/Security-Layer/20020225#SignatureManifest";
+
+ /** URI of the SHA1 digest algorithm */
+ public static final String SHA1_URI =
+ "http://www.w3.org/2000/09/xmldsig#sha1";
+
+ /** URI of the Canonical XML algorithm */
+ public static final String C14N_URI =
+ "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
+
+ /** URI of the Canoncial XML with comments algorithm */
+ public static final String C14N_WITH_COMMENTS_URI =
+ "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
+
+ /** URI of the Exclusive Canonical XML algorithm */
+ public static final String EXC_C14N_URI =
+ "http://www.w3.org/2001/10/xml-exc-c14n#";
+
+ /** URI of the Exclusive Canonical XML with commments algorithm */
+ public static final String EXC_C14N_WITH_COMMENTS_URI =
+ "http://www.w3.org/2001/10/xml-exc-c14n#WithComments";
+
+ //
+ // Local names for elements of the MOA SPSS schema
+ //
+
+ /**
+ * Local name of request for creating an XML signature.
+ */
+ public static final String MOA_SPSS_CREATE_XML_REQUEST = "CreateXMLSignatureRequest";
+
+ /**
+ * Local name of request for verifying an XML signature.
+ */
+ public static final String MOA_SPSS_VERIFY_XML_REQUEST = "VerifiyXMLSignatureRequest";
+
+ /**
+ * A map used to map namespace prefixes to namespace URIs
+ */
+ public static HashMap nSMap = new HashMap(5);
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/DOMUtils.java
new file mode 100644
index 000000000..5be0bb500
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/DOMUtils.java
@@ -0,0 +1,971 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.xerces.parsers.DOMParser;
+import org.apache.xerces.parsers.SAXParser;
+import org.apache.xerces.parsers.XMLGrammarPreparser;
+import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.util.XMLGrammarPoolImpl;
+import org.apache.xerces.xni.grammars.XMLGrammarDescription;
+import org.apache.xerces.xni.grammars.XMLGrammarPool;
+import org.apache.xerces.xni.parser.XMLInputSource;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * Various utility functions for handling XML DOM trees.
+ *
+ * The parsing methods in this class make use of some features internal to the
+ * Xerces DOM parser, mainly for performance reasons. As soon as JAXP
+ * (currently at version 1.2) is better at schema handling, it should be used as
+ * the parser interface.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class DOMUtils {
+
+ /** Feature URI for namespace aware parsing. */
+ private static final String NAMESPACES_FEATURE =
+ "http://xml.org/sax/features/namespaces";
+ /** Feature URI for validating parsing. */
+ private static final String VALIDATION_FEATURE =
+ "http://xml.org/sax/features/validation";
+ /** Feature URI for schema validating parsing. */
+ private static final String SCHEMA_VALIDATION_FEATURE =
+ "http://apache.org/xml/features/validation/schema";
+ /** Feature URI for normalization of element/attribute values. */
+ private static final String NORMALIZED_VALUE_FEATURE =
+ "http://apache.org/xml/features/validation/schema/normalized-value";
+ /** Feature URI for parsing ignorable whitespace. */
+ private static final String INCLUDE_IGNORABLE_WHITESPACE_FEATURE =
+ "http://apache.org/xml/features/dom/include-ignorable-whitespace";
+ /** Feature URI for creating EntityReference nodes in the DOM tree. */
+ private static final String CREATE_ENTITY_REF_NODES_FEATURE =
+ "http://apache.org/xml/features/dom/create-entity-ref-nodes";
+ /** Property URI for providing external schema locations. */
+ private static final String EXTERNAL_SCHEMA_LOCATION_PROPERTY =
+ "http://apache.org/xml/properties/schema/external-schemaLocation";
+ /** Property URI for providing the external schema location for elements
+ * without a namespace. */
+ private static final String EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY =
+ "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
+ /** Property URI for the Xerces grammar pool. */
+ private static final String GRAMMAR_POOL =
+ org.apache.xerces.impl.Constants.XERCES_PROPERTY_PREFIX
+ + org.apache.xerces.impl.Constants.XMLGRAMMAR_POOL_PROPERTY;
+ /** A prime number for initializing the symbol table. */
+ private static final int BIG_PRIME = 2039;
+ /** Symbol table for the grammar pool. */
+ private static SymbolTable symbolTable = new SymbolTable(BIG_PRIME);
+ /** Xerces schema grammar pool. */
+ private static XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
+ /** Set holding the NamespaceURIs of the grammarPool, to prevent multiple
+ * entries of same grammars to the pool */
+ private static Set grammarNamespaces;
+
+ static {
+ grammarPool.lockPool();
+ grammarNamespaces = new HashSet();
+ }
+
+ /**
+ * Preparse a schema and add it to the schema pool.
+ * The method only adds the schema to the pool if a schema having the same
+ * systemId (namespace URI) is not already present in the pool.
+ *
+ * @param inputStream An InputStream providing the contents of
+ * the schema.
+ * @param systemId The systemId (namespace URI) to use for the schema.
+ * @throws IOException An error occurred reading the schema.
+ */
+ public static void addSchemaToPool(InputStream inputStream, String systemId)
+ throws IOException {
+ XMLGrammarPreparser preparser;
+
+ if (!grammarNamespaces.contains(systemId)) {
+
+ grammarNamespaces.add(systemId);
+
+ // unlock the pool so that we can add another grammar
+ grammarPool.unlockPool();
+
+ // prepare the preparser
+ preparser = new XMLGrammarPreparser(symbolTable);
+ preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
+ preparser.setProperty(GRAMMAR_POOL, grammarPool);
+ preparser.setFeature(NAMESPACES_FEATURE, true);
+ preparser.setFeature(VALIDATION_FEATURE, true);
+
+ // add the grammar to the pool
+ preparser.preparseGrammar(
+ XMLGrammarDescription.XML_SCHEMA,
+ new XMLInputSource(null, systemId, null, inputStream, null));
+
+ // lock the pool again so that schemas are not added automatically
+ grammarPool.lockPool();
+ }
+ }
+
+ /**
+ * Parse an XML document from an InputStream.
+ *
+ * @param inputStream The InputStream containing the XML
+ * document.
+ * @param validating If true, parse validating.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @param entityResolver An EntityResolver to resolve external
+ * entities (schemas and DTDs). If null, it will not be set.
+ * @param errorHandler An ErrorHandler to decide what to do
+ * with parsing errors. If null, it will not be set.
+ * @return The parsed XML document as a DOM tree.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Document parseDocument(
+ InputStream inputStream,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation,
+ EntityResolver entityResolver,
+ ErrorHandler errorHandler)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ DOMParser parser;
+
+
+
+ //if Debug is enabled make a copy of inputStream to enable debug output in case of SAXException
+ byte buffer [] = null;
+ ByteArrayInputStream baStream = null;
+ if(true == Logger.isDebugEnabled()) {
+ int len = inputStream.available();
+ buffer = new byte[len];
+ inputStream.read(buffer);
+ baStream = new ByteArrayInputStream(buffer);
+ }
+
+ // create the DOM parser
+ if (symbolTable != null) {
+ parser = new DOMParser(symbolTable, grammarPool);
+ } else {
+ parser = new DOMParser();
+ }
+
+ // set parser features and properties
+ try {
+ parser.setFeature(NAMESPACES_FEATURE, true);
+ parser.setFeature(VALIDATION_FEATURE, validating);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE, validating);
+ parser.setFeature(NORMALIZED_VALUE_FEATURE, false);
+ parser.setFeature(INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true);
+ parser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE, false);
+
+ if (validating) {
+ if (externalSchemaLocations != null) {
+ parser.setProperty(
+ EXTERNAL_SCHEMA_LOCATION_PROPERTY,
+ externalSchemaLocations);
+ }
+ if (externalNoNamespaceSchemaLocation != null) {
+ parser.setProperty(
+ EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
+ externalNoNamespaceSchemaLocation);
+ }
+ }
+
+ // set entity resolver and error handler
+ if (entityResolver != null) {
+ parser.setEntityResolver(entityResolver);
+ }
+ if (errorHandler != null) {
+ parser.setErrorHandler(errorHandler);
+ }
+
+ // parse the document and return it
+ // if debug is enabled: use copy of strem (baStream) else use orig stream
+ if(null != baStream)
+ parser.parse(new InputSource(baStream));
+ else
+ parser.parse(new InputSource(inputStream));
+ } catch(SAXException e) {
+ if(true == Logger.isDebugEnabled() && null != buffer) {
+ String xmlContent = new String(buffer);
+ Logger.debug("SAXException in:\n" + xmlContent);
+ }
+ throw(e);
+ }
+
+ return parser.getDocument();
+ }
+
+ /**
+ * Parse an XML document from an InputStream.
+ *
+ * It uses a MOAEntityResolver as the EntityResolver
+ * and a MOAErrorHandler as the ErrorHandler.
+ *
+ * @param inputStream The InputStream containing the XML
+ * document.
+ * @param validating If true, parse validating.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @return The parsed XML document as a DOM tree.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Document parseDocument(
+ InputStream inputStream,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ return parseDocument(
+ inputStream,
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation,
+ new MOAEntityResolver(),
+ new MOAErrorHandler());
+ }
+
+ /**
+ * Parse an XML document from a String.
+ *
+ * It uses a MOAEntityResolver as the EntityResolver
+ * and a MOAErrorHandler as the ErrorHandler.
+ *
+ * @param xmlString The String containing the XML document.
+ * @param encoding The encoding of the XML document.
+ * @param validating If true, parse validating.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @return The parsed XML document as a DOM tree.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Document parseDocument(
+ String xmlString,
+ String encoding,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ InputStream in = new ByteArrayInputStream(xmlString.getBytes(encoding));
+ return parseDocument(
+ in,
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation);
+ }
+
+ /**
+ * Parse an UTF-8 encoded XML document from a String.
+ *
+ * @param xmlString The String containing the XML document.
+ * @param validating If true, parse validating.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @return The parsed XML document as a DOM tree.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Document parseDocument(
+ String xmlString,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ return parseDocument(
+ xmlString,
+ "UTF-8",
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation);
+ }
+
+ /**
+ * A convenience method to parse an XML document validating.
+ *
+ * @param inputStream The InputStream containing the XML
+ * document.
+ * @return The root element of the parsed XML document.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * parser.
+ */
+ public static Element parseXmlValidating(InputStream inputStream)
+ throws ParserConfigurationException, SAXException, IOException {
+ return DOMUtils
+ .parseDocument(inputStream, true, Constants.ALL_SCHEMA_LOCATIONS, null)
+ .getDocumentElement();
+ }
+
+ /**
+ * Schema validate a given DOM element.
+ *
+ * @param element The element to validate.
+ * @param externalSchemaLocations A String containing namespace
+ * URI to schema location pairs, the same way it is accepted by the xsi:
+ * schemaLocation attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the
+ * schema for elements without a namespace, the same way it is accepted by the
+ * xsi:noNamespaceSchemaLocation attribute.
+ * @return true, if the element validates against
+ * the schemas declared in it.
+ * @throws SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document from its
+ * serialized representation.
+ * @throws ParserConfigurationException An error occurred configuring the XML
+ * @throws TransformerException An error occurred serializing the element.
+ */
+ public static boolean validateElement(
+ Element element,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws
+ ParserConfigurationException,
+ IOException,
+ SAXException,
+ TransformerException {
+
+ byte[] docBytes;
+ SAXParser parser;
+
+ // create the SAX parser
+ if (symbolTable != null) {
+ parser = new SAXParser(symbolTable, grammarPool);
+ } else {
+ parser = new SAXParser();
+ }
+
+ // serialize the document
+ docBytes = serializeNode(element, "UTF-8");
+
+ // set up parser features and attributes
+ parser.setFeature(NAMESPACES_FEATURE, true);
+ parser.setFeature(VALIDATION_FEATURE, true);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE, true);
+ if (externalSchemaLocations != null) {
+ parser.setProperty(
+ EXTERNAL_SCHEMA_LOCATION_PROPERTY,
+ externalSchemaLocations);
+ }
+ if (externalNoNamespaceSchemaLocation != null) {
+ parser.setProperty(
+ EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
+ "externalNoNamespaceSchemaLocation");
+ }
+
+ // set up entity resolver and error handler
+ parser.setEntityResolver(new MOAEntityResolver());
+ parser.setErrorHandler(new MOAErrorHandler());
+
+ // parse validating
+ parser.parse(new InputSource(new ByteArrayInputStream(docBytes)));
+ return true;
+ }
+
+ /**
+ * Serialize the given DOM node.
+ *
+ * The node will be serialized using the UTF-8 encoding.
+ *
+ * @param node The node to serialize.
+ * @return String The String representation of the given DOM
+ * node.
+ * @throws TransformerException An error occurred transforming the
+ * node to a String.
+ * @throws IOException An IO error occurred writing the node to a byte array.
+ */
+ public static String serializeNode(Node node)
+ throws TransformerException, IOException {
+ return new String(serializeNode(node, "UTF-8", false), "UTF-8");
+ }
+
+
+ /**
+ * Serialize the given DOM node.
+ *
+ * The node will be serialized using the UTF-8 encoding.
+ *
+ * @param node The node to serialize.
+ * @param omitXmlDeclaration The boolean value for omitting the XML Declaration.
+ * @return String The String representation of the given DOM
+ * node.
+ * @throws TransformerException An error occurred transforming the
+ * node to a String.
+ * @throws IOException An IO error occurred writing the node to a byte array.
+ */
+ public static String serializeNode(Node node, boolean omitXmlDeclaration)
+ throws TransformerException, IOException {
+ return new String(serializeNode(node, "UTF-8", omitXmlDeclaration), "UTF-8");
+ }
+
+ /**
+ * Serialize the given DOM node.
+ *
+ * The node will be serialized using the UTF-8 encoding.
+ *
+ * @param node The node to serialize.
+ * @param omitXmlDeclaration The boolean value for omitting the XML Declaration.
+ * @param lineSeperator Sets the line seperator String of the parser
+ * @return String The String representation of the given DOM
+ * node.
+ * @throws TransformerException An error occurred transforming the
+ * node to a String.
+ * @throws IOException An IO error occurred writing the node to a byte array.
+ */
+ public static String serializeNode(Node node, boolean omitXmlDeclaration, String lineSeperator)
+ throws TransformerException, IOException {
+ return new String(serializeNode(node, "UTF-8", omitXmlDeclaration, lineSeperator), "UTF-8");
+ }
+
+ /**
+ * Serialize the given DOM node to a byte array.
+ *
+ * @param node The node to serialize.
+ * @param xmlEncoding The XML encoding to use.
+ * @return The serialized node, as a byte array. Using a compatible encoding
+ * this can easily be converted into a String.
+ * @throws TransformerException An error occurred transforming the node to a
+ * byte array.
+ * @throws IOException An IO error occurred writing the node to a byte array.
+ */
+ public static byte[] serializeNode(Node node, String xmlEncoding)
+ throws TransformerException, IOException {
+ return serializeNode(node, xmlEncoding, false);
+ }
+
+ /**
+ * Serialize the given DOM node to a byte array.
+ *
+ * @param node The node to serialize.
+ * @param xmlEncoding The XML encoding to use.
+ * @param omitDeclaration The boolean value for omitting the XML Declaration.
+ * @return The serialized node, as a byte array. Using a compatible encoding
+ * this can easily be converted into a String.
+ * @throws TransformerException An error occurred transforming the node to a
+ * byte array.
+ * @throws IOException An IO error occurred writing the node to a byte array.
+ */
+ public static byte[] serializeNode(Node node, String xmlEncoding, boolean omitDeclaration)
+ throws TransformerException, IOException {
+ return serializeNode(node, xmlEncoding, omitDeclaration, null);
+ }
+
+
+ /**
+ * Serialize the given DOM node to a byte array.
+ *
+ * @param node The node to serialize.
+ * @param xmlEncoding The XML encoding to use.
+ * @param omitDeclaration The boolean value for omitting the XML Declaration.
+ * @param lineSeperator Sets the line seperator String of the parser
+ * @return The serialized node, as a byte array. Using a compatible encoding
+ * this can easily be converted into a String.
+ * @throws TransformerException An error occurred transforming the node to a
+ * byte array.
+ * @throws IOException An IO error occurred writing the node to a byte array.
+ */
+ public static byte[] serializeNode(Node node, String xmlEncoding, boolean omitDeclaration, String lineSeperator)
+ throws TransformerException, IOException {
+
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(16384);
+
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.ENCODING, xmlEncoding);
+ String omit = omitDeclaration ? "yes" : "no";
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omit);
+ if (null!=lineSeperator) {
+ transformer.setOutputProperty("{http://xml.apache.org/xalan}line-separator", lineSeperator);//does not work for xalan <= 2.5.1
+ }
+ transformer.transform(new DOMSource(node), new StreamResult(bos));
+
+ bos.flush();
+ bos.close();
+
+ return bos.toByteArray();
+ }
+
+ /**
+ * Return the text that a node contains.
+ *
+ * This routine:
+ *
+ *
Ignores comments and processing instructions.
+ *
Concatenates TEXT nodes, CDATA nodes, and the results recursively
+ * processing EntityRef nodes.
+ *
Ignores any element nodes in the sublist. (Other possible options are
+ * to recurse into element sublists or throw an exception.)
+ *
+ *
+ * @param node A DOM node from which to extract text.
+ * @return A String representing its contents.
+ */
+ public static String getText(Node node) {
+ if (!node.hasChildNodes()) {
+ return "";
+ }
+
+ StringBuffer result = new StringBuffer();
+ NodeList list = node.getChildNodes();
+
+ for (int i = 0; i < list.getLength(); i++) {
+ Node subnode = list.item(i);
+ if (subnode.getNodeType() == Node.TEXT_NODE) {
+ result.append(subnode.getNodeValue());
+ } else if (subnode.getNodeType() == Node.CDATA_SECTION_NODE) {
+ result.append(subnode.getNodeValue());
+ } else if (subnode.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
+ // Recurse into the subtree for text
+ // (and ignore comments)
+ result.append(getText(subnode));
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Build the namespace prefix to namespace URL mapping in effect for a given
+ * node.
+ *
+ * @param node The context node for which build the map.
+ * @return The namespace prefix to namespace URL mapping (
+ * a String value to String value mapping).
+ */
+ public static Map getNamespaceDeclarations(Node node) {
+ Map nsDecls = new HashMap();
+ int i;
+
+ do {
+ if (node.hasAttributes()) {
+ NamedNodeMap attrs = node.getAttributes();
+
+ for (i = 0; i < attrs.getLength(); i++) {
+ Attr attr = (Attr) attrs.item(i);
+
+ // add prefix mapping if none exists
+ if ("xmlns".equals(attr.getPrefix())
+ || "xmlns".equals(attr.getName())) {
+
+ String nsPrefix =
+ attr.getPrefix() != null ? attr.getLocalName() : "";
+
+ if (nsDecls.get(nsPrefix) == null) {
+ nsDecls.put(nsPrefix, attr.getValue());
+ }
+ }
+ }
+ }
+ } while ((node = node.getParentNode()) != null);
+
+ return nsDecls;
+ }
+
+ /**
+ * Add all namespace declarations declared in the parent(s) of a given
+ * element and used in the subtree of the given element to the given element.
+ *
+ * @param context The element to which to add the namespaces.
+ */
+ public static void localizeNamespaceDeclarations(Element context) {
+ Node parent = context.getParentNode();
+
+ if (parent != null) {
+ Map namespaces = getNamespaceDeclarations(context.getParentNode());
+ Set nsUris = collectNamespaceURIs(context);
+ Iterator iter;
+
+ for (iter = namespaces.entrySet().iterator(); iter.hasNext();) {
+ Map.Entry e = (Map.Entry) iter.next();
+
+ if (nsUris.contains(e.getValue())) {
+ String prefix = (String) e.getKey();
+ String nsUri = (String) e.getValue();
+ String nsAttrName = "".equals(prefix) ? "xmlns" : "xmlns:" + prefix;
+
+ context.setAttributeNS(Constants.XMLNS_NS_URI, nsAttrName, nsUri);
+ }
+ }
+ }
+ }
+
+ /**
+ * Collect all the namespace URIs used in the subtree of a given element.
+ *
+ * @param context The element that should be searched for namespace URIs.
+ * @return All namespace URIs used in the subtree of context,
+ * including the ones used in context itself.
+ */
+ public static Set collectNamespaceURIs(Element context) {
+ Set result = new HashSet();
+
+ collectNamespaceURIsImpl(context, result);
+ return result;
+ }
+
+ /**
+ * A recursive method to do the work of collectNamespaceURIs.
+ *
+ * @param context The context element to evaluate.
+ * @param result The result, passed as a parameter to avoid unnecessary
+ * instantiations of Set.
+ */
+ private static void collectNamespaceURIsImpl(Element context, Set result) {
+ NamedNodeMap attrs = context.getAttributes();
+ NodeList childNodes = context.getChildNodes();
+ String nsUri;
+ int i;
+
+ // add the namespace of the context element
+ nsUri = context.getNamespaceURI();
+ if (nsUri != null && nsUri != Constants.XMLNS_NS_URI) {
+ result.add(nsUri);
+ }
+
+ // add all namespace URIs from attributes
+ for (i = 0; i < attrs.getLength(); i++) {
+ nsUri = attrs.item(i).getNamespaceURI();
+ if (nsUri != null && nsUri != Constants.XMLNS_NS_URI) {
+ result.add(nsUri);
+ }
+ }
+
+ // add all namespaces from subelements
+ for (i = 0; i < childNodes.getLength(); i++) {
+ Node node = childNodes.item(i);
+
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ collectNamespaceURIsImpl((Element) node, result);
+ }
+ }
+ }
+
+ /**
+ * Check, that each attribute node in the given NodeList has its
+ * parent in the NodeList as well.
+ *
+ * @param nodes The NodeList to check.
+ * @return true, if each attribute node in nodes
+ * has its parent in nodes as well.
+ */
+ public static boolean checkAttributeParentsInNodeList(NodeList nodes) {
+ Set nodeSet = new HashSet();
+ int i;
+
+ // put the nodes into the nodeSet
+ for (i = 0; i < nodes.getLength(); i++) {
+ nodeSet.add(nodes.item(i));
+ }
+
+ // check that each attribute node's parent is in the node list
+ for (i = 0; i < nodes.getLength(); i++) {
+ Node n = nodes.item(i);
+
+ if (n.getNodeType() == Node.ATTRIBUTE_NODE) {
+ Attr attr = (Attr) n;
+ Element owner = attr.getOwnerElement();
+
+ if (owner == null) {
+ if (!isNamespaceDeclaration(attr)) {
+ return false;
+ }
+ }
+
+ if (!nodeSet.contains(owner) && !isNamespaceDeclaration(attr)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Convert an unstructured NodeList into a
+ * DocumentFragment.
+ *
+ * @param nodeList Contains the node list to be converted into a DOM
+ * DocumentFragment.
+ * @return the resulting DocumentFragment. The DocumentFragment will be
+ * backed by a new DOM Document, i.e. all noded of the node list will be
+ * cloned.
+ * @throws ParserConfigurationException An error occurred creating the
+ * DocumentFragment.
+ * @precondition The nodes in the node list appear in document order
+ * @precondition for each Attr node in the node list, the owning Element is
+ * in the node list as well.
+ * @precondition each Element or Attr node in the node list is namespace
+ * aware.
+ */
+ public static DocumentFragment nodeList2DocumentFragment(NodeList nodeList)
+ throws ParserConfigurationException {
+
+ DocumentBuilder builder =
+ DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = builder.newDocument();
+ DocumentFragment result = doc.createDocumentFragment();
+
+ if (null == nodeList || nodeList.getLength() == 0) {
+ return result;
+ }
+
+ int currPos = 0;
+ currPos =
+ nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
+
+ while (currPos < nodeList.getLength()) {
+ currPos =
+ nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
+ }
+ return result;
+ }
+
+ /**
+ * Helper method for the nodeList2DocumentFragment.
+ *
+ * @param nodeList The NodeList to convert.
+ * @param currPos The current position in the nodeList.
+ * @param result The resulting DocumentFragment.
+ * @param currOrgElem The current original element.
+ * @param currClonedElem The current cloned element.
+ * @return The current position.
+ */
+ private static int nodeList2DocumentFragment(
+ NodeList nodeList,
+ int currPos,
+ DocumentFragment result,
+ Element currOrgElem,
+ Element currClonedElem) {
+
+ while (currPos < nodeList.getLength()) {
+ Node currentNode = nodeList.item(currPos);
+ switch (currentNode.getNodeType()) {
+ case Node.COMMENT_NODE :
+ case Node.PROCESSING_INSTRUCTION_NODE :
+ case Node.TEXT_NODE :
+ {
+ // Append current node either to resulting DocumentFragment or to
+ // current cloned Element
+ if (null == currClonedElem) {
+ result.appendChild(
+ result.getOwnerDocument().importNode(currentNode, false));
+ } else {
+ // Stop processing if current Node is not a descendant of
+ // current Element
+ if (!isAncestor(currOrgElem, currentNode)) {
+ return --currPos;
+ }
+
+ currClonedElem.appendChild(
+ result.getOwnerDocument().importNode(currentNode, false));
+ }
+ break;
+ }
+
+ case Node.ELEMENT_NODE :
+ {
+ Element nextCurrOrgElem = (Element) currentNode;
+ Element nextCurrClonedElem =
+ result.getOwnerDocument().createElementNS(
+ nextCurrOrgElem.getNamespaceURI(),
+ nextCurrOrgElem.getNodeName());
+
+ // Append current Node either to resulting DocumentFragment or to
+ // current cloned Element
+ if (null == currClonedElem) {
+ result.appendChild(nextCurrClonedElem);
+ currOrgElem = nextCurrOrgElem;
+ currClonedElem = nextCurrClonedElem;
+ } else {
+ // Stop processing if current Node is not a descendant of
+ // current Element
+ if (!isAncestor(currOrgElem, currentNode)) {
+ return --currPos;
+ }
+
+ currClonedElem.appendChild(nextCurrClonedElem);
+ }
+
+ // Process current Node (of type Element) recursively
+ currPos =
+ nodeList2DocumentFragment(
+ nodeList,
+ ++currPos,
+ result,
+ nextCurrOrgElem,
+ nextCurrClonedElem);
+
+ break;
+ }
+
+ case Node.ATTRIBUTE_NODE :
+ {
+ Attr currAttr = (Attr) currentNode;
+
+ // GK 20030411: Hack to overcome problems with IAIK IXSIL
+ if (currAttr.getOwnerElement() == null)
+ break;
+ if (currClonedElem == null)
+ break;
+
+ // currClonedElem must be the owner Element of currAttr if
+ // preconditions are met
+ currClonedElem.setAttributeNS(
+ currAttr.getNamespaceURI(),
+ currAttr.getNodeName(),
+ currAttr.getValue());
+ break;
+ }
+
+ default :
+ {
+ // All other nodes will be ignored
+ }
+ }
+
+ currPos++;
+ }
+
+ return currPos;
+ }
+
+ /**
+ * Check, if the given attribute is a namespace declaration.
+ *
+ * @param attr The attribute to check.
+ * @return true, if the attribute is a namespace declaration,
+ * false otherwise.
+ */
+ private static boolean isNamespaceDeclaration(Attr attr) {
+ return Constants.XMLNS_NS_URI.equals(attr.getNamespaceURI());
+ }
+
+ /**
+ * Check, if a given DOM element is an ancestor of a given node.
+ *
+ * @param candAnc The DOM element to check for being the ancestor.
+ * @param cand The node to check for being the child.
+ * @return true, if candAnc is an (indirect)
+ * ancestor of cand; false otherwise.
+ */
+ public static boolean isAncestor(Element candAnc, Node cand) {
+ Node currPar = cand.getParentNode();
+
+ while (currPar != null) {
+ if (candAnc == currPar)
+ return true;
+ currPar = currPar.getParentNode();
+ }
+ return false;
+ }
+
+ /**
+ * Selects the (first) element from a node list and returns it.
+ *
+ * @param nl The NodeList to get the element from.
+ * @return The (first) element included in the node list or null
+ * if the node list is null or empty or no element is
+ * included in the list.
+ */
+ public static Element getElementFromNodeList (NodeList nl) {
+ if ((nl == null) || (nl.getLength() == 0)) {
+ return null;
+ }
+ for (int i=0; idateTime,
+ * according to ISO 8601.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ * @see http://www.w3.org/2001/XMLSchema-datatypes"
+ */
+public class DateTimeUtils {
+ /** Error messages. */
+ private static MessageProvider msg = MessageProvider.getInstance();
+
+ /**
+ * Builds a dateTime value from a Calendar value.
+ * @param cal the Calendar value
+ * @return the dateTime value
+ */
+ public static String buildDateTime(Calendar cal) {
+ StringWriter out = new StringWriter();
+ out.write("" + cal.get(Calendar.YEAR));
+ out.write("-");
+ out.write(to2DigitString(cal.get(Calendar.MONTH) + 1));
+ out.write("-");
+ out.write(to2DigitString(cal.get(Calendar.DAY_OF_MONTH)));
+ out.write("T");
+ out.write(to2DigitString(cal.get(Calendar.HOUR_OF_DAY)));
+ out.write(":");
+ out.write(to2DigitString(cal.get(Calendar.MINUTE)));
+ out.write(":");
+ out.write(to2DigitString(cal.get(Calendar.SECOND)));
+ int tzOffsetMilliseconds =
+ cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
+ if (tzOffsetMilliseconds != 0) {
+ int tzOffsetMinutes = tzOffsetMilliseconds / (1000 * 60);
+ int tzOffsetHours = tzOffsetMinutes / 60;
+ tzOffsetMinutes -= tzOffsetHours * 60;
+ if (tzOffsetMilliseconds > 0) {
+ out.write("+");
+ out.write(to2DigitString(tzOffsetHours));
+ out.write(":");
+ out.write(to2DigitString(tzOffsetMinutes));
+ } else {
+ out.write("-");
+ out.write(to2DigitString(-tzOffsetHours));
+ out.write(":");
+ out.write(to2DigitString(-tzOffsetMinutes));
+ }
+ }
+ return out.toString();
+ }
+
+ /**
+ * Converts month, day, hour, minute, or second value
+ * to a 2 digit String.
+ * @param number the month, day, hour, minute, or second value
+ * @return 2 digit String
+ */
+ private static String to2DigitString(int number) {
+ if (number < 10)
+ return "0" + number;
+ else
+ return "" + number;
+ }
+
+ /**
+ * Parse a String containing a date and time instant, given in
+ * ISO 8601 format.
+ *
+ * @param dateTime The String to parse.
+ * @return The Date representation of the contents of
+ * dateTime.
+ * @throws ParseException Parsing the dateTime failed.
+ */
+ public static Date parseDateTime(String dateTime) throws ParseException {
+ GregorianCalendar calendar;
+ long time;
+ int yearSign = 1, year, month, day;
+ int hour, minute, second;
+ double fraction = 0.0;
+ int tzSign = 1, tzHour = 0, tzMinute = 0;
+ int curPos = 0;
+ String fractStr;
+ boolean localTime = false;
+ char c;
+
+ // parse year sign
+ ensureChars(dateTime, curPos, 1);
+ c = dateTime.charAt(curPos);
+ if (c == '+' || c == '-') {
+ yearSign = c == '+' ? 1 : -1;
+ curPos++;
+ }
+
+ // parse year
+ year = parseInt(dateTime, curPos, 4);
+ curPos += 4;
+
+ // parse '-'
+ ensureChar(dateTime, curPos, '-');
+ curPos++;
+
+ // parse month
+ month = parseInt(dateTime, curPos, 2);
+ ensureValue(month, 1, 12, curPos);
+ curPos += 2;
+
+ // parse '-'
+ ensureChar(dateTime, curPos, '-');
+ curPos++;
+
+ // parse day
+ day = parseInt(dateTime, curPos, 2);
+ ensureValue(day, 1, 31, curPos);
+ curPos += 2;
+
+ // parse 'T'
+ ensureChar(dateTime, curPos, 'T');
+ curPos++;
+
+ // parse hour
+ hour = parseInt(dateTime, curPos, 2);
+ ensureValue(hour, 0, 23, curPos);
+ curPos += 2;
+
+ // parse ':'
+ ensureChar(dateTime, curPos, ':');
+ curPos++;
+
+ // parse minute
+ minute = parseInt(dateTime, curPos, 2);
+ ensureValue(minute, 0, 59, curPos);
+ curPos += 2;
+
+ // parse ':'
+ ensureChar(dateTime, curPos, ':');
+ curPos++;
+
+ // parse second
+ second = parseInt(dateTime, curPos, 2);
+ ensureValue(second, 0, 59, curPos);
+ curPos += 2;
+
+ // parse a fraction
+ if (dateTime.length() > curPos && dateTime.charAt(curPos) == '.') {
+ curPos++;
+ ensureDigits(dateTime, curPos, 1);
+ fractStr = "0.";
+ fractStr
+ += dateTime.substring(curPos, curPos + countDigits(dateTime, curPos));
+ fraction = Double.parseDouble(fractStr);
+ curPos += countDigits(dateTime, curPos);
+ }
+
+ // parse a time zone
+ if (dateTime.length() > curPos) {
+ c = dateTime.charAt(curPos);
+ if (c == 'Z') {
+ curPos++;
+ } else if (c == '+' || c == '-') {
+ // parse time zone sign
+ tzSign = c == '+' ? 1 : -1;
+ curPos++;
+
+ // parse time zone hour
+ tzHour = parseInt(dateTime, curPos, 2);
+ ensureValue(tzHour, 0, 14, curPos);
+ curPos += 2;
+
+ // parse ':'
+ ensureChar(dateTime, curPos, ':');
+ curPos++;
+
+ // parse time zone minute
+ tzMinute = parseInt(dateTime, curPos, 2);
+ ensureValue(tzMinute, 0, 59, curPos);
+ curPos += 2;
+ }
+ } else {
+ localTime = true;
+ }
+
+ // if we have characters left, it's an error
+ if (dateTime.length() != curPos) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+
+ // build the Date object
+ year = year * yearSign;
+ try {
+ calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+ calendar.set(year, month - 1, day, hour, minute, second);
+ calendar.set(Calendar.MILLISECOND, 0);
+ time = calendar.getTime().getTime();
+ time += (long) (fraction * 1000.0);
+ time -= tzSign * ((tzHour * 60) + tzMinute) * 60 * 1000;
+ if (localTime) {
+ time -= TimeZone.getDefault().getRawOffset();
+ }
+ return new Date(time);
+ } catch (IllegalArgumentException e) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+
+ }
+
+ /**
+ * Parse an integer value.
+ *
+ * @param str The String containing the digits.
+ * @param curPos The starting position.
+ * @param digits The number of digist making up the integer value.
+ * @return int The integer representation of the digits contained in
+ * str.
+ * @throws ParseException Parsing the integer value failed.
+ */
+ private static int parseInt(String str, int curPos, int digits)
+ throws ParseException {
+
+ ensureDigits(str, curPos, digits);
+ return Integer.parseInt(str.substring(curPos, curPos + digits));
+ }
+
+ /**
+ * Count the number of digits following curPos.
+ *
+ * @param str The String in which to count digits.
+ * @param curPos The starting position.
+ * @return int The number of digits.
+ */
+ private static int countDigits(String str, int curPos) {
+ int i;
+
+ for (i = curPos; i < str.length() && Character.isDigit(str.charAt(i)); i++);
+ return i - curPos;
+ }
+
+ /**
+ * Ensure that a value falls in a given min/max range.
+ *
+ * @param value The value to check.
+ * @param min The minimum allowed value.
+ * @param max The maximum allowed value.
+ * @param curPos To indicate the parsing position in the
+ * ParseException.
+ * @throws ParseException Thrown, if value < min || value >
+ * max
+ */
+ private static void ensureValue(int value, int min, int max, int curPos)
+ throws ParseException {
+
+ if (value < min || value > max) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+ }
+
+ /**
+ * Ensure that the given String has a number of characters left.
+ *
+ * @param str The String to check for its length.
+ * @param curPos The starting position.
+ * @param count The minimum number of characters that str must
+ * contain, starting at from curPos.
+ * @throws ParseException Thrown, if
+ * curPos + count > str.length().
+ */
+ private static void ensureChars(String str, int curPos, int count)
+ throws ParseException {
+ if (curPos + count > str.length()) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+ }
+
+ /**
+ * Ensure that a given String contains a certain character at a
+ * certain position.
+ *
+ * @param str The String in which to look up the character.
+ * @param curPos The position in str that must contain the
+ * character.
+ * @param c The character value that must be contained at position
+ * curPos.
+ * @throws ParseException Thrown, if the characters do not match or
+ * curPos is out of range.
+ */
+ private static void ensureChar(String str, int curPos, char c)
+ throws ParseException {
+
+ ensureChars(str, curPos, 1);
+ if (str.charAt(curPos) != c) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+ }
+
+ /**
+ * Ensure that a given String contains a number of digits,
+ * starting at a given position.
+ *
+ * @param str The String to scan for digits.
+ * @param curPos The starting postion.
+ * @param count The number of digits that must be contained in
+ * str, starting at curPos.
+ * @throws ParseException Thrown, if str is not long enough, or
+ * one of the characters following curPos in str is
+ * not a digit.
+ */
+ private static void ensureDigits(String str, int curPos, int count)
+ throws ParseException {
+
+ ensureChars(str, curPos, count);
+ for (int i = curPos; i < curPos + count; i++) {
+ if (!Character.isDigit(str.charAt(i))) {
+ throw new ParseException(msg.getMessage("datetime.00", null), curPos);
+ }
+ }
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/EntityResolverChain.java b/common/src/main/java/at/gv/egovernment/moa/util/EntityResolverChain.java
new file mode 100644
index 000000000..e7008a701
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/EntityResolverChain.java
@@ -0,0 +1,52 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Implementation of the org.xml.sax.EntityResolver,
+ * for use by a org.apache.xerces.parsers.DOMParser.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class EntityResolverChain implements EntityResolver {
+ /** The EntityResolvers in the chain. */
+ private List resolvers = new ArrayList();
+
+ /**
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+
+ Iterator iter;
+
+ for (iter = resolvers.iterator(); iter.hasNext(); ) {
+ EntityResolver resolver = (EntityResolver) iter.next();
+ InputSource is = resolver.resolveEntity(publicId, systemId);
+
+ if (is != null) {
+ return is;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Add an EntityResolver to the chain.
+ *
+ * @param entityResolver The EntityResolver to add.
+ */
+ public void addEntityResolver(EntityResolver entityResolver) {
+ resolvers.add(entityResolver);
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/FileUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/FileUtils.java
new file mode 100644
index 000000000..a5e777c2d
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/FileUtils.java
@@ -0,0 +1,116 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Utility for accessing files on the file system, and for reading from input streams.
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class FileUtils {
+
+ /**
+ * Reads a file, given by URL, into a byte array.
+ * @param urlString file URL
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static byte[] readURL(String urlString) throws IOException {
+ URL url = new URL(urlString);
+ InputStream in = new BufferedInputStream(url.openStream());
+ byte[] content = StreamUtils.readStream(in);
+ in.close();
+ return content;
+ }
+ /**
+ * Reads a file, given by URL, into a String.
+ * @param urlString file URL
+ * @param encoding character encoding
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static String readURL(String urlString, String encoding) throws IOException {
+ byte[] content = readURL(urlString);
+ return new String(content, encoding);
+ }
+ /**
+ * Reads a file, given by filename, into a byte array.
+ * @param filename filename
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static byte[] readFile(String filename) throws IOException {
+ BufferedInputStream in = new BufferedInputStream(new FileInputStream(filename));
+ byte[] content = StreamUtils.readStream(in);
+ in.close();
+ return content;
+ }
+ /**
+ * Reads a file, given by filename, into a String.
+ * @param filename filename
+ * @param encoding character encoding
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static String readFile(String filename, String encoding) throws IOException {
+ byte[] content = readFile(filename);
+ return new String(content, encoding);
+ }
+ /**
+ * Reads a file from a resource.
+ * @param name resource name
+ * @return file content as a byte array
+ * @throws IOException on any exception thrown
+ */
+ public static byte[] readResource(String name) throws IOException {
+ ClassLoader cl = FileUtils.class.getClassLoader();
+ BufferedInputStream in = new BufferedInputStream(cl.getResourceAsStream(name));
+ byte[] content = StreamUtils.readStream(in);
+ in.close();
+ return content;
+ }
+ /**
+ * Reads a file from a resource.
+ * @param name filename
+ * @param encoding character encoding
+ * @return file content
+ * @throws IOException on any exception thrown
+ */
+ public static String readResource(String name, String encoding) throws IOException {
+ byte[] content = readResource(name);
+ return new String(content, encoding);
+ }
+
+ /**
+ * Returns the absolute URL of a given url which is relative to the parameter root
+ * @param url
+ * @param root
+ * @return String
+ */
+ public static String makeAbsoluteURL(String url, String root) {
+ //if url is relative to rootConfigFileDirName make it absolute
+
+ File keyFile;
+ String newURL = url;
+
+ if(null == url) return null;
+
+ if (url.startsWith("http:/") || url.startsWith("https:/") || url.startsWith("file:/") || url.startsWith("ftp:/")) {
+ return url;
+ } else {
+ // check if absolute - if not make it absolute
+ keyFile = new File(url);
+ if (!keyFile.isAbsolute()) {
+ keyFile = new File(root, url);
+ newURL = keyFile.getPath();
+ }
+ return newURL;
+ }
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java
new file mode 100644
index 000000000..d6a34a7b2
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/KeyStoreUtils.java
@@ -0,0 +1,134 @@
+package at.gv.egovernment.moa.util;
+
+import iaik.x509.X509Certificate;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+
+/**
+ * Utility for creating and loading key stores.
+ *
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class KeyStoreUtils {
+
+ /**
+ * Loads a key store from file.
+ *
+ * @param keystoreType key store type
+ * @param urlString URL of key store
+ * @param password password protecting the key store
+ * @return key store loaded
+ * @throws IOException thrown while reading the key store from file
+ * @throws GeneralSecurityException thrown while creating the key store
+ */
+ public static KeyStore loadKeyStore(
+ String keystoreType,
+ String urlString,
+ String password)
+ throws IOException, GeneralSecurityException {
+
+ URL keystoreURL = new URL(urlString);
+ InputStream in = keystoreURL.openStream();
+ return loadKeyStore(keystoreType, in, password);
+ }
+ /**
+ * Loads a key store from an InputStream, and
+ * closes the InputStream.
+ *
+ * @param keystoreType key store type
+ * @param in input stream
+ * @param password password protecting the key store
+ * @return key store loaded
+ * @throws IOException thrown while reading the key store from the stream
+ * @throws GeneralSecurityException thrown while creating the key store
+ */
+ public static KeyStore loadKeyStore(
+ String keystoreType,
+ InputStream in,
+ String password)
+ throws IOException, GeneralSecurityException {
+
+ char[] chPassword = null;
+ if (password != null)
+ chPassword = password.toCharArray();
+ KeyStore ks = KeyStore.getInstance(keystoreType);
+ ks.load(in, chPassword);
+ in.close();
+ return ks;
+ }
+ /**
+ * Creates a key store from X509 certificate files, aliasing them with
+ * the index in the String[], starting with "0".
+ *
+ * @param keyStoreType key store type
+ * @param certFilenames certificate filenames
+ * @return key store created
+ * @throws IOException thrown while reading the certificates from file
+ * @throws GeneralSecurityException thrown while creating the key store
+ */
+ public static KeyStore createKeyStore(
+ String keyStoreType,
+ String[] certFilenames)
+ throws IOException, GeneralSecurityException {
+
+ KeyStore ks = KeyStore.getInstance(keyStoreType);
+ ks.load(null, null);
+ for (int i = 0; i < certFilenames.length; i++) {
+ Certificate cert = loadCertificate(certFilenames[i]);
+ ks.setCertificateEntry("" + i, cert);
+ }
+ return ks;
+ }
+ /**
+ * Creates a key store from a directory containg X509 certificate files,
+ * aliasing them with the index in the String[], starting with "0".
+ * All the files in the directory are considered to be certificates.
+ *
+ * @param keyStoreType key store type
+ * @param certDirURLString file URL of directory containing certificate filenames
+ * @return key store created
+ * @throws IOException thrown while reading the certificates from file
+ * @throws GeneralSecurityException thrown while creating the key store
+ */
+ public static KeyStore createKeyStoreFromCertificateDirectory(
+ String keyStoreType,
+ String certDirURLString)
+ throws IOException, GeneralSecurityException {
+
+ URL certDirURL = new URL(certDirURLString);
+ String certDirname = certDirURL.getFile();
+ File certDir = new File(certDirname);
+ String[] certFilenames = certDir.list();
+ String separator =
+ (certDirname.endsWith(File.separator) ? "" : File.separator);
+ for (int i = 0; i < certFilenames.length; i++) {
+ certFilenames[i] = certDirname + separator + certFilenames[i];
+ }
+ return createKeyStore(keyStoreType, certFilenames);
+ }
+
+ /**
+ * Loads an X509 certificate from file.
+ * @param certFilename filename
+ * @return the certificate loaded
+ * @throws IOException thrown while reading the certificate from file
+ * @throws GeneralSecurityException thrown while creating the certificate
+ */
+ private static Certificate loadCertificate(String certFilename)
+ throws IOException, GeneralSecurityException {
+
+ FileInputStream in = new FileInputStream(certFilename);
+ Certificate cert = new X509Certificate(in);
+ in.close();
+ return cert;
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/MOADefaultHandler.java b/common/src/main/java/at/gv/egovernment/moa/util/MOADefaultHandler.java
new file mode 100644
index 000000000..0474d92cd
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/MOADefaultHandler.java
@@ -0,0 +1,82 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.IOException;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A DefaultHandler that uses a MOAEntityResolver and
+ * a MOAErrorHandler.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class MOADefaultHandler extends DefaultHandler {
+ /** The EntityResolver to use. */
+ private EntityResolver entityResolver;
+ /** The ErrorHandler to use. */
+ private ErrorHandler errorHandler;
+
+ /**
+ * Create a new MOADefaultHandler.
+ */
+ public MOADefaultHandler() {
+ entityResolver = new MOAEntityResolver();
+ errorHandler = new MOAErrorHandler();
+ }
+
+ /**
+ * Create a new MOADefaultHandler.
+ *
+ * @param entityResolver The EntityResolver to use for resolving
+ * external entities.
+ * @param errorHandler The ErrorHandler to use for reporting
+ * parsing errors.
+ */
+ public MOADefaultHandler(
+ EntityResolver entityResolver,
+ ErrorHandler errorHandler) {
+
+ this.entityResolver = entityResolver;
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException {
+ try {
+ return entityResolver.resolveEntity(publicId, systemId);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ /**
+ * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
+ */
+ public void warning(SAXParseException exception) throws SAXException {
+ errorHandler.warning(exception);
+ }
+
+ /**
+ * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
+ */
+ public void error(SAXParseException exception) throws SAXException {
+ errorHandler.error(exception);
+ }
+
+ /**
+ * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
+ */
+ public void fatalError(SAXParseException exception) throws SAXException {
+ errorHandler.fatalError(exception);
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/MOAEntityResolver.java b/common/src/main/java/at/gv/egovernment/moa/util/MOAEntityResolver.java
new file mode 100644
index 000000000..9406612e2
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/MOAEntityResolver.java
@@ -0,0 +1,103 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.InputStream;
+
+import org.apache.xerces.util.URI;
+import org.apache.xerces.util.URI.MalformedURIException;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+import at.gv.egovernment.moa.logging.LogMsg;
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * An EntityResolver that looks up entities stored as
+ * local resources.
+ *
+ *
The following DTDs are mapped to local resources:
+ *
+ *
The XMLSchema.dtd
+ *
The datatypes.dtd
+ *
+ *
+ *
For all other resources, an attempt is made to resolve them as resources,
+ * either absolute or relative to Constants.SCHEMA_ROOT.
+ *
+ * @author Patrick Peck
+ * @author Sven Aigner
+ */
+public class MOAEntityResolver implements EntityResolver {
+
+ /**
+ * Resolve an entity.
+ *
+ * The systemId parameter is used to perform the lookup of the
+ * entity as a resource, either by interpreting the systemId as
+ * an absolute resource path, or by appending the last path component of
+ * systemId to Constants.SCHEMA_ROOT.
+ *
+ * @param publicId The public ID of the resource.
+ * @param systemId The system ID of the resource.
+ * @return An InputSource from which the entity can be read, or
+ * null, if the entity could not be found.
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId) {
+ InputStream stream;
+ int slashPos;
+
+ if (Logger.isDebugEnabled()) {
+ Logger.debug(
+ new LogMsg("resolveEntity: p=" + publicId + " s=" + systemId));
+ }
+
+ if (publicId != null) {
+ // check if we can resolve some standard dtd's
+ if (publicId.equalsIgnoreCase("-//W3C//DTD XMLSchema 200102//EN")) {
+ return new InputSource(
+ getClass().getResourceAsStream(
+ Constants.SCHEMA_ROOT + "XMLSchema.dtd"));
+ } else if (publicId.equalsIgnoreCase("datatypes")) {
+ return new InputSource(
+ getClass().getResourceAsStream(
+ Constants.SCHEMA_ROOT + "datatypes.dtd"));
+ }
+ } else if (systemId != null) {
+ // get the URI path
+ try {
+ URI uri = new URI(systemId);
+ systemId = uri.getPath();
+ if (!"file".equals(uri.getScheme()) || "".equals(systemId.trim())) {
+ return null;
+ }
+ } catch (MalformedURIException e) {
+ return null;
+ }
+
+ // try to get the resource from the full path
+ stream = getClass().getResourceAsStream(systemId);
+ if (stream != null) {
+ InputSource source = new InputSource(stream);
+
+ source.setSystemId(systemId);
+ return source;
+ }
+
+ // try to get the resource from the last path component
+ slashPos = systemId.lastIndexOf('/');
+ if (slashPos >= 0 && systemId.length() > slashPos) {
+ systemId = systemId.substring(slashPos + 1, systemId.length());
+ stream =
+ getClass().getResourceAsStream(Constants.SCHEMA_ROOT + systemId);
+ if (stream != null) {
+ InputSource source = new InputSource(stream);
+
+ source.setSystemId(systemId);
+ return source;
+ }
+ }
+ }
+
+ return null; // nothing found - let the parser handle the entity
+ }
+}
\ No newline at end of file
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/MOAErrorHandler.java b/common/src/main/java/at/gv/egovernment/moa/util/MOAErrorHandler.java
new file mode 100644
index 000000000..1f7757c8f
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/MOAErrorHandler.java
@@ -0,0 +1,85 @@
+package at.gv.egovernment.moa.util;
+
+import org.apache.xml.utils.DefaultErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import at.gv.egovernment.moa.logging.LogMsg;
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * An ErrorHandler that logs a message and throws a
+ * SAXException upon error and fatal
+ * parsing errors.
+ *
+ * @author Patrick Peck
+ * @author Sven Aigner
+ */
+public class MOAErrorHandler extends DefaultErrorHandler {
+
+ /**
+ * Logs a warning message.
+ *
+ * @see org.xml.sax.ErrorHandler#warning(SAXParseException)
+ */
+ public void warning(SAXParseException exception) throws SAXException {
+ warn("parser.00", messageParams(exception), null);
+ }
+
+ /**
+ * Logs a warning and rethrows the exception.
+ *
+ * @see org.xml.sax.ErrorHandler#error(SAXParseException)
+ */
+ public void error(SAXParseException exception) throws SAXException {
+ warn("parser.01", messageParams(exception), null);
+ throw exception;
+ }
+
+ /**
+ * Logs a warning and rethrows the exception.
+ *
+ * @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
+ */
+ public void fatalError(SAXParseException exception) throws SAXException {
+ warn("parser.02", messageParams(exception), null);
+ throw exception;
+ }
+
+ /**
+ * Log a warning message.
+ *
+ * @param messageId The message ID to log.
+ * @param parameters Additional message parameters.
+ * @param t The Throwable to log; usually the cause of this
+ * warning.
+ */
+ private static void warn(
+ String messageId,
+ Object[] parameters,
+ Throwable t) {
+
+ MessageProvider msg = MessageProvider.getInstance();
+ Logger.warn(new LogMsg(msg.getMessage(messageId, parameters)), t);
+ }
+
+ /**
+ * Put the system id, line and column number information from the exception
+ * into an Object array, to provide it as a
+ * MessageFormat parameter.
+ *
+ * @param e The SAXParseException containing the
+ * source system id and line/column numbers.
+ * @return An array containing the system id (a String) as well
+ * as line/column numbers (2 Integer objects) from the
+ * SAXParseException.
+ */
+ private static Object[] messageParams(SAXParseException e) {
+ return new Object[] {
+ e.getMessage(),
+ e.getSystemId(),
+ new Integer(e.getLineNumber()),
+ new Integer(e.getColumnNumber())};
+ }
+
+}
\ No newline at end of file
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/MOATimer.java b/common/src/main/java/at/gv/egovernment/moa/util/MOATimer.java
new file mode 100644
index 000000000..d8bf64fc3
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/MOATimer.java
@@ -0,0 +1,110 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * A timer utility for named timers.
+ *
+ * @author Sven Aigner
+ */
+public class MOATimer {
+
+ /** The single instance of this class. */
+ private static MOATimer instance = null;
+ /** The starting points of single timings. */
+ private static Map timemapstart = new WeakHashMap();
+ /** The end points of single timings. */
+ private static Map timemapend = new WeakHashMap();
+
+ /**
+ * Return the single instance of this class.
+ *
+ * @return The single instance of this class.
+ */
+ public static MOATimer getInstance() {
+ if (instance == null) {
+ instance = new MOATimer();
+ }
+ return instance;
+ }
+
+ /**
+ * Create a new MOATimer.
+ *
+ * Protected to disallow multiple instances.
+ */
+ protected MOATimer() {
+ super();
+ }
+
+ /**
+ * Start timing a certain action.
+ *
+ * The timing belonging to the action ID is garbage collected as soon as there
+ * exists no other reference to the action ID.
+ *
+ * @param id The action ID.
+ */
+ public void startTiming(Object id) {
+ timemapstart.put(id, new Long(System.currentTimeMillis()));
+ }
+
+ /**
+ * Stop timing an action.
+ *
+ * @param id The action ID.
+ */
+ public void stopTiming(Object id) {
+ timemapend.put(id, new Long(System.currentTimeMillis()));
+ }
+
+ /**
+ * Get the duration of an action.
+ *
+ * @param id The action ID for which to compute the duration.
+ * @return long The duration in milliseconds between calls to
+ * startTiming() and stopTiming(). If
+ * only startTiming() has been called for the action, then
+ * current difference to the system time is returned. If no timing exists for
+ * the action, - 1 is returned.
+ */
+ public long duration(Object id) {
+ if (timemapstart.containsKey(id)) {
+ long start = ((Long) timemapstart.get(id)).longValue();
+ if (timemapend.containsKey(id)) {
+ long end = ((Long) timemapend.get(id)).longValue();
+ return end - start;
+ } else {
+ return System.currentTimeMillis() - start;
+ }
+ } else
+ return -1;
+ }
+
+ /**
+ * Get the duration of an action, as a nicely formatted String.
+ *
+ * @param id The action ID.
+ * @return String The duration() as a String.
+ */
+ public String durationAsString(Object id) {
+ long dur = duration(id);
+ long second = dur / 1000;
+ long mil = (dur) - (second * 1000);
+ return "Duration: " + second + "." + mil + " seconds";
+ }
+
+ /**
+ * Remove a timing.
+ *
+ * @param id The action ID.
+ */
+ public void clearTiming(String id) {
+ if (timemapstart.containsKey(id))
+ timemapstart.remove(id);
+ if (timemapend.containsKey(id))
+ timemapend.remove(id);
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/MessageProvider.java b/common/src/main/java/at/gv/egovernment/moa/util/MessageProvider.java
new file mode 100644
index 000000000..f5117e390
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/MessageProvider.java
@@ -0,0 +1,63 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.Locale;
+
+/**
+ * A singleton wrapper around a Message object.
+ *
+ * Provides the messages used in the common project.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class MessageProvider {
+ /** The location of the default message resources. */
+ private static final String[] DEFAULT_MESSAGE_RESOURCES =
+ { "resources/properties/common_messages" };
+ /** The locale of the default message resources. */
+ private static final Locale[] DEFAULT_MESSAGE_LOCALES =
+ new Locale[] { new Locale("de", "AT") };
+ /** The single instance of this class. */
+ private static MessageProvider instance;
+
+ /** The messages provided by this MessageProvider. */
+ private Messages messages;
+
+ /**
+ * Return the single instance of the MessageProvider.
+ *
+ * Intialilizes the MessageProvider with the default message
+ * locations: /resources/properties/common_messages.
+ *
+ * @return The single MessageProvider.
+ */
+ public static synchronized MessageProvider getInstance() {
+ if (instance == null) {
+ instance =
+ new MessageProvider(DEFAULT_MESSAGE_RESOURCES, DEFAULT_MESSAGE_LOCALES);
+ }
+ return instance;
+ }
+
+ /**
+ * Create a MessageProvider.
+ *
+ * @param resourceNames The names of the resources containing the messages.
+ * @param locales The corresponding locales.
+ */
+ protected MessageProvider(String[] resourceNames, Locale[] locales) {
+ this.messages = new Messages(resourceNames, locales);
+ }
+
+ /**
+ * Get the message corresponding to a given message ID.
+ *
+ * @param messageId The ID of the message.
+ * @param parameters The parameters to fill in into the message arguments.
+ * @return The formatted message.
+ */
+ public String getMessage(String messageId, Object[] parameters) {
+ return messages.getMessage(messageId, parameters);
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/Messages.java b/common/src/main/java/at/gv/egovernment/moa/util/Messages.java
new file mode 100644
index 000000000..a0139ae93
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/Messages.java
@@ -0,0 +1,117 @@
+package at.gv.egovernment.moa.util;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * Provides access to the system messages resource used for exception handling
+ * and logging messages.
+ *
+ * Messages must be provided as a resource bundle at the path.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class Messages {
+ /** Error message indicating that no messages are avaiable. */
+ private static final String ERROR_MESSAGES_UNAVAILABLE =
+ "Fehler in der Server-Konfiguration. "
+ + "Die Fehlertexte konnten nicht geladen werden.";
+ /** Error message indicating that the message is not available. */
+ private static final String ERROR_NO_MESSAGE =
+ "Keine Fehlermeldung für Fehler-Nr.={0}";
+
+ /** The names of the resources containing the messages. */
+ private String[] resourceNames;
+ /** The corresponding Locales of the resources. */
+ private Locale[] locales;
+ /** The ResourceBundles containing the messages. */
+ private ResourceBundleChain messages;
+
+ /**
+ * Create a new Message object containing the messages
+ * in the given resources.
+ *
+ * @param resourceNames The names of the resources containing the messages.
+ * @param locales The corresponding locales.
+ */
+ public Messages(String[] resourceNames, Locale[] locales) {
+ this.resourceNames = resourceNames;
+ this.locales = locales;
+ this.messages = null;
+ }
+
+ /**
+ * Get the message corresponding to a given message ID.
+ *
+ * @param messageId The ID of the message.
+ * @param parameters The parameters to fill in into the message arguments.
+ * @return The formatted message.
+ */
+ public String getMessage(String messageId, Object[] parameters) {
+ // initialize messages
+ if (messages == null) {
+ initMessages();
+ }
+
+ // create the message
+ if (messages == null) {
+ return ERROR_MESSAGES_UNAVAILABLE;
+ } else {
+ try {
+ String rawMessage = messages.getString(messageId);
+ return MessageFormat.format(rawMessage, parameters);
+ } catch (MissingResourceException e2) {
+ // couldn't find any message -> set to default error message
+ return MessageFormat.format(
+ ERROR_NO_MESSAGE,
+ new Object[] { messageId });
+ }
+ }
+ }
+
+ /**
+ * Return the names of the resources containing the messages.
+ *
+ * @return String[] The names of the resource bundles containing the messages.
+ */
+ private String[] getResourceNames() {
+ return resourceNames;
+ }
+
+ /**
+ * Return the Locales of the resources containing the messages.
+ *
+ * @return Locale[] The Locales of the resource bundles
+ * containing the messages.
+ */
+ private Locale[] getLocales() {
+ return locales;
+ }
+
+ /**
+ * Initialize the messagesResourceBundle containing
+ * the MOA error messages.
+ */
+ private void initMessages() {
+ messages = new ResourceBundleChain();
+ int i;
+
+ // initialize the message resources
+ for (i = 0; i < resourceNames.length; i++) {
+ try {
+ messages.addResourceBundle(
+ PropertyResourceBundle.getBundle(
+ getResourceNames()[i],
+ getLocales()[i]));
+ } catch (MissingResourceException e) {
+ Logger.error(ERROR_MESSAGES_UNAVAILABLE, e);
+ }
+ }
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/NodeIteratorAdapter.java b/common/src/main/java/at/gv/egovernment/moa/util/NodeIteratorAdapter.java
new file mode 100644
index 000000000..f71aa472d
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/NodeIteratorAdapter.java
@@ -0,0 +1,87 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.ListIterator;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Node;
+import org.w3c.dom.traversal.NodeFilter;
+import org.w3c.dom.traversal.NodeIterator;
+
+/**
+ * A NodeIterator implementation based on a
+ * ListIterator.
+ *
+ * @see java.util.ListIterator
+ * @see org.w3c.dom.traversal.NodeIterator
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class NodeIteratorAdapter implements NodeIterator {
+
+ /** The ListIterator to wrap. */
+ private ListIterator nodeIterator;
+
+ /**
+ * Create a new NodeIteratorAdapter.
+ * @param nodeIterator The ListIterator to iterate over.
+ */
+ public NodeIteratorAdapter(ListIterator nodeIterator) {
+ this.nodeIterator = nodeIterator;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#getRoot()
+ */
+ public Node getRoot() {
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#getWhatToShow()
+ */
+ public int getWhatToShow() {
+ return NodeFilter.SHOW_ALL;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#getFilter()
+ */
+ public NodeFilter getFilter() {
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#getExpandEntityReferences()
+ */
+ public boolean getExpandEntityReferences() {
+ return false;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#nextNode()
+ */
+ public Node nextNode() throws DOMException {
+ if (nodeIterator.hasNext()) {
+ return (Node) nodeIterator.next();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#previousNode()
+ */
+ public Node previousNode() throws DOMException {
+ if (nodeIterator.hasPrevious()) {
+ return (Node) nodeIterator.previous();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.w3c.dom.traversal.NodeIterator#detach()
+ */
+ public void detach() {
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/NodeListAdapter.java b/common/src/main/java/at/gv/egovernment/moa/util/NodeListAdapter.java
new file mode 100644
index 000000000..7102cadca
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/NodeListAdapter.java
@@ -0,0 +1,44 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.List;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A NodeList implementation based on a List.
+ *
+ * @see java.util.List
+ * @see org.w3c.dom.NodeList
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class NodeListAdapter implements NodeList {
+ /** The List to wrap. */
+ private List nodeList;
+
+ /**
+ * Create a new NodeListAdapter.
+ *
+ * @param nodeList The List containing the nodes.
+ */
+ public NodeListAdapter(List nodeList) {
+ this.nodeList = nodeList;
+ }
+
+ /**
+ * @see org.w3c.dom.NodeList#item(int)
+ */
+ public Node item(int index) {
+ return (Node) nodeList.get(index);
+ }
+
+ /**
+ * @see org.w3c.dom.NodeList#getLength()
+ */
+ public int getLength() {
+ return nodeList.size();
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/OutputXML2File.java b/common/src/main/java/at/gv/egovernment/moa/util/OutputXML2File.java
new file mode 100644
index 000000000..f9d330d41
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/OutputXML2File.java
@@ -0,0 +1,78 @@
+/*
+ * Created on 26.04.2004
+ *
+ * @author rschamberger
+ * $ID$
+ */
+package at.gv.egovernment.moa.util;
+
+import org.w3c.dom.Element;
+
+import at.gv.egovernment.moa.logging.Logger;
+
+/**
+ * utility functions to write XML data to files
+ * @author rschamberger
+ * @version $Id$
+ */
+public class OutputXML2File {
+
+ /**
+ * writes an XML structure to file if debug is enabled in hierarchy (Encoding: UTF-8)
+ *
+ * @param filename file name
+ * @param rootElem root element in DOM tree
+ * @param hierarchy of the Logger
+ */
+ public static void debugOutputXML2File(String filename, Element rootElem, String hierarchy) {
+ if (Logger.isDebugEnabled(hierarchy)) {
+ outputXML2File(filename, rootElem);
+ }
+ }
+
+ /**
+ * writes an XML structure to file if debug is enabled in hierarchy (Encoding: UTF-8)
+ *
+ * @param filename file name
+ * @param xmlString XML string
+ * @param hierarchy of the Logger
+ */
+ public static void debugOutputXML2File(String filename, String xmlString, String hierarchy) {
+ if (Logger.isDebugEnabled(hierarchy)) {
+ outputXML2File(filename, xmlString);
+ }
+ }
+
+ /**
+ * writes an XML structure to file (Encoding: UTF-8)
+ *
+ * @param filename file name
+ * @param rootElem root element in DOM tree
+ */
+ public static void outputXML2File(String filename, Element rootElem) {
+ try {
+ String xmlString = new String(DOMUtils.serializeNode(rootElem));
+ outputXML2File(filename, xmlString);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * writes an XML structure to file (Encoding: UTF-8)
+ *
+ * @param filename file name
+ * @param xmlString XML string
+ */
+ public static void outputXML2File(String filename, String xmlString) {
+ try {
+ java.io.OutputStream fout = new java.io.FileOutputStream(filename);
+ byte[] xmlData = xmlString.getBytes("UTF-8");
+ fout.write(xmlData);
+ fout.close();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/ResourceBundleChain.java b/common/src/main/java/at/gv/egovernment/moa/util/ResourceBundleChain.java
new file mode 100644
index 000000000..90b28548a
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/ResourceBundleChain.java
@@ -0,0 +1,66 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * A class to chain ResourceBundles.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class ResourceBundleChain {
+ /** Error message indicating the resource is not available. */
+ private static final String ERROR_MISSING_RESOURCE = "Missing resource";
+ /** The ResourceBundles contained in this chain. */
+ private List resourceBundles = new ArrayList();
+
+ /**
+ * Add a ResourceBundle to the chain.
+ *
+ * @param resourceBundle The ResourceBundle to add.
+ */
+ public void addResourceBundle(ResourceBundle resourceBundle) {
+ resourceBundles.add(resourceBundle);
+ }
+
+ /**
+ * Return the value of the resource.
+ *
+ * @param key The key to access the String resource.
+ * @return The resource value. All the registered ResourceBundles
+ * are searched in the order in which they have previously been added to this
+ * ResourceBundleChain.
+ * @throws MissingResourceException The resource coult not be found in any of
+ * the bundles.
+ */
+ public String getString(String key) throws MissingResourceException {
+ MissingResourceException lastException = null;
+ Iterator iter;
+
+ // handle case where no resource bundles have been added
+ if (resourceBundles.size() == 0) {
+ throw new MissingResourceException(
+ ERROR_MISSING_RESOURCE,
+ this.getClass().getName(),
+ key);
+ }
+
+ // try to find the resource in one of the bundles; if it cannot be found,
+ // return the exception thrown by the last bundle in the list
+ for (iter = resourceBundles.iterator(); iter.hasNext();) {
+ ResourceBundle resourceBundle = (ResourceBundle) iter.next();
+ try {
+ String value = resourceBundle.getString(key);
+ return value;
+ } catch (MissingResourceException e) {
+ lastException = e;
+ }
+ }
+ throw lastException;
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/SSLUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/SSLUtils.java
new file mode 100644
index 000000000..ada21b412
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/SSLUtils.java
@@ -0,0 +1,221 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+
+/**
+ * Utility for connecting to server applications via SSL.
+ *
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class SSLUtils {
+
+ /**
+ * Creates an SSLSocketFactory which utilizes the given trust store.
+ *
+ * @param trustStoreType key store type of trust store
+ * @param trustStoreInputStream input stream for reading JKS trust store containing
+ * trusted server certificates; if null, the default
+ * trust store will be utilized
+ * @param trustStorePassword if provided, it will be used to check
+ * the integrity of the trust store; if omitted, it will not be checked
+ * @return SSLSocketFactory to be used by an HttpsURLConnection
+ * @throws IOException thrown while reading from the input stream
+ * @throws GeneralSecurityException thrown while creating the socket factory
+ */
+ public static SSLSocketFactory getSSLSocketFactory(
+ String trustStoreType,
+ InputStream trustStoreInputStream,
+ String trustStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ TrustManager[] tms = getTrustManagers(trustStoreType, trustStoreInputStream, trustStorePassword);
+ SSLContext ctx = SSLContext.getInstance("TLS");
+ ctx.init(null, tms, null);
+
+ SSLSocketFactory sf = ctx.getSocketFactory();
+ return sf;
+ }
+ /**
+ * Creates an SSLSocketFactory which utilizes the
+ * given trust store and keystore.
+ *
+ * @param trustStore trust store containing trusted server certificates;
+ * if null, the default trust store will be utilized
+ * @param clientKeyStoreType key store type of clientKeyStore
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if null, the default key store will be utilized
+ * @param clientKeyStorePassword if provided, it will be used to check
+ * the integrity of the client key store; if omitted, it will not be checked
+ * @return SSLSocketFactory to be used by an HttpsURLConnection
+ * @throws IOException thrown while reading key store file
+ * @throws GeneralSecurityException thrown while creating the socket factory
+ */
+ public static SSLSocketFactory getSSLSocketFactory(
+ KeyStore trustStore,
+ String clientKeyStoreType,
+ String clientKeyStoreURL,
+ String clientKeyStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ SSLContext ctx = getSSLContext(
+ trustStore, clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ SSLSocketFactory sf = ctx.getSocketFactory();
+ return sf;
+ }
+ /**
+ * Creates an SSLContext initialized for the
+ * given trust store and keystore.
+ *
+ * @param trustStore trust store containing trusted server certificates;
+ * if null, the default trust store will be utilized
+ * @param clientKeyStoreType key store type of clientKeyStore
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if null, the default key store will be utilized
+ * @param clientKeyStorePassword if provided, it will be used to check
+ * the integrity of the client key store; if omitted, it will not be checked
+ * @return SSLContext to be used for creating an SSLSocketFactory
+ * @throws IOException thrown while reading key store file
+ * @throws GeneralSecurityException thrown while creating the SSL context
+ */
+ public static SSLContext getSSLContext(
+ KeyStore trustStore,
+ String clientKeyStoreType,
+ String clientKeyStoreURL,
+ String clientKeyStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ //System.setProperty("javax.net.debug", "all");
+ TrustManager[] tms = getTrustManagers(trustStore);
+ KeyManager[] kms = getKeyManagers(clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ SSLContext ctx = SSLContext.getInstance("TLS");
+ ctx.init(kms, tms, null);
+ return ctx;
+ }
+ /**
+ * Loads the trust store from an input stream and gets the
+ * TrustManagers from a default TrustManagerFactory,
+ * initialized from the given trust store.
+ * @param trustStoreType key store type of trust store
+ * @param trustStoreInputStream input stream for reading JKS trust store containing
+ * trusted server certificates; if null, the default
+ * trust store will be utilized
+ * @param trustStorePassword if provided, it will be used to check
+ * the integrity of the trust store; if omitted, it will not be checked
+ * @return TrustManagers to be used for creating an
+ * SSLSocketFactory utilizing the given trust store
+ * @throws IOException thrown while reading from the input stream
+ * @throws GeneralSecurityException thrown while initializing the
+ * default TrustManagerFactory
+ */
+ protected static TrustManager[] getTrustManagers(
+ String trustStoreType,
+ InputStream trustStoreInputStream,
+ String trustStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ if (trustStoreInputStream == null)
+ return null;
+
+ // Set up the TrustStore to use. We need to load the file into
+ // a KeyStore instance.
+ KeyStore trustStore = KeyStoreUtils.loadKeyStore(trustStoreType, trustStoreInputStream, trustStorePassword);
+ return getTrustManagers(trustStore);
+ }
+ /**
+ * Gets the TrustManagers from a default TrustManagerFactory,
+ * initialized from the given trust store.
+ *
+ * @param trustStore the trust store to use
+ * @return TrustManagers to be used for creating an
+ * SSLSocketFactory utilizing the given trust store
+ * @throws GeneralSecurityException thrown while initializing the
+ * default TrustManagerFactory
+ */
+ protected static TrustManager[] getTrustManagers(KeyStore trustStore)
+ throws GeneralSecurityException {
+
+ if (trustStore == null)
+ return null;
+
+ // Initialize the default TrustManagerFactory with this KeyStore
+ String alg=TrustManagerFactory.getDefaultAlgorithm();
+ TrustManagerFactory tmFact=TrustManagerFactory.getInstance(alg);
+ tmFact.init(trustStore);
+
+ // And now get the TrustManagers
+ TrustManager[] tms=tmFact.getTrustManagers();
+ return tms;
+ }
+ /**
+ * Loads the client key store from file and gets the
+ * KeyManagers from a default KeyManagerFactory,
+ * initialized from the given client key store.
+ * @param clientKeyStoreType key store type of clientKeyStore
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if null, the default key store will be utilized
+ * @param clientKeyStorePassword password used to check the integrity of the client key store;
+ * if null, it will not be checked
+ * @return KeyManagers to be used for creating an
+ * SSLSocketFactory utilizing the given client key store
+ * @throws IOException thrown while reading from the key store file
+ * @throws GeneralSecurityException thrown while initializing the
+ * default KeyManagerFactory
+ */
+ public static KeyManager[] getKeyManagers (
+ String clientKeyStoreType,
+ String clientKeyStoreURL,
+ String clientKeyStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ if (clientKeyStoreURL == null)
+ return null;
+
+ // Set up the KeyStore to use. We need to load the file into
+ // a KeyStore instance.
+ KeyStore clientKeyStore = KeyStoreUtils.loadKeyStore(
+ clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ return getKeyManagers(clientKeyStore, clientKeyStorePassword);
+ }
+ /**
+ * Gets the KeyManagers from a default KeyManagerFactory,
+ * initialized from the given client key store.
+ * @param clientKeyStore client key store
+ * @param clientKeyStorePassword if provided, it will be used to check
+ * the integrity of the client key store; if omitted, it will not be checked
+ * @return KeyManagers to be used for creating an
+ * SSLSocketFactory utilizing the given client key store
+ * @throws GeneralSecurityException thrown while initializing the
+ * default KeyManagerFactory
+ */
+ public static KeyManager[] getKeyManagers (
+ KeyStore clientKeyStore,
+ String clientKeyStorePassword)
+ throws GeneralSecurityException {
+
+ if (clientKeyStore == null)
+ return null;
+
+ // Now we initialize the default KeyManagerFactory with this KeyStore
+ String alg=KeyManagerFactory.getDefaultAlgorithm();
+ KeyManagerFactory kmFact=KeyManagerFactory.getInstance(alg);
+ char[] password = null;
+ if (clientKeyStorePassword != null)
+ password = clientKeyStorePassword.toCharArray();
+ kmFact.init(clientKeyStore, password);
+
+ // And now get the KeyManagers
+ KeyManager[] kms=kmFact.getKeyManagers();
+ return kms;
+ }
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/StreamEntityResolver.java b/common/src/main/java/at/gv/egovernment/moa/util/StreamEntityResolver.java
new file mode 100644
index 000000000..38c4e863c
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/StreamEntityResolver.java
@@ -0,0 +1,64 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * An EntityResolver that maps system IDs to
+ * InputStreams.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class StreamEntityResolver implements EntityResolver {
+
+ /** A mapping from Public ID or System ID to an InputStream
+ * containing the entity. */
+ private Map mappedEntities;
+
+ /**
+ * Create a StreamEntityResolver.
+ *
+ * @param mappedEntities A mapping from public or system IDs
+ * (String objects) to InputStreams.
+ */
+ public StreamEntityResolver(Map mappedEntities) {
+ this.mappedEntities = mappedEntities;
+ }
+
+ /**
+ * Resolve an entity by looking it up in the mapped entities.
+ *
+ * First, the public ID is looked up in the mapping, then the system ID.
+ *
+ * @param publicId The public ID of the entity.
+ * @param systemId The system ID of the entity.
+ * @return An InputStream containing the entity or
+ * null if no entity could be found.
+ * @throws SAXException Signalling a parsing exception.
+ * @throws IOException Error reading the entity.
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException, IOException {
+
+ InputSource src = null;
+
+ if (publicId != null && mappedEntities.get(publicId) != null) {
+ src = new InputSource((InputStream) mappedEntities.get(publicId));
+ } else if (systemId != null && mappedEntities.get(systemId) != null) {
+ src = new InputSource((InputStream) mappedEntities.get(systemId));
+ }
+
+ if (src != null) {
+ src.setPublicId(publicId);
+ src.setSystemId(systemId);
+ }
+
+ return src;
+ }
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/StreamUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/StreamUtils.java
new file mode 100644
index 000000000..a22f1c2a8
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/StreamUtils.java
@@ -0,0 +1,128 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+
+/**
+ * Utility methods for streams.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class StreamUtils {
+
+ /**
+ * Compare the contents of two InputStreams.
+ *
+ * @param is1 The 1st InputStream to compare.
+ * @param is2 The 2nd InputStream to compare.
+ * @return boolean true, if both streams contain the exactly the
+ * same content, false otherwise.
+ * @throws IOException An error occurred reading one of the streams.
+ */
+ public static boolean compareStreams(InputStream is1, InputStream is2)
+ throws IOException {
+
+ byte[] buf1 = new byte[256];
+ byte[] buf2 = new byte[256];
+ int length1;
+ int length2;
+
+ try {
+ while (true) {
+ length1 = is1.read(buf1);
+ length2 = is2.read(buf2);
+
+ if (length1 != length2) {
+ return false;
+ }
+ if (length1 <= 0) {
+ return true;
+ }
+ if (!compareBytes(buf1, buf2, length1)) {
+ return false;
+ }
+ }
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ // close both streams
+ try {
+ is1.close();
+ is2.close();
+ } catch (IOException e) {
+ // ignore this
+ }
+ }
+ }
+
+ /**
+ * Compare two byte arrays, up to a given maximum length.
+ *
+ * @param b1 1st byte array to compare.
+ * @param b2 2nd byte array to compare.
+ * @param length The maximum number of bytes to compare.
+ * @return true, if the byte arrays are equal, false
+ * otherwise.
+ */
+ private static boolean compareBytes(byte[] b1, byte[] b2, int length) {
+ if (b1.length != b2.length) {
+ return false;
+ }
+
+ for (int i = 0; i < b1.length && i < length; i++) {
+ if (b1[i] != b2[i]) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Reads a byte array from a stream.
+ * @param in The InputStream to read.
+ * @return The bytes contained in the given InputStream.
+ * @throws IOException on any exception thrown
+ */
+ public static byte[] readStream(InputStream in) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int b;
+ while ((b = in.read()) >= 0)
+ out.write(b);
+ in.close();
+ return out.toByteArray();
+ }
+
+ /**
+ * Reads a String from a stream, using given encoding.
+ * @param in The InputStream to read.
+ * @param encoding The character encoding to use for converting the bytes
+ * of the InputStream into a String.
+ * @return The content of the given InputStream converted into
+ * a String.
+ * @throws IOException on any exception thrown
+ */
+ public static String readStream(InputStream in, String encoding) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int b;
+ while ((b = in.read()) >= 0)
+ out.write(b);
+ in.close();
+ return out.toString(encoding);
+ }
+
+ /**
+ * Gets the stack trace of the Throwable passed in as a string.
+ * @param t The Throwable.
+ * @return a String representing the stack trace of the Throwable.
+ */
+ public static String getStackTraceAsString(Throwable t)
+ {
+ ByteArrayOutputStream stackTraceBIS = new ByteArrayOutputStream();
+ t.printStackTrace(new PrintStream(stackTraceBIS));
+ return new String(stackTraceBIS.toByteArray());
+ }
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/StringUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/StringUtils.java
new file mode 100644
index 000000000..61b1a18ea
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/StringUtils.java
@@ -0,0 +1,164 @@
+// Copyright (C) 2002 IAIK
+// email: jce-info@iaik.tu-graz.ac.at
+//
+// All rights reserved.
+//
+// This source is provided for inspection purposes and recompilation only,
+// unless specified differently in a contract with IAIK. This source has to
+// be kept in strict confidence and must not be disclosed to any third party
+// under any circumstances. Redistribution in source and binary forms, with
+// or without modification, are permitted in any case!
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+//
+
+package at.gv.egovernment.moa.util;
+
+import java.util.StringTokenizer;
+
+/**
+ * Utitility functions for string manipulations.
+ *
+ * @author Harald Bratko
+ */
+public class StringUtils {
+
+ /**
+ * Removes all blanks and tabs from the given string.
+ *
+ * @param s The string to remove all blanks and tabs from.
+ * @return The input string with all blanks and tabs removed from.
+ */
+ public static String removeBlanks(String s) {
+ StringTokenizer st = new StringTokenizer(s);
+ StringBuffer sb = new StringBuffer(s.length());
+ while (st.hasMoreTokens()) {
+ sb.append(st.nextToken());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Removes all occurences of the specified token from the the given string.
+ *
+ * @param s The string to remove all occurences of the specified token from.
+ * @return The input string with all occurences of the specified token removed from.
+ */
+ public static String removeToken(String s, String token) {
+ StringTokenizer st = new StringTokenizer(s, token);
+ StringBuffer sb = new StringBuffer(s.length());
+ while (st.hasMoreTokens()) {
+ sb.append(st.nextToken());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Removes all leading zeros from the input string.
+ *
+ * @param s The string remove the leading zeros from.
+ * @return The input string with the leading zeros removed from.
+ */
+ public static String deleteLeadingZeros(String s) {
+ StringBuffer sb = new StringBuffer(s);
+ int l = sb.length();
+ int j = 0;
+ for (int i=0; is that matches the given
+ * search string by the given replace string.
+ *
+ * @param s The string where the replacment should take place.
+ * @param search The pattern that should be replaced.
+ * @param replace The string that should replace all each search
+ * string within s.
+ * @return A string whrer all occurrence of search are
+ * replaced with replace.
+ */
+ public static String replaceAll (String s, String search, String replace)
+ {
+ StringBuffer sb = new StringBuffer();
+ int i = 0, j = 0;
+ int len = search.length();
+ while (j > -1)
+ {
+ j = s.indexOf(search, i);
+
+ if (j > -1)
+ {
+ sb.append(s.substring(i,j));
+ sb.append(replace);
+ i = j + len;
+ }
+ }
+
+ sb.append(s.substring(i, s.length()));
+
+ return sb.toString();
+ }
+
+ /**
+ * Changes the SecurityLayer version in the given string.
+ * This method usually takes as input an XML structure represented in a string
+ * format and changes the SecurityLayer namespaces prefixes and URIs from
+ * one SecurityLayer version to another.
+ * e.g.: code>sl10 to sl and
+ * http://www.buergerkarte.at/namespaces/securitylayer/20020225#
+ * to
+ * http://www.buergerkarte.at/namespaces/securitylayer/1.2#
+ *
+ * @param s The string (usally an XML structure) where the
+ * SecurityLayer version should be changed.
+ * @param slPrefixOld The SecurityLayer namespace prefix that should be
+ * replaced by the new one.
+ * @param slPrefixNew The new SecurityLayer namespace prefix that should
+ * replace the old one.
+ * @param slNSUriOld The SecurityLayer namespace URI that should be
+ * replaced by the new one.
+ * @param slNSUriNew The new SecurityLayer namespace URI that should
+ * replace the old one.
+ * @return A string where the SecurityLayer namespace prefixes
+ * and URIs are replaced by new ones.
+ */
+ public static String changeSLVersion(String s, String slPrefixOld, String slPrefixNew, String slNSUriOld, String slNSUriNew) {
+ String retString = replaceAll(s, slPrefixOld, slPrefixNew);
+ retString = replaceAll(retString, slNSUriOld, slNSUriNew);
+ return retString ;
+ }
+
+ /**
+ * Removes the XML declaration from an XML expression.
+ *
+ * @param xmlString XML expression as String
+ *
+ * @return XML expression, XML declaration removed
+ */
+ public static String removeXMLDeclaration(String xmlString) {
+ if (xmlString.startsWith("application/x-www-form-urlencoded string using a specific encoding scheme.
+ * @param s the string to decode
+ * @param encoding name of character encoding
+ * @return the newly decoded string
+ * @throws UnsupportedEncodingException if the encoding is not supported
+ */
+ public static String decode(String s, String encoding) throws UnsupportedEncodingException {
+ StringReader in = new StringReader(s);
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ for (int b = read(in); b >= 0; b = read(in))
+ bout.write(b);
+ return bout.toString(encoding);
+ }
+ /**
+ * Decodes the next byte from the string reader.
+ * @param in string reader
+ * @return the next byte decoded;
+ * -1 upon end of string, on erroneous data, and on any exception caught
+ * @todo syntax check on string
+ */
+ private static int read(StringReader in) {
+ try {
+ int b = in.read();
+ if (b == '+')
+ return ' ';
+ if (b == '%') {
+ char[] hex = new char[2];
+ if (in.read(hex, 0, 2) >= 0) {
+ String hexString = new String(hex);
+ return Integer.valueOf(hexString, 16).intValue();
+ }
+ else
+ return -1;
+ }
+ return b;
+ }
+ catch (IOException ex) {
+ return -1;
+ }
+ catch (NumberFormatException ex) {
+ return -1;
+ }
+ }
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/URLEncoder.java b/common/src/main/java/at/gv/egovernment/moa/util/URLEncoder.java
new file mode 100644
index 000000000..840c0c3bc
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/URLEncoder.java
@@ -0,0 +1,63 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Translates a string into mime format "x-www-form-urlencoded".
+ * Provides a function missing in JDK 1.3.
+ * @author Paul Ivancsics
+ * @version $Id$
+ */
+public class URLEncoder {
+
+ /**
+ * Translates a string into x-www-form-urlencoded format.
+ * @param s the string to be translated
+ * @param encoding the encoding to use
+ * @return the translated string
+ * @throws UnsupportedEncodingException when the desired encoding is not supported
+ */
+ public static String encode(String s, String encoding) throws UnsupportedEncodingException {
+ byte[] barr = s.getBytes(encoding);
+ ByteArrayInputStream bin = new ByteArrayInputStream(barr);
+ StringWriter out = new StringWriter();
+ for (int b = bin.read(); b >= 0; b = bin.read())
+ encode(b, out);
+ return out.toString();
+ }
+
+ /**
+ * Encode a character.
+ * @param ch The character to encode.
+ * @param out The StringWriter containing the result.
+ */
+ private static void encode(int ch, StringWriter out) {
+ if ((ch >= 'a' && ch <= 'z')
+ || (ch >= 'A' && ch <= 'Z')
+ || (ch >= '0' && ch <= '9')
+ || ch == '.' || ch == '-' || ch == '*' || ch == '_')
+ out.write(ch);
+ else if (ch == ' ')
+ out.write('+');
+ else
+ encodeHex(ch, out);
+ }
+
+ /**
+ * Encode a character as an escaped hex value.
+ * @param ch The character to encode.
+ * @param out The StringWriter containing the result.
+ */
+ private static void encodeHex(int ch, StringWriter out) {
+ out.write('%');
+ String hex = Integer.toHexString(ch).toUpperCase();
+ if (hex.length() < 2)
+ out.write('0');
+ else
+ out.write(hex.charAt(hex.length() - 2));
+ out.write(hex.charAt(hex.length() - 1));
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/XPathException.java b/common/src/main/java/at/gv/egovernment/moa/util/XPathException.java
new file mode 100644
index 000000000..e10c882e5
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/XPathException.java
@@ -0,0 +1,58 @@
+package at.gv.egovernment.moa.util;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * An exception occurred evaluating an XPath.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class XPathException extends RuntimeException {
+ /** The wrapped exception. */
+ private Throwable wrapped;
+
+ /**
+ * Create a XPathException.
+ *
+ * @param message The exception message.
+ * @param wrapped The exception being the likely cause of this exception.
+ */
+ public XPathException(String message, Throwable wrapped) {
+ super(message);
+ this.wrapped = wrapped;
+ }
+
+ /**
+ * Return the wrapped exception.
+ *
+ * @return The wrapped exception being the likely cause of this exception.
+ */
+ public Throwable getWrapped() {
+ return wrapped;
+ }
+
+ /**
+ * @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
+ */
+ public void printStackTrace(PrintStream s) {
+ super.printStackTrace(s);
+ if (getWrapped() != null) {
+ s.print("Caused by: ");
+ getWrapped().printStackTrace(s);
+ }
+ }
+
+ /**
+ * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+ */
+ public void printStackTrace(PrintWriter s) {
+ super.printStackTrace(s);
+ if (getWrapped() != null) {
+ s.print("Caused by: ");
+ getWrapped().printStackTrace(s);
+ }
+ }
+
+}
diff --git a/common/src/main/java/at/gv/egovernment/moa/util/XPathUtils.java b/common/src/main/java/at/gv/egovernment/moa/util/XPathUtils.java
new file mode 100644
index 000000000..5212ed13e
--- /dev/null
+++ b/common/src/main/java/at/gv/egovernment/moa/util/XPathUtils.java
@@ -0,0 +1,526 @@
+package at.gv.egovernment.moa.util;
+
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.traversal.NodeIterator;
+
+import org.jaxen.JaxenException;
+import org.jaxen.NamespaceContext;
+import org.jaxen.SimpleNamespaceContext;
+import org.jaxen.dom.DOMXPath;
+import org.jaxen.dom.DocumentNavigator;
+
+/**
+ * Utility methods to evaluate XPath expressions on DOM nodes.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class XPathUtils {
+
+ /**
+ * The XPath expression selecting all nodes under a given root (including the
+ * root node itself).
+ */
+ public static final String ALL_NODES_XPATH =
+ "(.//. | .//@* | .//namespace::*)";
+
+ /** The DocumentNavigator to use for navigating the document. */
+ private static DocumentNavigator documentNavigator =
+ DocumentNavigator.getInstance();
+ /** The default namespace prefix to namespace URI mappings. */
+ private static NamespaceContext NS_CONTEXT;
+
+ static {
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ ctx.addNamespace(Constants.MOA_PREFIX, Constants.MOA_NS_URI);
+ ctx.addNamespace(Constants.MOA_CONFIG_PREFIX, Constants.MOA_CONFIG_NS_URI);
+ ctx.addNamespace(Constants.MOA_ID_CONFIG_PREFIX, Constants.MOA_ID_CONFIG_NS_URI);
+ ctx.addNamespace(Constants.SL10_PREFIX, Constants.SL10_NS_URI);
+ ctx.addNamespace(Constants.SL11_PREFIX, Constants.SL11_NS_URI);
+ ctx.addNamespace(Constants.SL12_PREFIX, Constants.SL12_NS_URI);
+ ctx.addNamespace(Constants.ECDSA_PREFIX, Constants.ECDSA_NS_URI);
+ ctx.addNamespace(Constants.PD_PREFIX, Constants.PD_NS_URI);
+ ctx.addNamespace(Constants.SAML_PREFIX, Constants.SAML_NS_URI);
+ ctx.addNamespace(Constants.SAMLP_PREFIX, Constants.SAMLP_NS_URI);
+ ctx.addNamespace(Constants.DSIG_PREFIX, Constants.DSIG_NS_URI);
+ ctx.addNamespace(Constants.XSLT_PREFIX, Constants.XSLT_NS_URI);
+ ctx.addNamespace(Constants.XSI_PREFIX, Constants.XSI_NS_URI);
+ ctx.addNamespace(Constants.DSIG_FILTER2_PREFIX, Constants.DSIG_FILTER2_NS_URI);
+ ctx.addNamespace(Constants.DSIG_EC_PREFIX, Constants.DSIG_EC_NS_URI);
+ ctx.addNamespace(Constants.MD_PREFIX, Constants.MD_NS_URI);
+ ctx.addNamespace(Constants.MDP_PREFIX, Constants.MDP_NS_URI);
+ ctx.addNamespace(Constants.MVV_PREFIX, Constants.MVV_NS_URI);
+ ctx.addNamespace(Constants.STB_PREFIX, Constants.STB_NS_URI);
+ ctx.addNamespace(Constants.WRR_PREFIX, Constants.WRR_NS_URI);
+ NS_CONTEXT = ctx;
+ }
+
+ /**
+ * Return a NodeIterator over the nodes matching the XPath
+ * expression.
+ *
+ * All namespace URIs and prefixes declared in the Constants
+ * interface are used for resolving namespaces.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return An iterator over the resulting nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeIterator selectNodeIterator(Node contextNode, String exp)
+ throws XPathException {
+
+ return selectNodeIterator(contextNode, NS_CONTEXT, exp);
+ }
+
+ /**
+ * Return a NodeIterator over the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceElement An element from which to build the
+ * namespace mapping for evaluating the XPath expression
+ * @param exp The XPath expression to evaluate.
+ * @return An iterator over the resulting nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeIterator selectNodeIterator(
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
+
+ try {
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ ctx.addElementNamespaces(documentNavigator, namespaceElement);
+ return selectNodeIterator(contextNode, ctx, exp);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Return a NodeIterator over the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceMapping A namespace prefix to namespace URI mapping
+ * (String to String) for evaluating the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return An iterator over the resulting nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeIterator selectNodeIterator(
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
+
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+
+ return selectNodeIterator(contextNode, ctx, exp);
+ }
+
+ /**
+ * Return a NodeIterator over the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param nsContext The NamespaceContext for resolving namespace
+ * prefixes to namespace URIs for evaluating the XPath expression.
+ * @param exp The XPath expression to evaluate.
+ * @return An iterator over the resulting nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ private static NodeIterator selectNodeIterator(
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
+
+ try {
+ DOMXPath xpath = new DOMXPath(exp);
+ List nodes;
+
+ xpath.setNamespaceContext(nsContext);
+ nodes = xpath.selectNodes(contextNode);
+ return new NodeIteratorAdapter(nodes.listIterator());
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Return a NodeList of all the nodes matching the XPath
+ * expression.
+ *
+ * All namespace URIs and prefixes declared in the Constants
+ * interface are used for resolving namespaces.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return A NodeList containing the matching nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeList selectNodeList(Node contextNode, String exp)
+ throws XPathException {
+
+ return selectNodeList(contextNode, NS_CONTEXT, exp);
+ }
+
+ /**
+ * Return a NodeList of all the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceElement An element from which to build the
+ * namespace mapping for evaluating the XPath expression
+ * @param exp The XPath expression to evaluate.
+ * @return A NodeList containing the matching nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeList selectNodeList(
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
+
+ try {
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+
+ ctx.addElementNamespaces(documentNavigator, namespaceElement);
+ return selectNodeList(contextNode, ctx, exp);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Return a NodeList of all the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceMapping A namespace prefix to namespace URI mapping
+ * (String to String) for evaluating the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return A NodeList containing the matching nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static NodeList selectNodeList(
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
+
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+
+ return selectNodeList(contextNode, ctx, exp);
+ }
+
+ /**
+ * Return a NodeList of all the nodes matching the XPath
+ * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param nsContext The NamespaceContext for resolving namespace
+ * prefixes to namespace URIs for evaluating the XPath expression.
+ * @param exp The XPath expression to evaluate.
+ * @return A NodeList containing the matching nodes.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ private static NodeList selectNodeList(
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
+
+ try {
+ DOMXPath xpath = new DOMXPath(exp);
+ List nodes;
+
+ xpath.setNamespaceContext(nsContext);
+ nodes = xpath.selectNodes(contextNode);
+ return new NodeListAdapter(nodes);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Select the first node matching an XPath expression.
+ *
+ * All namespace URIs and prefixes declared in the Constants
+ * interface are used for resolving namespaces.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return Node The first node matching the XPath expression, or
+ * null, if no node matched.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static Node selectSingleNode(Node contextNode, String exp)
+ throws XPathException {
+
+ return selectSingleNode(contextNode, NS_CONTEXT, exp);
+ }
+
+ /**
+ * Select the first node matching an XPath expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceElement An element from which to build the
+ * namespace mapping for evaluating the XPath expression
+ * @param exp The XPath expression to evaluate.
+ * @return Node The first node matching the XPath expression, or
+ * null, if no node matched.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static Node selectSingleNode(
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
+
+ try {
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ ctx.addElementNamespaces(documentNavigator, namespaceElement);
+
+ return selectSingleNode(contextNode, ctx, exp);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Select the first node matching an XPath expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param namespaceMapping A namespace prefix to namespace URI mapping
+ * (String to String) for evaluating the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
+ * @return Node The first node matching the XPath expression, or
+ * null, if no node matched.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ public static Node selectSingleNode(
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
+
+ SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+
+ return selectSingleNode(contextNode, ctx, exp);
+ }
+
+ /**
+ * Select the first node matching an XPath expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
+ * @param nsContext The NamespaceContext for resolving namespace
+ * prefixes to namespace URIs for evaluating the XPath expression.
+ * @param exp The XPath expression to evaluate.
+ * @return Node The first node matching the XPath expression, or
+ * null, if no node matched.
+ * @throws XPathException An error occurred evaluating the XPath expression.
+ */
+ private static Node selectSingleNode(
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
+
+ try {
+ DOMXPath xpath = new DOMXPath(exp);
+ xpath.setNamespaceContext(nsContext);
+ return (Node) xpath.selectSingleNode(contextNode);
+ } catch (JaxenException e) {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { exp });
+ throw new XPathException(message, e);
+ }
+ }
+
+ /**
+ * Return the value of a DOM element whose location is given by an XPath
+ * expression.
+ *
+ * @param root The root element from which to evaluate the XPath.
+ * @param xpath The XPath expression pointing to the element whose value
+ * to return.
+ * @param def The default value to return, if no element can be found using
+ * the given xpath.
+ * @return The element value, if it can be located using the
+ * xpath. Otherwise, def is returned.
+ */
+ public static String getElementValue(
+ Element root,
+ String xpath,
+ String def) {
+
+ Element elem = (Element) XPathUtils.selectSingleNode(root, xpath);
+ return elem != null ? DOMUtils.getText(elem) : def;
+ }
+
+ /**
+ * Return the value of a DOM attribute whose location is given by an XPath
+ * expression.
+ *
+ * @param root The root element from which to evaluate the XPath.
+ * @param xpath The XPath expression pointing to the attribute whose value to
+ * return.
+ * @param def The default value to return, if no attribute can be found using
+ * the given xpath.
+ * @return The element value, if it can be located using the
+ * xpath. Otherwise, def is returned.
+ */
+ public static String getAttributeValue(
+ Element root,
+ String xpath,
+ String def) {
+
+ Attr attr = (Attr) XPathUtils.selectSingleNode(root, xpath);
+ return attr != null ? attr.getValue() : def;
+ }
+
+ /**
+ * Returns the namespace prefix used within XPathUtils for referring to
+ * the namespace of the specified (Security Layer command) element.
+ *
+ * This namespace prefix can be used in various XPath expression evaluation methods
+ * within XPathUtils without explicitely binding it to the particular
+ * namespace.
+ *
+ * @param contextElement The (Security Layer command) element.
+ *
+ * @return the namespace prefix used within XPathUtils for referring to
+ * the namespace of the specified (Security Layer command) element.
+ *
+ * throws XpathException If the specified element has a namespace other than the ones
+ * known by this implementation as valid Security Layer namespaces (cf.
+ * @link Constants#SL10_NS_URI, @link Constants#SL11_NS_URI, @link Constants#SL12_NS_URI).
+ */
+ public static String getSlPrefix (Element contextElement) throws XPathException
+ {
+ String sLNamespace = contextElement.getNamespaceURI();
+ String sLPrefix = null;
+
+ if (sLNamespace.equals(Constants.SL10_NS_URI))
+ {
+ sLPrefix = Constants.SL10_PREFIX;
+ }
+ else if (sLNamespace.equals(Constants.SL12_NS_URI))
+ {
+ sLPrefix = Constants.SL12_PREFIX;
+ }
+ else if (sLNamespace.equals(Constants.SL11_NS_URI))
+ {
+ sLPrefix = Constants.SL11_PREFIX;
+ }
+ else
+ {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger Security Layer Namespace: \"" + sLNamespace + "\"."});
+ throw new XPathException(message, null);
+ }
+
+ return sLPrefix;
+ }
+
+
+ /**
+ * Return the SecurityLayer namespace prefix of the context element.
+ * If the context element is not the element that lies within the
+ * SecurityLayer namespace. The Securitylayer namespace is derived from
+ * the xmlns:sl10, sl11 or sl
+ * attribute of the context element.
+ *
+ * The returned prefix is needed for evaluating XPATH expressions.
+ *
+ * @param contextElement The element to get a prefix for the Securitylayer namespace,
+ * that is used within the corresponding document.
+ *
+ * @return The string sl10, sl11 or sl,
+ * depending on the SecurityLayer namespace of the contextElement.
+ *
+ * throws XPathException If no (vlalid) SecurityLayer namespace prefix or namespace
+ * is defined.
+ */
+ public static String getSlPrefixFromNoRoot (Element contextElement) throws XPathException {
+
+ String slPrefix = checkSLnsDeclaration(contextElement, Constants.SL10_PREFIX, Constants.SL10_NS_URI);
+ if (slPrefix == null) {
+ slPrefix = checkSLnsDeclaration(contextElement, Constants.SL11_PREFIX, Constants.SL11_NS_URI);
+ }
+ if (slPrefix == null) {
+ slPrefix = checkSLnsDeclaration(contextElement, Constants.SL12_PREFIX, Constants.SL12_NS_URI);
+ }
+
+ return slPrefix;
+
+ }
+
+ /**
+ * Checks if the context element has an attribute xmlns:slPrefix and
+ * if the prefix of that attribute corresponds with a valid SecurityLayer namespace.
+ *
+ * @param contextElement The element to be checked.
+ * @param slPrefix The prefix which should be checked. Must be a valid SecurityLayer
+ * namespace prefix.
+ * @param slNameSpace The SecurityLayer namespace that corresponds to the specified prefix.
+ *
+ * @return The valid SecurityLayer prefix or null if this prefix is
+ * not used.
+ * @throws XPathException
+ */
+ private static String checkSLnsDeclaration(Element contextElement, String slPrefix, String slNameSpace)
+ throws XPathException
+ {
+ String nsAtt = "xmlns:" + slPrefix;
+ String nameSpace = contextElement.getAttribute(nsAtt);
+ if (nameSpace == "") {
+ return null;
+ } else {
+ // check if namespace is correct
+ if (nameSpace.equals(slNameSpace)) {
+ return slPrefix;
+ } else {
+ MessageProvider msg = MessageProvider.getInstance();
+ String message = msg.getMessage("xpath.00", new Object[] { "Ungültiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
+ throw new XPathException(message, null);
+ }
+ }
+ }
+
+}
diff --git a/common/src/test/at/gv/egovernment/moa/AllTests.java b/common/src/test/at/gv/egovernment/moa/AllTests.java
deleted file mode 100644
index 00e2c505f..000000000
--- a/common/src/test/at/gv/egovernment/moa/AllTests.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package test.at.gv.egovernment.moa;
-
-import test.at.gv.egovernment.moa.util.DOMUtilsTest;
-import test.at.gv.egovernment.moa.util.DateTimeUtilsTest;
-import test.at.gv.egovernment.moa.util.KeyStoreUtilsTest;
-import test.at.gv.egovernment.moa.util.SSLUtilsTest;
-import test.at.gv.egovernment.moa.util.XPathUtilsTest;
-
-import junit.awtui.TestRunner;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * @author patrick
- * @version $Id$
- */
-public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
-
- suite.addTestSuite(DOMUtilsTest.class);
- suite.addTestSuite(DateTimeUtilsTest.class);
- suite.addTestSuite(XPathUtilsTest.class);
- suite.addTestSuite(KeyStoreUtilsTest.class);
- suite.addTestSuite(SSLUtilsTest.class);
-
- return suite;
- }
-
- public static void main(String[] args) {
- try {
- TestRunner.run(AllTests.class);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/common/src/test/at/gv/egovernment/moa/MOATestCase.java b/common/src/test/at/gv/egovernment/moa/MOATestCase.java
deleted file mode 100644
index 86ea2ee6c..000000000
--- a/common/src/test/at/gv/egovernment/moa/MOATestCase.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package test.at.gv.egovernment.moa;
-
-import java.io.FileInputStream;
-import java.io.StringReader;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-
-import org.xml.sax.InputSource;
-
-import junit.framework.TestCase;
-
-import at.gv.egovernment.moa.util.Constants;
-import at.gv.egovernment.moa.util.DOMUtils;
-
-/**
- * Base class for MOA test cases.
- *
- * Provides some utility functions.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class MOATestCase extends TestCase {
-
- protected static final String TESTDATA_ROOT = "data/test/";
-
- /**
- * Constructor for MOATestCase.
- * @param arg0
- */
- public MOATestCase(String name) {
- super(name);
- }
-
- /**
- * Parse an XML file non-validating.
- */
- public static Document parseXml(String fileName) throws Exception {
- return DOMUtils.parseDocument(
- new FileInputStream(fileName),
- false,
- null,
- null);
- }
-
- /**
- * Parse an XML validating with a given file name.
- *
- * Uses the local schema resources.
- */
- public static Document parseXmlValidating(String fileName) throws Exception {
- return DOMUtils.parseDocument(
- new FileInputStream(fileName),
- true,
- Constants.ALL_SCHEMA_LOCATIONS,
- null);
- }
-
- /**
- * Parse an XML from a String.
- */
- public static Document parseXmlString(String xml) throws Exception {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
-
- factory.setNamespaceAware(true);
- builder = factory.newDocumentBuilder();
-
- return builder.parse(new InputSource(new StringReader(xml)));
- }
-
-}
diff --git a/common/src/test/at/gv/egovernment/moa/util/DOMUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/DOMUtilsTest.java
deleted file mode 100644
index eb3ad1a5c..000000000
--- a/common/src/test/at/gv/egovernment/moa/util/DOMUtilsTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package test.at.gv.egovernment.moa.util;
-import java.io.FileInputStream;
-import java.util.Map;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import test.at.gv.egovernment.moa.*;
-
-import at.gv.egovernment.moa.util.Constants;
-import at.gv.egovernment.moa.util.DOMUtils;
-
-/**
- * @author Patrick Peck
- * @version $Id$
- */
-public class DOMUtilsTest extends MOATestCase {
- private static final String TESTDATA_BASE = TESTDATA_ROOT + "xml/";
- private static boolean grammarsInitialized = false;
-
- /**
- * Constructor for DOMUtilsTest.
- * @param name
- */
- public DOMUtilsTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- if (!grammarsInitialized) {
- // preparse XML schema
- DOMUtils.addSchemaToPool(
- getClass().getResourceAsStream(Constants.XML_SCHEMA_LOCATION),
- Constants.XML_NS_URI);
- // preparse XMLDsig Filter2 schema
- DOMUtils.addSchemaToPool(
- getClass().getResourceAsStream(Constants.DSIG_FILTER2_SCHEMA_LOCATION),
- Constants.DSIG_FILTER2_NS_URI);
- // preparse XMLDsig schema
- DOMUtils.addSchemaToPool(
- getClass().getResourceAsStream(Constants.DSIG_SCHEMA_LOCATION),
- Constants.DSIG_NS_URI);
- // preparse MOA schema
- DOMUtils.addSchemaToPool(
- getClass().getResourceAsStream(Constants.MOA_SCHEMA_LOCATION),
- Constants.MOA_NS_URI);
- grammarsInitialized = true;
- }
- }
-
- private Document parse(String fileName) throws Exception {
- return DOMUtils.parseDocument(
- new FileInputStream(fileName),
- true,
- Constants.ALL_SCHEMA_LOCATIONS,
- null);
- }
-
- public void testParseCreateXMLSignature() throws Exception {
- parse(TESTDATA_BASE + "CreateXMLSignature/TestGeneratorCX2.005.Req.xml");
- parse(TESTDATA_BASE + "CreateXMLSignature/Req000.xml");
- parse(TESTDATA_BASE + "CreateXMLSignature/Req001.xml");
- parse(TESTDATA_BASE + "CreateXMLSignature/Req002.xml");
- parse(TESTDATA_BASE + "CreateXMLSignature/Req004.xml");
- }
-
- public void testParseVerifyCMSSignature() throws Exception {
- parse(TESTDATA_BASE + "VerifyCMSSignature/Req000.xml");
- }
-
- public void testParseVerifyXMLSignature() throws Exception {
- parse(TESTDATA_BASE + "VerifyXMLSignature/Req000.xml");
- parse(TESTDATA_BASE + "VerifyXMLSignature/Req001.xml");
- parse(TESTDATA_BASE + "VerifyXMLSignature/Req002.xml");
- parse(TESTDATA_BASE + "VerifyXMLSignature/TestGeneratorVX.002.Req.xml");
- //parse(TESTDATA_BASE + "VerifyXMLSignature/TestGeneratorVX.006.Req.xml");
- parse(TESTDATA_BASE + "VerifyXMLSignature/VerifySAMLRequest.xml");
- }
-
- public void testParseInfobox() throws Exception {
- parse(TESTDATA_BASE + "Infobox/InfoboxReadResponseMOA4.xml");
- parse(TESTDATA_BASE + "Infobox/InfoboxReadResponse.xml");
- }
-
-
- private Document parsePlain(String fileName) throws Exception {
- return DOMUtils.parseDocument(
- new FileInputStream(fileName),
- false,
- null,
- null);
- }
-
- public void testValidateCreateXMLSignature() throws Exception {
- Document doc;
- boolean valid;
-
- // test a valid request
- doc = parsePlain(TESTDATA_BASE + "CreateXMLSignature/Req000.xml");
- valid =
- DOMUtils.validateElement(
- doc.getDocumentElement(),
- Constants.ALL_SCHEMA_LOCATIONS,
- null);
- assertTrue(valid);
-
- // test an invalid request
- doc = parsePlain(TESTDATA_BASE + "CreateXMLSignature/invalid.xml");
- try {
- valid =
- DOMUtils.validateElement(
- doc.getDocumentElement(),
- Constants.ALL_SCHEMA_LOCATIONS,
- null);
- fail();
- } catch (Exception e) {
- }
- }
-
- public void testGetNamespaceDeclarations() throws Exception {
- Document doc;
- NodeList nl;
- Element elem;
- Map nsDecls;
-
- doc = parse(TESTDATA_BASE + "VerifyXMLSignature/Req002.xml");
- nl = doc.getElementsByTagNameNS(Constants.DSIG_NS_URI, "Reference");
- elem = (Element) nl.item(0);
- nsDecls = DOMUtils.getNamespaceDeclarations(elem);
-
- assertEquals(2, nsDecls.size());
- assertEquals(Constants.DSIG_NS_URI, nsDecls.get("dsig"));
- assertEquals(Constants.MOA_NS_URI, nsDecls.get(""));
- }
-
-}
diff --git a/common/src/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java
deleted file mode 100644
index da6b29b1c..000000000
--- a/common/src/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package test.at.gv.egovernment.moa.util;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
-import at.gv.egovernment.moa.util.DateTimeUtils;
-
-/**
- * @author Patrick Peck
- * @version $Id$
- */
-public class DateTimeUtilsTest extends TestCase {
-
- /**
- * Constructor for DateTimeUtilsTest.
- * @param arg0
- */
- public DateTimeUtilsTest(String arg0) {
- super(arg0);
- }
-
- public void testParseDateTimeValid() throws Exception {
- Date date;
- DateFormat format = SimpleDateFormat.getDateTimeInstance();
- String dateStr;
-
- format.setTimeZone(TimeZone.getTimeZone("GMT"));
- date = DateTimeUtils.parseDateTime("+1971-12-12T06:30:15");
- date.setTime(date.getTime() + TimeZone.getDefault().getRawOffset());
- dateStr = format.format(date);
- assertEquals("12.12.1971 06:30:15", dateStr);
-
- date = DateTimeUtils.parseDateTime("2000-01-01T23:59:59.012Z");
- dateStr = format.format(date);
- assertEquals("01.01.2000 23:59:59", dateStr);
-
- date = DateTimeUtils.parseDateTime("2003-05-20T12:17:30-05:00");
- dateStr = format.format(date);
- assertEquals("20.05.2003 17:17:30", dateStr);
-
-
- date = DateTimeUtils.parseDateTime("2002-02-02T02:02:02.33+04:30");
- dateStr = format.format(date);
- assertEquals("01.02.2002 21:32:02", dateStr);
- }
-
- public void testParseDateTimeInvalid() {
- try {
- DateTimeUtils.parseDateTime("+1971-12-12T6:30:15");
- fail();
- } catch (ParseException e) {
- }
-
- try {
- DateTimeUtils.parseDateTime("2000-01-0123:59:59.999999Z");
- fail();
- } catch (ParseException e) {
- }
-
- try {
- DateTimeUtils.parseDateTime("2003-05-20T12:17:3005:00");
- fail();
- } catch (ParseException e) {
- }
-
- try {
- DateTimeUtils.parseDateTime(" 2002-02-02T02:02:02.33+04:00");
- fail();
- } catch (ParseException e) {
- }
-
- }
-
- public void testBuildDateTimeGMTMinus3() {
- String should = "2002-01-01T01:01:01-03:00";
- doTestBuildDateTime(2002, 1, 1, 1, 1, 1, "GMT-03:00", should);
- }
- public void testBuildDateTimeMEZSommerzeit() {
- String should = "2002-07-31T23:59:59+02:00";
- doTestBuildDateTime(2002, 7, 31, 23, 59, 59, "GMT+01:00", should);
- }
- public void testBuildDateTimeGMT() {
- String should = "2002-01-01T01:01:01";
- doTestBuildDateTime(2002, 1, 1, 1, 1, 1, "GMT+00:00", should);
- }
- private void doTestBuildDateTime(
- int year, int month, int day,
- int hour, int min, int sec,
- String timeZone, String dateTimeShould) {
-
- Calendar cal = new GregorianCalendar(TimeZone.getTimeZone(timeZone));
- cal.set(year,month, day, hour, min, sec);
- cal.set(Calendar.MILLISECOND, 0);
- String dateTimeBuilt = DateTimeUtils.buildDateTime(cal);
- assertEquals(dateTimeShould, dateTimeBuilt);
- }
-
-}
diff --git a/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java
deleted file mode 100644
index a6d1847ce..000000000
--- a/common/src/test/at/gv/egovernment/moa/util/KeyStoreUtilsTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package test.at.gv.egovernment.moa.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.KeyStore;
-import java.security.Security;
-import java.security.cert.X509Certificate;
-import java.util.Enumeration;
-
-import at.gv.egovernment.moa.util.KeyStoreUtils;
-
-import junit.framework.TestCase;
-
-/**
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class KeyStoreUtilsTest extends TestCase {
- private String tmpDir = "tmp/KeyStoreUtilsTest";
- private String tmpDirURL = "file:" + tmpDir;
-
- public KeyStoreUtilsTest(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception {
- Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
- new File(tmpDir).mkdirs();
- }
- protected void tearDown() throws Exception {
- new File(tmpDir).delete();
- }
- public void testCreateKeyStoreJKS() throws Exception {
- String[] certFilenames = new String[] {
- "data/test/security/server-certs/baltimore.cer"
- };
- KeyStore ks = KeyStoreUtils.createKeyStore("jks", certFilenames);
- assertEquals(1, ks.size());
- X509Certificate cert = (X509Certificate)ks.getCertificate("0");
- assertEquals(3424, cert.getSerialNumber().intValue());
- }
- public void testCreateKeyStorePKCS12() throws Exception {
- String[] certFilenames = new String[] {
- "data/test/security/server-certs/baltimore.cer"
- };
- KeyStore ks = KeyStoreUtils.createKeyStore("pkcs12", certFilenames);
- assertEquals(1, ks.size());
- X509Certificate cert = (X509Certificate)ks.getCertificate("0");
- assertEquals(3424, cert.getSerialNumber().intValue());
- }
- public void testCreateKeyStoreFromCertificateDirectory() throws Exception {
- // copy certificate files to a temporary directory,
- // omitting the "CVS" directory in the source directory
- copyCertificates("data/test/security/server-certs", tmpDir);
- KeyStore ks = KeyStoreUtils.createKeyStoreFromCertificateDirectory("jks", tmpDirURL);
- assertEquals(2, ks.size());
- X509Certificate cert0 = (X509Certificate)ks.getCertificate("0");
- X509Certificate cert1 = (X509Certificate)ks.getCertificate("1");
- assertTrue(3424 == cert0.getSerialNumber().intValue() || 3424 == cert1.getSerialNumber().intValue());
- }
- private void copyCertificates(String from, String to) throws IOException {
- String[] fromList = new File(from).list();
- for (int i = 0; i < fromList.length; i++) {
- File fromFile = new File(from + File.separator + fromList[i]);
- if (fromFile.isFile()) {
- String toFile = to + "/" + fromList[i];
- FileInputStream in = new FileInputStream(fromFile);
- FileOutputStream out = new FileOutputStream(toFile);
- for (int ch = in.read(); ch >= 0; ch = in.read())
- out.write(ch);
- out.close();
- in.close();
- }
- }
-
- }
- public void testLoadKeyStore() throws Exception {
- String keyStoreURL = "file:data/test/security/client-certs/sicher-demo(buergerkarte).p12";
- KeyStore ks = KeyStoreUtils.loadKeyStore("pkcs12", keyStoreURL, "buergerkarte");
- assertEquals(1, ks.size());
- Enumeration aliases = ks.aliases();
- String alias = (String)aliases.nextElement();
- X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
- assertEquals(new BigInteger("1044289238331").intValue(), cert.getSerialNumber().intValue());
- }
-
-}
diff --git a/common/src/test/at/gv/egovernment/moa/util/SSLUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/SSLUtilsTest.java
deleted file mode 100644
index 7e55cb7d0..000000000
--- a/common/src/test/at/gv/egovernment/moa/util/SSLUtilsTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package test.at.gv.egovernment.moa.util;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.security.KeyStore;
-import java.security.Security;
-
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLSocketFactory;
-
-import com.sun.net.ssl.HostnameVerifier;
-import com.sun.net.ssl.HttpsURLConnection;
-
-import at.gv.egovernment.moa.util.KeyStoreUtils;
-import at.gv.egovernment.moa.util.SSLUtils;
-
-import junit.framework.TestCase;
-
-/**
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class SSLUtilsTest extends TestCase {
-
- public SSLUtilsTest(String arg0) {
- super(arg0);
- }
-
-
- protected void setUp() throws Exception {
- //System.setProperty("javax.net.debug", "all");
- Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
- System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
- System.setProperty("https.cipherSuites", "SSL_DHE_DSS_WITH_DES_CBC_SHA,SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA,SSL_RSA_WITH_DES_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_EXPORT_WITH_RC4_40_MD5");
- }
-
- public void testGetSSLSocketFactoryBaltimoreOK() throws Exception {
- doTestGetSSLSocketFactory(
- "GET",
- "https://www.baltimore.com/",
- false,
- "file:data/test/security/cacerts+gt_cybertrust_root",
- "changeit",
- true);
- }
- public void testGetSSLSocketFactoryBaltimoreNOK() throws Exception {
- doTestGetSSLSocketFactory(
- "GET",
- "https://www.baltimore.com/",
- false,
- "file:data/test/security/cacerts",
- "changeit",
- false);
- }
- public void testGetSSLSocketFactoryVerisignOK() throws Exception {
- doTestGetSSLSocketFactory(
- "GET",
- "https://www.verisign.com/",
- false,
- "file:data/test/security/cacerts",
- "changeit",
- true);
- }
- public void testGetSSLSocketFactoryVerisignNoTruststoreOK() throws Exception {
- doTestGetSSLSocketFactory(
- "GET",
- "https://www.verisign.com/",
- false,
- null,
- null,
- true);
- }
- public void testGetSSLSocketFactoryLocalhostOK() throws Exception {
- String urlString = "https://localhost:8443/moa-id-auth/index.jsp";
- doTestGetSSLSocketFactory(
- "GET",
- urlString,
- true,
- "file:data/test/security/server.keystore.tomcat",
- "changeit",
- true);
- }
- public void testGetSSLSocketFactoryLocalhostNOK() throws Exception {
- String urlString = "https://localhost:8443/moa-id-auth/index.jsp";
- doTestGetSSLSocketFactory(
- "GET",
- urlString,
- true,
- null,
- null,
- false);
- }
-
- public void doTestGetSSLSocketFactory(
- String requestMethod,
- String urlString,
- boolean useHostnameVerifierHack,
- String truststoreurl,
- String trustpassword,
- boolean shouldOk
- ) throws Exception {
-
- doTestGetSSLSocketFactory(
- requestMethod, urlString, useHostnameVerifierHack, truststoreurl, trustpassword, null, null, null, shouldOk);
- }
- public void doTestGetSSLSocketFactory(
- String requestMethod,
- String urlString,
- boolean useHostnameVerifierHack,
- String truststoreurl,
- String trustpassword,
- String keystoretype,
- String keystoreurl,
- String keypassword,
- boolean shouldOk
- ) throws Exception {
-
- KeyStore truststore = null;
- if (truststoreurl != null)
- truststore = KeyStoreUtils.loadKeyStore("jks", truststoreurl, trustpassword);
- SSLSocketFactory sf = SSLUtils.getSSLSocketFactory(
- truststore, keystoretype, keystoreurl, keypassword);
- System.out.println(requestMethod + " " + urlString);
-
- URL url = new URL(urlString);
- HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
- conn.setRequestMethod(requestMethod);
- conn.setDoInput(true);
- conn.setDoOutput(true);
- conn.setUseCaches(false);
- conn.setAllowUserInteraction(false);
- conn.setSSLSocketFactory(sf);
- if (useHostnameVerifierHack)
- conn.setHostnameVerifier(new HostnameVerifierHack());
- try {
- conn.connect();
- assertTrue(shouldOk);
- assertEquals(200, conn.getResponseCode());
- conn.disconnect();
- }
- catch (SSLException ex) {
- assertFalse(shouldOk);
- }
- }
- private byte[] readTruststore(String filename) throws IOException {
- if (filename == null)
- return null;
- FileInputStream in = new FileInputStream(filename);
- byte[] buffer = new byte[in.available()];
- in.read(buffer);
- in.close();
- return buffer;
- }
- private class HostnameVerifierHack implements HostnameVerifier {
- public boolean verify(String arg0, String arg1) {
- return true;
- }
- }
-}
diff --git a/common/src/test/at/gv/egovernment/moa/util/URLDecoderTest.java b/common/src/test/at/gv/egovernment/moa/util/URLDecoderTest.java
deleted file mode 100644
index b6ea0e152..000000000
--- a/common/src/test/at/gv/egovernment/moa/util/URLDecoderTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package test.at.gv.egovernment.moa.util;
-
-import java.net.URLEncoder;
-
-import at.gv.egovernment.moa.util.FileUtils;
-import at.gv.egovernment.moa.util.URLDecoder;
-
-import junit.framework.TestCase;
-
-/*
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class URLDecoderTest extends TestCase {
-
- public void test() throws Exception {
- String s = "immerZUA0129<>%==$$%&/()@?{()=} \\\"äöüÄÖÜ?§";
- String senc = URLEncoder.encode(s);
- String sdec = URLDecoder.decode(senc, "ISO-8859-1");
- assertEquals(s, sdec);
- }
- public void testUTF8() throws Exception {
- String s = new String(FileUtils.readFile("data/test/xml/CreateXMLSignature/CreateXMLSignatureResponse.xml"));
- String senc = URLEncoder.encode(s);
- String sdec = URLDecoder.decode(senc, "UTF-8");
- String sutf8 = FileUtils.readFile("data/test/xml/CreateXMLSignature/CreateXMLSignatureResponse.xml", "UTF-8");
- assertEquals(sutf8, sdec);
- }
-}
diff --git a/common/src/test/at/gv/egovernment/moa/util/URLEncoderTest.java b/common/src/test/at/gv/egovernment/moa/util/URLEncoderTest.java
deleted file mode 100644
index 43238c51f..000000000
--- a/common/src/test/at/gv/egovernment/moa/util/URLEncoderTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package test.at.gv.egovernment.moa.util;
-
-import at.gv.egovernment.moa.util.FileUtils;
-import at.gv.egovernment.moa.util.URLDecoder;
-import at.gv.egovernment.moa.util.URLEncoder;
-import junit.framework.TestCase;
-
-/*
- * @author Paul Ivancsics
- * @version $Id$
- */
-public class URLEncoderTest extends TestCase {
-
- public void testUnchangedString() throws Exception {
- String s = "AZaz0123456789.-*_";
- String senc = URLEncoder.encode(s, "UTF-8");
- assertEquals(s, senc);
- }
- public void testAumlUTF8() throws Exception {
- String s = "ä";
- String senc = URLEncoder.encode(s, "UTF-8");
- assertEquals("%C3%A4", senc);
- }
- public void testEncodeDecode() throws Exception {
- String s = "AZaz09.-*_ <>%=$%&/()@?{}[]\\\"'äöüÄÖÜß§";
- String senc = URLEncoder.encode(s, "UTF-8");
- String sdec = URLDecoder.decode(senc, "UTF-8");
- assertEquals(s, sdec);
- }
- public void testCertInfo() throws Exception {
- String s = new String(FileUtils.readFile("data/test/xml/VerifyXMLSignature/CertInfoVerifyXMLSignatureRequest.xml", "UTF-8"));
- String senc = URLEncoder.encode(s, "UTF-8");
- String sdec = URLDecoder.decode(senc, "UTF-8");
- assertEquals(s, sdec);
- }
- /*public void testJDK14() throws Exception {
- String s = new String(FileUtils.readFile("data/test/xml/VerifyXMLSignature/CertInfoVerifyXMLSignatureRequest.xml", "UTF-8"));
- String senc = URLEncoder.encode(s, "UTF-8");
- String senc14 = java.net.URLEncoder.encode(s, "UTF-8");
- assertEquals(senc, senc14);
- }*/
-
-}
diff --git a/common/src/test/at/gv/egovernment/moa/util/XMLGrammarBuilderTest.java b/common/src/test/at/gv/egovernment/moa/util/XMLGrammarBuilderTest.java
deleted file mode 100644
index 7986fe540..000000000
--- a/common/src/test/at/gv/egovernment/moa/util/XMLGrammarBuilderTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package test.at.gv.egovernment.moa.util;
-import java.io.FileInputStream;
-import java.io.InputStream;
-
-import org.apache.xerces.parsers.DOMParser;
-import org.apache.xerces.parsers.XMLGrammarPreparser;
-import org.apache.xerces.util.SymbolTable;
-import org.apache.xerces.util.XMLGrammarPoolImpl;
-import org.apache.xerces.xni.grammars.Grammar;
-import org.apache.xerces.xni.grammars.XMLGrammarDescription;
-import org.apache.xerces.xni.parser.XMLInputSource;
-import org.xml.sax.InputSource;
-
-import test.at.gv.egovernment.moa.MOATestCase;
-
-import at.gv.egovernment.moa.util.Constants;
-
-
-/**
- * Experimentation with Xerces grammar caching.
- *
- * Used the Xerces sample 'XMLGrammarBuilder' as a starting point.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class XMLGrammarBuilderTest extends MOATestCase {
-
- private static final String GRAMMAR_POOL =
- org.apache.xerces.impl.Constants.XERCES_PROPERTY_PREFIX
- + org.apache.xerces.impl.Constants.XMLGRAMMAR_POOL_PROPERTY;
-
- protected static final String NAMESPACES_FEATURE_ID =
- "http://xml.org/sax/features/namespaces";
- protected static final String VALIDATION_FEATURE_ID =
- "http://xml.org/sax/features/validation";
- protected static final String SCHEMA_VALIDATION_FEATURE_ID =
- "http://apache.org/xml/features/validation/schema";
- protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
- "http://apache.org/xml/features/validation/schema-full-checking";
-
- private static final int BIG_PRIME = 2039;
- private SymbolTable symbolTable;
- private XMLGrammarPoolImpl grammarPool;
-
- /**
- * Constructor for XMLGrammarBuilderTest.
- * @param name
- */
- public XMLGrammarBuilderTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- XMLGrammarPreparser preparser;
-
- // set up symbol table and grammar pool
- symbolTable = new SymbolTable(BIG_PRIME);
- grammarPool = new XMLGrammarPoolImpl();
- preparser = new XMLGrammarPreparser(symbolTable);
- preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
- preparser.setProperty(GRAMMAR_POOL, grammarPool);
- preparser.setFeature(NAMESPACES_FEATURE_ID, true);
- preparser.setFeature(VALIDATION_FEATURE_ID, true);
- // now we can still do schema features just in case,
- // so long as it's our configuraiton......
- preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
- preparseSchemaResource(
- preparser,
- Constants.DSIG_SCHEMA_LOCATION,
- "/resources/schemas/xmldsig-core-schema.xsd");
- }
-
- private static Grammar preparseSchemaResource(
- XMLGrammarPreparser preparser,
- String systemId,
- String resource)
- throws Exception {
-
- InputStream is = XMLGrammarBuilderTest.class.getResourceAsStream(resource);
- return preparser.preparseGrammar(
- XMLGrammarDescription.XML_SCHEMA,
- new XMLInputSource(null, systemId, null, is, null));
- }
-
- public void testParseValidating() throws Exception {
- DOMParser parser = new DOMParser(symbolTable, grammarPool);
-
- parser.setFeature(NAMESPACES_FEATURE_ID, true);
- parser.setFeature(VALIDATION_FEATURE_ID, true);
- parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
-
- parser.parse(
- new InputSource(
- new FileInputStream(TESTDATA_ROOT + "xml/dsigTransform/base64.xml")));
- parser.getDocument();
- }
-
-}
diff --git a/common/src/test/at/gv/egovernment/moa/util/XPathUtilsTest.java b/common/src/test/at/gv/egovernment/moa/util/XPathUtilsTest.java
deleted file mode 100644
index 559494300..000000000
--- a/common/src/test/at/gv/egovernment/moa/util/XPathUtilsTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package test.at.gv.egovernment.moa.util;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-
-import test.at.gv.egovernment.moa.MOATestCase;
-
-import at.gv.egovernment.moa.util.XPathUtils;
-
-
-/**
- * @author Patrick Peck
- * @version $Id$
- */
-public class XPathUtilsTest extends MOATestCase {
-
- private Document doc1;
-
- /**
- * Constructor for XPathUtilsTest.
- * @param name
- */
- public XPathUtilsTest(String name) {
- super(name);
- }
-
- /**
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- doc1 =
- parseXml(TESTDATA_ROOT + "xml/VerifyXMLSignature/Req000.xml");
- }
-
- public void testSelectNodeList() throws Exception {
- NodeList nodes;
-
- nodes =
- XPathUtils.selectNodeList(
- doc1.getDocumentElement(),
- doc1.getDocumentElement(),
- "/VerifyXMLSignatureRequest");
- assertEquals(1, nodes.getLength());
- nodes =
- XPathUtils.selectNodeList(
- doc1.getDocumentElement(),
- "//dsig:Signature");
- assertEquals(1, nodes.getLength());
- }
-
-}
diff --git a/id.oa/.classpath b/id.oa/.classpath
deleted file mode 100644
index 5af765a17..000000000
--- a/id.oa/.classpath
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/id.oa/.cvsignore b/id.oa/.cvsignore
deleted file mode 100644
index a9a5aecf4..000000000
--- a/id.oa/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-tmp
diff --git a/id.oa/.project b/id.oa/.project
deleted file mode 100644
index e49130a5f..000000000
--- a/id.oa/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- id.oa
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.ibm.etools.ctc.serviceprojectbuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- com.ibm.etools.ctc.javaprojectnature
-
-
diff --git a/id.oa/build.xml b/id.oa/build.xml
deleted file mode 100644
index adb191e76..000000000
--- a/id.oa/build.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
- Time (hhmm): ${TSTAMP}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.oa/html/auth.jsp b/id.oa/html/auth.jsp
deleted file mode 100644
index 0b563a83e..000000000
--- a/id.oa/html/auth.jsp
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-MOA ID Auth Sample Login
-
-
-<% /** assumes moa-id-auth and oa in the same servlet container,
- and moa-id-proxy on a different fixed location */
- String authUrlPath =
- request.getScheme() + "://"
- + request.getServerName() + ":" + request.getServerPort()
- + "/moa-id-auth/";
- String proxyUrlPath = "http://10.16.126.28:9080/moa-id-proxy/";
- String oaUrlPath =
- request.getScheme() + "://"
- + request.getServerName() + ":" + request.getServerPort()
- + "/oa/";
- String params =
- "Target=gb&" +
- "OA=" + proxyUrlPath + "index.jsp";
- String urlStartAuth =
- authUrlPath +
- "StartAuthentication?" +
- params;
- String templateParam =
- "&Template=" + oaUrlPath + "AuthTemplate.jsp";
- String urlStartAuthCustom =
- urlStartAuth +
- templateParam;
- String urlSelectBKU =
- authUrlPath +
- "SelectBKU?" +
- params;
- String urlSelectBKUCustom =
- urlSelectBKU +
- templateParam +
- "&BKUSelectionTemplate=" + oaUrlPath + "BKUSelectionTemplate.jsp";
-%>
-Log in to sample application
-
-Log in to sample application using custom form
-
-Choose BKU (HTMLComplete or HTMLSelect) and log in
-
-Choose BKU (HTMLSelect) using custom form and log in
-
-">Wrong parameters example
-
-
\ No newline at end of file
diff --git a/id.oa/html/chooseBKU.jsp b/id.oa/html/chooseBKU.jsp
deleted file mode 100644
index 0135b6fdf..000000000
--- a/id.oa/html/chooseBKU.jsp
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-BKU Auswahl
-
-
-
BKU Auswahl
-
-
-
-
-
\ No newline at end of file
diff --git a/id.oa/html/form.jsp b/id.oa/html/form.jsp
deleted file mode 100644
index d439fa84d..000000000
--- a/id.oa/html/form.jsp
+++ /dev/null
@@ -1,20 +0,0 @@
-<%@ page import="java.util.*" %>
-
-
-Sample Online Application
-
-
-
-
-
\ No newline at end of file
diff --git a/id.oa/html/stateful_login.jsp b/id.oa/html/stateful_login.jsp
deleted file mode 100644
index eaede507f..000000000
--- a/id.oa/html/stateful_login.jsp
+++ /dev/null
@@ -1,29 +0,0 @@
-<%@ page import="javax.servlet.http.*" %>
-<%
- /* check request's remote IP address - must be moa-id-proxy's address */
- String remoteIPAddress = request.getRemoteAddr();
- if (! "127.0.0.1".equals(remoteIPAddress)) { /* Substitute "127.0.0.1" for moa-id-proxy's IP address */
- response.setStatus(403);
- return;
- }
-
- /* store authentication data in cookies */
- String fn = request.getParameter("FamilyName");
- String gn = request.getParameter("GivenName");
- /* set cookie domain and cookie path ! */
- String cookieDomain = ".test.test"; /* Set this to the common domain of moa-id-proxy and of the online application */
- String cookiePath = request.getContextPath(); /* Set this to the context path of the online application */
-
- Cookie cfn = new Cookie("familyname", fn);
- cfn.setDomain(cookieDomain);
- cfn.setPath(cookiePath);
- response.addCookie(cfn);
-
- Cookie cgn = new Cookie("givenname", gn);
- cgn.setDomain(cookieDomain);
- cgn.setPath(cookiePath);
- response.addCookie(cgn);
-
- /* redirect to online application's start page */
- response.sendRedirect("http://oa.test.test:8080/oa/index.jsp"); /* Substitute for URL in online application */
-%>
diff --git a/id.oa/web.xml b/id.oa/web.xml
deleted file mode 100644
index 13158fdaa..000000000
--- a/id.oa/web.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
- Sample OA
- MOA Sample OA
-
-
diff --git a/id.server/data/deploy/conf/Catalina/localhost/proxy.xml b/id.server/data/deploy/conf/Catalina/localhost/proxy.xml
deleted file mode 100644
index eef60b953..000000000
--- a/id.server/data/deploy/conf/Catalina/localhost/proxy.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/MOAIdentities.xsd b/id.server/data/deploy/conf/moa-id/MOAIdentities.xsd
deleted file mode 100644
index 91c7a6cc0..000000000
--- a/id.server/data/deploy/conf/moa-id/MOAIdentities.xsd
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
- MOAIdentities provides a mapping from identities to parameters used in the XMLLoginParameterResolver of MOA-ID
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleIdentities.xml b/id.server/data/deploy/conf/moa-id/SampleIdentities.xml
deleted file mode 100644
index fc6dc2ccf..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleIdentities.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
-
-
- 1
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration.xml b/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration.xml
deleted file mode 100644
index f8dbd4b13..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Globale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte"<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MOAIDBuergerkartePersonenbindung
-
-
-
- MOAIDBuergerkarteAuthentisierungsDaten
-
-
- MOAIDTransformAuthBlockText
- MOAIDTransformAuthBlockText_deprecated
-
-
-
- Auskommentieren, falls die in der Beispiel-Onlineapplikation definierte Transformationverwendet wird:<-->
-
-
-
-
-
-
-
- CN=zmr,OU=BMI-IV-2,O=BMI,C=AT
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitgieds der Datenschutzkommission
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitglieds der Datenschutzkommission
-
-
-
-
-
-
-
-
- Lokale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte" nur für diese Online Applikation<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- certs/ca-certs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleMOAIDConfigurationProxy.xml b/id.server/data/deploy/conf/moa-id/SampleMOAIDConfigurationProxy.xml
deleted file mode 100644
index 51d62bd72..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleMOAIDConfigurationProxy.xml
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Globale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte"<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MOAIDBuergerkartePersonenbindung
-
-
-
- MOAIDBuergerkarteAuthentisierungsDaten
-
-
- MOAIDTransformAuthBlockText
- MOAIDTransformAuthBlockText_deprecated
-
-
-
- Auskommentieren, falls die in der Beispiel-Onlineapplikation definierte Transformationverwendet wird:<-->
-
-
-
-
-
-
-
- CN=zmr,OU=BMI-IV-2,O=BMI,C=AT
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitgieds der Datenschutzkommission
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitglieds der Datenschutzkommission
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Lokale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte" nur für diese Online Applikation<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- certs/ca-certs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration_withTestBKs.xml b/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration_withTestBKs.xml
deleted file mode 100644
index 8a9898792..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration_withTestBKs.xml
+++ /dev/null
@@ -1,118 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Globale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte"<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MOAIDBuergerkartePersonenbindungMitTestkarten
-
-
-
-
- MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten
-
-
- MOAIDTransformAuthBlockText
- MOAIDTransformAuthBlockText_deprecated
-
-
-
- Auskommentieren, falls die in der Beispiel-Onlineapplikation definierte Transformationverwendet wird:<-->
-
-
-
-
-
-
-
- CN=zmr,OU=BMI-IV-2,O=BMI,C=AT
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitgieds der Datenschutzkommission
-
- CN=Test Signaturdienst Personenbindung,OU=IKT-Stabsstelle des Bundes,O=Bundeskanzleramt,C=AT
-
-
-
-
-
-
-
-
-
- Lokale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte" nur für diese Online Applikation<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- certs/ca-certs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration_withTestBKsProxy.xml b/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration_withTestBKsProxy.xml
deleted file mode 100644
index b859fe758..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleMOAIDConfiguration_withTestBKsProxy.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Globale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte"<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MOAIDBuergerkartePersonenbindungMitTestkarten
-
-
-
-
- MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten
-
-
- MOAIDTransformAuthBlockText
- MOAIDTransformAuthBlockText_deprecated
-
-
-
- Auskommentieren, falls die in der Beispiel-Onlineapplikation definierte Transformationverwendet wird:<-->
-
-
-
-
-
-
-
- CN=zmr,OU=BMI-IV-2,O=BMI,C=AT
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitgieds der Datenschutzkommission
-
- CN=Test Signaturdienst Personenbindung,OU=IKT-Stabsstelle des Bundes,O=Bundeskanzleramt,C=AT
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Lokale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte" nur für diese Online Applikation<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- certs/ca-certs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration.xml b/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration.xml
deleted file mode 100644
index e5b49bbe1..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Globale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte"<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MOAIDBuergerkartePersonenbindung
-
-
-
- MOAIDBuergerkarteAuthentisierungsDaten
-
-
- MOAIDTransformAuthBlockText
- MOAIDTransformAuthBlockText_deprecated
-
-
-
- Auskommentieren, falls die in der Beispiel-Onlineapplikation definierte Transformationverwendet wird:<-->
-
-
-
-
-
-
-
- CN=zmr,OU=BMI-IV-2,O=BMI,C=AT
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitgieds der Datenschutzkommission
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitglieds der Datenschutzkommission
-
-
-
-
-
-
-
-
-
-
-
- 468924i
-
- Lokale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte" nur für diese Online Applikation<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- certs/ca-certs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfigurationProxy.xml b/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfigurationProxy.xml
deleted file mode 100644
index 4e7a8ae54..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfigurationProxy.xml
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Globale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte"<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MOAIDBuergerkartePersonenbindung
-
-
-
- MOAIDBuergerkarteAuthentisierungsDaten
-
-
- MOAIDTransformAuthBlockText
- MOAIDTransformAuthBlockText_deprecated
-
-
-
- Auskommentieren, falls die in der Beispiel-Onlineapplikation definierte Transformationverwendet wird:<-->
-
-
-
-
-
-
-
- CN=zmr,OU=BMI-IV-2,O=BMI,C=AT
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitgieds der Datenschutzkommission
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitglieds der Datenschutzkommission
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 468924i
-
- Lokale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte" nur für diese Online Applikation<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- certs/ca-certs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration_withTestBKs.xml b/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration_withTestBKs.xml
deleted file mode 100644
index 1d5c410ec..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration_withTestBKs.xml
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Globale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte"<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MOAIDBuergerkartePersonenbindungMitTestkarten
-
-
-
-
- MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten
-
-
- MOAIDTransformAuthBlockText
- MOAIDTransformAuthBlockText_deprecated
-
-
-
- Auskommentieren, falls die in der Beispiel-Onlineapplikation definierte Transformationverwendet wird:<-->
-
-
-
-
-
-
-
- CN=zmr,OU=BMI-IV-2,O=BMI,C=AT
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitgieds der Datenschutzkommission
-
- CN=Test Signaturdienst Personenbindung,OU=IKT-Stabsstelle des Bundes,O=Bundeskanzleramt,C=AT
-
-
-
-
-
-
-
-
-
-
-
-
- 468924i
-
- Lokale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte" nur für diese Online Applikation<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- certs/ca-certs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration_withTestBKsProxy.xml b/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration_withTestBKsProxy.xml
deleted file mode 100644
index 2afa97e77..000000000
--- a/id.server/data/deploy/conf/moa-id/SampleMOAWIDConfiguration_withTestBKsProxy.xml
+++ /dev/null
@@ -1,145 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- Globale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte"<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MOAIDBuergerkartePersonenbindungMitTestkarten
-
-
-
-
- MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten
-
-
- MOAIDTransformAuthBlockText
- MOAIDTransformAuthBlockText_deprecated
-
-
-
- Auskommentieren, falls die in der Beispiel-Onlineapplikation definierte Transformationverwendet wird:<-->
-
-
-
-
-
-
-
- CN=zmr,OU=BMI-IV-2,O=BMI,C=AT
-
- T=Dr.,CN=Nikolaus Schwab,O=BM f. Inneres i.A. des gf. Mitgieds der Datenschutzkommission
-
- CN=Test Signaturdienst Personenbindung,OU=IKT-Stabsstelle des Bundes,O=Bundeskanzleramt,C=AT
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 468924i
-
- Lokale Templates zum Anpassen der Seiten "Auswahl der Bürgerkartenumgebung" und
- "Anmeldung mit Bürgerkarte" nur für diese Online Applikation<-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- certs/ca-certs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/log4j.properties b/id.server/data/deploy/conf/moa-id/log4j.properties
deleted file mode 100644
index debdb146c..000000000
--- a/id.server/data/deploy/conf/moa-id/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# commons-logging setup
-org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory
-
-# define log4j root loggers
-log4j.rootLogger=info, stdout, R
-log4j.logger.moa=info
-log4j.logger.moa.spss.server=info
-log4j.logger.iaik.server=info
-log4j.logger.moa.id.auth=info
-log4j.logger.moa.id.proxy=info
-
-# configure the stdout appender
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-#log4j.appender.stdout.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20c | %10t | %m%n
-log4j.appender.stdout.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20.20c | %10t | %m%n
-
-# configure the rolling file appender (R)
-log4j.appender.R=org.apache.log4j.RollingFileAppender
-log4j.appender.R.File=${catalina.home}/logs/moa-id.log
-log4j.appender.R.MaxFileSize=10000KB
-log4j.appender.R.MaxBackupIndex=1
-log4j.appender.R.layout=org.apache.log4j.PatternLayout
-log4j.appender.R.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %t | %m%n
-
diff --git a/id.server/data/deploy/conf/moa-id/oa/BasicOAConfiguration.xml b/id.server/data/deploy/conf/moa-id/oa/BasicOAConfiguration.xml
deleted file mode 100644
index fc99cea79..000000000
--- a/id.server/data/deploy/conf/moa-id/oa/BasicOAConfiguration.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- stateless
-
- MOAFamilyName
- MOAGivenName
-
-
diff --git a/id.server/data/deploy/conf/moa-id/oa/HeaderOAConfiguration.xml b/id.server/data/deploy/conf/moa-id/oa/HeaderOAConfiguration.xml
deleted file mode 100644
index 4d34c3646..000000000
--- a/id.server/data/deploy/conf/moa-id/oa/HeaderOAConfiguration.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- stateless
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/oa/ParamOAConfiguration.xml b/id.server/data/deploy/conf/moa-id/oa/ParamOAConfiguration.xml
deleted file mode 100644
index 979faca95..000000000
--- a/id.server/data/deploy/conf/moa-id/oa/ParamOAConfiguration.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- stateless
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-id/oa/SampleOAConfiguration.xml b/id.server/data/deploy/conf/moa-id/oa/SampleOAConfiguration.xml
deleted file mode 100644
index edbfe7aa5..000000000
--- a/id.server/data/deploy/conf/moa-id/oa/SampleOAConfiguration.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- stateless
-
- MOAFamilyName
- MOAGivenName
-
-
diff --git a/id.server/data/deploy/conf/moa-id/oa/SamplewbPKOAConfiguration.xml b/id.server/data/deploy/conf/moa-id/oa/SamplewbPKOAConfiguration.xml
deleted file mode 100644
index 2cff3bd67..000000000
--- a/id.server/data/deploy/conf/moa-id/oa/SamplewbPKOAConfiguration.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- stateless
-
- MOAWBPK
- MOAGivenName
-
-
diff --git a/id.server/data/deploy/conf/moa-id/sampleTemplates/LIESMICH_TEMPLATES.txt b/id.server/data/deploy/conf/moa-id/sampleTemplates/LIESMICH_TEMPLATES.txt
deleted file mode 100644
index 01f724cc4..000000000
--- a/id.server/data/deploy/conf/moa-id/sampleTemplates/LIESMICH_TEMPLATES.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-TEMPLATES:
-==========
-Zweck:
-------
-Mithilfe von Templates können Sie das Aussehen der Seiten
-"Auswahl der Bürgerkartenumgebung" sowie "Anmeldung mit Bürgerkarte"
-anpassen. Damit können Sie zusätzliche Hintergrundinformationen (Wozu
-dient die Anmeldung, etc.) zu diesen Seiten hinzufügen und das Layout an
-Ihre sonstigen Anwendungen anpassen.
-
-Wenn Sie in den Beispielkonfigurationsdateien die Elmente
-"AuthComponent/Templates" oder "OnlineApplication/AuthComponent/Templates"
-aktivieren, dann werden die in diesem Verzeichnis enthaltenen Beispieltemplates
-geladen. Es sind dies sehr einfache Templates, die nur das Laden über die
-Konfigurationsdatei demonstrieren sollen. (Das Laden der Templates über
-die Konfigurationsdatei steht erst ab Version 1.3.1 zur Verfügung).
-Etwas aufwendigere Templates (mit CSS) finden Sie als eigene Webapplikation im
-Verzeichnis "/auth/templates" der entpackten Distribution.
-
-Nähere Informationen zu den Templates finden Sie im MOA-ID-Konfigurationshandbuch.
-
diff --git a/id.server/data/deploy/conf/moa-id/sampleTemplates/SampleBKUSelectionTemplate.html b/id.server/data/deploy/conf/moa-id/sampleTemplates/SampleBKUSelectionTemplate.html
deleted file mode 100644
index 2f2ea6552..000000000
--- a/id.server/data/deploy/conf/moa-id/sampleTemplates/SampleBKUSelectionTemplate.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-MOA ID - Auswahl der B&uuuml;rgerkartenumgebung
-
-
-
-
-
-
-
-
Auswahl der Bürgerkartenumgebung
-
-
-
Sie haben sich für Anmeldung mit Ihrer Bürgerkarte entschieden. Da es verschiedene Formen der Bürgerkarte gibt, müssen Sie nun wählen, welche Sie bei der Anmeldung verwenden wollen.
Sicherer Zugang zur Online-Anwendung mit Bürgerkarte
-
-
-
-Der identifizierte Zugang erfolgt über die Module für Online Applikationen (MOA) unter Verwendung einer Bürgerkarte und deren Signaturfunktion.
-
-
-
Wenn Sie in Folge die Schaltfläche "Anmeldung mit Bürgerkarte"
-aktivieren, so werden Sie zur Signatur der Anmeldedaten aufgefordert. Wenn Sie diese
-signieren, so werden Sie zur Online-Anwendung weitergeleitet und angemeldet.
Bitte bestätigen Sie mit Ihrer Unterschrift folgende Angaben:
-
-
-
- Name:
-
-
-
-
-
-
-
- Geburtsdatum:
-
-
- ..
-
-
-
-
- Applikation:
-
-
-
-
-
-
-
-
- Geschäftsbereich:
-
-
-
-
-
-
-
-
- Anmeldeserver:
-
-
-
-
-
-
-
- Datum:
-
-
- ..
-
-
-
-
- Uhrzeit:
-
-
- ::
-
-
-
-
-
- wbPK (*):
-
-
-
-
-
-
-
-
-
-
-
(*): Das wirtschaftsbereichsspezifische Personenkennzeichen (wbPK) wird aus den jeweiligen Stammzahlen des Bürgers und des Wirtschaftsunternehmens berechnet und ermöglicht eine eindeutige Zuordnung des Bürgers zum Wirtschaftsunternehmen.
Mit meiner elektronischen Signatur beantrage ich,
-
- ,
-geboren am
-.., den Zugang zur gesicherten Anwendung.
-
-
Datum und Uhrzeit: .., ::
-
-
-
wbPK(*):
-
-
-
-
(*) wbPK: Das wirtschaftsbereichsspezifische Personenkennzeichen wird aus den jeweiligen Stammzahlen des Bürgers und des Wirtschaftsunternehmens berechnet und ermöglicht eine eindeutige Zuordnung des Bürgers zum Wirtschaftsunternehmen.
Mit meiner elektronischen Signatur beantrage ich, ,
- geboren am
- .
- .
- ,
- den Zugang zur gesicherten Anwendung.
-
-
Datum und Uhrzeit:
- .
- .
- ,
- :
- :
-
-
-
-
wbPK(*):
-
-
-
-
(*) wbPK: Das wirtschaftsbereichsspezifische
- Personenkennzeichen wird aus den jeweiligen Stammzahlen des Bürgers und des Wirtschaftsunternehmens
- berechnet und ermöglicht eine eindeutige Zuordnung des Bürgers zum Wirtschaftsunternehmen.
Bitte bestätigen Sie mit Ihrer Unterschrift folgende Angaben:
-
-
-
- Name:
-
-
-
-
-
-
-
- Geburtsdatum:
-
-
- .
- .
-
-
-
-
-
- Applikation:
-
-
-
-
-
-
-
-
- Geschäftsbereich:
-
-
-
-
-
-
-
-
- Anmeldeserver:
-
-
-
-
-
-
-
- Datum:
-
-
- .
- .
-
-
-
-
-
- Uhrzeit:
-
-
- :
- :
-
-
-
-
-
-
- wbPK (*):
-
-
-
-
-
-
-
-
-
-
-
(*): Das wirtschaftsbereichsspezifische Personenkennzeichen (wbPK) wird aus den jeweiligen
- Stammzahlen des Bürgers und des Wirtschaftsunternehmens berechnet und ermöglicht eine eindeutige
- Zuordnung des Bürgers zum Wirtschaftsunternehmen.
Bitte bestätigen Sie mit Ihrer Unterschrift folgende Angaben:
-
-
-
- Name:
-
-
-
-
-
-
-
- Geburtsdatum:
-
-
- ..
-
-
-
-
- Applikation:
-
-
-
-
-
-
-
-
- Geschäftsbereich:
-
-
-
-
-
-
-
-
- Anmeldeserver:
-
-
-
-
-
-
-
- Datum:
-
-
- ..
-
-
-
-
- Uhrzeit:
-
-
- ::
-
-
-
-
-
- wbPK (*):
-
-
-
-
-
-
-
-
-
-
-
(*): Das wirtschaftsbereichsspezifische Personenkennzeichen (wbPK) wird aus den jeweiligen Stammzahlen des Bürgers und des Wirtschaftsunternehmens berechnet und ermöglicht eine eindeutige Zuordnung des Bürgers zum Wirtschaftsunternehmen.
Mit meiner elektronischen Signatur beantrage ich,
-
- ,
-geboren am
-.., den Zugang zur gesicherten Anwendung.
-
-
Datum und Uhrzeit: .., ::
-
-
-
wbPK(*):
-
-
-
-
(*) wbPK: Das wirtschaftsbereichsspezifische Personenkennzeichen wird aus den jeweiligen Stammzahlen des Bürgers und des Wirtschaftsunternehmens berechnet und ermöglicht eine eindeutige Zuordnung des Bürgers zum Wirtschaftsunternehmen.
Mit meiner elektronischen Signatur beantrage ich, ,
- geboren am
- .
- .
- ,
- den Zugang zur gesicherten Anwendung.
-
-
Datum und Uhrzeit:
- .
- .
- ,
- :
- :
-
-
-
-
wbPK(*):
-
-
-
-
(*) wbPK: Das wirtschaftsbereichsspezifische
- Personenkennzeichen wird aus den jeweiligen Stammzahlen des Bürgers und des Wirtschaftsunternehmens
- berechnet und ermöglicht eine eindeutige Zuordnung des Bürgers zum Wirtschaftsunternehmen.
Bitte bestätigen Sie mit Ihrer Unterschrift folgende Angaben:
-
-
-
- Name:
-
-
-
-
-
-
-
- Geburtsdatum:
-
-
- .
- .
-
-
-
-
-
- Applikation:
-
-
-
-
-
-
-
-
- Geschäftsbereich:
-
-
-
-
-
-
-
-
- Anmeldeserver:
-
-
-
-
-
-
-
- Datum:
-
-
- .
- .
-
-
-
-
-
- Uhrzeit:
-
-
- :
- :
-
-
-
-
-
-
- wbPK (*):
-
-
-
-
-
-
-
-
-
-
-
(*): Das wirtschaftsbereichsspezifische Personenkennzeichen (wbPK) wird aus den jeweiligen
- Stammzahlen des Bürgers und des Wirtschaftsunternehmens berechnet und ermöglicht eine eindeutige
- Zuordnung des Bürgers zum Wirtschaftsunternehmen.
-
-
-
-
-
-
-
-
-
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/moa-ssl-kunde1(pwd=kunde1).p12 b/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/moa-ssl-kunde1(pwd=kunde1).p12
deleted file mode 100644
index 33f76bf9c..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/moa-ssl-kunde1(pwd=kunde1).p12 and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/moa-ssl-kunde1.der b/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/moa-ssl-kunde1.der
deleted file mode 100644
index b6091332c..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/moa-ssl-kunde1.der and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/trustedServers(pwd=servers).keystore b/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/trustedServers(pwd=servers).keystore
deleted file mode 100644
index 9c6c55359..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/customer1/trustedServers(pwd=servers).keystore and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/moa-ssl-kunde2(pwd=kunde2).p12 b/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/moa-ssl-kunde2(pwd=kunde2).p12
deleted file mode 100644
index ec7bf8e48..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/moa-ssl-kunde2(pwd=kunde2).p12 and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/moa-ssl-kunde2.der b/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/moa-ssl-kunde2.der
deleted file mode 100644
index 20bc38e14..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/moa-ssl-kunde2.der and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/trustedServers(pwd=servers).keystore b/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/trustedServers(pwd=servers).keystore
deleted file mode 100644
index d32a22f0f..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/customer2/trustedServers(pwd=servers).keystore and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/server/moa-ssl-server(pwd=server).p12 b/id.server/data/deploy/conf/moa-spss/sslKeys/server/moa-ssl-server(pwd=server).p12
deleted file mode 100644
index af524d060..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/server/moa-ssl-server(pwd=server).p12 and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/server/moa-ssl-server.der b/id.server/data/deploy/conf/moa-spss/sslKeys/server/moa-ssl-server.der
deleted file mode 100644
index c3b3003d9..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/server/moa-ssl-server.der and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/tomcat/tomcat(pwd=server).keystore b/id.server/data/deploy/conf/moa-spss/sslKeys/tomcat/tomcat(pwd=server).keystore
deleted file mode 100644
index 780e58934..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/tomcat/tomcat(pwd=server).keystore and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/sslKeys/tomcat/trustedClients(pwd=clients).keystore b/id.server/data/deploy/conf/moa-spss/sslKeys/tomcat/trustedClients(pwd=clients).keystore
deleted file mode 100644
index 908e00b42..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/sslKeys/tomcat/trustedClients(pwd=clients).keystore and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20011130-20041130.SerNo01f6(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20011130-20041130.SerNo01f6(SecureSignatureKeypair).cer
deleted file mode 100644
index d361d919f..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20011130-20041130.SerNo01f6(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20011215-20041215.SerNo021e(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20011215-20041215.SerNo021e(SecureSignatureKeypair).cer
deleted file mode 100644
index ad13d7b28..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20011215-20041215.SerNo021e(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo0291(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo0291(SecureSignatureKeypair).cer
deleted file mode 100644
index f9f27442b..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo0291(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo210d(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo210d(SecureSignatureKeypair).cer
deleted file mode 100644
index b6f39e354..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo210d(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20041201-20141201.SerNoE243(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20041201-20141201.SerNoE243(SecureSignatureKeypair).cer
deleted file mode 100644
index f9fef65fc..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-01.20041201-20141201.SerNoE243(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-02.20041203-20141203.SerNoE248(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-02.20041203-20141203.SerNoE248(SecureSignatureKeypair).cer
deleted file mode 100644
index 36a442b89..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-Qual-02.20041203-20141203.SerNoE248(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-TrustSignTest-Enc-01-SN0450(CertifiedKeypair_alt).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-TrustSignTest-Enc-01-SN0450(CertifiedKeypair_alt).cer
deleted file mode 100644
index 836ba3767..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-TrustSignTest-Enc-01-SN0450(CertifiedKeypair_alt).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-TrustSignTest-Sig-01-SN0588(SecureSignatureKeypair_alt).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-TrustSignTest-Sig-01-SN0588(SecureSignatureKeypair_alt).cer
deleted file mode 100644
index 28cb48bb0..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-TrustSignTest-Sig-01-SN0588(SecureSignatureKeypair_alt).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01-20011201-20041201.SerNo0213(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01-20011201-20041201.SerNo0213(CertifiedKeypair).cer
deleted file mode 100644
index 289fc2198..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01-20011201-20041201.SerNo0213(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20010427-20040427.SerNo006f(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20010427-20040427.SerNo006f(CertifiedKeypair).cer
deleted file mode 100644
index b7d4b08a6..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20010427-20040427.SerNo006f(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0213(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0213(CertifiedKeypair).cer
deleted file mode 100644
index 289fc2198..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0213(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0218(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0218(CertifiedKeypair).cer
deleted file mode 100644
index 69de75609..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0218(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20040326-20070326.SerNo6632(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20040326-20070326.SerNo6632(CertifiedKeypair).cer
deleted file mode 100644
index 8c434777e..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20040326-20070326.SerNo6632(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20041201-20141201.SerNoe242(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20041201-20141201.SerNoe242(CertifiedKeypair).cer
deleted file mode 100644
index efa28178e..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-01.20041201-20141201.SerNoe242(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-03.20050817-20150817.SerNo016c1e.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-03.20050817-20150817.SerNo016c1e.cer
deleted file mode 100644
index 33e776369..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/A-Trust-nQual-03.20050817-20150817.SerNo016c1e.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/C=AT,O=Hauptverband oesterr. Sozialvers.,CN=Root-CA 1-2045.der b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/C=AT,O=Hauptverband oesterr. Sozialvers.,CN=Root-CA 1-2045.der
deleted file mode 100644
index 3be7b6a06..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/C=AT,O=Hauptverband oesterr. Sozialvers.,CN=Root-CA 1-2045.der and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/Stabsstelle-TestCACrypt-SN04(CertifiedKeypair).der b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/Stabsstelle-TestCACrypt-SN04(CertifiedKeypair).der
deleted file mode 100644
index d3c213711..000000000
--- a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/Stabsstelle-TestCACrypt-SN04(CertifiedKeypair).der
+++ /dev/null
@@ -1,22 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDljCCAwOgAwIBAgIBBDAJBgUrDgMCHQUAMHQxCzAJBgNVBAYTAkFUMSwwKgYD
-VQQKEyNTdGFic3RlbGxlIElLVC1TdHJhdGVnaWUgZGVzIEJ1bmRlczEeMBwGA1UE
-CxMVVGVjaG5payB1bmQgU3RhbmRhcmRzMRcwFQYDVQQDEw5UZXN0IENBIC0gUm9v
-dDAeFw0wNDA1MTgxMzQ1NTdaFw0wOTEyMzEyMjU5MzBaMIGGMQswCQYDVQQGEwJB
-VDEsMCoGA1UEChMjU3RhYnN0ZWxsZSBJS1QtU3RyYXRlZ2llIGRlcyBCdW5kZXMx
-HjAcBgNVBAsTFVRlY2huaWsgdW5kIFN0YW5kYXJkczEpMCcGA1UEAxQgVGVzdCBD
-QSAtIFZlcnNjaGz8c3NlbHVuZyBC/HJnZXIwgZ8wDQYJKoZIhvcNAQEBBQADgY0A
-MIGJAoGBALmykoSgYUpJiaK5NlC5jTcMQikEIB6kOdS7e82DBbT5G13zQeuiNBA2
-KzLMPMBK62Go+ZV8w94N5cSm2auuempVAHNF80ao9G3wYgK0xOVZXvf/145o8TIw
-StPPckmVPL2OPa8/DIB8tqNjblFxy+XcBnTQMLKaxYSzwA/zULoNAgMBAAGjggEr
-MIIBJzAOBgNVHQ8BAf8EBAMCAcYwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4E
-FgQUjRMKvtgH3PngerFS/Rt+vuEDbLMwXQYDVR0gBFYwVDBSBgwrBgEEAZUSAQID
-AQEwQjBABggrBgEFBQcCAjA0GjJEaWVzZXMgWmVydGlmaWthdCBpc3QgbnVyIGb8
-ciBUZXN0endlY2tlIGdlZWlnbmV0LjA5BgNVHR8EMjAwMC6gLKAqhihodHRwOi8v
-bGFicy5jaW8uZ3YuYXQvdGVtcC9jcmxzL3Jvb3QuY3JsMBQGByooAAoBAQEECQwH
-QktBLUlLVDARBglghkgBhvhCAQEEBAMCAQIwHwYDVR0jBBgwFoAUZWxSwiqQLpxu
-4vk3Op4dYHG46XswCQYFKw4DAh0FAAOBgQAnuY7RPFXLpO2hb3h1B0cy5p861j6E
-eD+c/ZKAGqIh4kh3A65D8Zl90GSv9vV4L03dnN5hc7rm/bwKzDI57/PI2dL0H/S4
-OOl4tt4fZmjN8Xrv3oJxNEa+6AJ8TGCcouc/Eqxnpc0SxkP6UQrA8J8RM/8fk05U
-DAyTZbTQ5wPIhA==
------END CERTIFICATE-----
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/Stabsstelle-TestCASig-SN03(SecureSignatureKeypair).der b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/Stabsstelle-TestCASig-SN03(SecureSignatureKeypair).der
deleted file mode 100644
index 807fa786c..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/Stabsstelle-TestCASig-SN03(SecureSignatureKeypair).der and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Enc-01SN16f8(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Enc-01SN16f8(CertifiedKeypair).cer
deleted file mode 100644
index fc5bd433b..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Enc-01SN16f8(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Enc-01SN4848(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Enc-01SN4848(CertifiedKeypair).cer
deleted file mode 100644
index f3cf5e676..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Enc-01SN4848(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Sig-01SN16f9(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Sig-01SN16f9(SecureSignatureKeypair).cer
deleted file mode 100644
index 28fbdf42f..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Sig-01SN16f9(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Sig-01SN484a(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Sig-01SN484a(SecureSignatureKeypair).cer
deleted file mode 100644
index c9da41583..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/a-sign-TEST-Premium-Sig-01SN484a(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom.A1 Signatur.20040326-20140326.SerNo6646(SecureSignatureKeypair_CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom.A1 Signatur.20040326-20140326.SerNo6646(SecureSignatureKeypair_CertifiedKeypair).cer
deleted file mode 100644
index 06b40aa67..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom.A1 Signatur.20040326-20140326.SerNo6646(SecureSignatureKeypair_CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom_A1-Signatur_20060912-20110912_SerNo027866.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom_A1-Signatur_20060912-20110912_SerNo027866.cer
deleted file mode 100644
index 7e9fd5b0b..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom_A1-Signatur_20060912-20110912_SerNo027866.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom_A1-Signatur_20070501-20120501_SerNo6650.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom_A1-Signatur_20070501-20120501_SerNo6650.cer
deleted file mode 100644
index da38ce028..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenMitTestkarten/mobilkom_A1-Signatur_20070501-20120501_SerNo6650.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20011130-20041130.SerNo01f6(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20011130-20041130.SerNo01f6(SecureSignatureKeypair).cer
deleted file mode 100644
index d361d919f..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20011130-20041130.SerNo01f6(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20011215-20041215.SerNo021e(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20011215-20041215.SerNo021e(SecureSignatureKeypair).cer
deleted file mode 100644
index ad13d7b28..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20011215-20041215.SerNo021e(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo0291(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo0291(SecureSignatureKeypair).cer
deleted file mode 100644
index f9f27442b..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo0291(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo210d(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo210d(SecureSignatureKeypair).cer
deleted file mode 100644
index b6f39e354..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20020207-20050207.SerNo210d(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20041201-20141201.SerNoE243(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20041201-20141201.SerNoE243(SecureSignatureKeypair).cer
deleted file mode 100644
index f9fef65fc..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-01.20041201-20141201.SerNoE243(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-02.20041203-20141203.SerNoE248(SecureSignatureKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-02.20041203-20141203.SerNoE248(SecureSignatureKeypair).cer
deleted file mode 100644
index 36a442b89..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-Qual-02.20041203-20141203.SerNoE248(SecureSignatureKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01-20011201-20041201.SerNo0213(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01-20011201-20041201.SerNo0213(CertifiedKeypair).cer
deleted file mode 100644
index 289fc2198..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01-20011201-20041201.SerNo0213(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20010427-20040427.SerNo006f(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20010427-20040427.SerNo006f(CertifiedKeypair).cer
deleted file mode 100644
index b7d4b08a6..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20010427-20040427.SerNo006f(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0213(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0213(CertifiedKeypair).cer
deleted file mode 100644
index 289fc2198..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0213(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0218(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0218(CertifiedKeypair).cer
deleted file mode 100644
index 69de75609..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20011212-20041212.SerNo0218(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20040326-20070326.SerNo6632(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20040326-20070326.SerNo6632(CertifiedKeypair).cer
deleted file mode 100644
index 8c434777e..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20040326-20070326.SerNo6632(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20041201-20141201.SerNoe242(CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20041201-20141201.SerNoe242(CertifiedKeypair).cer
deleted file mode 100644
index efa28178e..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-01.20041201-20141201.SerNoe242(CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-03.20050817-20150817.SerNo016c1e.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-03.20050817-20150817.SerNo016c1e.cer
deleted file mode 100644
index 33e776369..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/A-Trust-nQual-03.20050817-20150817.SerNo016c1e.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/C=AT,O=Hauptverband oesterr. Sozialvers.,CN=Root-CA 1-2045.der b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/C=AT,O=Hauptverband oesterr. Sozialvers.,CN=Root-CA 1-2045.der
deleted file mode 100644
index 3be7b6a06..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/C=AT,O=Hauptverband oesterr. Sozialvers.,CN=Root-CA 1-2045.der and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom.A1 Signatur.20040326-20140326.SerNo6646(SecureSignatureKeypair_CertifiedKeypair).cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom.A1 Signatur.20040326-20140326.SerNo6646(SecureSignatureKeypair_CertifiedKeypair).cer
deleted file mode 100644
index 06b40aa67..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom.A1 Signatur.20040326-20140326.SerNo6646(SecureSignatureKeypair_CertifiedKeypair).cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom_A1-Signatur_20060912-20110912_SerNo027866.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom_A1-Signatur_20060912-20110912_SerNo027866.cer
deleted file mode 100644
index 7e9fd5b0b..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom_A1-Signatur_20060912-20110912_SerNo027866.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom_A1-Signatur_20070501-20120501_SerNo6650.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom_A1-Signatur_20070501-20120501_SerNo6650.cer
deleted file mode 100644
index da38ce028..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkarteAuthentisierungsDatenOhneTestkarten/mobilkom_A1-Signatur_20070501-20120501_SerNo6650.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungMitTestkarten/Nikolaus_Schwab.20040219-20070219.SerNo5C39.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungMitTestkarten/Nikolaus_Schwab.20040219-20070219.SerNo5C39.cer
deleted file mode 100644
index 376d0753f..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungMitTestkarten/Nikolaus_Schwab.20040219-20070219.SerNo5C39.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungMitTestkarten/a-sign-corporate-light-03-20051114-20151114.SerNo01AAED.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungMitTestkarten/a-sign-corporate-light-03-20051114-20151114.SerNo01AAED.cer
deleted file mode 100644
index 5171276f4..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungMitTestkarten/a-sign-corporate-light-03-20051114-20151114.SerNo01AAED.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungOhneTestkarten/Nikolaus_Schwab.20040219-20070219.SerNo5C39.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungOhneTestkarten/Nikolaus_Schwab.20040219-20070219.SerNo5C39.cer
deleted file mode 100644
index 376d0753f..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungOhneTestkarten/Nikolaus_Schwab.20040219-20070219.SerNo5C39.cer and /dev/null differ
diff --git a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungOhneTestkarten/a-sign-corporate-light-03-20051114-20151114.SerNo01AAED.cer b/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungOhneTestkarten/a-sign-corporate-light-03-20051114-20151114.SerNo01AAED.cer
deleted file mode 100644
index 5171276f4..000000000
Binary files a/id.server/data/deploy/conf/moa-spss/trustprofiles/MOAIDBuergerkartePersonenbindungOhneTestkarten/a-sign-corporate-light-03-20051114-20151114.SerNo01AAED.cer and /dev/null differ
diff --git a/id.server/data/deploy/templates/LIESMICH_TEMPLATES.txt b/id.server/data/deploy/templates/LIESMICH_TEMPLATES.txt
deleted file mode 100644
index e23ebad6e..000000000
--- a/id.server/data/deploy/templates/LIESMICH_TEMPLATES.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-TEMPLATES:
-==========
-Zweck:
-------
-Mithilfe von Templates können Sie das Aussehen der Seiten
-"Auswahl der Bürgerkartenumgebung" sowie "Anmeldung mit Bürgerkarte"
-anpassen. Damit können Sie zusätzliche Hintergrundinformationen (Wozu
-dient die Anmeldung, etc.) zu diesen Seiten hinzufügen und das Layout an
-Ihre sonstigen Anwendungen anpassen.
-
-Wird kein Template mit den Parametern Template und BKUSelectionTemplate
-angegeben, so wird defaultmäßig jew. eine schlichte "neutrale" Variante
-angezeigt.
-
-Bei der Erstellung von Template muss die Form gemäß MOA-ID Dokumentation
-Abschnitt: "Aufruf von MOA-ID" (id-anwendung_1.htm) eingehalten werden.
-
-Templates können Grundsätzlich von jeder HTTP Adresse abgerufen
-werden, d.h. sie können auf einen belibigen Webserver abgelegt werden.
-
-
-Anwendung des Beispiels:
-------------------------
-Wenn Sie keinen anderen Webserver zum Ablegen der Templates verwenden möchten,
-so kann die Webcontainer Fähigkeit von Tomcat für die Ablage der HTML-Templates
-genutzt werden. Ein einfaches Beispiel mit den beiden Templates
-"SampleBKUSelectionTemplate.html" sowie "SampleTemplate.html" findet sich im
-WAR Archiv moaid-templates.war
-
-
-Wenn dieses WAR Archiv in das webapps Verzeichnis von Tomcat gestellt wird, so
-wird diese automatisch entpackt und deployed. In Folge können Sie die Template
-Dateien per Parameter beim Aufruf von MOA-ID angeben.
-
-Beispiel Link mit Einsatz von Template:
-https://localhost:8443/moa-id-auth/SelectBKU?Target=Test-Bereich&OA=https://localhost:8443/&BKUSelectionTemplate=http://localhost:8080/moaid-templates/SampleBKUSelectionTemplate.html&Template=http://localhost:8080/moaid-templates/SampleTemplate.html
-
-
-Sie können diese beiden Templates als Vorlage für eigene Designs verwenden.
\ No newline at end of file
diff --git a/id.server/data/deploy/templates/moaid-templates.war b/id.server/data/deploy/templates/moaid-templates.war
deleted file mode 100644
index 72b034d5c..000000000
Binary files a/id.server/data/deploy/templates/moaid-templates.war and /dev/null differ
diff --git a/id.server/data/deploy/tomcat/server.mod_jk.xml b/id.server/data/deploy/tomcat/server.mod_jk.xml
deleted file mode 100644
index b32cf7844..000000000
--- a/id.server/data/deploy/tomcat/server.mod_jk.xml
+++ /dev/null
@@ -1,162 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/id.server/data/deploy/tomcat/server.xml b/id.server/data/deploy/tomcat/server.xml
deleted file mode 100644
index 2fd7b6439..000000000
--- a/id.server/data/deploy/tomcat/server.xml
+++ /dev/null
@@ -1,171 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/id.server/data/deploy/tomcat/tomcat-util-4.1.27-patched/tomcat-util.jar b/id.server/data/deploy/tomcat/tomcat-util-4.1.27-patched/tomcat-util.jar
deleted file mode 100644
index 62c7645b9..000000000
Binary files a/id.server/data/deploy/tomcat/tomcat-util-4.1.27-patched/tomcat-util.jar and /dev/null differ
diff --git a/id.server/data/deploy/tomcat/unix/tomcat-start.sh b/id.server/data/deploy/tomcat/unix/tomcat-start.sh
deleted file mode 100644
index 6dc0289d5..000000000
--- a/id.server/data/deploy/tomcat/unix/tomcat-start.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#! /bin/bash
-
-export JAVA_HOME=
-export CATALINA_HOME=
-export CATALINA_BASE=$CATALINA_HOME
-
-CONFIG_OPT=-Dmoa.id.configuration=$CATALINA_BASE/conf/moa-id/SampleMOAIDConfiguration.xml
-LOGGING_OPT=-Dlog4j.configuration=file:$CATALINA_BASE/conf/moa-id/log4j.properties
-SPSS_OPT=-Dmoa.spss.server.configuration=$CATALINA_BASE/conf/moa-spss/SampleMOASPSSConfiguration.xml
-
-#TRUST_STORE_OPT=-Djavax.net.ssl.trustStore=$CATALINA_BASE/conf/moa-spss/keys/clients/trustedMOAClients-password=changeit.keystore
-#TRUST_STORE_PASS_OPT=-Djavax.net.ssl.trustStorePassword=changeit
-#TRUST_STORE_TYPE_OPT=-Djavax.net.ssl.trustStoreType=jks
-
-export CATALINA_OPTS="$CONFIG_OPT $LOGGING_OPT $SPSS_OPT $TRUST_STORE_OPT $TRUST_STORE_PASS_OPT $TRUST_STORE_TYPE_OPT"
-
-echo CATALINA_HOME: $CATALINA_HOME
-echo CATALINA_BASE: $CATALINA_BASE
-echo CATALINA_OPTS: $CATALINA_OPTS
-
-echo
-echo Moving old log files to logs\backup
-mv logs/*.out logs/backup
-mv logs/*.txt logs/backup
-mv logs/*.log logs/backup
-
-cd $CATALINA_HOME
-./bin/startup.sh
diff --git a/id.server/data/deploy/tomcat/unix/tomcat-stop.sh b/id.server/data/deploy/tomcat/unix/tomcat-stop.sh
deleted file mode 100644
index 82e4ffcfe..000000000
--- a/id.server/data/deploy/tomcat/unix/tomcat-stop.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /bin/bash
-
-export JAVA_HOME=
-export CATALINA_HOME=
-
-cd $CATALINA_HOME
-./bin/shutdown.sh
\ No newline at end of file
diff --git a/id.server/data/deploy/tomcat/uriworkermap.properties b/id.server/data/deploy/tomcat/uriworkermap.properties
deleted file mode 100644
index 32b4c1f50..000000000
--- a/id.server/data/deploy/tomcat/uriworkermap.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-# a sample mod_jk uriworkermap.properties file for mapping
-# MOA-ID-AUTH and MOA-ID-PROXY web service requests to workers
-#
-# omit the mappings you don't need
-
-#/moa-id-auth/*=moaworker
-
-#forward all requests to tomcat (e.g.)
-/*=moaworker
\ No newline at end of file
diff --git a/id.server/data/deploy/tomcat/win32/startTomcat.bat b/id.server/data/deploy/tomcat/win32/startTomcat.bat
deleted file mode 100644
index f6ebc3613..000000000
--- a/id.server/data/deploy/tomcat/win32/startTomcat.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-rem ----------------------------------------------------------------------------------------------
-rem Modify these entries according to your needs
-
-rem JDK home directory (no trailing path separator)
-set JAVA_HOME=
-
-rem Tomcat 4.1.x home directory (no trailing path separator)
-set CATALINA_HOME=
-
-rem ----------------------------------------------------------------------------------------------
-
-set CONFIG_OPT_SPSS=-Dmoa.spss.server.configuration=%CATALINA_HOME%/conf/moa-spss/SampleMOASPSSConfiguration.xml
-set CONFIG_OPT_ID=-Dmoa.id.configuration=%CATALINA_HOME%/conf/moa-id/SampleMOAIDConfiguration.xml
-set LOGGING_OPT=-Dlog4j.configuration=file:%CATALINA_HOME%/conf/moa-id/log4j.properties
-
-set PARAMS_MOA=%CONFIG_OPT_SPSS% %CONFIG_OPT_ID% %LOGGING_OPT%
-
-rem set PARAM_TRUST_STORE=-Djavax.net.ssl.trustStore=truststore.jks
-rem set PARAM_TRUST_STORE_PASS=-Djavax.net.ssl.trustStorePassword=changeit
-rem set PARAM_TRUST_STORE_TYPE=-Djavax.net.ssl.trustStoreType=jks
-rem set PARAMS_SSL=%PARAM_TRUST_STORE% %PARAM_TRUST_STORE_PASS% %PARAM_TRUST_STORE_TYPE%
-
-set CATALINA_OPTS=%PARAMS_MOA% %PARAMS_SSL%
-
-cd %CATALINA_HOME%
-bin\catalina.bat start
\ No newline at end of file
diff --git a/id.server/data/deploy/tomcat/win32/stopTomcat.bat b/id.server/data/deploy/tomcat/win32/stopTomcat.bat
deleted file mode 100644
index 09dd83f2d..000000000
--- a/id.server/data/deploy/tomcat/win32/stopTomcat.bat
+++ /dev/null
@@ -1,13 +0,0 @@
-rem ----------------------------------------------------------------------------------------------
-rem Modify these entries according to your needs
-
-rem JDK home directory (no trailing path separator)
-set JAVA_HOME=
-
-rem Tomcat 4.1.x home directory (no trailing path separator)
-set CATALINA_HOME=
-
-rem ----------------------------------------------------------------------------------------------
-
-cd %CATALINA_HOME%
-bin\catalina.bat stop
\ No newline at end of file
diff --git a/id.server/data/deploy/tomcat/workers.properties b/id.server/data/deploy/tomcat/workers.properties
deleted file mode 100644
index 9350ddc77..000000000
--- a/id.server/data/deploy/tomcat/workers.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# a sample workers.properties file defining a single mod_jk worker
-
-worker.list=moaworker
-worker.moaworker.type=ajp13
-worker.moaworker.host=localhost
-worker.moaworker.port=8009
diff --git a/id.server/doc/Architektur ID.vsd b/id.server/doc/Architektur ID.vsd
deleted file mode 100644
index d4678007a..000000000
Binary files a/id.server/doc/Architektur ID.vsd and /dev/null differ
diff --git a/id.server/doc/MOA ID 1.x.wsdl b/id.server/doc/MOA ID 1.x.wsdl
deleted file mode 100644
index 06daae8f1..000000000
--- a/id.server/doc/MOA ID 1.x.wsdl
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/doc/MOA-ID Feinspezifikation.doc b/id.server/doc/MOA-ID Feinspezifikation.doc
deleted file mode 100644
index e71ffa8e6..000000000
Binary files a/id.server/doc/MOA-ID Feinspezifikation.doc and /dev/null differ
diff --git a/id.server/doc/MOA-ID-Configuration-1.2.xsd b/id.server/doc/MOA-ID-Configuration-1.2.xsd
deleted file mode 100644
index 4b018db64..000000000
--- a/id.server/doc/MOA-ID-Configuration-1.2.xsd
+++ /dev/null
@@ -1,350 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter der
- Authentisierungs-Komponente
-
-
-
-
- enthält Konfigurationsparameter der
- Proxy-Komponente
-
-
-
-
-
- enthält Parameter für die Kommunikation zw.
- Proxykomponente und Authenttisierungskomponente
-
-
-
-
-
- enthält Parameter für die SOAP-Verbindung von der
- Proxy-Komponente zur Auth-Komponente (vgl.
- AuthComponent/MOA-SP/ConnectionParameter)
-
-
-
-
-
-
-
-
-
-
- enthält Parameter für die OA
-
-
-
-
-
-
-
-
-
-
-
-
- spezifiziert den Algorithmus ("pkix" oder "chaining") für die
- Zertifikatspfadvalidierung
-
-
-
-
-
- ein vom SystemDefaultMode abweichender ChiningMode kann
- für jeden TrustAnchor gesetzt werden
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- verweist auf ein Verzeichnis, das vertrauenswürdige CA
- (Zwischen-CA, Wurzel-CA) Zertifikate enthält.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter für die Kommunikation mit dem
- Security-Layer
-
-
-
-
-
- das Attribut filename verweist auf eine Datei mit globalem
- Element TransformsInfo vom Typ sl10:TransformsInfo; diese TransformsInfo
- werden in den CreateXMLSignatureRequest für die Signatur des AUTH-Blocks
- inkludiert
-
-
-
-
-
-
-
-
-
-
- enthält Konfiguratiosnparameter für die Kommunikation mit dem MOA
- SP Modul
-
-
-
-
-
- enthält Parameter für die SOAP-Verbindung von der
- AUTH-Komponente zu MOA-SP; das Attribut URL enthält den Endpunkt des Server;
- wird das Schema "https" verwendet müssen die Kind-Elemente angegeben werden;
- wird das Schema "http" verwendet dürfen keine Kind-Elemente angegeben
- werden; wird das Element nicht verwendet dann wird MOA-SP über das API
- aufgerufen
-
-
-
-
- enthält Parameter für die Überprüfung der
- Personenbindung
-
-
-
-
-
-
-
-
-
- enthält Parameter für die Überprüfung des
- AUTH-Blocks
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Informationen über akzeptierte Signers des
- IdentityLinks
-
-
-
-
-
- akzeptierte Signer des IdentityLinks werden per
- X509SubjectName (Kodierung nach RFC 2253) identifiziert
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter über die OA, die die
- Authentisierungs-Komponente betreffen
-
-
-
-
-
-
-
-
-
- enthält Parameter über die OA, die die Proxy-Komponente
- betreffen
-
-
-
-
-
- enthält Parameter über die OA, die die Proxy-Komponente
- betreffen
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- URL zu einem Verzeichnis, das akzeptierte Server-Zertifikate der
- TLS-Verbindung enthält (keine CA-Zertifikate)
-
-
-
-
-
-
-
-
-
-
-
- URL zu einem KeyStore, der den privaten Schlüssel, der für
- die TLS-Client-Authentisierung verwendetwird, enthält
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/doc/MOA-ID-Configuration-1.3.xsd b/id.server/doc/MOA-ID-Configuration-1.3.xsd
deleted file mode 100644
index 66c6e1832..000000000
--- a/id.server/doc/MOA-ID-Configuration-1.3.xsd
+++ /dev/null
@@ -1,424 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter der
- Authentisierungs-Komponente
-
-
-
-
- enthält Konfigurationsparameter der
- Proxy-Komponente
-
-
-
-
-
- enthält Parameter für die Kommunikation zw.
- Proxykomponente und Authenttisierungskomponente
-
-
-
-
-
- enthält Parameter für die SOAP-Verbindung von der
- Proxy-Komponente zur Auth-Komponente (vgl.
- AuthComponent/MOA-SP/ConnectionParameter)
-
-
-
-
-
-
-
-
-
-
- enthält Parameter für die OA
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- spezifiziert den Algorithmus ("pkix" oder "chaining") für die
- Zertifikatspfadvalidierung
-
-
-
-
-
- ein vom SystemDefaultMode abweichender ChiningMode kann
- für jeden TrustAnchor gesetzt werden
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- verweist auf ein Verzeichnis, das vertrauenswürdige CA
- (Zwischen-CA, Wurzel-CA) Zertifikate enthält.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter für die Kommunikation mit dem
- Security-Layer
-
-
-
-
-
-
-
-
-
- enthält Konfiguratiosnparameter für die Kommunikation mit dem MOA
- SP Modul
-
-
-
-
-
- enthält Parameter für die SOAP-Verbindung von der
- AUTH-Komponente zu MOA-SP; das Attribut URL enthält den Endpunkt des Server;
- wird das Schema "https" verwendet müssen die Kind-Elemente angegeben werden;
- wird das Schema "http" verwendet dürfen keine Kind-Elemente angegeben
- werden; wird das Element nicht verwendet dann wird MOA-SP über das API
- aufgerufen
-
-
-
-
- enthält Parameter für die Überprüfung der
- Personenbindung
-
-
-
-
-
-
-
-
-
- enthält Parameter für die Überprüfung des
- AUTH-Blocks
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Informationen über akzeptierte Signers des
- IdentityLinks
-
-
-
-
-
- akzeptierte Signer des IdentityLinks werden per
- X509SubjectName (Kodierung nach RFC 2253) identifiziert
-
-
-
-
-
-
-
-
-
- das Attribut filename verweist auf eine Datei mit globalem
- Element TransformsInfo vom Typ sl10:TransformsInfo; diese TransformsInfo
- werden in den CreateXMLSignatureRequest für die Signatur des AUTH-Blocks
- inkludiert
-
-
-
-
-
-
-
-
-
-
-
- das Attribut URL spezifiziert die Lage des Templates
-
-
-
-
-
-
-
-
- enthält Parameter über die OA, die die
- Authentisierungs-Komponente betreffen
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter über die OA, die die Proxy-Komponente
- betreffen
-
-
-
-
-
- enthält Parameter über die OA, die die Proxy-Komponente
- betreffen
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- URL zu einem Verzeichnis, das akzeptierte Server-Zertifikate der
- TLS-Verbindung enthält (keine CA-Zertifikate)
-
-
-
-
-
-
-
-
-
-
-
- URL zu einem KeyStore, der den privaten Schlüssel, der für
- die TLS-Client-Authentisierung verwendetwird, enthält
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/doc/MOA-ID-Configuration-1.4.xsd b/id.server/doc/MOA-ID-Configuration-1.4.xsd
deleted file mode 100644
index 66a9c0ed4..000000000
--- a/id.server/doc/MOA-ID-Configuration-1.4.xsd
+++ /dev/null
@@ -1,505 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter der
- Authentisierungs-Komponente
-
-
-
-
- enthält Konfigurationsparameter der
- Proxy-Komponente
-
-
-
-
-
- enthält Parameter für die Kommunikation zw.
- Proxykomponente und Authenttisierungskomponente
-
-
-
-
-
- enthält Parameter für die SOAP-Verbindung von der
- Proxy-Komponente zur Auth-Komponente (vgl.
- AuthComponent/MOA-SP/ConnectionParameter)
-
-
-
-
-
-
-
-
-
-
- enthält Parameter für die OA
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- spezifiziert den Algorithmus ("pkix" oder "chaining") für die
- Zertifikatspfadvalidierung
-
-
-
-
-
- ein vom SystemDefaultMode abweichender ChiningMode kann
- für jeden TrustAnchor gesetzt werden
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- verweist auf ein Verzeichnis, das vertrauenswürdige CA
- (Zwischen-CA, Wurzel-CA) Zertifikate enthält.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter für die Kommunikation mit dem
- Security-Layer
-
-
-
-
-
-
-
-
-
- enthält Konfiguratiosnparameter für die Kommunikation mit dem MOA
- SP Modul
-
-
-
-
-
- enthält Parameter für die SOAP-Verbindung von der
- AUTH-Komponente zu MOA-SP; das Attribut URL enthält den Endpunkt des Server;
- wird das Schema "https" verwendet müssen die Kind-Elemente angegeben werden;
- wird das Schema "http" verwendet dürfen keine Kind-Elemente angegeben
- werden; wird das Element nicht verwendet dann wird MOA-SP über das API
- aufgerufen
-
-
-
-
- enthält Parameter für die Überprüfung der
- Personenbindung
-
-
-
-
-
-
-
-
-
- enthält Parameter für die Überprüfung des
- AUTH-Blocks
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Informationen über akzeptierte Signers des
- IdentityLinks
-
-
-
-
-
- akzeptierte Signer des IdentityLinks werden per
- X509SubjectName (Kodierung nach RFC 2253) identifiziert
-
-
-
-
-
-
-
- enthält Defaultparameter für die Überprüfung weiterer Infoboxen
-
-
-
-
-
-
- das Attribut filename verweist auf eine Datei mit globalem
- Element TransformsInfo vom Typ sl10:TransformsInfo; diese TransformsInfo
- werden in den CreateXMLSignatureRequest für die Signatur des AUTH-Blocks
- inkludiert
-
-
-
-
-
-
-
-
-
-
-
- das Attribut URL spezifiziert die Lage des Templates
-
-
-
-
-
- Verifikation zusätzlicher Infoboxen
-
-
-
-
- Optionales DefaultTrustprofil für die Überprüfung aller weiteren Infoboxen
-
-
-
-
-
-
-
-
-
- Parameter für Überprüfung weiterer Infoboxen
-
-
-
-
-
- optionalervName, der für Fehlermeldungen verwendet werden soll;
- z.B.: "Stellvertretungen" für "Mandates"; fehlt dieser Parameter, dann wird
- das Identifier-Attribut verwendet
-
-
-
-
- TrustProfil, das für die Überprüfung der Infobox
- verwendet werden soll
-
-
-
-
- Validatorklasse, die für die Prüfung der Infobox
- verwendet werden soll; muss gesetzt werden, wenn Package- und Klassenname
- vom Default Package- und Klassennamen abweichen
-
-
-
-
-
- Infobox spezifische Parameter, die der jeweiligen Prüfapplikation
- übergeben werden
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Spezifiziert die Lage von XML Schemas
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter über die OA, die die
- Authentisierungs-Komponente betreffen
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enthält Parameter über die OA, die die Proxy-Komponente
- betreffen
-
-
-
-
-
- enthält Parameter über die OA, die die Proxy-Komponente
- betreffen
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- URL zu einem Verzeichnis, das akzeptierte Server-Zertifikate der
- TLS-Verbindung enthält (keine CA-Zertifikate)
-
-
-
-
-
-
-
-
-
-
-
- URL zu einem KeyStore, der den privaten Schlüssel, der für
- die TLS-Client-Authentisierung verwendetwird, enthält
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/id.server/doc/MOA_ID_1.2_20040315.pdf b/id.server/doc/MOA_ID_1.2_20040315.pdf
deleted file mode 100644
index 0c89c2730..000000000
Binary files a/id.server/doc/MOA_ID_1.2_20040315.pdf and /dev/null differ
diff --git a/id.server/doc/MOA_ID_1.3_20060315.pdf b/id.server/doc/MOA_ID_1.3_20060315.pdf
deleted file mode 100644
index c9b0d160c..000000000
Binary files a/id.server/doc/MOA_ID_1.3_20060315.pdf and /dev/null differ
diff --git a/id.server/doc/MOA_ID_1.4_20070802.pdf b/id.server/doc/MOA_ID_1.4_20070802.pdf
deleted file mode 100644
index a3a2f1177..000000000
Binary files a/id.server/doc/MOA_ID_1.4_20070802.pdf and /dev/null differ
diff --git a/id.server/doc/OID-1-0-3.pdf b/id.server/doc/OID-1-0-3.pdf
deleted file mode 100644
index 4beab3e41..000000000
Binary files a/id.server/doc/OID-1-0-3.pdf and /dev/null differ
diff --git a/id.server/doc/api-doc/allclasses-frame.html b/id.server/doc/api-doc/allclasses-frame.html
deleted file mode 100644
index 114c4b426..000000000
--- a/id.server/doc/api-doc/allclasses-frame.html
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-All Classes
-
-
-
-
-
-All Classes
-
-
-
AuthenticationServer.verifyIdentityLink(String sessionID,
- String xmlInfoboxReadResponse)
-
-
- Processes an <InfoboxReadResponse> sent by the
- security layer implementation.
-
- Validates given <InfoboxReadResponse>
- Parses identity link enclosed in <InfoboxReadResponse>
- Verifies identity link by calling the MOA SP component
- Checks certificate authority of identity link
- Stores identity link in the session
- Creates an authentication block to be signed by the user
- Creates and returns a <CreateXMLSignatureRequest>
- containg the authentication block, meant to be returned to the
- security layer implementation
-
AuthenticationServer.verifyAuthenticationBlock(String sessionID,
- String xmlCreateXMLSignatureReadResponse)
-
-
- Processes a <CreateXMLSignatureResponse> sent by the
- security layer implementation.
-
- Validates given <CreateXMLSignatureResponse>
- Parses <CreateXMLSignatureResponse> for error codes
- Parses authentication block enclosed in
- <CreateXMLSignatureResponse>
- Verifies authentication block by calling the MOA SP component
- Creates authentication data
- Creates a corresponding SAML artifact
- Stores authentication data in the authentication data store
- indexed by the SAML artifact
- Deletes authentication session
- Returns the SAML artifact, encoded BASE64
-
-Holds configuration data concerning an online application for use by the MOA-ID Proxy component.
- These include the login type (stateful or stateless), the HTTP authentication type,
- and information needed to add authentication parameters or headers for a URL connection
- to the remote online application.
-
buildConnection(javax.servlet.http.HttpServletRequest request,
- String publicURLPrefix,
- String realURLPrefix,
- javax.net.ssl.SSLSocketFactory sslSocketFactory)
-
-
- Builds an HttpURLConnection to a URL which is derived
- from an HttpServletRequest URL, by substitution of a
- public URL prefix for the real URL prefix.
- The HttpURLConnection has been created by URL.openConnection(), but
- it has not yet been connected to by URLConnection.connect().
- The field settings of the HttpURLConnection are:
-
- allowUserInteraction = false
- doInput = true
- doOutput = true
- requestMethod = request.getMethod()
- useCaches = false
-
Builds an HttpURLConnection to a URL which is derived
- from an HttpServletRequest URL, by substitution of a
- public URL prefix for the real URL prefix.
- The HttpURLConnection has been created by URL.openConnection(), but
- it has not yet been connected to by URLConnection.connect().
- The field settings of the HttpURLConnection are:
-
-
allowUserInteraction = false
-
doInput = true
-
doOutput = true
-
requestMethod = request.getMethod()
-
useCaches = false
-
-
Parameters:
request - the incoming request which shall be forwarded
publicURLPrefix - the public URL prefix to be substituted by the real URL prefix
realURLPrefix - the URL prefix to substitute the public URL prefix
sslSocketFactory - factory to be used for creating an SSL socket in case
- of a URL for scheme "https:";
- if null, the default SSL socket factory would be used
Returns:
a URLConnection created by URL.openConnection(), connecting to
- the requested URL with publicURLPrefix substituted by realURLPrefix
Throws:
IOException - if an I/O exception occurs during opening the connection
Returns authentication headers to be added to a URLConnection.
-
Parameters:
authConf - configuration data
authData - authentication data
clientIPAddress - client IP address
Returns:
A map, the keys being header names and values being corresponding header values.
- In case of authentication type "basic-auth", header fields
- username and password.
- In case of authentication type "header-auth", header fields
- derived from parameter mapping and authentication data provided.
- Otherwise, an empty map.
Returns request parameters to be added to a URLConnection.
-
Parameters:
authConf - configuration data
authData - authentication data
clientIPAddress - client IP address
Returns:
A map, the keys being parameter names and values being corresponding parameter values.
- In case of authentication type "param-auth", parameters
- derived from parameter mapping and authentication data provided.
- Otherwise, an empty map.
-This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
-Package
-
-
-
-Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
-
Interfaces (italic)
Classes
Exceptions
Errors
-
-
-Class/Interface
-
-
-
-Each class, interface, inner class and inner interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
-
Class inheritance diagram
Direct Subclasses
All Known Subinterfaces
All Known Implementing Classes
Class/interface declaration
Class/interface description
-
-
Inner Class Summary
Field Summary
Constructor Summary
Method Summary
-
-
Field Detail
Constructor Detail
Method Detail
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
-
-Use
-
-Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
-
-Tree (Class Hierarchy)
-
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
-
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
-
-
-Deprecated API
-
-The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-
-Index
-
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-
-Prev/Next
-These links take you to the next or previous class, interface, package, or related page.
-Frames/No Frames
-These links show and hide the HTML frames. All pages are available with or without frames.
-
-
-Serialized Form
-Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
-
-
-
-This help file applies to API documentation generated using the standard doclet.
-
-
-
Builds an HttpURLConnection to a URL which is derived
- from an HttpServletRequest URL, by substitution of a
- public URL prefix for the real URL prefix.
- The HttpURLConnection has been created by URL.openConnection(), but
- it has not yet been connected to by URLConnection.connect().
- The field settings of the HttpURLConnection are:
-
- allowUserInteraction = false
- doInput = true
- doOutput = true
- requestMethod = request.getMethod()
- useCaches = false
-
-
Processes a <CreateXMLSignatureResponse> sent by the
- security layer implementation.
-
- Validates given <CreateXMLSignatureResponse>
- Parses <CreateXMLSignatureResponse> for error codes
- Parses authentication block enclosed in
- <CreateXMLSignatureResponse>
- Verifies authentication block by calling the MOA SP component
- Creates authentication data
- Creates a corresponding SAML artifact
- Stores authentication data in the authentication data store
- indexed by the SAML artifact
- Deletes authentication session
- Returns the SAML artifact, encoded BASE64
-
-
Processes an <InfoboxReadResponse> sent by the
- security layer implementation.
-
- Validates given <InfoboxReadResponse>
- Parses identity link enclosed in <InfoboxReadResponse>
- Verifies identity link by calling the MOA SP component
- Checks certificate authority of identity link
- Stores identity link in the session
- Creates an authentication block to be signed by the user
- Creates and returns a <CreateXMLSignatureRequest>
- containg the authentication block, meant to be returned to the
- security layer implementation
-
-
-This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
-
-Link to Non-frame version.