aboutsummaryrefslogtreecommitdiff
path: root/moaSig/common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/common/src/main')
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LogMsg.java26
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/Logger.java161
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContext.java21
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContextManager.java25
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Base64Utils.java92
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/BoolUtils.java15
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/CollectionUtils.java29
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Constants.java649
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DOMUtils.java1153
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DateTimeUtils.java344
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Empty.java18
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/EntityResolverChain.java33
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/FileUtils.java160
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/KeyStoreUtils.java243
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOADefaultHandler.java30
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAEntityResolver.java55
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAErrorHandler.java73
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOATimer.java46
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MessageProvider.java29
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java55
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MiscUtil.java469
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeIteratorAdapter.java15
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeListAdapter.java15
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/OutputXML2File.java116
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ResourceBundleChain.java27
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/SSLUtils.java399
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java47
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamUtils.java118
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StringUtils.java159
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLDecoder.java50
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLEncoder.java55
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathException.java29
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathUtils.java477
-rw-r--r--moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ex/EgovUtilException.java32
34 files changed, 2703 insertions, 2562 deletions
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LogMsg.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LogMsg.java
index 9eb84fa..54ab102 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LogMsg.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LogMsg.java
@@ -21,23 +21,22 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.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;
+ private final Object message;
/**
* Create a <code>LogMsg</code> object.
- *
- * @param message The actual message to log. May be <code>null</code>.
+ *
+ * @param message The actual message to log. May be <code>null</code>.
*/
public LogMsg(Object message) {
this.message = message;
@@ -45,16 +44,17 @@ public class LogMsg {
/**
* Convert this log message to a <code>String</code>.
- *
- * @return The <code>String</code> representation of this log message.
+ *
+ * @return The <code>String</code> representation of this log message.
*/
+ @Override
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;
-
+ final StringBuffer msg = new StringBuffer();
+ final LoggingContext ctx =
+ LoggingContextManager.getInstance().getLoggingContext();
+ final String tid = ctx != null ? ctx.getTransactionID() : null;
+ final String nodeId = ctx != null ? ctx.getNodeID() : null;
+
msg.append("TID=");
msg.append(tid != null ? tid : "<null>");
msg.append(" NID=");
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/Logger.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/Logger.java
index 532a8be..23908ab 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/Logger.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/Logger.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.logging;
import java.util.HashMap;
@@ -29,28 +28,28 @@ import java.util.Map;
/**
* A utility class acting as a facade to the logging subsystem.
- *
+ *
* Configure the logging defaultHierarchy that the <code>Logger</code> uses by
* calling <code>setHierarchy</code> once before calling any of the logging
* output functions.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class Logger {
-
+
/**
* Set the default hierarchy to which the <code>Logger</code> should send its
* logging output.
+ *
* @param hierarchy The logging defaultHierarchy.
*/
public static void setHierarchy(String hierarchy) {
- // there is no need for that anymore
+ // there is no need for that anymore
}
-
/** The Constant instances. */
- private static final Map<String, org.slf4j.Logger> instances = new HashMap<String, org.slf4j.Logger>();
+ private static final Map<String, org.slf4j.Logger> instances = new HashMap<>();
/**
* Gets the logger.
@@ -58,173 +57,177 @@ public class Logger {
* @return the logger
*/
private static synchronized org.slf4j.Logger getLogger() {
- StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
-
- int i;
- for(i = 2; i < stacktrace.length; i++)
- if(!stacktrace[i].getClassName().equals(Logger.class.getName()))
- break;
+ final StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
- String className = stacktrace[i].getClassName();
-
- org.slf4j.Logger logger = instances.get(className);
- if (logger != null) {
- return logger;
+ int i;
+ for (i = 2; i < stacktrace.length; i++) {
+ if (!stacktrace[i].getClassName().equals(Logger.class.getName())) {
+ break;
}
+ }
- logger = org.slf4j.LoggerFactory.getLogger(className);
- instances.put(className, logger);
+ final String className = stacktrace[i].getClassName();
+ org.slf4j.Logger logger = instances.get(className);
+ if (logger != null) {
return logger;
+ }
+
+ logger = org.slf4j.LoggerFactory.getLogger(className);
+ instances.put(className, logger);
+
+ return logger;
}
-
+
/**
* Prepare the message for printing it as string.
- * <p>Mainly introduce because the <code>message</code> might be <code>null</code>.
+ * <p>
+ * Mainly introduce because the <code>message</code> might be <code>null</code>.
*
* @param message the message
* @return the string
*/
private static String prepareMessage(Object message) {
- if(null == message)
- return "no message given";
- return message.toString();
+ if (null == message) {
+ return "no message given";
+ }
+ return message.toString();
}
-
+
/**
* Test, if the trace log level is enabled.
- *
+ *
* @return boolean <code>true</code>, if tracing output is enabled
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
public static boolean isTraceEnabled() {
- org.slf4j.Logger logger = getLogger();
- return logger.isTraceEnabled();
+ final org.slf4j.Logger logger = getLogger();
+ return logger.isTraceEnabled();
}
-
+
/**
* Test, if the trace log level is enabled for a given hierarchy.
- *
+ *
* @param hierarchy requested log hierarchy
* @return boolean <code>true</code>, if tracing output is enabled
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
public static boolean isTraceEnabled(String hierarchy) {
- org.slf4j.Logger logger = getLogger();
- return logger.isTraceEnabled();
+ final org.slf4j.Logger logger = getLogger();
+ return logger.isTraceEnabled();
}
-
+
/**
* Trace a message.
- *
+ *
* @param message The message to trace.
*/
public static void trace(Object message) {
- org.slf4j.Logger logger = getLogger();
- logger.trace(prepareMessage(message));
+ final org.slf4j.Logger logger = getLogger();
+ logger.trace(prepareMessage(message));
}
-
+
/**
* Test, if the debug log level is enabled.
- *
+ *
* @return boolean <code>true</code>, if debug output is enabled
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
public static boolean isDebugEnabled() {
- org.slf4j.Logger logger = getLogger();
- return logger.isDebugEnabled();
+ final org.slf4j.Logger logger = getLogger();
+ return logger.isDebugEnabled();
}
-
+
/**
* Test, if the debug log level is enabled for a given hierarchy.
- *
+ *
* @param hierarchy requested log hierarchy
* @return boolean <code>true</code>, if debug output is enabled
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
public static boolean isDebugEnabled(String hierarchy) {
- org.slf4j.Logger logger = getLogger();
- return logger.isDebugEnabled();
+ final org.slf4j.Logger logger = getLogger();
+ return logger.isDebugEnabled();
}
-
+
/**
* Log a debug message.
- *
+ *
* @param message The message to log.
*/
public static void debug(Object message) {
- org.slf4j.Logger logger = getLogger();
- logger.debug(prepareMessage(message));
+ final org.slf4j.Logger logger = getLogger();
+ logger.debug(prepareMessage(message));
}
-/**
+ /**
* Log an info message.
- *
+ *
* @param message The message to log.
*/
public static void info(Object message) {
- org.slf4j.Logger logger = getLogger();
- logger.info(prepareMessage(message));
+ final org.slf4j.Logger logger = getLogger();
+ logger.info(prepareMessage(message));
}
-
+
/**
* Log a warning message.
- *
+ *
* @param message The message to log.
*/
public static void warn(Object message) {
- org.slf4j.Logger logger = getLogger();
- logger.warn(prepareMessage(message));
+ final org.slf4j.Logger logger = getLogger();
+ logger.warn(prepareMessage(message));
}
/**
* Log a warning message.
- *
+ *
* @param message The message to log.
- * @param t An exception that may be the cause of the warning.
+ * @param t An exception that may be the cause of the warning.
*/
public static void warn(Object message, Throwable t) {
- org.slf4j.Logger logger = getLogger();
- logger.warn(prepareMessage(message), t);
+ final org.slf4j.Logger logger = getLogger();
+ logger.warn(prepareMessage(message), t);
}
-
+
/**
* Log an error message.
- *
+ *
* @param message The message to log.
*/
public static void error(Object message) {
- org.slf4j.Logger logger = getLogger();
- logger.error(prepareMessage(message));
+ final org.slf4j.Logger logger = getLogger();
+ logger.error(prepareMessage(message));
}
/**
* Log an error message.
- *
+ *
* @param message The message to log.
- * @param t An exception that may be the cause of the error.
+ * @param t An exception that may be the cause of the error.
*/
public static void error(Object message, Throwable t) {
- org.slf4j.Logger logger = getLogger();
- logger.error(prepareMessage(message), t);
+ final org.slf4j.Logger logger = getLogger();
+ logger.error(prepareMessage(message), t);
}
-
+
/**
* Log a fatal error message.
- *
+ *
* @param message The message to log.
*/
public static void fatal(Object message) {
- error(message);
+ error(message);
}
/**
* Log a fatal error message.
- *
+ *
* @param message The message to log.
- * @param t An exception that may be the cause of the error.
+ * @param t An exception that may be the cause of the error.
*/
public static void fatal(Object message, Throwable t) {
- error(message, t);
+ error(message, t);
}
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContext.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContext.java
index 0fb0e7d..d8f03a6 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContext.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContext.java
@@ -21,47 +21,46 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.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;
+ private final String transactionID;
/** The node ID. */
- private String nodeID;
-
+ private final String nodeID;
+
/**
* Create a new <code>LoggingContext</code>.
- *
+ *
* @param transactionID The transaction ID. May be <code>null</code>.
*/
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() {
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContextManager.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContextManager.java
index b4cd294..aa4bfe8 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContextManager.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/logging/LoggingContextManager.java
@@ -21,25 +21,24 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.logging;
/**
* Provides each thread with a single instance of <code>LoggingContext</code>.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class LoggingContextManager {
/** The single instance of this class. */
private static LoggingContextManager instance = null;
-
+
/** The <code>LoggingContext</code> for each thread. */
- private ThreadLocal context;
-
+ private final ThreadLocal context;
+
/**
* Get the single instance of the <code>LoggingContextManager</code> class.
- *
+ *
* @return LoggingContextManager The single instance.
*/
public static synchronized LoggingContextManager getInstance() {
@@ -48,30 +47,30 @@ public class LoggingContextManager {
}
return instance;
}
-
+
/**
* Creates a new <code>LoggingContextManager</code>.
- *
+ *
* Protected to disallow direct instantiation.
*/
protected LoggingContextManager() {
context = new ThreadLocal();
}
-
+
/**
* Set the <code>LoggingContext</code> context for the current thread.
- *
+ *
* @param ctx The <code>LoggingContext</code> for the current thread.
*/
public void setLoggingContext(LoggingContext ctx) {
context.set(ctx);
}
-
+
/**
* Return the <code>LoggingContext</code> for the current thread.
- *
+ *
* @return LoggingContext The <code>LoggingContext</code> for the current
- * thread, or <code>null</code> if none has been set.
+ * thread, or <code>null</code> if none has been set.
*/
public LoggingContext getLoggingContext() {
return (LoggingContext) context.get();
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Base64Utils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Base64Utils.java
index 25a19bc..2c9b4c0 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Base64Utils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Base64Utils.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.ByteArrayInputStream;
@@ -35,81 +34,81 @@ 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 <code>String</code>.
- *
- * @param base64String The <code>String</code> containing the Base64 encoded
- * bytes.
+ * Read the bytes encoded in a Base64 encoded <code>String</code>.
+ *
+ * @param base64String The <code>String</code> containing the Base64
+ * encoded bytes.
* @param ignoreInvalidChars Whether to ignore invalid Base64 characters.
* @return byte[] The raw bytes contained in the <code>base64String</code>.
* @throws IOException Failed to read the Base64 data.
*/
public static byte[] decode(String base64String, boolean ignoreInvalidChars, String encoding)
- throws IOException {
-
- Base64InputStream in =
- new Base64InputStream(
- new ByteArrayInputStream(base64String.getBytes(encoding)),
- ignoreInvalidChars);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] bytes = new byte[256];
+ throws IOException {
+
+ final Base64InputStream in =
+ new Base64InputStream(
+ new ByteArrayInputStream(base64String.getBytes(encoding)),
+ ignoreInvalidChars);
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final byte[] bytes = new byte[256];
int bytesRead;
while ((bytesRead = in.read(bytes)) > 0) {
out.write(bytes, 0, bytesRead);
}
in.close();
-
+
return out.toByteArray();
}
public static byte[] decode(String base64String, boolean ignoreInvalidChars) throws IOException {
- return decode(base64String, ignoreInvalidChars, "UTF-8");
+ return decode(base64String, ignoreInvalidChars, "UTF-8");
}
-
+
/**
* Read the bytes encoded in a Base64 encoded <code>String</code> and provide
* them via an <code>InputStream</code>.
- *
- * @param base64String The <code>String</code> containing the Base64 encoded
- * bytes.
+ *
+ * @param base64String The <code>String</code> containing the Base64
+ * encoded bytes.
* @param ignoreInvalidChars Whether to ignore invalid Base64 characters.
* @return The <code>InputStream</code> from which the binary content of the
- * <code>base64String</code> can be read.
+ * <code>base64String</code> can be read.
*/
public static InputStream decodeToStream(
- String base64String,
- boolean ignoreInvalidChars,
- String encoding) {
+ String base64String,
+ boolean ignoreInvalidChars,
+ String encoding) {
try {
- ByteArrayInputStream bin =
- new ByteArrayInputStream(base64String.getBytes(encoding));
- Base64InputStream in = new Base64InputStream(bin, ignoreInvalidChars);
-
+ final ByteArrayInputStream bin =
+ new ByteArrayInputStream(base64String.getBytes(encoding));
+ final Base64InputStream in = new Base64InputStream(bin, ignoreInvalidChars);
+
return in;
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
// cannot occur, since UTF-8 is required to be supported by every JRE
- return null;
+ return null;
}
}
public static InputStream decodeToStream(
- String base64String,
- boolean ignoreInvalidChars) {
- return decodeToStream(base64String, ignoreInvalidChars, "UTF-8");
-
+ String base64String,
+ boolean ignoreInvalidChars) {
+ return decodeToStream(base64String, ignoreInvalidChars, "UTF-8");
+
}
-
+
/**
* Convert a byte array to a Base64 encoded <code>String</code>.
- *
+ *
* @param bytes The bytes to encode.
* @return String The Base64 encoded representation of the <code>bytes</code>.
* @throws IOException Failed to write the bytes as Base64 data.
@@ -119,25 +118,26 @@ public class Base64Utils {
}
public static String encode(byte[] bytes, String encoding) throws IOException {
- return encode(new ByteArrayInputStream(bytes), encoding);
- }
-
+ return encode(new ByteArrayInputStream(bytes), encoding);
+ }
+
public static String encode(InputStream inputStream) throws IOException {
- return encode(inputStream, "UTF-8");
+ return encode(inputStream, "UTF-8");
}
+
/**
* Convert the data contained in the given stream to a Base64 encoded
* <code>String</code>.
- *
+ *
* @param inputStream The stream containing the data to encode.
- * @return The Base64 encoded data of <code>inputStream</code>, as a
- * <code>String</code>.
+ * @return The Base64 encoded data of <code>inputStream</code>, as a
+ * <code>String</code>.
* @throws IOException Failed to convert the data in the stream.
*/
public static String encode(InputStream inputStream, String encoding) throws IOException {
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- Base64OutputStream base64Stream = new Base64OutputStream(byteStream, "\n".getBytes());
- byte[] bytes = new byte[256];
+ final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ final Base64OutputStream base64Stream = new Base64OutputStream(byteStream, "\n".getBytes());
+ final byte[] bytes = new byte[256];
int bytesRead;
while ((bytesRead = inputStream.read(bytes)) > 0) {
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/BoolUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/BoolUtils.java
index 56eab08..42f98bc 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/BoolUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/BoolUtils.java
@@ -21,25 +21,24 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
/**
* Utility class for parsing XML schema boolean values.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class BoolUtils {
-
+
/**
- * Return the boolean value of an <code>xsd:boolean</code> type of DOM
+ * Return the boolean value of an <code>xsd:boolean</code> type of DOM
* element/attribute.
- *
+ *
* @param boolStr The value of the <code>xsd:boolean</code> element/attribute.
- * @return <code>true</code>, if <code>boolStr</code> equals
- * <code>&quot;true&quot;</code> or <code>&quot;1;&quot;</code>. Otherwise,
- * <code>false</code> is returned.
+ * @return <code>true</code>, if <code>boolStr</code> equals
+ * <code>&quot;true&quot;</code> or <code>&quot;1;&quot;</code>.
+ * Otherwise, <code>false</code> is returned.
*/
public static boolean valueOf(String boolStr) {
return "true".equals(boolStr) || "1".equals(boolStr);
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/CollectionUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/CollectionUtils.java
index 01a80ea..dcca377 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/CollectionUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/CollectionUtils.java
@@ -21,40 +21,39 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.util.Iterator;
import java.util.List;
/**
- * Various utility methods for dealing with <code>java.util.Collection</code>
- * classes.
- *
+ * Various utility methods for dealing with <code>java.util.Collection</code>
+ * classes.
+ *
* @author Patrick Peck
* @version $Id$
*/
public class CollectionUtils {
-
+
/**
- * Convert a <code>List</code> of <code>Number</code> objects to an
+ * Convert a <code>List</code> of <code>Number</code> objects to an
* <code>int</code> array.
- *
- * @param nums The <code>List</code> containing the numbers whose integer
- * value to put into the result.
- * @return The <code>int</code> values of the <code>Number</code>s contained
- * in <code>nums</code>.
+ *
+ * @param nums The <code>List</code> containing the numbers whose integer value
+ * to put into the result.
+ * @return The <code>int</code> values of the <code>Number</code>s contained in
+ * <code>nums</code>.
*/
public static int[] toIntArray(List nums) {
- int[] result = new int[nums.size()];
+ final int[] result = new int[nums.size()];
Iterator iter;
int i;
-
+
for (i = 0, iter = nums.iterator(); iter.hasNext(); i++) {
- Number num = (Number) iter.next();
+ final Number num = (Number) iter.next();
result[i] = num.intValue();
}
-
+
return result;
}
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Constants.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Constants.java
index 54caf3e..1102975 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Constants.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Constants.java
@@ -21,556 +21,557 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.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/";
+ 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";
+ 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";
+ 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#";
+ String STB_NS_URI =
+ "http://reference.e-government.gv.at/namespace/standardtextblock/20041105#";
/** Prefix used for the standard text block XML namespace */
- public static final String STB_PREFIX = "stb";
+ 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#";
+ String MOA_NS_URI =
+ "http://reference.e-government.gv.at/namespace/moa/20020822#";
/** Name of the mandates infobox */
- public static final String INFOBOXIDENTIFIER_MANDATES = "Mandates";
+ String INFOBOXIDENTIFIER_MANDATES = "Mandates";
/** Prefix used for the Mandate XML namespace */
- public static final String MD_PREFIX = "md";
+ 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#";
+ 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";
+ 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";
+ 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";
+ 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#";
+ 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";
+ String MOA_PREFIX = "moa";
/** Local location of the MOA XML schema definition. */
- public static final String MOA_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOA-SPSS-3.1.2.xsd";
+ String MOA_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-SPSS-3.1.2.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#";
+ 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#";
+ 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";
+ String MOA_CONFIG_PREFIX = "conf";
/** Prefix used for the MOA configuration XML namespace */
- public static final String MOA_ID_CONFIG_PREFIX = "confID";
+ 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-3.0.0.xsd";
+ String MOA_CONFIG_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-SPSS-config-3.0.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.5.2.xsd";
+ String MOA_ID_CONFIG_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOA-ID-Configuration-1.5.2.xsd";
/** URI of the Security Layer 1.0 namespace. */
- public static final String SL10_NS_URI =
- "http://www.buergerkarte.at/namespaces/securitylayer/20020225#";
+ 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";
+ 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";
+ 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#";
+ 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";
+ 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";
-
+ 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#";
+ 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";
+ 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";
-
+ 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#";
-
+ String ECDSA_NS_URI =
+ "http://www.w3.org/2001/04/xmldsig-more#";
+
/** Prefix used for ECDSA namespace */
- public static final String ECDSA_PREFIX = "ecdsa";
+ String ECDSA_PREFIX = "ecdsa";
/** Local location of ECDSA XML schema definition */
- public static final String ECDSA_SCHEMA_LOCATION =
- SCHEMA_ROOT + "ECDSAKeyValue.xsd";
+ 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#";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ 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";
+ String XML_NS_URI =
+ "http://www.w3.org/XML/1998/namespace";
/** Prefix used for the XML namespace */
- public static final String XML_PREFIX = "xml";
+ String XML_PREFIX = "xml";
/** Local location of the XML schema definition. */
- public static final String XML_SCHEMA_LOCATION = SCHEMA_ROOT + "xml.xsd";
+ 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/";
+ String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/";
/** Prefix used for the XSI namespace */
- public static final String XSI_PREFIX = "xsi";
+ String XSI_PREFIX = "xsi";
/** Local location of the XSI schema definition. */
- public static final String XSI_SCHEMA_LOCATION =
- SCHEMA_ROOT + "XMLSchema-instance.xsd";
+ 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";
+ 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";
+ 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";
+ String XSLT_PREFIX = "xsl";
/** URI of the XMLDSig XML namespace. */
- public static final String DSIG_NS_URI = "http://www.w3.org/2000/09/xmldsig#";
+ 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";
+ String DSIG_PREFIX = "dsig";
/** Local location of the XMLDSig XML schema. */
- public static final String DSIG_SCHEMA_LOCATION =
- SCHEMA_ROOT + "xmldsig-core-schema.xsd";
+ 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";
+ 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";
+ 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";
+ 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#";
-
+ 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";
+ 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";
+ String DSIG_EC_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "exclusive-canonicalization.xsd";
+
+ /** URI of the XMLLoginParameterResolver Configuration XML namespace */
+ String XMLLPR_NS_URI = "http://reference.e-government.gv.at/namespace/moa/20020822#/xmllpr20030814";
- /** 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
+ */
+ String XMLLPR_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "MOAIdentities.xsd";
- /** Local location of the XMLLoginParameterResolver Configuration XML schema definition */
- public static final String XMLLPR_SCHEMA_LOCATION =
- SCHEMA_ROOT + "MOAIdentities.xsd";
-
- /** Local location of the XAdES v1.1.1 schema definition */
- public static final String XADES_1_1_1_SCHEMA_LOCATION =
- SCHEMA_ROOT + "XAdES-1.1.1.xsd";
+ /** Local location of the XAdES v1.1.1 schema definition */
+ String XADES_1_1_1_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "XAdES-1.1.1.xsd";
/** URI of the XAdES v1.1.1 namespace */
- public static final String XADES_1_1_1_NS_URI = "http://uri.etsi.org/01903/v1.1.1#";
-
- public static final String XADES_1_1_1_NS_PREFIX = "xades111";
-
- /** Local location of the XAdES v1.2.2 schema definition */
- public static final String XADES_1_2_2_SCHEMA_LOCATION =
- SCHEMA_ROOT + "XAdES-1.2.2.xsd";
+ String XADES_1_1_1_NS_URI = "http://uri.etsi.org/01903/v1.1.1#";
+
+ String XADES_1_1_1_NS_PREFIX = "xades111";
+
+ /** Local location of the XAdES v1.2.2 schema definition */
+ String XADES_1_2_2_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "XAdES-1.2.2.xsd";
/** URI of the XAdES v1.2.2 namespace */
- public static final String XADES_1_2_2_NS_URI = "http://uri.etsi.org/01903/v1.2.2#";
-
- public static final String XADES_1_2_2_NS_PREFIX = "xades122";
+ String XADES_1_2_2_NS_URI = "http://uri.etsi.org/01903/v1.2.2#";
- /** Local location of the XAdES v1.1.1 schema definition */
- public static final String XADES_1_3_2_SCHEMA_LOCATION =
- SCHEMA_ROOT + "XAdES01903v132-201601.xsd";
+ String XADES_1_2_2_NS_PREFIX = "xades122";
+
+ /** Local location of the XAdES v1.1.1 schema definition */
+ String XADES_1_3_2_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "XAdES01903v132-201601.xsd";
/** URI of the XAdES v1.3.2 namespace */
- public static final String XADES_1_3_2_NS_URI = "http://uri.etsi.org/01903/v1.3.2#";
-
- public static final String XADES_1_3_2_NS_PREFIX = "xades132";
+ String XADES_1_3_2_NS_URI = "http://uri.etsi.org/01903/v1.3.2#";
+
+ String XADES_1_3_2_NS_PREFIX = "xades132";
- /** Local location of the XAdES v1.4.1 schema definition */
- public static final String XADES_1_4_1_SCHEMA_LOCATION =
- SCHEMA_ROOT + "XAdES01903v141-201601.xsd";
+ /** Local location of the XAdES v1.4.1 schema definition */
+ String XADES_1_4_1_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "XAdES01903v141-201601.xsd";
/** URI of the XAdES v1.4.1 namespace */
- public static final String XADES_1_4_1_NS_URI = "http://uri.etsi.org/01903/v1.4.1#";
-
- public static final String XADES_1_4_1_NS_PREFIX = "xades141";
+ String XADES_1_4_1_NS_URI = "http://uri.etsi.org/01903/v1.4.1#";
+
+ String XADES_1_4_1_NS_PREFIX = "xades141";
/** URI of the SAML 2.0 namespace. */
- public static final String SAML2_NS_URI =
- "urn:oasis:names:tc:SAML:2.0:assertion";
+ String SAML2_NS_URI =
+ "urn:oasis:names:tc:SAML:2.0:assertion";
/** Prefix used for the SAML 2.0 XML namespace */
- public static final String SAML2_PREFIX = "saml2";
+ String SAML2_PREFIX = "saml2";
/** Local location of the SAML 2.0 XML schema definition. */
- public static final String SAML2_SCHEMA_LOCATION =
- SCHEMA_ROOT + "saml-schema-assertion-2.0.xsd";
-
+ String SAML2_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "saml-schema-assertion-2.0.xsd";
+
/** URI of the SAML 2.0 protocol namespace. */
- public static final String SAML2P_NS_URI =
- "urn:oasis:names:tc:SAML:2.0:protocol";
+ String SAML2P_NS_URI =
+ "urn:oasis:names:tc:SAML:2.0:protocol";
/** Prefix used for the SAML 2.0 protocol XML namespace */
- public static final String SAML2P_PREFIX = "saml2p";
+ String SAML2P_PREFIX = "saml2p";
/** Local location of the SAML 2.0 protocol XML schema definition. */
- public static final String SAML2P_SCHEMA_LOCATION =
- SCHEMA_ROOT + "saml-schema-protocol-2.0.xsd";
-
+ String SAML2P_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "saml-schema-protocol-2.0.xsd";
+
/** URI of the STORK namespace. */
- public static final String STORK_NS_URI =
- "urn:eu:stork:names:tc:STORK:1.0:assertion";
+ String STORK_NS_URI =
+ "urn:eu:stork:names:tc:STORK:1.0:assertion";
/** Prefix used for the STORK XML namespace */
- public static final String STORK_PREFIX = "stork";
+ String STORK_PREFIX = "stork";
/** Local location of the STORK XML schema definition. */
- public static final String STORK_SCHEMA_LOCATION =
- SCHEMA_ROOT + "stork-schema-assertion-1.0.xsd";
-
+ String STORK_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "stork-schema-assertion-1.0.xsd";
+
/** URI of the STORK protocol namespace. */
- public static final String STORKP_NS_URI =
- "urn:eu:stork:names:tc:STORK:1.0:protocol";
+ String STORKP_NS_URI =
+ "urn:eu:stork:names:tc:STORK:1.0:protocol";
/** Prefix used for the STORK protocol XML namespace */
- public static final String STORKP_PREFIX = "storkp";
+ String STORKP_PREFIX = "storkp";
/** Local location of the STORK protocol XML schema definition. */
- public static final String STORKP_SCHEMA_LOCATION =
- SCHEMA_ROOT + "stork-schema-protocol-1.0.xsd";
-
+ String STORKP_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "stork-schema-protocol-1.0.xsd";
+
/** URI of the TSL namespace. */
- public static final String TSL_NS_URI =
- "http://uri.etsi.org/02231/v2#";
+ String TSL_NS_URI =
+ "http://uri.etsi.org/02231/v2#";
/** Prefix used for the TSL namespace */
- public static final String TSL_PREFIX = "tsl1";
+ String TSL_PREFIX = "tsl1";
/** Local location of the TSL schema definition. */
- public static final String TSL_SCHEMA_LOCATION =
- SCHEMA_ROOT + "ts_119612v010201_xsd.xsd";
+ String TSL_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "ts_119612v010201_xsd.xsd";
/** URI of the TSL SIE namespace. */
- public static final String TSL_SIE_NS_URI =
- "http://uri.etsi.org/TrstSvc/SvcInfoExt/eSigDir-1999-93-EC-TrustedList/#";
+ String TSL_SIE_NS_URI =
+ "http://uri.etsi.org/TrstSvc/SvcInfoExt/eSigDir-1999-93-EC-TrustedList/#";
/** Prefix used for the TSL SIE namespace */
- public static final String TSL_SIE_PREFIX = "tslsie";
+ String TSL_SIE_PREFIX = "tslsie";
/** Local location of the TSL SIE schema definition. */
- public static final String TSL_SIE_SCHEMA_LOCATION =
- SCHEMA_ROOT + "ts_119612v010201_sie_xsd.xsd";
-
+ String TSL_SIE_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "ts_119612v010201_sie_xsd.xsd";
+
/** URI of the TSL additional types namespace. */
- public static final String TSL_ADDTYPES_NS_URI =
- "http://uri.etsi.org/02231/v2/additionaltypes#";
+ String TSL_ADDTYPES_NS_URI =
+ "http://uri.etsi.org/02231/v2/additionaltypes#";
/** Prefix used for the TSL additional types namespace */
- public static final String TSL_ADDTYPES_PREFIX = "tsltype";
+ String TSL_ADDTYPES_PREFIX = "tsltype";
/** Local location of the TSL additional types schema definition. */
- public static final String TSL_ADDTYPES_SCHEMA_LOCATION =
- SCHEMA_ROOT + "ts_ts_119612v010201_additionaltypes_xsd.xsd";
-
+ String TSL_ADDTYPES_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "ts_ts_119612v010201_additionaltypes_xsd.xsd";
+
/** URI of the XML Encryption namespace. */
- public static final String XENC_NS_URI =
- "http://www.w3.org/2001/04/xmlenc#";
+ String XENC_NS_URI =
+ "http://www.w3.org/2001/04/xmlenc#";
/** Prefix used for the XML Encryption XML namespace */
- public static final String XENC_PREFIX = "xenc";
+ String XENC_PREFIX = "xenc";
/** Local location of the XML Encryption XML schema definition. */
- public static final String XENC_SCHEMA_LOCATION =
- SCHEMA_ROOT + "xenc-schema.xsd";
+ String XENC_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "xenc-schema.xsd";
/* Prefix used for the XML Encryption XML namespace */
- public static final String SAML2_METADATA_PREFIX = "md";
-
+ String SAML2_METADATA_PREFIX = "md";
+
/* Prefix used for the XML Encryption XML namespace */
- public static final String SAML2_METADATA_URI = "urn:oasis:names:tc:SAML:2.0:metadata";
+ String SAML2_METADATA_URI = "urn:oasis:names:tc:SAML:2.0:metadata";
/* Local location of the XML Encryption XML schema definition. */
- public static final String SAML2_METADATA_SCHEMA_LOCATION =
- SCHEMA_ROOT + "saml-schema-metadata-2.0.xsd";
+ String SAML2_METADATA_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "saml-schema-metadata-2.0.xsd";
/** Prefix used for the XML Encryption XML namespace */
- public static final String ASIC_PREFIX = "asic";
+ String ASIC_PREFIX = "asic";
/* Prefix used for the XML Encryption XML namespace */
- public static final String ASIC_URI = "http://uri.etsi.org/02918/v1.2.1#";
+ String ASIC_URI = "http://uri.etsi.org/02918/v1.2.1#";
/** Local location of the XML Encryption XML schema definition. */
- public static final String ASIC_SCHEMA_LOCATION =
- SCHEMA_ROOT + "asic.xsd";
-
- /* Prefix and Schema definition for eIDAS specific SAML2 extensions*/
- public static final String SAML2_eIDAS_EXTENSIONS_PREFIX = "eidas";
- public static final String SAML2_eIDAS_EXTENSIONS = "http://eidas.europa.eu/saml-extensions";
- public static final String SAML2_eIDAS_EXTENSIONS_SCHEMA_LOCATION = SCHEMA_ROOT + "eIDAS_saml_extensions.xsd";
-
- public static final String eDELIVERY20_PREFIX = "zu";
- public static final String eDELIVERY20 = "http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#";
- public static final String eDELIVERY20_SCHEMA_LOCATION = SCHEMA_ROOT + "zuse_p2.xsd";
-
- public static final String eDELIVERY_PERSON_20_PREFIX = "zup";
- public static final String eDELIVERY_PERSON_20 = "http://reference.e-government.gv.at/namespace/persondata/phase2/20181206#";
- public static final String eDELIVERY_PERSON_20_SCHEMA_LOCATION = SCHEMA_ROOT + "zuse_mypersondata_en_p2.xsd";
-
-
- public static final String ONLY_MOASIG_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 + " ")
- + (XADES_1_1_1_NS_URI + " " + XADES_1_1_1_SCHEMA_LOCATION + " ")
- + (XADES_1_2_2_NS_URI + " " + XADES_1_2_2_SCHEMA_LOCATION + " ")
- + (XADES_1_3_2_NS_URI + " " + XADES_1_3_2_SCHEMA_LOCATION + " ")
- + (XADES_1_4_1_NS_URI + " " + XADES_1_4_1_SCHEMA_LOCATION + " ")
- + (TSL_NS_URI + " " + TSL_SCHEMA_LOCATION + " ")
- + (TSL_SIE_NS_URI + " " + TSL_SIE_SCHEMA_LOCATION + " ")
- + (TSL_ADDTYPES_NS_URI + " " + TSL_ADDTYPES_SCHEMA_LOCATION + " ")
- + (SAML2_NS_URI + " " + SAML2_SCHEMA_LOCATION + " ")
- + (SAML2P_NS_URI + " " + SAML2P_SCHEMA_LOCATION + " ")
- + (STORK_NS_URI + " " + STORK_SCHEMA_LOCATION + " ")
- + (STORKP_NS_URI + " " + STORKP_SCHEMA_LOCATION + " ")
- + (XENC_NS_URI + " " + XENC_SCHEMA_LOCATION + " ")
- + (SAML2_METADATA_URI + " " + SAML2_METADATA_SCHEMA_LOCATION + " ")
- + (ASIC_URI + " " + ASIC_SCHEMA_LOCATION + " ")
- + (SAML2_eIDAS_EXTENSIONS + " " + SAML2_eIDAS_EXTENSIONS_SCHEMA_LOCATION);
-
+ String ASIC_SCHEMA_LOCATION =
+ SCHEMA_ROOT + "asic.xsd";
+
+ /* Prefix and Schema definition for eIDAS specific SAML2 extensions */
+ String SAML2_eIDAS_EXTENSIONS_PREFIX = "eidas";
+ String SAML2_eIDAS_EXTENSIONS = "http://eidas.europa.eu/saml-extensions";
+ String SAML2_eIDAS_EXTENSIONS_SCHEMA_LOCATION = SCHEMA_ROOT + "eIDAS_saml_extensions.xsd";
+
+ String eDELIVERY20_PREFIX = "zu";
+ String eDELIVERY20 = "http://reference.e-government.gv.at/namespace/zustellung/msg/phase2/20181206#";
+ String eDELIVERY20_SCHEMA_LOCATION = SCHEMA_ROOT + "zuse_p2.xsd";
+
+ String eDELIVERY_PERSON_20_PREFIX = "zup";
+ String eDELIVERY_PERSON_20 = "http://reference.e-government.gv.at/namespace/persondata/phase2/20181206#";
+ String eDELIVERY_PERSON_20_SCHEMA_LOCATION = SCHEMA_ROOT + "zuse_mypersondata_en_p2.xsd";
+
+ String ONLY_MOASIG_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 + " "
+ + XADES_1_1_1_NS_URI + " " + XADES_1_1_1_SCHEMA_LOCATION + " "
+ + XADES_1_2_2_NS_URI + " " + XADES_1_2_2_SCHEMA_LOCATION + " "
+ + XADES_1_3_2_NS_URI + " " + XADES_1_3_2_SCHEMA_LOCATION + " "
+ + XADES_1_4_1_NS_URI + " " + XADES_1_4_1_SCHEMA_LOCATION + " "
+ + TSL_NS_URI + " " + TSL_SCHEMA_LOCATION + " "
+ + TSL_SIE_NS_URI + " " + TSL_SIE_SCHEMA_LOCATION + " "
+ + TSL_ADDTYPES_NS_URI + " " + TSL_ADDTYPES_SCHEMA_LOCATION + " "
+ + SAML2_NS_URI + " " + SAML2_SCHEMA_LOCATION + " "
+ + SAML2P_NS_URI + " " + SAML2P_SCHEMA_LOCATION + " "
+ + STORK_NS_URI + " " + STORK_SCHEMA_LOCATION + " "
+ + STORKP_NS_URI + " " + STORKP_SCHEMA_LOCATION + " "
+ + XENC_NS_URI + " " + XENC_SCHEMA_LOCATION + " "
+ + SAML2_METADATA_URI + " " + SAML2_METADATA_SCHEMA_LOCATION + " "
+ + ASIC_URI + " " + ASIC_SCHEMA_LOCATION + " "
+ + SAML2_eIDAS_EXTENSIONS + " " + SAML2_eIDAS_EXTENSIONS_SCHEMA_LOCATION;
+
/**
- * Contains all namespaces and local schema locations for XML schema
- * definitions relevant for MOA. For use in validating XML parsers.
+ * 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 + " ")
- + (XADES_1_1_1_NS_URI + " " + XADES_1_1_1_SCHEMA_LOCATION + " ")
- + (XADES_1_2_2_NS_URI + " " + XADES_1_2_2_SCHEMA_LOCATION + " ")
- + (XADES_1_3_2_NS_URI + " " + XADES_1_3_2_SCHEMA_LOCATION + " ")
- + (XADES_1_4_1_NS_URI + " " + XADES_1_4_1_SCHEMA_LOCATION + " ")
- + (TSL_NS_URI + " " + TSL_SCHEMA_LOCATION + " ")
- + (TSL_SIE_NS_URI + " " + TSL_SIE_SCHEMA_LOCATION + " ")
- + (TSL_ADDTYPES_NS_URI + " " + TSL_ADDTYPES_SCHEMA_LOCATION + " ")
- + (SAML2_NS_URI + " " + SAML2_SCHEMA_LOCATION + " ")
- + (SAML2P_NS_URI + " " + SAML2P_SCHEMA_LOCATION + " ")
- + (STORK_NS_URI + " " + STORK_SCHEMA_LOCATION + " ")
- + (STORKP_NS_URI + " " + STORKP_SCHEMA_LOCATION + " ")
- + (XENC_NS_URI + " " + XENC_SCHEMA_LOCATION + " ")
- + (SAML2_METADATA_URI + " " + SAML2_METADATA_SCHEMA_LOCATION + " ")
- + (ASIC_URI + " " + ASIC_SCHEMA_LOCATION + " ")
- + (SAML2_eIDAS_EXTENSIONS + " " + SAML2_eIDAS_EXTENSIONS_SCHEMA_LOCATION + " ")
- + (eDELIVERY20 + " " + eDELIVERY20_SCHEMA_LOCATION + " ")
- + (eDELIVERY_PERSON_20 + " " + eDELIVERY_PERSON_20_SCHEMA_LOCATION);
+ 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 + " "
+ + XADES_1_1_1_NS_URI + " " + XADES_1_1_1_SCHEMA_LOCATION + " "
+ + XADES_1_2_2_NS_URI + " " + XADES_1_2_2_SCHEMA_LOCATION + " "
+ + XADES_1_3_2_NS_URI + " " + XADES_1_3_2_SCHEMA_LOCATION + " "
+ + XADES_1_4_1_NS_URI + " " + XADES_1_4_1_SCHEMA_LOCATION + " "
+ + TSL_NS_URI + " " + TSL_SCHEMA_LOCATION + " "
+ + TSL_SIE_NS_URI + " " + TSL_SIE_SCHEMA_LOCATION + " "
+ + TSL_ADDTYPES_NS_URI + " " + TSL_ADDTYPES_SCHEMA_LOCATION + " "
+ + SAML2_NS_URI + " " + SAML2_SCHEMA_LOCATION + " "
+ + SAML2P_NS_URI + " " + SAML2P_SCHEMA_LOCATION + " "
+ + STORK_NS_URI + " " + STORK_SCHEMA_LOCATION + " "
+ + STORKP_NS_URI + " " + STORKP_SCHEMA_LOCATION + " "
+ + XENC_NS_URI + " " + XENC_SCHEMA_LOCATION + " "
+ + SAML2_METADATA_URI + " " + SAML2_METADATA_SCHEMA_LOCATION + " "
+ + ASIC_URI + " " + ASIC_SCHEMA_LOCATION + " "
+ + SAML2_eIDAS_EXTENSIONS + " " + SAML2_eIDAS_EXTENSIONS_SCHEMA_LOCATION + " "
+ + eDELIVERY20 + " " + eDELIVERY20_SCHEMA_LOCATION + " "
+ + eDELIVERY_PERSON_20 + " " + eDELIVERY_PERSON_20_SCHEMA_LOCATION;
/** URN prefix for bPK and wbPK. */
- public static final String URN_PREFIX = "urn:publicid:gv.at";
-
+ String URN_PREFIX = "urn:publicid:gv.at";
+
/** URN prefix for context dependent id. */
- public static final String URN_PREFIX_CDID = URN_PREFIX + ":cdid";
-
+ 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";
+ 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";
-
+ 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";
+ String URN_PREFIX_WBPK = URN_PREFIX + ":wbpk";
/** URN prefix for context dependent id (stork). */
- public static final String URN_PREFIX_STORK = URN_PREFIX + ":storkid";
+ String URN_PREFIX_STORK = URN_PREFIX + ":storkid";
/** URN prefix for context dependent id. */
- public static final String URN_PREFIX_BASEID = URN_PREFIX + ":baseid";
-
+ 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";
+ 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";
-
+ String SHA1_URI =
+ "http://www.w3.org/2000/09/xmldsig#sha1";
+
/** URI of the SHA1 digest algorithm */
- public static final String SHA256_URI =
- "http://www.w3.org/2000/09/xmldsig#sha256";
-
+ String SHA256_URI =
+ "http://www.w3.org/2000/09/xmldsig#sha256";
+
/** URI of the SHA1 digest algorithm */
- public static final String SHA384_URI =
- "http://www.w3.org/2000/09/xmldsig#sha384";
-
+ String SHA384_URI =
+ "http://www.w3.org/2000/09/xmldsig#sha384";
+
/** URI of the SHA1 digest algorithm */
- public static final String SHA512_URI =
- "http://www.w3.org/2000/09/xmldsig#sha512";
-
+ String SHA512_URI =
+ "http://www.w3.org/2000/09/xmldsig#sha512";
+
/** URI of the Canonical XML algorithm */
- public static final String C14N_URI =
- "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
+ 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";
+ 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#";
-
+ 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";
-
+ 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";
-
- /**
+ String MOA_SPSS_CREATE_XML_REQUEST = "CreateXMLSignatureRequest";
+
+ /**
* Local name of request for creating a CMS signature.
*/
- public static final String MOA_SPSS_CREATE_CMS_REQUEST = "CreateCMSSignatureRequest";
-
- /**
+ String MOA_SPSS_CREATE_CMS_REQUEST = "CreateCMSSignatureRequest";
+
+ /**
* Local name of request for creating a CMS signature.
*/
- public static final String MOA_SPSS_CREATE_PDF_REQUEST = "CreatePDFSignatureRequest";
-
- /**
+ String MOA_SPSS_CREATE_PDF_REQUEST = "CreatePDFSignatureRequest";
+
+ /**
* 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<String, String> nSMap = new HashMap<String, String>(5);
-
+ String MOA_SPSS_VERIFY_XML_REQUEST = "VerifiyXMLSignatureRequest";
+
+ /**
+ * A map used to map namespace prefixes to namespace URIs
+ */
+ HashMap<String, String> nSMap = new HashMap<>(5);
+
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DOMUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DOMUtils.java
index 44eba5a..2f96196 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DOMUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DOMUtils.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.ByteArrayInputStream;
@@ -73,12 +72,12 @@ import at.gv.egovernment.moaspss.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.
- *
+ * 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$
*/
@@ -86,57 +85,61 @@ public class DOMUtils {
/** Feature URI for namespace aware parsing. */
private static final String NAMESPACES_FEATURE =
- "http://xml.org/sax/features/namespaces";
+ "http://xml.org/sax/features/namespaces";
/** Feature URI for validating parsing. */
private static final String VALIDATION_FEATURE =
- "http://xml.org/sax/features/validation";
+ "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";
+ "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";
+ "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";
+ "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";
+ "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. */
+ "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";
-
+ "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
+
private static final String EXTERNAL_GENERAL_ENTITIES_FEATURE =
- "http://xml.org/sax/features/external-general-entities";
-
+ "http://xml.org/sax/features/external-general-entities";
+
private static final String EXTERNAL_PARAMETER_ENTITIES_FEATURE =
- "http://xml.org/sax/features/external-parameter-entities";
-
+ "http://xml.org/sax/features/external-parameter-entities";
+
private static final String DISALLOW_DOCTYPE_FEATURE =
- "http://apache.org/xml/features/disallow-doctype-decl";
-
- //Security Manager feature for XERCES XML parser
+ "http://apache.org/xml/features/disallow-doctype-decl";
+
+ // Security Manager feature for XERCES XML parser
private static final String SECURITY_MANAGER =
- org.apache.xerces.impl.Constants.XERCES_PROPERTY_PREFIX + org.apache.xerces.impl.Constants.SECURITY_MANAGER_PROPERTY;
-
-
+ org.apache.xerces.impl.Constants.XERCES_PROPERTY_PREFIX
+ + org.apache.xerces.impl.Constants.SECURITY_MANAGER_PROPERTY;
+
/** 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;
+ 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;
+ /**
+ * Set holding the NamespaceURIs of the grammarPool, to prevent multiple entries
+ * of same grammars to the pool
+ */
+ private static Set grammarNamespaces;
static {
grammarPool.lockPool();
@@ -144,38 +147,38 @@ public class DOMUtils {
}
/**
- * 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
- * <code>systemId</code> (namespace URI) is not already present in the pool.
- *
- * @param inputStream An <code>InputStream</code> providing the contents of
- * the schema.
- * @param systemId The systemId (namespace URI) to use for the schema.
+ * 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 <code>systemId</code>
+ * (namespace URI) is not already present in the pool.
+ *
+ * @param inputStream An <code>InputStream</code> 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 {
+ throws IOException {
XMLGrammarPreparser preparser;
- if (!grammarNamespaces.contains(systemId)) {
+ 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));
-
+ XMLGrammarDescription.XML_SCHEMA,
+ new XMLInputSource(null, systemId, null, inputStream, null));
+
// lock the pool again so that schemas are not added automatically
grammarPool.lockPool();
}
@@ -183,34 +186,43 @@ public class DOMUtils {
/**
* Parse an XML document from an <code>InputStream</code>.
- *
- * @param inputStream The <code>InputStream</code> containing the XML
- * document.
- * @param validating If <code>true</code>, parse validating.
- * @param externalSchemaLocations A <code>String</code> containing namespace
- * URI to schema location pairs, the same way it is accepted by the <code>xsi:
- * schemaLocation</code> attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * <code>xsi:noNamespaceSchemaLocation</code> attribute.
- * @param entityResolver An <code>EntityResolver</code> to resolve external
- * entities (schemas and DTDs). If <code>null</code>, it will not be set.
- * @param errorHandler An <code>ErrorHandler</code> to decide what to do
- * with parsing errors. If <code>null</code>, it will not be set.
+ *
+ * @param inputStream The <code>InputStream</code>
+ * containing the XML document.
+ * @param validating If <code>true</code>, parse
+ * validating.
+ * @param externalSchemaLocations A <code>String</code> containing
+ * namespace URI to schema location
+ * pairs, the same way it is accepted
+ * by the <code>xsi:
+ * schemaLocation</code> attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the schema
+ * for elements without a namespace,
+ * the same way it is accepted by the
+ * <code>xsi:noNamespaceSchemaLocation</code>
+ * attribute.
+ * @param entityResolver An <code>EntityResolver</code> to
+ * resolve external entities (schemas
+ * and DTDs). If <code>null</code>, it
+ * will not be set.
+ * @param errorHandler An <code>ErrorHandler</code> to
+ * decide what to do with parsing
+ * errors. If <code>null</code>, 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 SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
* @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
+ * parser.
*/
public static Document parseDocument(
- InputStream inputStream,
- boolean validating,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation,
- EntityResolver entityResolver,
- ErrorHandler errorHandler)
- throws SAXException, IOException, ParserConfigurationException {
+ InputStream inputStream,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation,
+ EntityResolver entityResolver,
+ ErrorHandler errorHandler)
+ throws SAXException, IOException, ParserConfigurationException {
DOMParser parser;
@@ -222,77 +234,77 @@ public class DOMUtils {
// }
// }
+ // 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()) {
+ final int len = inputStream.available();
+ buffer = new byte[len];
+ inputStream.read(buffer);
+ baStream = new ByteArrayInputStream(buffer);
+ }
- //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);
- parser.setFeature(EXTERNAL_GENERAL_ENTITIES_FEATURE, false);
- parser.setFeature(EXTERNAL_PARAMETER_ENTITIES_FEATURE, false);
-
- SecurityManager xmlParserSecManager = new org.apache.xerces.util.SecurityManager();
- parser.setProperty(SECURITY_MANAGER, xmlParserSecManager);
-
- //fix XXE problem
- //parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
-
- 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);
+ 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);
+ parser.setFeature(EXTERNAL_GENERAL_ENTITIES_FEATURE, false);
+ parser.setFeature(EXTERNAL_PARAMETER_ENTITIES_FEATURE, false);
+
+ final SecurityManager xmlParserSecManager = new org.apache.xerces.util.SecurityManager();
+ parser.setProperty(SECURITY_MANAGER, xmlParserSecManager);
+
+ // fix XXE problem
+ // parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl",
+ // true);
+
+ 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 (final SAXException e) {
+ if (true == Logger.isDebugEnabled() && null != buffer) {
+ final String xmlContent = new String(buffer);
+ Logger.debug("SAXException in:\n" + xmlContent);
+ }
+ throw e;
}
return parser.getDocument();
@@ -300,31 +312,40 @@ public class DOMUtils {
/**
* Parse an XML document from an <code>InputStream</code>.
- *
- * @param inputStream The <code>InputStream</code> containing the XML
- * document.
- * @param validating If <code>true</code>, parse validating.
- * @param externalSchemaLocations A <code>String</code> containing namespace
- * URI to schema location pairs, the same way it is accepted by the <code>xsi:
- * schemaLocation</code> attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * <code>xsi:noNamespaceSchemaLocation</code> attribute.
- * @param entityResolver An <code>EntityResolver</code> to resolve external
- * entities (schemas and DTDs). If <code>null</code>, it will not be set.
- * @param errorHandler An <code>ErrorHandler</code> to decide what to do
- * with parsing errors. If <code>null</code>, it will not be set.
+ *
+ * @param inputStream The <code>InputStream</code>
+ * containing the XML document.
+ * @param validating If <code>true</code>, parse
+ * validating.
+ * @param externalSchemaLocations A <code>String</code> containing
+ * namespace URI to schema location
+ * pairs, the same way it is accepted
+ * by the <code>xsi:
+ * schemaLocation</code> attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the schema
+ * for elements without a namespace,
+ * the same way it is accepted by the
+ * <code>xsi:noNamespaceSchemaLocation</code>
+ * attribute.
+ * @param entityResolver An <code>EntityResolver</code> to
+ * resolve external entities (schemas
+ * and DTDs). If <code>null</code>, it
+ * will not be set.
+ * @param errorHandler An <code>ErrorHandler</code> to
+ * decide what to do with parsing
+ * errors. If <code>null</code>, 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 SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
* @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
+ * parser.
*/
public static Document parseDocumentSimple(InputStream inputStream)
- throws SAXException, IOException, ParserConfigurationException {
+ throws SAXException, IOException, ParserConfigurationException {
DOMParser parser;
-
+
parser = new DOMParser();
// set parser features and properties
parser.setFeature(NAMESPACES_FEATURE, true);
@@ -333,184 +354,200 @@ public class DOMUtils {
parser.setFeature(NORMALIZED_VALUE_FEATURE, false);
parser.setFeature(INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true);
parser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE, false);
-
- SecurityManager xmlParserSecManager = new org.apache.xerces.util.SecurityManager();
+
+ final SecurityManager xmlParserSecManager = new org.apache.xerces.util.SecurityManager();
parser.setProperty(SECURITY_MANAGER, xmlParserSecManager);
-
+
parser.parse(new InputSource(inputStream));
-
+
return parser.getDocument();
}
-
/**
* Parse an XML document from an <code>InputStream</code>.
- *
+ *
* It uses a <code>MOAEntityResolver</code> as the <code>EntityResolver</code>
* and a <code>MOAErrorHandler</code> as the <code>ErrorHandler</code>.
- *
- * @param inputStream The <code>InputStream</code> containing the XML
- * document.
- * @param validating If <code>true</code>, parse validating.
- * @param externalSchemaLocations A <code>String</code> containing namespace
- * URI to schema location pairs, the same way it is accepted by the <code>xsi:
- * schemaLocation</code> attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * <code>xsi:noNamespaceSchemaLocation</code> attribute.
+ *
+ * @param inputStream The <code>InputStream</code>
+ * containing the XML document.
+ * @param validating If <code>true</code>, parse
+ * validating.
+ * @param externalSchemaLocations A <code>String</code> containing
+ * namespace URI to schema location
+ * pairs, the same way it is accepted
+ * by the <code>xsi:
+ * schemaLocation</code> attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the schema
+ * for elements without a namespace,
+ * the same way it is accepted by the
+ * <code>xsi:noNamespaceSchemaLocation</code>
+ * 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 SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
* @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
+ * parser.
*/
public static Document parseDocument(
- InputStream inputStream,
- boolean validating,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation)
- throws SAXException, IOException, ParserConfigurationException {
-
-
-
+ InputStream inputStream,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
+
return parseDocument(
- inputStream,
- validating,
- externalSchemaLocations,
- externalNoNamespaceSchemaLocation,
- new MOAEntityResolver(),
- new MOAErrorHandler());
+ inputStream,
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation,
+ new MOAEntityResolver(),
+ new MOAErrorHandler());
}
/**
* Parse an XML document from a <code>String</code>.
- *
+ *
* It uses a <code>MOAEntityResolver</code> as the <code>EntityResolver</code>
* and a <code>MOAErrorHandler</code> as the <code>ErrorHandler</code>.
- *
- * @param xmlString The <code>String</code> containing the XML document.
- * @param encoding The encoding of the XML document.
- * @param validating If <code>true</code>, parse validating.
- * @param externalSchemaLocations A <code>String</code> containing namespace
- * URI to schema location pairs, the same way it is accepted by the <code>xsi:
- * schemaLocation</code> attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * <code>xsi:noNamespaceSchemaLocation</code> attribute.
+ *
+ * @param xmlString The <code>String</code> containing
+ * the XML document.
+ * @param encoding The encoding of the XML document.
+ * @param validating If <code>true</code>, parse
+ * validating.
+ * @param externalSchemaLocations A <code>String</code> containing
+ * namespace URI to schema location
+ * pairs, the same way it is accepted
+ * by the <code>xsi:
+ * schemaLocation</code> attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the schema
+ * for elements without a namespace,
+ * the same way it is accepted by the
+ * <code>xsi:noNamespaceSchemaLocation</code>
+ * 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 SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
* @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
+ * 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));
+ String xmlString,
+ String encoding,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
+
+ final InputStream in = new ByteArrayInputStream(xmlString.getBytes(encoding));
return parseDocument(
- in,
- validating,
- externalSchemaLocations,
- externalNoNamespaceSchemaLocation);
+ in,
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation);
}
/**
* Parse an UTF-8 encoded XML document from a <code>String</code>.
- *
- * @param xmlString The <code>String</code> containing the XML document.
- * @param validating If <code>true</code>, parse validating.
- * @param externalSchemaLocations A <code>String</code> containing namespace
- * URI to schema location pairs, the same way it is accepted by the <code>xsi:
- * schemaLocation</code> attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * <code>xsi:noNamespaceSchemaLocation</code> attribute.
+ *
+ * @param xmlString The <code>String</code> containing
+ * the XML document.
+ * @param validating If <code>true</code>, parse
+ * validating.
+ * @param externalSchemaLocations A <code>String</code> containing
+ * namespace URI to schema location
+ * pairs, the same way it is accepted
+ * by the <code>xsi:
+ * schemaLocation</code> attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the schema
+ * for elements without a namespace,
+ * the same way it is accepted by the
+ * <code>xsi:noNamespaceSchemaLocation</code>
+ * 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 SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
* @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
+ * parser.
*/
public static Document parseDocument(
- String xmlString,
- boolean validating,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation)
- throws SAXException, IOException, ParserConfigurationException {
+ String xmlString,
+ boolean validating,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws SAXException, IOException, ParserConfigurationException {
return parseDocument(
- xmlString,
- "UTF-8",
- validating,
- externalSchemaLocations,
- externalNoNamespaceSchemaLocation);
+ xmlString,
+ "UTF-8",
+ validating,
+ externalSchemaLocations,
+ externalNoNamespaceSchemaLocation);
}
/**
* A convenience method to parse an XML document validating.
- *
- * @param inputStream The <code>InputStream</code> containing the XML
- * document.
+ *
+ * @param inputStream The <code>InputStream</code> 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 SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
* @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
+ * parser.
*/
public static Element parseXmlValidating(InputStream inputStream)
- throws ParserConfigurationException, SAXException, IOException {
+ throws ParserConfigurationException, SAXException, IOException {
return DOMUtils
- .parseDocument(inputStream, true, Constants.ALL_SCHEMA_LOCATIONS, null)
- .getDocumentElement();
+ .parseDocument(inputStream, true, Constants.ALL_SCHEMA_LOCATIONS, null)
+ .getDocumentElement();
}
-
+
/**
* A convenience method to parse an XML document non validating.
- *
- * @param inputStream The <code>InputStream</code> containing the XML
- * document.
+ *
+ * @param inputStream The <code>InputStream</code> 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 SAXException An error occurred parsing the document.
+ * @throws IOException An error occurred reading the document.
* @throws ParserConfigurationException An error occurred configuring the XML
- * parser.
+ * parser.
*/
public static Element parseXmlNonValidating(InputStream inputStream)
- throws ParserConfigurationException, SAXException, IOException {
+ throws ParserConfigurationException, SAXException, IOException {
return DOMUtils
- .parseDocument(inputStream, false, Constants.ALL_SCHEMA_LOCATIONS, null)
- .getDocumentElement();
+ .parseDocument(inputStream, false, Constants.ALL_SCHEMA_LOCATIONS, null)
+ .getDocumentElement();
}
/**
* Schema validate a given DOM element.
- *
- * @param element The element to validate.
- * @param externalSchemaLocations A <code>String</code> containing namespace
- * URI to schema location pairs, the same way it is accepted by the <code>xsi:
- * schemaLocation</code> attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * <code>xsi:noNamespaceSchemaLocation</code> attribute.
- * @return <code>true</code>, if the <code>element</code> 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.
+ *
+ * @param element The element to validate.
+ * @param externalSchemaLocations A <code>String</code> containing
+ * namespace URI to schema location
+ * pairs, the same way it is accepted
+ * by the <code>xsi:
+ * schemaLocation</code> attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the schema
+ * for elements without a namespace,
+ * the same way it is accepted by the
+ * <code>xsi:noNamespaceSchemaLocation</code>
+ * attribute.
+ * @return <code>true</code>, if the <code>element</code> 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.
+ * @throws TransformerException An error occurred serializing the
+ * element.
*/
public static boolean validateElement(
- Element element,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation)
- throws
- ParserConfigurationException,
+ Element element,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation)
+ throws ParserConfigurationException,
IOException,
SAXException,
TransformerException {
@@ -534,16 +571,16 @@ public class DOMUtils {
parser.setFeature(SCHEMA_VALIDATION_FEATURE, true);
parser.setFeature(EXTERNAL_GENERAL_ENTITIES_FEATURE, false);
parser.setFeature(DISALLOW_DOCTYPE_FEATURE, true);
-
+
if (externalSchemaLocations != null) {
parser.setProperty(
- EXTERNAL_SCHEMA_LOCATION_PROPERTY,
- externalSchemaLocations);
+ EXTERNAL_SCHEMA_LOCATION_PROPERTY,
+ externalSchemaLocations);
}
if (externalNoNamespaceSchemaLocation != null) {
parser.setProperty(
- EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
- "externalNoNamespaceSchemaLocation");
+ EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
+ "externalNoNamespaceSchemaLocation");
}
// set up entity resolver and error handler
@@ -555,32 +592,35 @@ public class DOMUtils {
return true;
}
-
/**
* Schema validate a given DOM element.
- *
- * @param element The element to validate.
- * @param externalSchemaLocations A <code>String</code> containing namespace
- * URI to schema location pairs, the same way it is accepted by the <code>xsi:
- * schemaLocation</code> attribute.
- * @param externalNoNamespaceSchemaLocation The schema location of the
- * schema for elements without a namespace, the same way it is accepted by the
- * <code>xsi:noNamespaceSchemaLocation</code> attribute.
- * @return <code>true</code>, if the <code>element</code> 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.
+ *
+ * @param element The element to validate.
+ * @param externalSchemaLocations A <code>String</code> containing
+ * namespace URI to schema location
+ * pairs, the same way it is accepted
+ * by the <code>xsi:
+ * schemaLocation</code> attribute.
+ * @param externalNoNamespaceSchemaLocation The schema location of the schema
+ * for elements without a namespace,
+ * the same way it is accepted by the
+ * <code>xsi:noNamespaceSchemaLocation</code>
+ * attribute.
+ * @return <code>true</code>, if the <code>element</code> 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.
+ * @throws TransformerException An error occurred serializing the
+ * element.
*/
public static boolean validateElement(
- Element element,
- String externalSchemaLocations,
- String externalNoNamespaceSchemaLocation,
- EntityResolver entityResolver)
- throws
- ParserConfigurationException,
+ Element element,
+ String externalSchemaLocations,
+ String externalNoNamespaceSchemaLocation,
+ EntityResolver entityResolver)
+ throws ParserConfigurationException,
IOException,
SAXException,
TransformerException {
@@ -602,19 +642,19 @@ public class DOMUtils {
parser.setFeature(NAMESPACES_FEATURE, true);
parser.setFeature(VALIDATION_FEATURE, true);
parser.setFeature(SCHEMA_VALIDATION_FEATURE, true);
-
- SecurityManager xmlParserSecManager = new org.apache.xerces.util.SecurityManager();
+
+ final SecurityManager xmlParserSecManager = new org.apache.xerces.util.SecurityManager();
parser.setProperty(SECURITY_MANAGER, xmlParserSecManager);
-
+
if (externalSchemaLocations != null) {
parser.setProperty(
- EXTERNAL_SCHEMA_LOCATION_PROPERTY,
- externalSchemaLocations);
+ EXTERNAL_SCHEMA_LOCATION_PROPERTY,
+ externalSchemaLocations);
}
if (externalNoNamespaceSchemaLocation != null) {
parser.setProperty(
- EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
- "externalNoNamespaceSchemaLocation");
+ EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
+ "externalNoNamespaceSchemaLocation");
}
// set up entity resolver and error handler
@@ -625,122 +665,127 @@ public class DOMUtils {
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 <code>String</code> representation of the given DOM
- * node.
- * @throws TransformerException An error occurred transforming the
- * node to a <code>String</code>.
- * @throws IOException An IO error occurred writing the node to a byte array.
+ * @return String The <code>String</code> representation of the given DOM node.
+ * @throws TransformerException An error occurred transforming the node to a
+ * <code>String</code>.
+ * @throws IOException An IO error occurred writing the node to a byte
+ * array.
*/
public static String serializeNode(Node node)
- throws TransformerException, IOException {
+ 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 node The node to serialize.
* @param omitXmlDeclaration The boolean value for omitting the XML Declaration.
- * @return String The <code>String</code> representation of the given DOM
- * node.
- * @throws TransformerException An error occurred transforming the
- * node to a <code>String</code>.
- * @throws IOException An IO error occurred writing the node to a byte array.
+ * @return String The <code>String</code> representation of the given DOM node.
+ * @throws TransformerException An error occurred transforming the node to a
+ * <code>String</code>.
+ * @throws IOException An IO error occurred writing the node to a byte
+ * array.
*/
public static String serializeNode(Node node, boolean omitXmlDeclaration)
- throws TransformerException, IOException {
+ 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 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 <code>String</code> representation of the given DOM
- * node.
- * @throws TransformerException An error occurred transforming the
- * node to a <code>String</code>.
- * @throws IOException An IO error occurred writing the node to a byte array.
+ * @param lineSeperator Sets the line seperator String of the parser
+ * @return String The <code>String</code> representation of the given DOM node.
+ * @throws TransformerException An error occurred transforming the node to a
+ * <code>String</code>.
+ * @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 {
+ 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 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 <code>String</code>.
- * @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.
+ * this can easily be converted into a <code>String</code>.
+ * @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 {
+ 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 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 <code>String</code>.
- * @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.
+ * this can easily be converted into a <code>String</code>.
+ * @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 {
+ 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 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
+ * @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 <code>String</code>.
- * @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.
+ * this can easily be converted into a <code>String</code>.
+ * @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 {
+ 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);
+ final TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ final Transformer transformer = transformerFactory.newTransformer();
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream(16384);
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING, xmlEncoding);
- String omit = omitDeclaration ? "yes" : "no";
+ final 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
+ 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));
@@ -751,30 +796,30 @@ public class DOMUtils {
}
/**
- * Return the text that a node contains.
- *
- * This routine:
- * <ul>
- * <li>Ignores comments and processing instructions.</li>
- * <li>Concatenates TEXT nodes, CDATA nodes, and the results recursively
- * processing EntityRef nodes.</li>
- * <li>Ignores any element nodes in the sublist. (Other possible options are
- * to recurse into element sublists or throw an exception.)</li>
- * </ul>
- *
- * @param node A DOM node from which to extract text.
- * @return A String representing its contents.
- */
+ * Return the text that a node contains.
+ *
+ * This routine:
+ * <ul>
+ * <li>Ignores comments and processing instructions.</li>
+ * <li>Concatenates TEXT nodes, CDATA nodes, and the results recursively
+ * processing EntityRef nodes.</li>
+ * <li>Ignores any element nodes in the sublist. (Other possible options are to
+ * recurse into element sublists or throw an exception.)</li>
+ * </ul>
+ *
+ * @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();
+ final StringBuffer result = new StringBuffer();
+ final NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
- Node subnode = list.item(i);
+ final Node subnode = list.item(i);
if (subnode.getNodeType() == Node.TEXT_NODE) {
result.append(subnode.getNodeValue());
} else if (subnode.getNodeType() == Node.CDATA_SECTION_NODE) {
@@ -791,28 +836,28 @@ public class DOMUtils {
/**
* 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 <code>String</code> value to <code>String</code> value mapping).
+ * @return The namespace prefix to namespace URL mapping ( a <code>String</code>
+ * value to <code>String</code> value mapping).
*/
public static Map getNamespaceDeclarations(Node node) {
- Map nsDecls = new HashMap();
+ final Map nsDecls = new HashMap();
int i;
do {
if (node.hasAttributes()) {
- NamedNodeMap attrs = node.getAttributes();
+ final NamedNodeMap attrs = node.getAttributes();
for (i = 0; i < attrs.getLength(); i++) {
- Attr attr = (Attr) attrs.item(i);
+ final Attr attr = (Attr) attrs.item(i);
// add prefix mapping if none exists
if ("xmlns".equals(attr.getPrefix())
- || "xmlns".equals(attr.getName())) {
+ || "xmlns".equals(attr.getName())) {
- String nsPrefix =
- attr.getPrefix() != null ? attr.getLocalName() : "";
+ final String nsPrefix =
+ attr.getPrefix() != null ? attr.getLocalName() : "";
if (nsDecls.get(nsPrefix) == null) {
nsDecls.put(nsPrefix, attr.getValue());
@@ -826,26 +871,26 @@ public class DOMUtils {
}
/**
- * 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.
- *
+ * 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();
+ final Node parent = context.getParentNode();
if (parent != null) {
- Map namespaces = getNamespaceDeclarations(context.getParentNode());
- Set nsUris = collectNamespaceURIs(context);
+ final Map namespaces = getNamespaceDeclarations(context.getParentNode());
+ final Set nsUris = collectNamespaceURIs(context);
Iterator iter;
for (iter = namespaces.entrySet().iterator(); iter.hasNext();) {
- Map.Entry e = (Map.Entry) iter.next();
+ final 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;
+ final String prefix = (String) e.getKey();
+ final String nsUri = (String) e.getValue();
+ final String nsAttrName = "".equals(prefix) ? "xmlns" : "xmlns:" + prefix;
context.setAttributeNS(Constants.XMLNS_NS_URI, nsAttrName, nsUri);
}
@@ -855,13 +900,13 @@ public class DOMUtils {
/**
* 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 <code>context</code>,
- * including the ones used in <code>context</code> itself.
+ * including the ones used in <code>context</code> itself.
*/
public static Set collectNamespaceURIs(Element context) {
- Set result = new HashSet();
+ final Set result = new HashSet();
collectNamespaceURIsImpl(context, result);
return result;
@@ -869,14 +914,14 @@ public class DOMUtils {
/**
* A recursive method to do the work of <code>collectNamespaceURIs</code>.
- *
+ *
* @param context The context element to evaluate.
- * @param result The result, passed as a parameter to avoid unnecessary
- * instantiations of <code>Set</code>.
+ * @param result The result, passed as a parameter to avoid unnecessary
+ * instantiations of <code>Set</code>.
*/
private static void collectNamespaceURIsImpl(Element context, Set result) {
- NamedNodeMap attrs = context.getAttributes();
- NodeList childNodes = context.getChildNodes();
+ final NamedNodeMap attrs = context.getAttributes();
+ final NodeList childNodes = context.getChildNodes();
String nsUri;
int i;
@@ -896,7 +941,7 @@ public class DOMUtils {
// add all namespaces from subelements
for (i = 0; i < childNodes.getLength(); i++) {
- Node node = childNodes.item(i);
+ final Node node = childNodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
collectNamespaceURIsImpl((Element) node, result);
@@ -907,13 +952,13 @@ public class DOMUtils {
/**
* Check, that each attribute node in the given <code>NodeList</code> has its
* parent in the <code>NodeList</code> as well.
- *
+ *
* @param nodes The <code>NodeList</code> to check.
- * @return <code>true</code>, if each attribute node in <code>nodes</code>
- * has its parent in <code>nodes</code> as well.
+ * @return <code>true</code>, if each attribute node in <code>nodes</code> has
+ * its parent in <code>nodes</code> as well.
*/
public static boolean checkAttributeParentsInNodeList(NodeList nodes) {
- Set nodeSet = new HashSet();
+ final Set nodeSet = new HashSet();
int i;
// put the nodes into the nodeSet
@@ -923,11 +968,11 @@ public class DOMUtils {
// check that each attribute node's parent is in the node list
for (i = 0; i < nodes.getLength(); i++) {
- Node n = nodes.item(i);
+ final Node n = nodes.item(i);
if (n.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr attr = (Attr) n;
- Element owner = attr.getOwnerElement();
+ final Attr attr = (Attr) n;
+ final Element owner = attr.getOwnerElement();
if (owner == null) {
if (!isNamespaceDeclaration(attr)) {
@@ -945,29 +990,28 @@ public class DOMUtils {
}
/**
- * Convert an unstructured <code>NodeList</code> into a
+ * Convert an unstructured <code>NodeList</code> into a
* <code>DocumentFragment</code>.
*
- * @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.
+ * @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.
+ * 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.
+ * @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 {
+ throws ParserConfigurationException {
- DocumentBuilder builder =
- DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = builder.newDocument();
- DocumentFragment result = doc.createDocumentFragment();
+ final DocumentBuilder builder =
+ DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ final Document doc = builder.newDocument();
+ final DocumentFragment result = doc.createDocumentFragment();
if (null == nodeList || nodeList.getLength() == 0) {
return result;
@@ -975,116 +1019,114 @@ public class DOMUtils {
int currPos = 0;
currPos =
- nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
+ nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
while (currPos < nodeList.getLength()) {
currPos =
- nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
+ nodeList2DocumentFragment(nodeList, currPos, result, null, null) + 1;
}
return result;
}
/**
* Helper method for the <code>nodeList2DocumentFragment</code>.
- *
- * @param nodeList The <code>NodeList</code> to convert.
- * @param currPos The current position in the <code>nodeList</code>.
- * @param result The resulting <code>DocumentFragment</code>.
- * @param currOrgElem The current original element.
+ *
+ * @param nodeList The <code>NodeList</code> to convert.
+ * @param currPos The current position in the <code>nodeList</code>.
+ * @param result The resulting <code>DocumentFragment</code>.
+ * @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) {
+ NodeList nodeList,
+ int currPos,
+ DocumentFragment result,
+ Element currOrgElem,
+ Element currClonedElem) {
while (currPos < nodeList.getLength()) {
- Node currentNode = nodeList.item(currPos);
+ final 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(
+ 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;
}
- break;
+
+ currClonedElem.appendChild(
+ result.getOwnerDocument().importNode(currentNode, false));
}
+ break;
+ }
- case Node.ELEMENT_NODE :
- {
- Element nextCurrOrgElem = (Element) currentNode;
- Element nextCurrClonedElem =
+ case Node.ELEMENT_NODE: {
+ final Element nextCurrOrgElem = (Element) currentNode;
+ final 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);
+ 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;
}
- // Process current Node (of type Element) recursively
- currPos =
+ currClonedElem.appendChild(nextCurrClonedElem);
+ }
+
+ // Process current Node (of type Element) recursively
+ currPos =
nodeList2DocumentFragment(
- nodeList,
- ++currPos,
- result,
- nextCurrOrgElem,
- nextCurrClonedElem);
+ nodeList,
+ ++currPos,
+ result,
+ nextCurrOrgElem,
+ nextCurrClonedElem);
- break;
- }
+ break;
+ }
- case Node.ATTRIBUTE_NODE :
- {
- Attr currAttr = (Attr) currentNode;
+ case Node.ATTRIBUTE_NODE: {
+ final Attr currAttr = (Attr) currentNode;
- // GK 20030411: Hack to overcome problems with IAIK IXSIL
- if (currAttr.getOwnerElement() == null)
- break;
- if (currClonedElem == null)
- break;
+ // 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(
+ // currClonedElem must be the owner Element of currAttr if
+ // preconditions are met
+ currClonedElem.setAttributeNS(
currAttr.getNamespaceURI(),
currAttr.getNodeName(),
currAttr.getValue());
- break;
- }
+ break;
+ }
- default :
- {
- // All other nodes will be ignored
- }
+ default: {
+ // All other nodes will be ignored
+ }
}
currPos++;
@@ -1095,10 +1137,10 @@ public class DOMUtils {
/**
* Check, if the given attribute is a namespace declaration.
- *
+ *
* @param attr The attribute to check.
* @return <code>true</code>, if the attribute is a namespace declaration,
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
private static boolean isNamespaceDeclaration(Attr attr) {
return Constants.XMLNS_NS_URI.equals(attr.getNamespaceURI());
@@ -1106,81 +1148,82 @@ public class DOMUtils {
/**
* 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 <code>true</code>, if <code>candAnc</code> is an (indirect)
- * ancestor of <code>cand</code>; <code>false</code> otherwise.
+ * @param cand The node to check for being the child.
+ * @return <code>true</code>, if <code>candAnc</code> is an (indirect) ancestor
+ * of <code>cand</code>; <code>false</code> otherwise.
*/
public static boolean isAncestor(Element candAnc, Node cand) {
Node currPar = cand.getParentNode();
while (currPar != null) {
- if (candAnc == currPar)
+ 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 <code>null</code>
- * if the node list is <code>null</code> or empty or no element is
- * included in the list.
+ *
+ * @param nl The NodeList to get the element from.
+ * @return The (first) element included in the node list or <code>null</code> if
+ * the node list is <code>null</code> or empty or no element is included
+ * in the list.
*/
- public static Element getElementFromNodeList (NodeList nl) {
- if ((nl == null) || (nl.getLength() == 0)) {
+ public static Element getElementFromNodeList(NodeList nl) {
+ if (nl == null || nl.getLength() == 0) {
return null;
}
- for (int i=0; i<nl.getLength(); i++) {
- Node node = nl.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- return (Element)node;
+ for (int i = 0; i < nl.getLength(); i++) {
+ final Node node = nl.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) node;
}
}
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.
+ *
+ * @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);
+ public static List getChildElements(Element parent) {
+ final Vector v = new Vector();
+ final NodeList nl = parent.getChildNodes();
+ final int length = nl.getLength();
+ for (int i = 0; i < length; i++) {
+ final Node node = nl.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
- v.add((Element)node);
+ v.add(node);
}
}
return v;
}
-
+
/**
* Returns a byte array from given node.
+ *
* @param node
* @return
* @throws TransformerException
*/
public static byte[] nodeToByteArray(Node node) throws TransformerException {
- Source source = new DOMSource(node);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- //StringWriter stringWriter = new StringWriter();
- Result result = new StreamResult(out);
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTransformer();
- transformer.transform(source, result);
- return out.toByteArray();
+ final Source source = new DOMSource(node);
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ // StringWriter stringWriter = new StringWriter();
+ final Result result = new StreamResult(out);
+ final TransformerFactory factory = TransformerFactory.newInstance();
+ final Transformer transformer = factory.newTransformer();
+ transformer.transform(source, result);
+ return out.toByteArray();
}
-
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DateTimeUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DateTimeUtils.java
index c199c29..a874bd5 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DateTimeUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/DateTimeUtils.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.StringWriter;
@@ -38,9 +37,9 @@ import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
/**
- * Utility for parsing and building XML type <code>dateTime</code>,
- * according to ISO 8601.
- *
+ * Utility for parsing and building XML type <code>dateTime</code>, according to
+ * ISO 8601.
+ *
* @author Patrick Peck
* @version $Id$
* @see <code>http://www.w3.org/2001/XMLSchema-datatypes"</code>
@@ -55,7 +54,7 @@ public class DateTimeUtils {
// * @return the <code>dateTime</code> value
// */
// public static String buildDateTime(Calendar cal, boolean useUTC) {
-//
+//
// if (useUTC)
// return buildDateTimeUTC(cal);
// else {
@@ -92,41 +91,46 @@ public class DateTimeUtils {
// return out.toString();
// }
// }
-
+
/**
- * Builds a <code>dateTime</code> value in UTC from a <code>Calendar</code> value.
+ * Builds a <code>dateTime</code> value in UTC from a <code>Calendar</code>
+ * value.
+ *
* @param cal the <code>Calendar</code> value
* @return the <code>dateTime</code> value
*/
public static String buildDateTimeUTC(Calendar cal) {
-
- SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
- f.setTimeZone(TimeZone.getTimeZone("UTC"));
-
- return f.format(cal.getTime());
+
+ final SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ f.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ return f.format(cal.getTime());
}
-
+
/**
- * Builds a <code>dateTime</code> value in UTC from a <code>Calendar</code> value.
+ * Builds a <code>dateTime</code> value in UTC from a <code>Calendar</code>
+ * value.
+ *
* @param cal the <code>Calendar</code> value
* @return the <code>dateTime</code> value
*/
public static String buildDateTimeUTC(Date cal) {
-
- SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
- f.setTimeZone(TimeZone.getTimeZone("UTC"));
-
- return f.format(cal);
-
+
+ final SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ f.setTimeZone(TimeZone.getTimeZone("UTC"));
+
+ return f.format(cal);
+
}
-
+
/**
* Builds a <code>dateTime</code> value from a <code>Calendar</code> value.
+ *
* @param cal the <code>Calendar</code> value
* @return the <code>dateTime</code> value
*/
public static String buildDate(Calendar cal) {
- StringWriter out = new StringWriter();
+ final StringWriter out = new StringWriter();
out.write("" + cal.get(Calendar.YEAR));
out.write("-");
out.write(to2DigitString(cal.get(Calendar.MONTH) + 1));
@@ -134,43 +138,45 @@ public class DateTimeUtils {
out.write(to2DigitString(cal.get(Calendar.DAY_OF_MONTH)));
return out.toString();
}
-
+
/**
* Builds a <code>dateTime</code> value from a <code>Calendar</code> value.
+ *
* @param cal the <code>Calendar</code> value
* @return the <code>dateTime</code> value
*/
public static String buildTime(Calendar cal) {
- StringWriter out = new StringWriter();
- 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)));
-
- return out.toString();
+ final StringWriter out = new StringWriter();
+ 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)));
+
+ return out.toString();
}
-
+
/**
- * Converts month, day, hour, minute, or second value
- * to a 2 digit String.
+ * 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)
+ if (number < 10) {
return "0" + number;
- else
+ } else {
return "" + number;
+ }
}
/**
- * Parse a <code>String</code> containing a date and time instant, given in
- * ISO 8601 format.
- *
+ * Parse a <code>String</code> containing a date and time instant, given in ISO
+ * 8601 format.
+ *
* @param dateTime The <code>String</code> to parse.
* @return The <code>Date</code> representation of the contents of
- * <code>dateTime</code>.
+ * <code>dateTime</code>.
* @throws ParseException Parsing the <code>dateTime</code> failed.
*/
public static Date parseDateTime(String dateTime) throws ParseException {
@@ -247,8 +253,7 @@ public class DateTimeUtils {
curPos++;
ensureDigits(dateTime, curPos, 1);
fractStr = "0.";
- fractStr
- += dateTime.substring(curPos, curPos + countDigits(dateTime, curPos));
+ fractStr += dateTime.substring(curPos, curPos + countDigits(dateTime, curPos));
fraction = Double.parseDouble(fractStr);
curPos += countDigits(dateTime, curPos);
}
@@ -294,12 +299,12 @@ public class DateTimeUtils {
calendar.set(Calendar.MILLISECOND, 0);
time = calendar.getTime().getTime();
time += (long) (fraction * 1000.0);
- time -= tzSign * ((tzHour * 60) + tzMinute) * 60 * 1000;
+ time -= tzSign * (tzHour * 60 + tzMinute) * 60 * 1000;
if (localTime) {
- time -= TimeZone.getDefault().getRawOffset();
+ time -= TimeZone.getDefault().getRawOffset();
}
return new Date(time);
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
throw new ParseException(msg.getMessage("datetime.00", null), curPos);
}
@@ -307,16 +312,16 @@ public class DateTimeUtils {
/**
* Parse an integer value.
- *
- * @param str The <code>String</code> containing the digits.
+ *
+ * @param str The <code>String</code> 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
- * <code>str</code>.
+ * <code>str</code>.
* @throws ParseException Parsing the integer value failed.
*/
private static int parseInt(String str, int curPos, int digits)
- throws ParseException {
+ throws ParseException {
ensureDigits(str, curPos, digits);
return Integer.parseInt(str.substring(curPos, curPos + digits));
@@ -324,31 +329,33 @@ public class DateTimeUtils {
/**
* Count the number of digits following <code>curPos</code>.
- *
- * @param str The <code>String</code> in which to count digits.
+ *
+ * @param str The <code>String</code> 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++);
+ 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 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
- * <code>ParseException</code>.
+ * <code>ParseException</code>.
* @throws ParseException Thrown, if <code>value &lt; min || value &gt;
* max</code>
*/
private static void ensureValue(int value, int min, int max, int curPos)
- throws ParseException {
+ throws ParseException {
if (value < min || value > max) {
throw new ParseException(msg.getMessage("datetime.00", null), curPos);
@@ -357,16 +364,16 @@ public class DateTimeUtils {
/**
* Ensure that the given <code>String</code> has a number of characters left.
- *
- * @param str The <code>String</code> to check for its length.
+ *
+ * @param str The <code>String</code> to check for its length.
* @param curPos The starting position.
- * @param count The minimum number of characters that <code>str</code> must
- * contain, starting at from <code>curPos</code>.
- * @throws ParseException Thrown, if
- * <code>curPos + count &gt; str.length()</code>.
+ * @param count The minimum number of characters that <code>str</code> must
+ * contain, starting at from <code>curPos</code>.
+ * @throws ParseException Thrown, if
+ * <code>curPos + count &gt; str.length()</code>.
*/
private static void ensureChars(String str, int curPos, int count)
- throws ParseException {
+ throws ParseException {
if (curPos + count > str.length()) {
throw new ParseException(msg.getMessage("datetime.00", null), curPos);
}
@@ -375,17 +382,17 @@ public class DateTimeUtils {
/**
* Ensure that a given <code>String</code> contains a certain character at a
* certain position.
- *
- * @param str The <code>String</code> in which to look up the character.
+ *
+ * @param str The <code>String</code> in which to look up the character.
* @param curPos The position in <code>str</code> that must contain the
- * character.
- * @param c The character value that must be contained at position
- * <code>curPos</code>.
+ * character.
+ * @param c The character value that must be contained at position
+ * <code>curPos</code>.
* @throws ParseException Thrown, if the characters do not match or
- * <code>curPos</code> is out of range.
+ * <code>curPos</code> is out of range.
*/
private static void ensureChar(String str, int curPos, char c)
- throws ParseException {
+ throws ParseException {
ensureChars(str, curPos, 1);
if (str.charAt(curPos) != c) {
@@ -394,19 +401,19 @@ public class DateTimeUtils {
}
/**
- * Ensure that a given <code>String</code> contains a number of digits,
- * starting at a given position.
- *
- * @param str The <code>String</code> to scan for digits.
+ * Ensure that a given <code>String</code> contains a number of digits, starting
+ * at a given position.
+ *
+ * @param str The <code>String</code> to scan for digits.
* @param curPos The starting postion.
- * @param count The number of digits that must be contained in
- * <code>str</code>, starting at <code>curPos</code>.
- * @throws ParseException Thrown, if <code>str</code> is not long enough, or
- * one of the characters following <code>curPos</code> in <code>str</code> is
- * not a digit.
+ * @param count The number of digits that must be contained in
+ * <code>str</code>, starting at <code>curPos</code>.
+ * @throws ParseException Thrown, if <code>str</code> is not long enough, or one
+ * of the characters following <code>curPos</code> in
+ * <code>str</code> is not a digit.
*/
private static void ensureDigits(String str, int curPos, int count)
- throws ParseException {
+ throws ParseException {
ensureChars(str, curPos, count);
for (int i = curPos; i < curPos + count; i++) {
@@ -415,101 +422,108 @@ public class DateTimeUtils {
}
}
}
-
+
/**
* Calculates the age if date of birth is given (for a calendar time stamp)
+ *
* @param dateOfBirth Date of Birth
- * @param now Calendar time stamp at which the age needs to be calculated for
+ * @param now Calendar time stamp at which the age needs to be
+ * calculated for
* @return Age of a person
*/
public static int calcAge(Calendar dateOfBirth, Calendar now) {
- int age = now.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);
-
- int nowM = now.get(Calendar.MONTH);
- int dobM = dateOfBirth.get(Calendar.MONTH);
- int nowDOM = now.get(Calendar.DAY_OF_MONTH);
- int dobDOM = dateOfBirth.get(Calendar.DAY_OF_MONTH);
-
- if ((nowM < dobM) || ((nowM == dobM) && (nowDOM < dobDOM))) {
- age--;
- }
-
- if (age < 0) {
- throw new IllegalArgumentException("Calculated age results in negative value.");
- }
- return age;
- }
+ int age = now.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);
+
+ final int nowM = now.get(Calendar.MONTH);
+ final int dobM = dateOfBirth.get(Calendar.MONTH);
+ final int nowDOM = now.get(Calendar.DAY_OF_MONTH);
+ final int dobDOM = dateOfBirth.get(Calendar.DAY_OF_MONTH);
+
+ if (nowM < dobM || nowM == dobM && nowDOM < dobDOM) {
+ age--;
+ }
+
+ if (age < 0) {
+ throw new IllegalArgumentException("Calculated age results in negative value.");
+ }
+ return age;
+ }
/**
* Calculates the age if date of birth is given as Calendar object
+ *
* @param dateOfBirth Date of Birth as Calendar object
* @return Age of a person
*/
- public static int calcAge(Calendar dateOfBirth) {
- return calcAge(dateOfBirth, Calendar.getInstance());
- }
-
- /**
- * Calculates the age if date of birth is given (for a date time stamp)
- * @param dateOfBirth Date of Birth
- * @param now Date time stamp at which the age needs to be calculated for
- * @return Age of a person
- */
- public static int calcAge(Date dateOfBirth, Date now) {
- Calendar dob = Calendar.getInstance();
- dob.setTime(dateOfBirth);
- Calendar nowCal = Calendar.getInstance();
- nowCal.setTime(now);
- return calcAge(dob, nowCal);
- }
-
- /**
- * Calculates the age if date of birth is given as Date object
- * @param dateOfBirth Date of Birth as Date object
- * @return Age of a person
- */
- public static int calcAge(Date dateOfBirth) {
- return calcAge(dateOfBirth, new Date());
- }
-
- public static String formatPEPSDateToMOADate(String pepsDate) {
-
- if (StringUtils.isEmpty(pepsDate)) {
- return null;
- }
-
- DateTimeFormatter fmt = null;
-
- switch (pepsDate.length()) {
- case 4:
- fmt = DateTimeFormat.forPattern("yyyy");
- break;
- case 6:
- fmt = DateTimeFormat.forPattern("yyyyMM");
- break;
- case 8:
- fmt = DateTimeFormat.forPattern("yyyyMMdd");
- break;
- default:
- fmt = DateTimeFormat.forPattern("yyyy-MM-dd");
- break;
- }
-
- DateTime dt = fmt.parseDateTime(pepsDate);
- DateTimeFormatter fmt2 = DateTimeFormat.forPattern("yyyy-MM-dd");
- return fmt2.print(dt);
-
- }
-
- /**
- * Returns a date as String using a provided format
- * @param format Format the date/time should be returned
- * @return Date/Time as String formatted according the provided format
- */
- public static String getDateTimeWithFormat(String format) {
- DateFormat dateFormat = new SimpleDateFormat(format);
- Date date = new Date();
- return dateFormat.format(date);
+ public static int calcAge(Calendar dateOfBirth) {
+ return calcAge(dateOfBirth, Calendar.getInstance());
+ }
+
+ /**
+ * Calculates the age if date of birth is given (for a date time stamp)
+ *
+ * @param dateOfBirth Date of Birth
+ * @param now Date time stamp at which the age needs to be calculated
+ * for
+ * @return Age of a person
+ */
+ public static int calcAge(Date dateOfBirth, Date now) {
+ final Calendar dob = Calendar.getInstance();
+ dob.setTime(dateOfBirth);
+ final Calendar nowCal = Calendar.getInstance();
+ nowCal.setTime(now);
+ return calcAge(dob, nowCal);
+ }
+
+ /**
+ * Calculates the age if date of birth is given as Date object
+ *
+ * @param dateOfBirth Date of Birth as Date object
+ * @return Age of a person
+ */
+ public static int calcAge(Date dateOfBirth) {
+ return calcAge(dateOfBirth, new Date());
+ }
+
+ public static String formatPEPSDateToMOADate(String pepsDate) {
+
+ if (StringUtils.isEmpty(pepsDate)) {
+ return null;
}
+ DateTimeFormatter fmt = null;
+
+ switch (pepsDate.length()) {
+ case 4:
+ fmt = DateTimeFormat.forPattern("yyyy");
+ break;
+ case 6:
+ fmt = DateTimeFormat.forPattern("yyyyMM");
+ break;
+ case 8:
+ fmt = DateTimeFormat.forPattern("yyyyMMdd");
+ break;
+ default:
+ fmt = DateTimeFormat.forPattern("yyyy-MM-dd");
+ break;
+ }
+
+ final DateTime dt = fmt.parseDateTime(pepsDate);
+ final DateTimeFormatter fmt2 = DateTimeFormat.forPattern("yyyy-MM-dd");
+ return fmt2.print(dt);
+
+ }
+
+ /**
+ * Returns a date as String using a provided format
+ *
+ * @param format Format the date/time should be returned
+ * @return Date/Time as String formatted according the provided format
+ */
+ public static String getDateTimeWithFormat(String format) {
+ final DateFormat dateFormat = new SimpleDateFormat(format);
+ final Date date = new Date();
+ return dateFormat.format(date);
+ }
+
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Empty.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Empty.java
index 9c678d4..8b16a97 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Empty.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Empty.java
@@ -1,13 +1,13 @@
/*
* Copyright 2011 Federal Chancellery Austria and
* Graz University of Technology
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,11 +21,11 @@ package at.gv.egovernment.moaspss.util;
*/
public interface Empty {
- /**
- * Returns {@code true} if underlying object is empty.
- *
- * @return {@code true} if empty, {@code false} if not empty.
- */
- boolean isEmpty();
+ /**
+ * Returns {@code true} if underlying object is empty.
+ *
+ * @return {@code true} if empty, {@code false} if not empty.
+ */
+ boolean isEmpty();
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/EntityResolverChain.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/EntityResolverChain.java
index 487c6a4..6f61517 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/EntityResolverChain.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/EntityResolverChain.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.IOException;
@@ -34,39 +33,41 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
- * Implementation of the <code>org.xml.sax.EntityResolver</code>,
- * for use by a <code>org.apache.xerces.parsers.DOMParser</code>.
- *
+ * Implementation of the <code>org.xml.sax.EntityResolver</code>, for use by a
+ * <code>org.apache.xerces.parsers.DOMParser</code>.
+ *
* @author Patrick Peck
* @version $Id$
*/
public class EntityResolverChain implements EntityResolver {
/** The <code>EntityResolver</code>s in the chain. */
- private List resolvers = new ArrayList();
+ private final List resolvers = new ArrayList();
/**
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
+ * java.lang.String)
*/
+ @Override
public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
-
+ throws SAXException, IOException {
+
Iterator iter;
-
- for (iter = resolvers.iterator(); iter.hasNext(); ) {
- EntityResolver resolver = (EntityResolver) iter.next();
- InputSource is = resolver.resolveEntity(publicId, systemId);
-
+
+ for (iter = resolvers.iterator(); iter.hasNext();) {
+ final EntityResolver resolver = (EntityResolver) iter.next();
+ final InputSource is = resolver.resolveEntity(publicId, systemId);
+
if (is != null) {
return is;
}
}
-
+
return null;
}
-
+
/**
* Add an <code>EntityResolver</code> to the chain.
- *
+ *
* @param entityResolver The <code>EntityResolver</code> to add.
*/
public void addEntityResolver(EntityResolver entityResolver) {
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/FileUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/FileUtils.java
index 309e01a..d64cda0 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/FileUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/FileUtils.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.BufferedInputStream;
@@ -34,146 +33,167 @@ import java.io.OutputStream;
import java.net.URL;
/**
- * Utility for accessing files on the file system, and for reading from input streams.
+ * 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);
+ public static byte[] readURL(String urlString) throws IOException {
+ final URL url = new URL(urlString);
+ final InputStream in = new BufferedInputStream(url.openStream());
+ final 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
+ * @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);
+ final 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);
+ final BufferedInputStream in = new BufferedInputStream(new FileInputStream(filename));
+ final 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);
+ final 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);
+ final ClassLoader cl = FileUtils.class.getClassLoader();
+ final BufferedInputStream in = new BufferedInputStream(cl.getResourceAsStream(name));
+ final byte[] content = StreamUtils.readStream(in);
in.close();
return content;
}
+
/**
* Reads a file from a resource.
- * @param name filename
+ *
+ * @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);
+ final 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
-
+
+ /**
+ * 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;
+ 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);
- if (keyFile.toString().startsWith("file:"))
- newURL = keyFile.toString();
-
- else
- newURL = keyFile.toURI().toString();
-
+ if (keyFile.toString().startsWith("file:")) {
+ newURL = keyFile.toString();
+ } else {
+ newURL = keyFile.toURI().toString();
+ }
+
}
return newURL;
}
- }
-
-
- private static void copy( InputStream fis, OutputStream fos )
- {
- try
- {
- byte[] buffer = new byte[ 0xFFFF ];
- for ( int len; (len = fis.read(buffer)) != -1; )
- fos.write( buffer, 0, len );
- }
- catch( IOException e ) {
- System.err.println( e );
- }
- finally {
- if ( fis != null )
- try { fis.close(); } catch ( IOException e ) { e.printStackTrace(); }
- if ( fos != null )
- try { fos.close(); } catch ( IOException e ) { e.printStackTrace(); }
- }
- }
-
- public static void copyFile(File src, File dest)
- {
- try
- {
- copy( new FileInputStream( src ), new FileOutputStream( dest ) );
- }
- catch( IOException e ) {
- e.printStackTrace();
- }
- }
-
+ }
+
+ private static void copy(InputStream fis, OutputStream fos) {
+ try {
+ final byte[] buffer = new byte[0xFFFF];
+ for (int len; (len = fis.read(buffer)) != -1;) {
+ fos.write(buffer, 0, len);
+ }
+ } catch (final IOException e) {
+ System.err.println(e);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (fos != null) {
+ try {
+ fos.close();
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public static void copyFile(File src, File dest) {
+ try {
+ copy(new FileInputStream(src), new FileOutputStream(dest));
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/KeyStoreUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/KeyStoreUtils.java
index b4d7b02..f62b82a 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/KeyStoreUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/KeyStoreUtils.java
@@ -21,11 +21,8 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
-import iaik.x509.X509Certificate;
-
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -38,116 +35,125 @@ import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.cert.Certificate;
+import iaik.x509.X509Certificate;
+
/**
* Utility for creating and loading key stores.
- *
+ *
* @author Paul Ivancsics
* @version $Id$
*/
public class KeyStoreUtils {
-
- /**
- * JAVA KeyStore
- */
- private static final String KEYSTORE_TYPE_JKS = "JKS";
-
- /**
- * PKCS12 KeyStore
- */
- private static final String KEYSTORE_TYPE_PKCS12 = "PKCS12";
-
-
+
+ /**
+ * JAVA KeyStore
+ */
+ private static final String KEYSTORE_TYPE_JKS = "JKS";
+
+ /**
+ * PKCS12 KeyStore
+ */
+ private static final String KEYSTORE_TYPE_PKCS12 = "PKCS12";
/**
* Loads a key store from file.
- *
+ *
* @param keystoreType key store type
- * @param urlString URL of key store
- * @param password password protecting the key store
+ * @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 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 {
+ String keystoreType,
+ String urlString,
+ String password)
+ throws IOException, GeneralSecurityException {
- URL keystoreURL = new URL(urlString);
- InputStream in = keystoreURL.openStream();
+ final URL keystoreURL = new URL(urlString);
+ final InputStream in = keystoreURL.openStream();
return loadKeyStore(keystoreType, in, password);
}
+
/**
- * Loads a key store from an <code>InputStream</code>, and
- * closes the <code>InputStream</code>.
- *
+ * Loads a key store from an <code>InputStream</code>, and closes the
+ * <code>InputStream</code>.
+ *
* @param keystoreType key store type
- * @param in input stream
- * @param password password protecting the key store
+ * @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 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 {
+ String keystoreType,
+ InputStream in,
+ String password)
+ throws IOException, GeneralSecurityException {
char[] chPassword = null;
- if (password != null)
+ if (password != null) {
chPassword = password.toCharArray();
- KeyStore ks = KeyStore.getInstance(keystoreType);
+ }
+ final 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 <code>String[]</code>, starting with <code>"0"</code>.
- *
- * @param keyStoreType key store type
+ * Creates a key store from X509 certificate files, aliasing them with the index
+ * in the <code>String[]</code>, starting with <code>"0"</code>.
+ *
+ * @param keyStoreType key store type
* @param certFilenames certificate filenames
* @return key store created
- * @throws IOException thrown while reading the certificates from file
+ * @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 {
+ String keyStoreType,
+ String[] certFilenames)
+ throws IOException, GeneralSecurityException {
- KeyStore ks = KeyStore.getInstance(keyStoreType);
+ final KeyStore ks = KeyStore.getInstance(keyStoreType);
ks.load(null, null);
for (int i = 0; i < certFilenames.length; i++) {
- Certificate cert = loadCertificate(certFilenames[i]);
+ final 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 <code>String[]</code>, starting with <code>"0"</code>.
- * 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
+ * Creates a key store from a directory containg X509 certificate files,
+ * aliasing them with the index in the <code>String[]</code>, starting with
+ * <code>"0"</code>. 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 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);
+ String keyStoreType,
+ String certDirURLString)
+ throws IOException, GeneralSecurityException {
+
+ final URL certDirURL = new URL(certDirURLString);
+ final String certDirname = certDirURL.getFile();
+ final File certDir = new File(certDirname);
+ final String[] certFilenames = certDir.list();
+ final String separator =
+ certDirname.endsWith(File.separator) ? "" : File.separator;
for (int i = 0; i < certFilenames.length; i++) {
certFilenames[i] = certDirname + separator + certFilenames[i];
}
@@ -156,68 +162,69 @@ public class KeyStoreUtils {
/**
* Loads an X509 certificate from file.
+ *
* @param certFilename filename
* @return the certificate loaded
- * @throws IOException thrown while reading the certificate from file
+ * @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 {
+ throws IOException, GeneralSecurityException {
- FileInputStream in = new FileInputStream(certFilename);
- Certificate cert = new X509Certificate(in);
+ final FileInputStream in = new FileInputStream(certFilename);
+ final Certificate cert = new X509Certificate(in);
in.close();
return cert;
}
-
-
- /**
- * Loads a keyStore without knowing the keyStore type
- * @param keyStorePath URL to the keyStore
- * @param password Password protecting the keyStore
- * @return keyStore loaded
- * @throws KeyStoreException thrown if keyStore cannot be loaded
- * @throws FileNotFoundException
- * @throws IOException
- */
- public static KeyStore loadKeyStore(String keyStorePath, String password) throws KeyStoreException, IOException{
-
- //InputStream is = new FileInputStream(keyStorePath);
- URL keystoreURL = new URL(keyStorePath);
- InputStream in = keystoreURL.openStream();
- InputStream isBuffered = new BufferedInputStream(in);
- return loadKeyStore(isBuffered, password);
-
- }
-
- /**
- * Loads a keyStore without knowing the keyStore type
- * @param in input stream
- * @param password Password protecting the keyStore
- * @return keyStore loaded
- * @throws KeyStoreException thrown if keyStore cannot be loaded
- * @throws FileNotFoundException
- * @throws IOException
- */
-public static KeyStore loadKeyStore(InputStream is, String password) throws KeyStoreException, IOException{
- is.mark(1024*1024);
- KeyStore ks = null;
- try {
- try {
- ks = loadKeyStore(KEYSTORE_TYPE_PKCS12, is, password);
- } catch (IOException e2) {
- is.reset();
- ks = loadKeyStore(KEYSTORE_TYPE_JKS, is, password);
- }
- } catch(Exception e) {
- e.printStackTrace();
- //throw new KeyStoreException(e);
- }
- return ks;
-
- }
-
-
+ /**
+ * Loads a keyStore without knowing the keyStore type
+ *
+ * @param keyStorePath URL to the keyStore
+ * @param password Password protecting the keyStore
+ * @return keyStore loaded
+ * @throws KeyStoreException thrown if keyStore cannot be loaded
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ public static KeyStore loadKeyStore(String keyStorePath, String password) throws KeyStoreException,
+ IOException {
+
+ // InputStream is = new FileInputStream(keyStorePath);
+ final URL keystoreURL = new URL(keyStorePath);
+ final InputStream in = keystoreURL.openStream();
+ final InputStream isBuffered = new BufferedInputStream(in);
+ return loadKeyStore(isBuffered, password);
+
+ }
+
+ /**
+ * Loads a keyStore without knowing the keyStore type
+ *
+ * @param in input stream
+ * @param password Password protecting the keyStore
+ * @return keyStore loaded
+ * @throws KeyStoreException thrown if keyStore cannot be loaded
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
+ public static KeyStore loadKeyStore(InputStream is, String password) throws KeyStoreException, IOException {
+ is.mark(1024 * 1024);
+ KeyStore ks = null;
+ try {
+ try {
+ ks = loadKeyStore(KEYSTORE_TYPE_PKCS12, is, password);
+ } catch (final IOException e2) {
+ is.reset();
+ ks = loadKeyStore(KEYSTORE_TYPE_JKS, is, password);
+ }
+ } catch (final Exception e) {
+ e.printStackTrace();
+ // throw new KeyStoreException(e);
+ }
+ return ks;
+
+ }
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOADefaultHandler.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOADefaultHandler.java
index 3dde827..9d1f01f 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOADefaultHandler.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOADefaultHandler.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.IOException;
@@ -36,15 +35,15 @@ import org.xml.sax.helpers.DefaultHandler;
/**
* A <code>DefaultHandler</code> that uses a <code>MOAEntityResolver</code> and
* a <code>MOAErrorHandler</code>.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class MOADefaultHandler extends DefaultHandler {
/** The <code>EntityResolver</code> to use. */
- private EntityResolver entityResolver;
+ private final EntityResolver entityResolver;
/** The <code>ErrorHandler</code> to use. */
- private ErrorHandler errorHandler;
+ private final ErrorHandler errorHandler;
/**
* Create a new <code>MOADefaultHandler</code>.
@@ -56,28 +55,30 @@ public class MOADefaultHandler extends DefaultHandler {
/**
* Create a new <code>MOADefaultHandler</code>.
- *
+ *
* @param entityResolver The <code>EntityResolver</code> to use for resolving
- * external entities.
- * @param errorHandler The <code>ErrorHandler</code> to use for reporting
- * parsing errors.
+ * external entities.
+ * @param errorHandler The <code>ErrorHandler</code> to use for reporting
+ * parsing errors.
*/
public MOADefaultHandler(
- EntityResolver entityResolver,
- ErrorHandler errorHandler) {
+ EntityResolver entityResolver,
+ ErrorHandler errorHandler) {
this.entityResolver = entityResolver;
this.errorHandler = errorHandler;
}
/**
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
+ * java.lang.String)
*/
+ @Override
public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException {
+ throws SAXException {
try {
return entityResolver.resolveEntity(publicId, systemId);
- } catch (IOException e) {
+ } catch (final IOException e) {
return null;
}
}
@@ -85,6 +86,7 @@ public class MOADefaultHandler extends DefaultHandler {
/**
* @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
*/
+ @Override
public void warning(SAXParseException exception) throws SAXException {
errorHandler.warning(exception);
}
@@ -92,6 +94,7 @@ public class MOADefaultHandler extends DefaultHandler {
/**
* @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
*/
+ @Override
public void error(SAXParseException exception) throws SAXException {
errorHandler.error(exception);
}
@@ -99,6 +102,7 @@ public class MOADefaultHandler extends DefaultHandler {
/**
* @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
*/
+ @Override
public void fatalError(SAXParseException exception) throws SAXException {
errorHandler.fatalError(exception);
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAEntityResolver.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAEntityResolver.java
index 7f529ca..d7c6a5b 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAEntityResolver.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAEntityResolver.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.InputStream;
@@ -35,18 +34,20 @@ import at.gv.egovernment.moaspss.logging.LogMsg;
import at.gv.egovernment.moaspss.logging.Logger;
/**
- * An <code>EntityResolver</code> that looks up entities stored as
- * local resources.
- *
- * <p>The following DTDs are mapped to local resources:
+ * An <code>EntityResolver</code> that looks up entities stored as local
+ * resources.
+ *
+ * <p>
+ * The following DTDs are mapped to local resources:
* <ul>
* <li>The XMLSchema.dtd</li>
* <li>The datatypes.dtd</li>
* </ul>
* </p>
- * <p>For all other resources, an attempt is made to resolve them as resources,
+ * <p>
+ * For all other resources, an attempt is made to resolve them as resources,
* either absolute or relative to <code>Constants.SCHEMA_ROOT</code>.
- *
+ *
* @author Patrick Peck
* @author Sven Aigner
*/
@@ -54,56 +55,58 @@ public class MOAEntityResolver implements EntityResolver {
/**
* Resolve an entity.
- *
+ *
* The <code>systemId</code> parameter is used to perform the lookup of the
- * entity as a resource, either by interpreting the <code>systemId</code> as
- * an absolute resource path, or by appending the last path component of
+ * entity as a resource, either by interpreting the <code>systemId</code> as an
+ * absolute resource path, or by appending the last path component of
* <code>systemId</code> to <code>Constants.SCHEMA_ROOT</code>.
- *
+ *
* @param publicId The public ID of the resource.
* @param systemId The system ID of the resource.
* @return An <code>InputSource</code> from which the entity can be read, or
- * <code>null</code>, if the entity could not be found.
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ * <code>null</code>, if the entity could not be found.
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
+ * java.lang.String)
*/
+ @Override
public InputSource resolveEntity(String publicId, String systemId) {
InputStream stream;
int slashPos;
if (Logger.isDebugEnabled()) {
Logger.debug(
- new LogMsg("resolveEntity: p=" + publicId + " s=" + systemId));
+ 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"));
+ getClass().getResourceAsStream(
+ Constants.SCHEMA_ROOT + "XMLSchema.dtd"));
} else if (publicId.equalsIgnoreCase("datatypes")) {
return new InputSource(
- getClass().getResourceAsStream(
- Constants.SCHEMA_ROOT + "datatypes.dtd"));
+ getClass().getResourceAsStream(
+ Constants.SCHEMA_ROOT + "datatypes.dtd"));
}
} else if (systemId != null) {
// get the URI path
try {
- URI uri = new URI(systemId);
+ final URI uri = new URI(systemId);
systemId = uri.getPath();
-
+
if (!"file".equals(uri.getScheme()) || "".equals(systemId.trim())) {
return null;
}
-
- } catch (MalformedURIException e) {
+
+ } catch (final 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);
+ final InputSource source = new InputSource(stream);
source.setSystemId(systemId);
return source;
@@ -114,9 +117,9 @@ public class MOAEntityResolver implements EntityResolver {
if (slashPos >= 0 && systemId.length() > slashPos) {
systemId = systemId.substring(slashPos + 1, systemId.length());
stream =
- getClass().getResourceAsStream(Constants.SCHEMA_ROOT + systemId);
+ getClass().getResourceAsStream(Constants.SCHEMA_ROOT + systemId);
if (stream != null) {
- InputSource source = new InputSource(stream);
+ final InputSource source = new InputSource(stream);
source.setSystemId(systemId);
return source;
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAErrorHandler.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAErrorHandler.java
index 1842d03..f4acabf 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAErrorHandler.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOAErrorHandler.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import org.apache.xml.utils.DefaultErrorHandler;
@@ -35,42 +34,48 @@ import at.gv.egovernment.moaspss.logging.Logger;
* An <code>ErrorHandler</code> that logs a message and throws a
* <code>SAXException</code> upon <code>error</code> and <code>fatal</code>
* parsing errors.
- *
+ *
* @author Patrick Peck
* @author Sven Aigner
*/
public class MOAErrorHandler extends DefaultErrorHandler {
-
/**
* Logs a warning message.
- *
+ *
* @see org.xml.sax.ErrorHandler#warning(SAXParseException)
*/
+ @Override
public void warning(SAXParseException exception) throws SAXException {
warn("parser.00", messageParams(exception), null);
}
/**
* Logs a warning and rethrows the <code>exception</code>.
- *
+ *
* @see org.xml.sax.ErrorHandler#error(SAXParseException)
*/
+ @Override
public void error(SAXParseException exception) throws SAXException {
- warn("parser.01", messageParams(exception), null);
-
- // if Target attribute is missing in QualifyingProperties - don't throw exception (bug fix for old MOCCA signatures)
- if (exception.getMessage().startsWith("cvc-complex-type.4: Attribute 'Target' must appear on element"))
- warn("parser.04", new Object[] {"Attribute 'Target' must appear on element 'QualifyingProperties' - ignored for compatibility reasons."}, null);
- else
- throw exception;
+ warn("parser.01", messageParams(exception), null);
+
+ // if Target attribute is missing in QualifyingProperties - don't throw
+ // exception (bug fix for old MOCCA signatures)
+ if (exception.getMessage().startsWith("cvc-complex-type.4: Attribute 'Target' must appear on element")) {
+ warn("parser.04", new Object[] {
+ "Attribute 'Target' must appear on element 'QualifyingProperties' - ignored for compatibility reasons." },
+ null);
+ } else {
+ throw exception;
+ }
}
/**
* Logs a warning and rethrows the <code>exception</code>.
- *
+ *
* @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
*/
+ @Override
public void fatalError(SAXParseException exception) throws SAXException {
warn("parser.02", messageParams(exception), null);
throw exception;
@@ -78,38 +83,38 @@ public class MOAErrorHandler extends DefaultErrorHandler {
/**
* Log a warning message.
- *
- * @param messageId The message ID to log.
+ *
+ * @param messageId The message ID to log.
* @param parameters Additional message parameters.
- * @param t The <code>Throwable</code> to log; usually the cause of this
- * warning.
+ * @param t The <code>Throwable</code> to log; usually the cause of
+ * this warning.
*/
private static void warn(
- String messageId,
- Object[] parameters,
- Throwable t) {
+ String messageId,
+ Object[] parameters,
+ Throwable t) {
- MessageProvider msg = MessageProvider.getInstance();
+ final 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 <code>Object</code> array, to provide it as a
- * <code>MessageFormat</code> parameter.
- *
- * @param e The <code>SAXParseException</code> containing the
- * source system id and line/column numbers.
- * @return An array containing the system id (a <code>String</code>) as well
- * as line/column numbers (2 <code>Integer</code> objects) from the
- * <code>SAXParseException</code>.
+ * Put the system id, line and column number information from the exception into
+ * an <code>Object</code> array, to provide it as a <code>MessageFormat</code>
+ * parameter.
+ *
+ * @param e The <code>SAXParseException</code> containing the source system id
+ * and line/column numbers.
+ * @return An array containing the system id (a <code>String</code>) as well as
+ * line/column numbers (2 <code>Integer</code> objects) from the
+ * <code>SAXParseException</code>.
*/
private static Object[] messageParams(SAXParseException e) {
return new Object[] {
- e.getMessage(),
- e.getSystemId(),
- new Integer(e.getLineNumber()),
- new Integer(e.getColumnNumber())};
+ e.getMessage(),
+ e.getSystemId(),
+ new Integer(e.getLineNumber()),
+ new Integer(e.getColumnNumber()) };
}
} \ No newline at end of file
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOATimer.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOATimer.java
index 8542b58..591495a 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOATimer.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MOATimer.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.util.Map;
@@ -29,7 +28,7 @@ import java.util.WeakHashMap;
/**
* A timer utility for named timers.
- *
+ *
* @author Sven Aigner
*/
public class MOATimer {
@@ -43,7 +42,7 @@ public class MOATimer {
/**
* Return the single instance of this class.
- *
+ *
* @return The single instance of this class.
*/
public static MOATimer getInstance() {
@@ -55,7 +54,7 @@ public class MOATimer {
/**
* Create a new <code>MOATimer</code>.
- *
+ *
* Protected to disallow multiple instances.
*/
protected MOATimer() {
@@ -64,10 +63,10 @@ public class MOATimer {
/**
* 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) {
@@ -76,7 +75,7 @@ public class MOATimer {
/**
* Stop timing an action.
- *
+ *
* @param id The action ID.
*/
public void stopTiming(Object id) {
@@ -85,50 +84,53 @@ public class MOATimer {
/**
* 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
- * <code>startTiming()</code> and <code>stopTiming()</code>. If
- * only <code>startTiming()</code> has been called for the action, then
- * current difference to the system time is returned. If no timing exists for
- * the action, <code>- 1</code> is returned.
+ * <code>startTiming()</code> and <code>stopTiming()</code>. If only
+ * <code>startTiming()</code> has been called for the action, then
+ * current difference to the system time is returned. If no timing
+ * exists for the action, <code>- 1</code> is returned.
*/
public long duration(Object id) {
if (timemapstart.containsKey(id)) {
- long start = ((Long) timemapstart.get(id)).longValue();
+ final long start = ((Long) timemapstart.get(id)).longValue();
if (timemapend.containsKey(id)) {
- long end = ((Long) timemapend.get(id)).longValue();
+ final long end = ((Long) timemapend.get(id)).longValue();
return end - start;
} else {
return System.currentTimeMillis() - start;
}
- } else
+ } else {
return -1;
+ }
}
/**
* Get the duration of an action, as a nicely formatted <code>String</code>.
- *
+ *
* @param id The action ID.
* @return String The <code>duration()</code> as a <code>String</code>.
*/
public String durationAsString(Object id) {
- long dur = duration(id);
- long second = dur / 1000;
- long mil = (dur) - (second * 1000);
+ final long dur = duration(id);
+ final long second = dur / 1000;
+ final 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))
+ if (timemapstart.containsKey(id)) {
timemapstart.remove(id);
- if (timemapend.containsKey(id))
+ }
+ if (timemapend.containsKey(id)) {
timemapend.remove(id);
+ }
}
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MessageProvider.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MessageProvider.java
index da97ea1..163e903 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MessageProvider.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MessageProvider.java
@@ -21,53 +21,52 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.util.Locale;
/**
* A singleton wrapper around a <code>Message</code> 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" };
+ { "resources/properties/common_messages" };
/** The locale of the default message resources. */
private static final Locale[] DEFAULT_MESSAGE_LOCALES =
- new Locale[] { new Locale("de", "AT") };
+ new Locale[] { new Locale("de", "AT") };
/** The single instance of this class. */
private static MessageProvider instance;
-
+
/** The messages provided by this <code>MessageProvider</code>. */
- private Messages messages;
-
+ private final Messages messages;
+
/**
* Return the single instance of the <code>MessageProvider</code>.
- *
+ *
* Intialilizes the <code>MessageProvider</code> with the default message
* locations: <code>/resources/properties/common_messages</code>.
- *
+ *
* @return The single <code>MessageProvider</code>.
*/
public static synchronized MessageProvider getInstance() {
if (instance == null) {
instance =
- new MessageProvider(DEFAULT_MESSAGE_RESOURCES, DEFAULT_MESSAGE_LOCALES);
+ new MessageProvider(DEFAULT_MESSAGE_RESOURCES, DEFAULT_MESSAGE_LOCALES);
}
return instance;
}
/**
* Create a <code>MessageProvider</code>.
- *
+ *
* @param resourceNames The names of the resources containing the messages.
- * @param locales The corresponding locales.
+ * @param locales The corresponding locales.
*/
protected MessageProvider(String[] resourceNames, Locale[] locales) {
this.messages = new Messages(resourceNames, locales);
@@ -76,9 +75,9 @@ public class MessageProvider {
/**
* Get the message corresponding to a given message ID.
*
- * @param messageId The ID of the message.
+ * @param messageId The ID of the message.
* @param parameters The parameters to fill in into the message arguments.
- * @return The formatted message.
+ * @return The formatted message.
*/
public String getMessage(String messageId, Object[] parameters) {
return messages.getMessage(messageId, parameters);
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java
index 6e324b7..61d9b65 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/Messages.java
@@ -21,47 +21,46 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
import at.gv.egovernment.moaspss.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.";
+ "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 =
- "No errormesseage for error with number.={0}";
+ "No errormesseage for error with number.={0}";
/** The names of the resources containing the messages. */
- private String[] resourceNames;
+ private final String[] resourceNames;
/** The corresponding <code>Locale</code>s of the resources. */
- private Locale[] locales;
+ private final Locale[] locales;
/** The <code>ResourceBundle</code>s containing the messages. */
private ResourceBundleChain messages;
/**
- * Create a new <code>Message</code> object containing the messages
- * in the given resources.
- *
+ * Create a new <code>Message</code> object containing the messages in the given
+ * resources.
+ *
* @param resourceNames The names of the resources containing the messages.
- * @param locales The corresponding locales.
+ * @param locales The corresponding locales.
*/
public Messages(String[] resourceNames, Locale[] locales) {
this.resourceNames = resourceNames;
@@ -72,9 +71,9 @@ public class Messages {
/**
* Get the message corresponding to a given message ID.
*
- * @param messageId The ID of the message.
+ * @param messageId The ID of the message.
* @param parameters The parameters to fill in into the message arguments.
- * @return The formatted message.
+ * @return The formatted message.
*/
public String getMessage(String messageId, Object[] parameters) {
// initialize messages
@@ -87,20 +86,20 @@ public class Messages {
return ERROR_MESSAGES_UNAVAILABLE;
} else {
try {
- String rawMessage = messages.getString(messageId);
+ final String rawMessage = messages.getString(messageId);
return MessageFormat.format(rawMessage, parameters);
- } catch (MissingResourceException e2) {
- // couldn't find any message -> set to default error message
+ } catch (final MissingResourceException e2) {
+ // couldn't find any message -> set to default error message
return MessageFormat.format(
- ERROR_NO_MESSAGE,
- new Object[] { messageId });
+ 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() {
@@ -109,9 +108,9 @@ public class Messages {
/**
* Return the <code>Locale</code>s of the resources containing the messages.
- *
- * @return Locale[] The <code>Locale</code>s of the resource bundles
- * containing the messages.
+ *
+ * @return Locale[] The <code>Locale</code>s of the resource bundles containing
+ * the messages.
*/
private Locale[] getLocales() {
return locales;
@@ -129,10 +128,10 @@ public class Messages {
for (i = 0; i < resourceNames.length; i++) {
try {
messages.addResourceBundle(
- PropertyResourceBundle.getBundle(
- getResourceNames()[i],
- getLocales()[i]));
- } catch (MissingResourceException e) {
+ ResourceBundle.getBundle(
+ getResourceNames()[i],
+ getLocales()[i]));
+ } catch (final MissingResourceException e) {
Logger.error(ERROR_MESSAGES_UNAVAILABLE, e);
}
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MiscUtil.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MiscUtil.java
index 5510ac8..d2431e4 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MiscUtil.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/MiscUtil.java
@@ -1,13 +1,13 @@
/*
* Copyright 2011 Federal Chancellery Austria and
* Graz University of Technology
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,6 +25,7 @@ import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -44,91 +45,89 @@ import javax.xml.transform.stream.StreamResult;
import at.gv.egovernment.moaspss.logging.Logger;
import at.gv.egovernment.moaspss.util.ex.EgovUtilException;
-
-
/**
* Class providing several utility methods.
- *
+ *
* @author <a href="mailto:Arne.Tauber@egiz.gv.at">Arne Tauber</a>
- *
+ *
*/
public class MiscUtil {
- public static final String DEFAULT_SLASH = "/";
-
- private static final int IO_BUFFER_SIZE = 4 * 1024;
-
- public static void copyStream(InputStream is, OutputStream os) throws IOException {
- byte[] b = new byte[IO_BUFFER_SIZE];
- int read;
- while ((read = is.read(b)) != -1) {
- os.write(b, 0, read);
- }
- }
-
- public static void assertNotNull(Object param, String name) {
- if (param == null) {
- throw new NullPointerException(name + " must not be null.");
- }
- }
-
- public static boolean areAllNull(Object... objects) {
- for (Object o : objects) {
- if (o != null) {
- return false;
- }
- }
- return true;
- }
-
- public static String extractContentType(String contentTypeString) {
- if (contentTypeString == null) {
- return "";
- }
- if (contentTypeString.indexOf(";") != -1) {
- return contentTypeString.substring(0, contentTypeString.indexOf(";"));
- }
- return contentTypeString;
- }
-
- public static XMLGregorianCalendar getXMLGregorianCalendar(Date date)
- throws DatatypeConfigurationException {
- GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();
- cal.setTime(date);
- return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
- }
-
- public static XMLGregorianCalendar getXMLGregorianCalendar(String str)
- throws DatatypeConfigurationException {
- return DatatypeFactory.newInstance().newXMLGregorianCalendar(str);
- }
-
- public static X509Certificate readCertificate(InputStream certStream)
- throws CertificateException {
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- return (X509Certificate) cf.generateCertificate(certStream);
- }
-
- public static boolean isEmpty(String str) {
- return str == null || "".equals(str);
- }
-
- public static boolean isNotEmpty(String str) {
- return str != null && !"".equals(str);
- }
-
- public static byte[] sourceToByteArray(Source result)
- throws TransformerException {
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTransformer();
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- StreamResult streamResult = new StreamResult();
- streamResult.setOutputStream(out);
- transformer.transform(result, streamResult);
- return out.toByteArray();
- }
+ public static final String DEFAULT_SLASH = "/";
+
+ private static final int IO_BUFFER_SIZE = 4 * 1024;
+
+ public static void copyStream(InputStream is, OutputStream os) throws IOException {
+ final byte[] b = new byte[IO_BUFFER_SIZE];
+ int read;
+ while ((read = is.read(b)) != -1) {
+ os.write(b, 0, read);
+ }
+ }
+
+ public static void assertNotNull(Object param, String name) {
+ if (param == null) {
+ throw new NullPointerException(name + " must not be null.");
+ }
+ }
+
+ public static boolean areAllNull(Object... objects) {
+ for (final Object o : objects) {
+ if (o != null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static String extractContentType(String contentTypeString) {
+ if (contentTypeString == null) {
+ return "";
+ }
+ if (contentTypeString.indexOf(";") != -1) {
+ return contentTypeString.substring(0, contentTypeString.indexOf(";"));
+ }
+ return contentTypeString;
+ }
+
+ public static XMLGregorianCalendar getXMLGregorianCalendar(Date date)
+ throws DatatypeConfigurationException {
+ final GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
+ cal.setTime(date);
+ return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
+ }
+
+ public static XMLGregorianCalendar getXMLGregorianCalendar(String str)
+ throws DatatypeConfigurationException {
+ return DatatypeFactory.newInstance().newXMLGregorianCalendar(str);
+ }
+
+ public static X509Certificate readCertificate(InputStream certStream)
+ throws CertificateException {
+ final CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ return (X509Certificate) cf.generateCertificate(certStream);
+ }
+
+ public static boolean isEmpty(String str) {
+ return str == null || "".equals(str);
+ }
+
+ public static boolean isNotEmpty(String str) {
+ return str != null && !"".equals(str);
+ }
+
+ public static byte[] sourceToByteArray(Source result)
+ throws TransformerException {
+ final TransformerFactory factory = TransformerFactory.newInstance();
+ final Transformer transformer = factory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final StreamResult streamResult = new StreamResult();
+ streamResult.setOutputStream(out);
+ transformer.transform(result, streamResult);
+ return out.toByteArray();
+ }
// public static Document parseDocument(InputStream inputStream)
// throws IOException {
@@ -145,159 +144,159 @@ public class MiscUtil {
// }
// }
- public static String removePrecedingSlash(String path, String slash) {
- assertNotEmpty(slash, "Shash");
- if (!isEmpty(path)) {
- while (path.startsWith(slash)) {
- path = path.substring(slash.length(), path.length());
- }
- }
- return path;
- }
-
- public static String removePrecedingSlash(String path) {
- return removePrecedingSlash(path, DEFAULT_SLASH);
- }
-
- public static void assertNotEmpty(String param, String name) {
- if (param == null) {
- throw new NullPointerException(name + " must not be null.");
- }
- if (param.length() == 0) {
- throw new IllegalArgumentException(name + " must not be empty.");
- }
- }
-
- @SuppressWarnings("rawtypes")
+ public static String removePrecedingSlash(String path, String slash) {
+ assertNotEmpty(slash, "Shash");
+ if (!isEmpty(path)) {
+ while (path.startsWith(slash)) {
+ path = path.substring(slash.length(), path.length());
+ }
+ }
+ return path;
+ }
+
+ public static String removePrecedingSlash(String path) {
+ return removePrecedingSlash(path, DEFAULT_SLASH);
+ }
+
+ public static void assertNotEmpty(String param, String name) {
+ if (param == null) {
+ throw new NullPointerException(name + " must not be null.");
+ }
+ if (param.length() == 0) {
+ throw new IllegalArgumentException(name + " must not be empty.");
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
public static boolean isEmpty(Properties props) {
- if (props == null || props.isEmpty()) {
- return true;
- }
- Iterator it = props.values().iterator();
- while (it.hasNext()) {
- if (MiscUtil.isNotEmpty((String) it.next())) {
- return false;
- }
- }
- return true;
- }
-
- public static boolean isEmpty(Empty empty) {
- return empty == null || empty.isEmpty();
- }
-
- public static boolean isNotEmpty(Empty empty) {
- return !isEmpty(empty);
- }
-
- public static boolean isEmpty(byte[] data) {
- return data == null || data.length == 0;
- }
-
- public static boolean isNotEmpty(byte[] data) {
- return !isEmpty(data);
- }
-
- public static <T> boolean isEmpty(Collection<T> c) {
- return c == null || c.isEmpty();
- }
-
- public static <T> boolean isNotEmpty(Collection<T> c) {
- return !isEmpty(c);
- }
-
- public static boolean areAllEmpty(String... strings) {
- for (String s : strings) {
- if (s != null && s.trim().length() != 0) {
- return false;
- }
- }
- return true;
- }
-
- public static boolean areAllEmpty(Empty... empties) {
- if (empties != null) {
- for (Empty e : empties) {
- if (e != null && !e.isEmpty()) {
- return false;
- }
- }
- }
- return true;
- }
-
- public static <T> void assertNotEmpty(T[] param, String name) {
- if (param == null) {
- throw new NullPointerException(name + " must not be null.");
- }
- if (param.length == 0) {
- throw new IllegalArgumentException(name + " must not be empty.");
- }
- }
-
- public static void assertNotEmpty(Empty empty, String name) {
- if (empty == null) {
- throw new NullPointerException(name + " must not be null.");
- }
- if (empty.isEmpty()) {
- throw new IllegalArgumentException(name + " must not be empty.");
- }
- }
-
- public static void assertNotEmpty(byte[] param, String name) {
- if (param == null) {
- throw new NullPointerException(name + " must not be null.");
- }
- if (param.length == 0) {
- throw new IllegalArgumentException(name + " must not be empty.");
- }
- }
-
- public static Date parseXMLDate(String xmlDate) throws EgovUtilException {
- if (xmlDate == null) {
- return null;
- }
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- try {
- return sdf.parse(xmlDate);
- } catch (ParseException e) {
- throw new EgovUtilException(e);
- }
- }
-
- public static <T> boolean isEmpty(T[] array) {
- return array == null || array.length == 0;
- }
-
- public static <T> boolean isNotEmpty(T[] array) {
- return !isEmpty(array);
- }
-
- public static String convertDateFromStandardToXML(String dateString) {
- MiscUtil.assertNotNull(dateString, "dateString");
- Date date = parseDate(dateString);
- return formatDate(date, "yyyy-MM-dd");
- }
-
- public static Date parseDate(String dateString) {
- return parseDate(dateString, "dd.MM.yyyy");
- }
-
- public static Date parseDate(String dateString, String pattern) {
- MiscUtil.assertNotNull(dateString, "dateString");
- MiscUtil.assertNotNull(pattern, "pattern");
- SimpleDateFormat sdf = new SimpleDateFormat(pattern);
- try {
- return sdf.parse(dateString);
- } catch (ParseException e) {
- Logger.warn("Error parsing date.", e);
- return null;
+ if (props == null || props.isEmpty()) {
+ return true;
}
- }
-
- public static String formatDate(Date date, String format) {
- SimpleDateFormat sdf = new SimpleDateFormat(format);
- return sdf.format(date);
- }
-
+ final Iterator it = props.values().iterator();
+ while (it.hasNext()) {
+ if (MiscUtil.isNotEmpty((String) it.next())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean isEmpty(Empty empty) {
+ return empty == null || empty.isEmpty();
+ }
+
+ public static boolean isNotEmpty(Empty empty) {
+ return !isEmpty(empty);
+ }
+
+ public static boolean isEmpty(byte[] data) {
+ return data == null || data.length == 0;
+ }
+
+ public static boolean isNotEmpty(byte[] data) {
+ return !isEmpty(data);
+ }
+
+ public static <T> boolean isEmpty(Collection<T> c) {
+ return c == null || c.isEmpty();
+ }
+
+ public static <T> boolean isNotEmpty(Collection<T> c) {
+ return !isEmpty(c);
+ }
+
+ public static boolean areAllEmpty(String... strings) {
+ for (final String s : strings) {
+ if (s != null && s.trim().length() != 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean areAllEmpty(Empty... empties) {
+ if (empties != null) {
+ for (final Empty e : empties) {
+ if (e != null && !e.isEmpty()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public static <T> void assertNotEmpty(T[] param, String name) {
+ if (param == null) {
+ throw new NullPointerException(name + " must not be null.");
+ }
+ if (param.length == 0) {
+ throw new IllegalArgumentException(name + " must not be empty.");
+ }
+ }
+
+ public static void assertNotEmpty(Empty empty, String name) {
+ if (empty == null) {
+ throw new NullPointerException(name + " must not be null.");
+ }
+ if (empty.isEmpty()) {
+ throw new IllegalArgumentException(name + " must not be empty.");
+ }
+ }
+
+ public static void assertNotEmpty(byte[] param, String name) {
+ if (param == null) {
+ throw new NullPointerException(name + " must not be null.");
+ }
+ if (param.length == 0) {
+ throw new IllegalArgumentException(name + " must not be empty.");
+ }
+ }
+
+ public static Date parseXMLDate(String xmlDate) throws EgovUtilException {
+ if (xmlDate == null) {
+ return null;
+ }
+ final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ try {
+ return sdf.parse(xmlDate);
+ } catch (final ParseException e) {
+ throw new EgovUtilException(e);
+ }
+ }
+
+ public static <T> boolean isEmpty(T[] array) {
+ return array == null || array.length == 0;
+ }
+
+ public static <T> boolean isNotEmpty(T[] array) {
+ return !isEmpty(array);
+ }
+
+ public static String convertDateFromStandardToXML(String dateString) {
+ MiscUtil.assertNotNull(dateString, "dateString");
+ final Date date = parseDate(dateString);
+ return formatDate(date, "yyyy-MM-dd");
+ }
+
+ public static Date parseDate(String dateString) {
+ return parseDate(dateString, "dd.MM.yyyy");
+ }
+
+ public static Date parseDate(String dateString, String pattern) {
+ MiscUtil.assertNotNull(dateString, "dateString");
+ MiscUtil.assertNotNull(pattern, "pattern");
+ final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+ try {
+ return sdf.parse(dateString);
+ } catch (final ParseException e) {
+ Logger.warn("Error parsing date.", e);
+ return null;
+ }
+ }
+
+ public static String formatDate(Date date, String format) {
+ final SimpleDateFormat sdf = new SimpleDateFormat(format);
+ return sdf.format(date);
+ }
+
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeIteratorAdapter.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeIteratorAdapter.java
index 998edb4..66907d2 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeIteratorAdapter.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeIteratorAdapter.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.util.ListIterator;
@@ -34,20 +33,21 @@ import org.w3c.dom.traversal.NodeIterator;
/**
* A <code>NodeIterator</code> implementation based on a
* <code>ListIterator</code>.
- *
+ *
* @see java.util.ListIterator
* @see org.w3c.dom.traversal.NodeIterator
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class NodeIteratorAdapter implements NodeIterator {
/** The <code>ListIterator</code> to wrap. */
- private ListIterator nodeIterator;
+ private final ListIterator nodeIterator;
/**
* Create a new <code>NodeIteratorAdapter</code>.
+ *
* @param nodeIterator The <code>ListIterator</code> to iterate over.
*/
public NodeIteratorAdapter(ListIterator nodeIterator) {
@@ -57,6 +57,7 @@ public class NodeIteratorAdapter implements NodeIterator {
/**
* @see org.w3c.dom.traversal.NodeIterator#getRoot()
*/
+ @Override
public Node getRoot() {
return null;
}
@@ -64,6 +65,7 @@ public class NodeIteratorAdapter implements NodeIterator {
/**
* @see org.w3c.dom.traversal.NodeIterator#getWhatToShow()
*/
+ @Override
public int getWhatToShow() {
return NodeFilter.SHOW_ALL;
}
@@ -71,6 +73,7 @@ public class NodeIteratorAdapter implements NodeIterator {
/**
* @see org.w3c.dom.traversal.NodeIterator#getFilter()
*/
+ @Override
public NodeFilter getFilter() {
return null;
}
@@ -78,6 +81,7 @@ public class NodeIteratorAdapter implements NodeIterator {
/**
* @see org.w3c.dom.traversal.NodeIterator#getExpandEntityReferences()
*/
+ @Override
public boolean getExpandEntityReferences() {
return false;
}
@@ -85,6 +89,7 @@ public class NodeIteratorAdapter implements NodeIterator {
/**
* @see org.w3c.dom.traversal.NodeIterator#nextNode()
*/
+ @Override
public Node nextNode() throws DOMException {
if (nodeIterator.hasNext()) {
return (Node) nodeIterator.next();
@@ -95,6 +100,7 @@ public class NodeIteratorAdapter implements NodeIterator {
/**
* @see org.w3c.dom.traversal.NodeIterator#previousNode()
*/
+ @Override
public Node previousNode() throws DOMException {
if (nodeIterator.hasPrevious()) {
return (Node) nodeIterator.previous();
@@ -105,6 +111,7 @@ public class NodeIteratorAdapter implements NodeIterator {
/**
* @see org.w3c.dom.traversal.NodeIterator#detach()
*/
+ @Override
public void detach() {
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeListAdapter.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeListAdapter.java
index d88ef4b..d569516 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeListAdapter.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/NodeListAdapter.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.util.List;
@@ -31,21 +30,21 @@ import org.w3c.dom.NodeList;
/**
* A <code>NodeList</code> implementation based on a <code>List</code>.
- *
+ *
* @see java.util.List
* @see org.w3c.dom.NodeList
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class NodeListAdapter implements NodeList {
/** The <code>List</code> to wrap. */
- private List nodeList;
-
+ private final List nodeList;
+
/**
* Create a new <code>NodeListAdapter</code>.
- *
- * @param nodeList The <code>List</code> containing the nodes.
+ *
+ * @param nodeList The <code>List</code> containing the nodes.
*/
public NodeListAdapter(List nodeList) {
this.nodeList = nodeList;
@@ -54,6 +53,7 @@ public class NodeListAdapter implements NodeList {
/**
* @see org.w3c.dom.NodeList#item(int)
*/
+ @Override
public Node item(int index) {
return (Node) nodeList.get(index);
}
@@ -61,6 +61,7 @@ public class NodeListAdapter implements NodeList {
/**
* @see org.w3c.dom.NodeList#getLength()
*/
+ @Override
public int getLength() {
return nodeList.size();
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/OutputXML2File.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/OutputXML2File.java
index e4e6cc5..6ce951d 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/OutputXML2File.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/OutputXML2File.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
/*
* Created on 26.04.2004
*
@@ -36,67 +35,70 @@ import at.gv.egovernment.moaspss.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 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 {
+ final String xmlString = new String(DOMUtils.serializeNode(rootElem));
+ outputXML2File(filename, xmlString);
+ } catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+ }
- /**
- * 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();
- }
- }
+ /**
+ * 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 {
+ final java.io.OutputStream fout = new java.io.FileOutputStream(filename);
+ final byte[] xmlData = xmlString.getBytes("UTF-8");
+ fout.write(xmlData);
+ fout.close();
+ } catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+ }
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ResourceBundleChain.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ResourceBundleChain.java
index 1edad95..a5c7ecc 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ResourceBundleChain.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ResourceBundleChain.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.util.ArrayList;
@@ -32,7 +31,7 @@ import java.util.ResourceBundle;
/**
* A class to chain <code>ResourceBundle</code>s.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -40,11 +39,11 @@ public class ResourceBundleChain {
/** Error message indicating the resource is not available. */
private static final String ERROR_MISSING_RESOURCE = "Missing resource";
/** The <code>ResourceBundle</code>s contained in this chain. */
- private List resourceBundles = new ArrayList();
+ private final List resourceBundles = new ArrayList();
/**
* Add a <code>ResourceBundle</code> to the chain.
- *
+ *
* @param resourceBundle The <code>ResourceBundle</code> to add.
*/
public void addResourceBundle(ResourceBundle resourceBundle) {
@@ -53,13 +52,13 @@ public class ResourceBundleChain {
/**
* Return the value of the resource.
- *
+ *
* @param key The key to access the <code>String</code> resource.
* @return The resource value. All the registered <code>ResourceBundle</code>s
- * are searched in the order in which they have previously been added to this
- * <code>ResourceBundleChain</code>.
+ * are searched in the order in which they have previously been added to
+ * this <code>ResourceBundleChain</code>.
* @throws MissingResourceException The resource coult not be found in any of
- * the bundles.
+ * the bundles.
*/
public String getString(String key) throws MissingResourceException {
MissingResourceException lastException = null;
@@ -68,19 +67,19 @@ public class ResourceBundleChain {
// handle case where no resource bundles have been added
if (resourceBundles.size() == 0) {
throw new MissingResourceException(
- ERROR_MISSING_RESOURCE,
- this.getClass().getName(),
- key);
+ 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();
+ final ResourceBundle resourceBundle = (ResourceBundle) iter.next();
try {
- String value = resourceBundle.getString(key);
+ final String value = resourceBundle.getString(key);
return value;
- } catch (MissingResourceException e) {
+ } catch (final MissingResourceException e) {
lastException = e;
}
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/SSLUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/SSLUtils.java
index 5078f01..d2d63cb 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/SSLUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/SSLUtils.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.IOException;
@@ -38,207 +37,239 @@ import javax.net.ssl.TrustManagerFactory;
/**
* Utility for connecting to server applications via SSL.
- *
+ *
* @author Paul Ivancsics
* @version $Id$
*/
public class SSLUtils {
-
- /**
- * Creates an <code>SSLSocketFactory</code> 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 <code>null</code>, 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 <code>SSLSocketFactory</code> to be used by an <code>HttpsURLConnection</code>
- * @throws IOException thrown while reading from the input stream
+
+ /**
+ * Creates an <code>SSLSocketFactory</code> 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
+ * <code>null</code>, 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 <code>SSLSocketFactory</code> to be used by an
+ * <code>HttpsURLConnection</code>
+ * @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;
+ String trustStoreType,
+ InputStream trustStoreInputStream,
+ String trustStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ final TrustManager[] tms = getTrustManagers(trustStoreType, trustStoreInputStream, trustStorePassword);
+ final SSLContext ctx = SSLContext.getInstance("TLS");
+ ctx.init(null, tms, null);
+
+ final SSLSocketFactory sf = ctx.getSocketFactory();
+ return sf;
}
- /**
- * Creates an <code>SSLSocketFactory</code> which utilizes the
- * given trust store and keystore.
- *
- * @param trustStore trust store containing trusted server certificates;
- * if <code>null</code>, the default trust store will be utilized
- * @param clientKeyStoreType key store type of <code>clientKeyStore</code>
- * @param clientKeyStoreURL URL of key store containing keys to be used for
- * client authentication; if <code>null</code>, 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 <code>SSLSocketFactory</code> to be used by an <code>HttpsURLConnection</code>
- * @throws IOException thrown while reading key store file
+
+ /**
+ * Creates an <code>SSLSocketFactory</code> which utilizes the given trust store
+ * and keystore.
+ *
+ * @param trustStore trust store containing trusted server
+ * certificates; if <code>null</code>, the default
+ * trust store will be utilized
+ * @param clientKeyStoreType key store type of <code>clientKeyStore</code>
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if <code>null</code>,
+ * 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 <code>SSLSocketFactory</code> to be used by an
+ * <code>HttpsURLConnection</code>
+ * @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;
+ KeyStore trustStore,
+ String clientKeyStoreType,
+ String clientKeyStoreURL,
+ String clientKeyStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ final SSLContext ctx = getSSLContext(
+ trustStore, clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ final SSLSocketFactory sf = ctx.getSocketFactory();
+ return sf;
}
- /**
- * Creates an <code>SSLContext</code> initialized for the
- * given trust store and keystore.
- *
- * @param trustStore trust store containing trusted server certificates;
- * if <code>null</code>, the default trust store will be utilized
- * @param clientKeyStoreType key store type of <code>clientKeyStore</code>
- * @param clientKeyStoreURL URL of key store containing keys to be used for
- * client authentication; if <code>null</code>, 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 <code>SSLContext</code> to be used for creating an <code>SSLSocketFactory</code>
- * @throws IOException thrown while reading key store file
+
+ /**
+ * Creates an <code>SSLContext</code> initialized for the given trust store and
+ * keystore.
+ *
+ * @param trustStore trust store containing trusted server
+ * certificates; if <code>null</code>, the default
+ * trust store will be utilized
+ * @param clientKeyStoreType key store type of <code>clientKeyStore</code>
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if <code>null</code>,
+ * 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 <code>SSLContext</code> to be used for creating an
+ * <code>SSLSocketFactory</code>
+ * @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 {
-
- TrustManager[] tms = getTrustManagers(trustStore);
- KeyManager[] kms = getKeyManagers(clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
- SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(kms, tms, null);
- return ctx;
+ KeyStore trustStore,
+ String clientKeyStoreType,
+ String clientKeyStoreURL,
+ String clientKeyStorePassword)
+ throws IOException, GeneralSecurityException {
+
+ final TrustManager[] tms = getTrustManagers(trustStore);
+ final KeyManager[] kms = getKeyManagers(clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ final SSLContext ctx = SSLContext.getInstance("TLS");
+ ctx.init(kms, tms, null);
+ return ctx;
}
+
/**
- * Loads the trust store from an input stream and gets the
+ * Loads the trust store from an input stream and gets the
* <code>TrustManager</code>s from a default <code>TrustManagerFactory</code>,
- * 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 <code>null</code>, 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 <code>TrustManager</code>s to be used for creating an
- * <code>SSLSocketFactory</code> utilizing the given trust store
- * @throws IOException thrown while reading from the input stream
- * @throws GeneralSecurityException thrown while initializing the
- * default <code>TrustManagerFactory</code>
+ * 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
+ * <code>null</code>, 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 <code>TrustManager</code>s to be used for creating an
+ * <code>SSLSocketFactory</code> utilizing the given trust store
+ * @throws IOException thrown while reading from the input stream
+ * @throws GeneralSecurityException thrown while initializing the default
+ * <code>TrustManagerFactory</code>
*/
- 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 <code>TrustManager</code>s from a default <code>TrustManagerFactory</code>,
- * initialized from the given trust store.
- *
- * @param trustStore the trust store to use
- * @return <code>TrustManager</code>s to be used for creating an
- * <code>SSLSocketFactory</code> utilizing the given trust store
- * @throws GeneralSecurityException thrown while initializing the
- * default <code>TrustManagerFactory</code>
- */
- 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;
- }
+ 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.
+ final KeyStore trustStore = KeyStoreUtils.loadKeyStore(trustStoreType, trustStoreInputStream,
+ trustStorePassword);
+ return getTrustManagers(trustStore);
+ }
+
/**
- * Loads the client key store from file and gets the
- * <code>KeyManager</code>s from a default <code>KeyManagerFactory</code>,
- * initialized from the given client key store.
- * @param clientKeyStoreType key store type of <code>clientKeyStore</code>
- * @param clientKeyStoreURL URL of key store containing keys to be used for
- * client authentication; if <code>null</code>, the default key store will be utilized
- * @param clientKeyStorePassword password used to check the integrity of the client key store;
- * if <code>null</code>, it will not be checked
- * @return <code>KeyManager</code>s to be used for creating an
- * <code>SSLSocketFactory</code> utilizing the given client key store
- * @throws IOException thrown while reading from the key store file
- * @throws GeneralSecurityException thrown while initializing the
- * default <code>KeyManagerFactory</code>
+ * Gets the <code>TrustManager</code>s from a default
+ * <code>TrustManagerFactory</code>, initialized from the given trust store.
+ *
+ * @param trustStore the trust store to use
+ * @return <code>TrustManager</code>s to be used for creating an
+ * <code>SSLSocketFactory</code> utilizing the given trust store
+ * @throws GeneralSecurityException thrown while initializing the default
+ * <code>TrustManagerFactory</code>
*/
- 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);
- }
+ protected static TrustManager[] getTrustManagers(KeyStore trustStore)
+ throws GeneralSecurityException {
+
+ if (trustStore == null) {
+ return null;
+ }
+
+ // Initialize the default TrustManagerFactory with this KeyStore
+ final String alg = TrustManagerFactory.getDefaultAlgorithm();
+ final TrustManagerFactory tmFact = TrustManagerFactory.getInstance(alg);
+ tmFact.init(trustStore);
+
+ // And now get the TrustManagers
+ final TrustManager[] tms = tmFact.getTrustManagers();
+ return tms;
+ }
+
/**
- * Gets the <code>KeyManager</code>s from a default <code>KeyManagerFactory</code>,
- * 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 <code>KeyManager</code>s to be used for creating an
- * <code>SSLSocketFactory</code> utilizing the given client key store
- * @throws GeneralSecurityException thrown while initializing the
- * default <code>KeyManagerFactory</code>
+ * Loads the client key store from file and gets the <code>KeyManager</code>s
+ * from a default <code>KeyManagerFactory</code>, initialized from the given
+ * client key store.
+ *
+ * @param clientKeyStoreType key store type of <code>clientKeyStore</code>
+ * @param clientKeyStoreURL URL of key store containing keys to be used for
+ * client authentication; if <code>null</code>,
+ * the default key store will be utilized
+ * @param clientKeyStorePassword password used to check the integrity of the
+ * client key store; if <code>null</code>, it will
+ * not be checked
+ * @return <code>KeyManager</code>s to be used for creating an
+ * <code>SSLSocketFactory</code> utilizing the given client key store
+ * @throws IOException thrown while reading from the key store file
+ * @throws GeneralSecurityException thrown while initializing the default
+ * <code>KeyManagerFactory</code>
*/
- 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;
- }
+ 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.
+ final KeyStore clientKeyStore = KeyStoreUtils.loadKeyStore(
+ clientKeyStoreType, clientKeyStoreURL, clientKeyStorePassword);
+ return getKeyManagers(clientKeyStore, clientKeyStorePassword);
+ }
+
+ /**
+ * Gets the <code>KeyManager</code>s from a default
+ * <code>KeyManagerFactory</code>, 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 <code>KeyManager</code>s to be used for creating an
+ * <code>SSLSocketFactory</code> utilizing the given client key store
+ * @throws GeneralSecurityException thrown while initializing the default
+ * <code>KeyManagerFactory</code>
+ */
+ public static KeyManager[] getKeyManagers(
+ KeyStore clientKeyStore,
+ String clientKeyStorePassword)
+ throws GeneralSecurityException {
+
+ if (clientKeyStore == null) {
+ return null;
+ }
+
+ // Now we initialize the default KeyManagerFactory with this KeyStore
+ final String alg = KeyManagerFactory.getDefaultAlgorithm();
+ final KeyManagerFactory kmFact = KeyManagerFactory.getInstance(alg);
+ char[] password = null;
+ if (clientKeyStorePassword != null) {
+ password = clientKeyStorePassword.toCharArray();
+ }
+ kmFact.init(clientKeyStore, password);
+
+ // And now get the KeyManagers
+ final KeyManager[] kms = kmFact.getKeyManagers();
+ return kms;
+ }
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java
index 5d328cf..06efdda 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamEntityResolver.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.IOException;
@@ -33,23 +32,26 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
- * An <code>EntityResolver</code> that maps system IDs to
+ * An <code>EntityResolver</code> that maps system IDs to
* <code>InputStream</code>s.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class StreamEntityResolver implements EntityResolver {
-
- /** A mapping from Public ID or System ID to an <code>InputStream</code>
- * containing the entity. */
- private Map mappedEntities;
-
+
+ /**
+ * A mapping from Public ID or System ID to an <code>InputStream</code>
+ * containing the entity.
+ */
+ private final Map mappedEntities;
+
/**
* Create a <code>StreamEntityResolver</code>.
- *
- * @param mappedEntities A mapping from public or system IDs
- * (<code>String</code> objects) to <code>InputStream</code>s.
+ *
+ * @param mappedEntities A mapping from public or system IDs
+ * (<code>String</code> objects) to
+ * <code>InputStream</code>s.
*/
public StreamEntityResolver(Map mappedEntities) {
this.mappedEntities = mappedEntities;
@@ -57,32 +59,33 @@ public class StreamEntityResolver implements EntityResolver {
/**
* 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 <code>InputStream</code> containing the entity or
- * <code>null</code> if no entity could be found.
+ * @return An <code>InputStream</code> containing the entity or
+ * <code>null</code> if no entity could be found.
* @throws SAXException Signalling a parsing exception.
- * @throws IOException Error reading the entity.
+ * @throws IOException Error reading the entity.
*/
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
-
+ @Override
+ 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/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamUtils.java
index f3abe9c..41eae87 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StreamUtils.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.ByteArrayOutputStream;
@@ -32,34 +31,34 @@ import java.io.PrintStream;
/**
* Utility methods for streams.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class StreamUtils {
-
+
/**
* Compare the contents of two <code>InputStream</code>s.
- *
+ *
* @param is1 The 1st <code>InputStream</code> to compare.
* @param is2 The 2nd <code>InputStream</code> to compare.
* @return boolean <code>true</code>, if both streams contain the exactly the
- * same content, <code>false</code> otherwise.
+ * same content, <code>false</code> 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];
+ public static boolean compareStreams(InputStream is1, InputStream is2)
+ throws IOException {
+
+ final byte[] buf1 = new byte[256];
+ final 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;
}
@@ -70,127 +69,128 @@ public class StreamUtils {
return false;
}
}
- } catch (IOException e) {
+ } catch (final IOException e) {
throw e;
} finally {
// close both streams
try {
is1.close();
is2.close();
- } catch (IOException e) {
+ } catch (final 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 b1 1st byte array to compare.
+ * @param b2 2nd byte array to compare.
* @param length The maximum number of bytes to compare.
* @return <code>true</code>, if the byte arrays are equal, <code>false</code>
- * otherwise.
+ * 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 <code>InputStream</code> to read.
* @return The bytes contained in the given <code>InputStream</code>.
* @throws IOException on any exception thrown
*/
public static byte[] readStream(InputStream in) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
copyStream(in, out, null);
-
- /*
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- int b;
- while ((b = in.read()) >= 0)
- out.write(b);
-
- */
+
+ /*
+ * ByteArrayOutputStream out = new ByteArrayOutputStream(); int b; while ((b =
+ * in.read()) >= 0) out.write(b);
+ *
+ */
in.close();
return out.toByteArray();
}
/**
* Reads a <code>String</code> from a stream, using given encoding.
- * @param in The <code>InputStream</code> to read.
- * @param encoding The character encoding to use for converting the bytes
- * of the <code>InputStream</code> into a <code>String</code>.
- * @return The content of the given <code>InputStream</code> converted into
- * a <code>String</code>.
+ *
+ * @param in The <code>InputStream</code> to read.
+ * @param encoding The character encoding to use for converting the bytes of the
+ * <code>InputStream</code> into a <code>String</code>.
+ * @return The content of the given <code>InputStream</code> converted into a
+ * <code>String</code>.
* @throws IOException on any exception thrown
*/
public static String readStream(InputStream in, String encoding) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
copyStream(in, out, null);
/*
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- int b;
- while ((b = in.read()) >= 0)
- out.write(b);
- */
+ * ByteArrayOutputStream out = new ByteArrayOutputStream(); int b; while ((b =
+ * in.read()) >= 0) out.write(b);
+ */
in.close();
return out.toString(encoding);
}
-
+
/**
- * Reads all data (until EOF is reached) from the given source to the
+ * Reads all data (until EOF is reached) from the given source to the
* destination stream. If the destination stream is null, all data is dropped.
- * It uses the given buffer to read data and forward it. If the buffer is
- * null, this method allocates a buffer.
+ * It uses the given buffer to read data and forward it. If the buffer is null,
+ * this method allocates a buffer.
*
- * @param source The stream providing the data.
- * @param destination The stream that takes the data. If this is null, all
- * data from source will be read and discarded.
- * @param buffer The buffer to use for forwarding. If it is null, the method
- * allocates a buffer.
- * @exception IOException If reading from the source or writing to the
+ * @param source The stream providing the data.
+ * @param destination The stream that takes the data. If this is null, all data
+ * from source will be read and discarded.
+ * @param buffer The buffer to use for forwarding. If it is null, the
+ * method allocates a buffer.
+ * @exception IOException If reading from the source or writing to the
* destination fails.
*/
- private static void copyStream(InputStream source, OutputStream destination, byte[] buffer) throws IOException {
+ private static void copyStream(InputStream source, OutputStream destination, byte[] buffer)
+ throws IOException {
if (source == null) {
throw new NullPointerException("Argument \"source\" must not be null.");
}
if (buffer == null) {
buffer = new byte[8192];
}
-
+
if (destination != null) {
int bytesRead;
while ((bytesRead = source.read(buffer)) >= 0) {
destination.write(buffer, 0, bytesRead);
}
} else {
- while (source.read(buffer) >= 0);
- }
+ while (source.read(buffer) >= 0) {
+ ;
+ }
+ }
}
-
+
/**
* Gets the stack trace of the <code>Throwable</code> passed in as a string.
+ *
* @param t The <code>Throwable</code>.
* @return a String representing the stack trace of the <code>Throwable</code>.
*/
- public static String getStackTraceAsString(Throwable t)
- {
- ByteArrayOutputStream stackTraceBIS = new ByteArrayOutputStream();
+ public static String getStackTraceAsString(Throwable t) {
+ final ByteArrayOutputStream stackTraceBIS = new ByteArrayOutputStream();
t.printStackTrace(new PrintStream(stackTraceBIS));
return new String(stackTraceBIS.toByteArray());
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StringUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StringUtils.java
index 695be18..4c22340 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StringUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/StringUtils.java
@@ -21,59 +21,59 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.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.
+ * @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());
+ final StringTokenizer st = new StringTokenizer(s);
+ final 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.
+ * @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());
+ final StringTokenizer st = new StringTokenizer(s, token);
+ final 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.
+ *
+ * @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();
+ final StringBuffer sb = new StringBuffer(s);
+ final int l = sb.length();
int j = 0;
- for (int i=0; i<l; i++) {
+ for (int i = 0; i < l; i++) {
if (sb.charAt(i) == '0') {
j++;
} else {
@@ -82,97 +82,94 @@ public class StringUtils {
}
return sb.substring(j, l);
}
-
+
/**
* Replaces each substring of string <code>s</code> that matches the given
* <code>search</code> string by the given <code>replace</code> string.
- *
- * @param s The string where the replacement should take place.
- * @param search The pattern that should be replaced.
- * @param replace The string that should replace all each <code>search</code>
- * string within <code>s</code>.
- * @return A string where all occurrence of <code>search</code> are
- * replaced with <code>replace</code>.
+ *
+ * @param s The string where the replacement should take place.
+ * @param search The pattern that should be replaced.
+ * @param replace The string that should replace all each <code>search</code>
+ * string within <code>s</code>.
+ * @return A string where all occurrence of <code>search</code> are replaced
+ * with <code>replace</code>.
*/
- 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);
+ public static String replaceAll(String s, String search, String replace) {
+ final StringBuffer sb = new StringBuffer();
+ int i = 0, j = 0;
+ final 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;
+ }
+ }
- if (j > -1)
- {
- sb.append(s.substring(i,j));
- sb.append(replace);
- i = j + len;
- }
- }
-
- sb.append(s.substring(i, s.length()));
+ sb.append(s.substring(i, s.length()));
- return sb.toString();
+ 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</code> to <code>sl</code> and
- * <code>http://www.buergerkarte.at/namespaces/securitylayer/20020225#</code>
- * to
- * <code>http://www.buergerkarte.at/namespaces/securitylayer/1.2#</code>
- *
- * @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.
+ * 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</code> to <code>sl</code> and
+ * <code>http://www.buergerkarte.at/namespaces/securitylayer/20020225#</code> to
+ * <code>http://www.buergerkarte.at/namespaces/securitylayer/1.2#</code>
+ *
+ * @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) {
+ 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 ;
+ 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!=null && xmlString.startsWith("<?xml")) {
- int firstElement = xmlString.indexOf("<", 1);
+ if (xmlString != null && xmlString.startsWith("<?xml")) {
+ final int firstElement = xmlString.indexOf("<", 1);
return xmlString.substring(firstElement);
} else {
return xmlString;
}
}
-
+
/**
* Checks if String is empty
+ *
* @param s String to be checked if empty
* @return True if String is empty, false otherwise
*/
public static boolean isEmpty(String s) {
- if (s == null || s.length() == 0)
- return true;
- else
- return false;
-
+ if (s == null || s.length() == 0) {
+ return true;
+ } else {
+ return false;
+ }
+
}
-
-
+
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLDecoder.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLDecoder.java
index af71e2d..cfebbb2 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLDecoder.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLDecoder.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.ByteArrayOutputStream;
@@ -30,55 +29,60 @@ 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.
+ * 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 <code>application/x-www-form-urlencoded</code> string using a specific encoding scheme.
- * @param s the string to decode
+ * Decodes an <code>application/x-www-form-urlencoded</code> 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))
+ final StringReader in = new StringReader(s);
+ final 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
+ * @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 == '+')
+ try {
+ final int b = in.read();
+ if (b == '+') {
return ' ';
+ }
if (b == '%') {
- char[] hex = new char[2];
+ final char[] hex = new char[2];
if (in.read(hex, 0, 2) >= 0) {
- String hexString = new String(hex);
+ final String hexString = new String(hex);
return Integer.valueOf(hexString, 16).intValue();
- }
- else
+ } else {
return -1;
+ }
}
return b;
- }
- catch (IOException ex) {
- return -1;
- }
- catch (NumberFormatException ex) {
- return -1;
+ } catch (final IOException ex) {
+ return -1;
+ } catch (final NumberFormatException ex) {
+ return -1;
}
}
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLEncoder.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLEncoder.java
index 2aa7e22..5eaece3 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLEncoder.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/URLEncoder.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.ByteArrayInputStream;
@@ -29,60 +28,68 @@ 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.
+ * 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 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
+ * @throws UnsupportedEncodingException when the desired encoding is not
+ * supported
*/
public static String encode(String s, String encoding) throws UnsupportedEncodingException {
// if (MiscUtil.isEmpty(s))
// return null;
- byte[] barr = s.getBytes(encoding);
- ByteArrayInputStream bin = new ByteArrayInputStream(barr);
- StringWriter out = new StringWriter();
- for (int b = bin.read(); b >= 0; b = bin.read())
+ final byte[] barr = s.getBytes(encoding);
+ final ByteArrayInputStream bin = new ByteArrayInputStream(barr);
+ final 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 ch The character to encode.
* @param out The <code>StringWriter</code> 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 == '_')
+ if (ch >= 'a' && ch <= 'z'
+ || ch >= 'A' && ch <= 'Z'
+ || ch >= '0' && ch <= '9'
+ || ch == '.' || ch == '-' || ch == '*' || ch == '_') {
out.write(ch);
- else if (ch == ' ')
+ } else if (ch == ' ') {
out.write('+');
- else
+ } else {
encodeHex(ch, out);
+ }
}
-
+
/**
- * Encode a character as an escaped hex value.
- * @param ch The character to encode.
+ * Encode a character as an escaped hex value.
+ *
+ * @param ch The character to encode.
* @param out The <code>StringWriter</code> containing the result.
*/
private static void encodeHex(int ch, StringWriter out) {
out.write('%');
- String hex = Integer.toHexString(ch).toUpperCase();
- if (hex.length() < 2)
+ final String hex = Integer.toHexString(ch).toUpperCase();
+ if (hex.length() < 2) {
out.write('0');
- else
+ } else {
out.write(hex.charAt(hex.length() - 2));
+ }
out.write(hex.charAt(hex.length() - 1));
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathException.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathException.java
index cbf3e4e..9a60bd2 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathException.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathException.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.util;
import java.io.PrintStream;
@@ -29,33 +28,33 @@ import java.io.PrintWriter;
/**
* An exception occurred evaluating an XPath.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class XPathException extends RuntimeException {
/**
- *
- */
- private static final long serialVersionUID = 1736311265333034392L;
-/** The wrapped exception. */
- private Throwable wrapped;
-
+ *
+ */
+ private static final long serialVersionUID = 1736311265333034392L;
+ /** The wrapped exception. */
+ private final Throwable wrapped;
+
/**
* Create a <code>XPathException</code>.
- *
+ *
* @param message The exception message.
* @param wrapped The exception being the likely cause of this exception.
*/
public XPathException(String message, Throwable wrapped) {
// TODO: remove wrapped from super cstr. again
- super(message, wrapped);
- this.wrapped = wrapped;
+ super(message, wrapped);
+ this.wrapped = wrapped;
}
-
+
/**
* Return the wrapped exception.
- *
+ *
* @return The wrapped exception being the likely cause of this exception.
*/
public Throwable getWrapped() {
@@ -65,6 +64,7 @@ public class XPathException extends RuntimeException {
/**
* @see java.lang.Throwable#printStackTrace(java.io.PrintStream)
*/
+ @Override
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
if (getWrapped() != null) {
@@ -76,6 +76,7 @@ public class XPathException extends RuntimeException {
/**
* @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
*/
+ @Override
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
if (getWrapped() != null) {
@@ -83,5 +84,5 @@ public class XPathException extends RuntimeException {
getWrapped().printStackTrace(s);
}
}
-
+
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathUtils.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathUtils.java
index 2604c20..3bc3bb9 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathUtils.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/XPathUtils.java
@@ -21,28 +21,26 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moaspss.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.Navigator;
import org.jaxen.SimpleNamespaceContext;
import org.jaxen.dom.DOMXPath;
import org.jaxen.dom.DocumentNavigator;
+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;
/**
* Utility methods to evaluate XPath expressions on DOM nodes.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -53,16 +51,16 @@ public class XPathUtils {
* root node itself).
*/
public static final String ALL_NODES_XPATH =
- "(.//. | .//@* | .//namespace::*)";
+ "(.//. | .//@* | .//namespace::*)";
/** The <code>DocumentNavigator</code> to use for navigating the document. */
private static Navigator documentNavigator =
- DocumentNavigator.getInstance();
+ DocumentNavigator.getInstance();
/** The default namespace prefix to namespace URI mappings. */
private static NamespaceContext NS_CONTEXT;
static {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ final 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);
@@ -95,18 +93,17 @@ public class XPathUtils {
/**
* Return a <code>NodeIterator</code> over the nodes matching the XPath
* expression.
- *
+ *
* All namespace URIs and prefixes declared in the <code>Constants</code>
* 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.
+ *
+ * @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 {
+ throws XPathException {
return selectNodeIterator(contextNode, NS_CONTEXT, exp);
}
@@ -114,28 +111,28 @@ public class XPathUtils {
/**
* Return a <code>NodeIterator</code> 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.
+ *
+ * @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 {
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
try {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ final 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 });
+ } catch (final JaxenException e) {
+ final MessageProvider msg = MessageProvider.getInstance();
+ final String message = msg.getMessage("xpath.00", new Object[] { exp });
throw new XPathException(message, e);
}
}
@@ -143,23 +140,23 @@ public class XPathUtils {
/**
* Return a <code>NodeIterator</code> over the nodes matching the XPath
* expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
* @param namespaceMapping A namespace prefix to namespace URI mapping
- * (<code>String</code> to <code>String</code>) for evaluating the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
+ * (<code>String</code> to <code>String</code>) 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 {
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+ final SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
return selectNodeIterator(contextNode, ctx, exp);
}
@@ -167,31 +164,31 @@ public class XPathUtils {
/**
* Return a <code>NodeIterator</code> over the nodes matching the XPath
* expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param nsContext The <code>NamespaceContext</code> for resolving namespace
- * prefixes to namespace URIs for evaluating the XPath expression.
- * @param exp The XPath expression to evaluate.
+ *
+ * @param contextNode The root node from which to evaluate the XPath expression.
+ * @param nsContext The <code>NamespaceContext</code> 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 {
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
try {
- DOMXPath xpath = new DOMXPath(exp);
+ final 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 });
+ } catch (final JaxenException e) {
+ final MessageProvider msg = MessageProvider.getInstance();
+ final String message = msg.getMessage("xpath.00", new Object[] { exp });
throw new XPathException(message, e);
}
}
@@ -199,18 +196,17 @@ public class XPathUtils {
/**
* Return a <code>NodeList</code> of all the nodes matching the XPath
* expression.
- *
+ *
* All namespace URIs and prefixes declared in the <code>Constants</code>
* 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.
+ *
+ * @param contextNode The root node from which to evaluate the XPath expression.
+ * @param exp The XPath expression to evaluate.
* @return A <code>NodeList</code> containing the matching nodes.
* @throws XPathException An error occurred evaluating the XPath expression.
*/
public static NodeList selectNodeList(Node contextNode, String exp)
- throws XPathException {
+ throws XPathException {
return selectNodeList(contextNode, NS_CONTEXT, exp);
}
@@ -218,29 +214,29 @@ public class XPathUtils {
/**
* Return a <code>NodeList</code> 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.
+ *
+ * @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 <code>NodeList</code> 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 {
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
try {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ final 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 });
+ } catch (final JaxenException e) {
+ final MessageProvider msg = MessageProvider.getInstance();
+ final String message = msg.getMessage("xpath.00", new Object[] { exp });
throw new XPathException(message, e);
}
}
@@ -248,23 +244,23 @@ public class XPathUtils {
/**
* Return a <code>NodeList</code> of all the nodes matching the XPath
* expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
+ *
+ * @param contextNode The root node from which to evaluate the XPath
+ * expression.
* @param namespaceMapping A namespace prefix to namespace URI mapping
- * (<code>String</code> to <code>String</code>) for evaluating the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
+ * (<code>String</code> to <code>String</code>) for
+ * evaluating the XPath expression.
+ * @param exp The XPath expression to evaluate.
* @return A <code>NodeList</code> 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 {
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+ final SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
return selectNodeList(contextNode, ctx, exp);
}
@@ -272,133 +268,132 @@ public class XPathUtils {
/**
* Return a <code>NodeList</code> of all the nodes matching the XPath
* expression.
- *
- * @param contextNode The root node from which to evaluate the XPath
- * expression.
- * @param nsContext The <code>NamespaceContext</code> for resolving namespace
- * prefixes to namespace URIs for evaluating the XPath expression.
- * @param exp The XPath expression to evaluate.
+ *
+ * @param contextNode The root node from which to evaluate the XPath expression.
+ * @param nsContext The <code>NamespaceContext</code> for resolving namespace
+ * prefixes to namespace URIs for evaluating the XPath
+ * expression.
+ * @param exp The XPath expression to evaluate.
* @return A <code>NodeList</code> 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 {
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
try {
- DOMXPath xpath = new DOMXPath(exp);
+ final 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 });
+ } catch (final JaxenException e) {
+ final MessageProvider msg = MessageProvider.getInstance();
+ final 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 <code>Constants</code>
* 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.
+ *
+ * @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
- * <code>null</code>, if no node matched.
+ * <code>null</code>, if no node matched.
* @throws XPathException An error occurred evaluating the XPath expression.
*/
public static Node selectSingleNode(Node contextNode, String exp)
- throws XPathException {
+ 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.
+ *
+ * @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
- * <code>null</code>, if no node matched.
+ * <code>null</code>, 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 {
+ Node contextNode,
+ Element namespaceElement,
+ String exp)
+ throws XPathException {
try {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext();
+ final 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 });
+ } catch (final JaxenException e) {
+ final MessageProvider msg = MessageProvider.getInstance();
+ final 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 contextNode The root node from which to evaluate the XPath
+ * expression.
* @param namespaceMapping A namespace prefix to namespace URI mapping
- * (<code>String</code> to <code>String</code>) for evaluating the XPath
- * expression.
- * @param exp The XPath expression to evaluate.
+ * (<code>String</code> to <code>String</code>) for
+ * evaluating the XPath expression.
+ * @param exp The XPath expression to evaluate.
* @return Node The first node matching the XPath expression, or
- * <code>null</code>, if no node matched.
+ * <code>null</code>, 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 {
+ Node contextNode,
+ Map namespaceMapping,
+ String exp)
+ throws XPathException {
- SimpleNamespaceContext ctx = new SimpleNamespaceContext(namespaceMapping);
+ final 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 <code>NamespaceContext</code> for resolving namespace
- * prefixes to namespace URIs for evaluating the XPath expression.
- * @param exp The XPath expression to evaluate.
+ *
+ * @param contextNode The root node from which to evaluate the XPath expression.
+ * @param nsContext The <code>NamespaceContext</code> 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
- * <code>null</code>, if no node matched.
+ * <code>null</code>, if no node matched.
* @throws XPathException An error occurred evaluating the XPath expression.
*/
public static Node selectSingleNode(
- Node contextNode,
- NamespaceContext nsContext,
- String exp)
- throws XPathException {
+ Node contextNode,
+ NamespaceContext nsContext,
+ String exp)
+ throws XPathException {
try {
- DOMXPath xpath = new DOMXPath(exp);
+ final 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 });
+ } catch (final JaxenException e) {
+ final MessageProvider msg = MessageProvider.getInstance();
+ final String message = msg.getMessage("xpath.00", new Object[] { exp });
throw new XPathException(message, e);
}
}
@@ -406,140 +401,137 @@ public class XPathUtils {
/**
* 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 <code>xpath</code>.
- * @return The element value, if it can be located using the
- * <code>xpath</code>. Otherwise, <code>def</code> is returned.
+ *
+ * @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 <code>xpath</code>.
+ * @return The element value, if it can be located using the <code>xpath</code>.
+ * Otherwise, <code>def</code> is returned.
*/
public static String getElementValue(
- Element root,
- String xpath,
- String def) {
+ Element root,
+ String xpath,
+ String def) {
- Element elem = (Element) XPathUtils.selectSingleNode(root, xpath);
+ final 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 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 <code>xpath</code>.
- * @return The element value, if it can be located using the
- * <code>xpath</code>. Otherwise, <code>def</code> is returned.
+ * return.
+ * @param def The default value to return, if no attribute can be found using
+ * the given <code>xpath</code>.
+ * @return The element value, if it can be located using the <code>xpath</code>.
+ * Otherwise, <code>def</code> is returned.
*/
public static String getAttributeValue(
- Element root,
- String xpath,
- String def) {
+ Element root,
+ String xpath,
+ String def) {
- Attr attr = (Attr) XPathUtils.selectSingleNode(root, xpath);
+ final Attr attr = (Attr) XPathUtils.selectSingleNode(root, xpath);
return attr != null ? attr.getValue() : def;
}
-
+
/**
- * Returns the namespace prefix used within <code>XPathUtils</code> for referring to
- * the namespace of the specified (Security Layer command) element.
+ * Returns the namespace prefix used within <code>XPathUtils</code> 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 <code> XPathUtils</code> without explicitely binding it to the
+ * particular namespace.
+ *
+ * @param contextElement The (Security Layer command) element.
*
- * This namespace prefix can be used in various XPath expression evaluation methods
- * within <code> XPathUtils</code> without explicitely binding it to the particular
- * namespace.
- *
- * @param contextElement The (Security Layer command) element.
- *
- * @return the namespace prefix used within <code>XPathUtils</code> 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).
+ * @return the namespace prefix used within <code>XPathUtils</code> 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();
+ public static String getSlPrefix(Element contextElement) throws XPathException {
+ final String sLNamespace = contextElement.getNamespaceURI();
String sLPrefix = null;
- if (sLNamespace.equals(Constants.SL10_NS_URI))
- {
+ if (sLNamespace.equals(Constants.SL10_NS_URI)) {
sLPrefix = Constants.SL10_PREFIX;
- }
- else if (sLNamespace.equals(Constants.SL12_NS_URI))
- {
+ } else if (sLNamespace.equals(Constants.SL12_NS_URI)) {
sLPrefix = Constants.SL12_PREFIX;
- }
- else if (sLNamespace.equals(Constants.SL11_NS_URI))
- {
+ } 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 + "\"."});
+ } else {
+ final MessageProvider msg = MessageProvider.getInstance();
+ final 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 <code>xmlns:sl10</code>, <code>sl11</code> or <code>sl</code>
- * attribute of the context element.
- *
+ * 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
+ * <code>xmlns:sl10</code>, <code>sl11</code> or <code>sl</code> 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.
*
- * @param contextElement The element to get a prefix for the Securitylayer namespace,
- * that is used within the corresponding document.
- *
- * @return The string <code>sl10</code>, <code>sl11</code> or <code>sl</code>,
- * depending on the SecurityLayer namespace of the contextElement.
- *
- * throws XPathException If no (vlalid) SecurityLayer namespace prefix or namespace
- * is defined.
+ * @return The string <code>sl10</code>, <code>sl11</code> or <code>sl</code>,
+ * 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 {
-
+ 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 <code>xmlns:slPrefix</code> and
- * if the prefix of that attribute corresponds with a valid SecurityLayer namespace.
+ * Checks if the context element has an attribute <code>xmlns:slPrefix</code>
+ * 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.
*
- * @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 <code>null</code> if this prefix is
- * not used.
+ * @return The valid SecurityLayer prefix or <code>null</code> 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);
+ throws XPathException {
+ final String nsAtt = "xmlns:" + slPrefix;
+ final String nameSpace = contextElement.getAttribute(nsAtt);
if (nameSpace == "") {
return null;
} else {
@@ -547,8 +539,9 @@ public class XPathUtils {
if (nameSpace.equals(slNameSpace)) {
return slPrefix;
} else {
- MessageProvider msg = MessageProvider.getInstance();
- String message = msg.getMessage("xpath.00", new Object[] { "Ung�ltiger SecurityLayer Namespace: \"" + nameSpace + "\"."});
+ final MessageProvider msg = MessageProvider.getInstance();
+ final String message = msg.getMessage("xpath.00", new Object[] {
+ "Ung�ltiger SecurityLayer Namespace: \"" + nameSpace + "\"." });
throw new XPathException(message, null);
}
}
diff --git a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ex/EgovUtilException.java b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ex/EgovUtilException.java
index 27169b4..5960fce 100644
--- a/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ex/EgovUtilException.java
+++ b/moaSig/common/src/main/java/at/gv/egovernment/moaspss/util/ex/EgovUtilException.java
@@ -1,13 +1,13 @@
/*
* Copyright 2011 Federal Chancellery Austria and
* Graz University of Technology
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,24 +18,24 @@ package at.gv.egovernment.moaspss.util.ex;
public class EgovUtilException extends Exception {
- /**
- *
+ /**
+ *
*/
private static final long serialVersionUID = 1L;
- public EgovUtilException() {
- }
+ public EgovUtilException() {
+ }
- public EgovUtilException(String message) {
- super(message);
- }
+ public EgovUtilException(String message) {
+ super(message);
+ }
- public EgovUtilException(Throwable cause) {
- super(cause);
- }
+ public EgovUtilException(Throwable cause) {
+ super(cause);
+ }
- public EgovUtilException(String message, Throwable cause) {
- super(message, cause);
- }
+ public EgovUtilException(String message, Throwable cause) {
+ super(message, cause);
+ }
}