aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/Base64TransformationImpl.java29
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteArrayDataObjectImpl.java27
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteStreamDataObjectImpl.java18
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/CanonicalizationImpl.java27
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/DataObjectImpl.java25
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/EnvelopedSignatureTransformationImpl.java22
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ExclusiveCanonicalizationImpl.java53
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/SigningTimeImpl.java12
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/TransformationImpl.java15
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLDataObjectImpl.java21
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLNodeListDataObjectImpl.java14
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLSignatureImpl.java14
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2FilterImpl.java45
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2TransformationImpl.java31
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPathTransformationImpl.java43
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XSLTTransformationImpl.java350
16 files changed, 373 insertions, 373 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/Base64TransformationImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/Base64TransformationImpl.java
index cc12861..1bba712 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/Base64TransformationImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/Base64TransformationImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import iaik.server.modules.xml.Base64Transformation;
@@ -29,39 +28,39 @@ import iaik.server.modules.xml.Base64Transformation;
/**
* An implementation of the <code>Base64Transformation</code>
* <code>Transformation</code> type.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class Base64TransformationImpl
- extends TransformationImpl
- implements Base64Transformation {
-
+ extends TransformationImpl
+ implements Base64Transformation {
+
/**
* Create a new <code>Base64TransformationImpl</code>.
- *
+ *
* @see java.lang.Object#Object()
- */
+ */
public Base64TransformationImpl() {
setAlgorithmURI(Base64Transformation.BASE64_DECODING);
}
/**
* Compare this <code>Base64Transformation</code> to another.
- *
- * @param other The object to compare this<code>Base64Transformation</code>
- * to.
+ *
+ * @param other The object to compare this<code>Base64Transformation</code> to.
* @return <code>true</code>, if <code>other</code> is a
- * <code>Base64Transformation</code> and the algorithm URIs match, otherwise
- * <code>false</code>.
+ * <code>Base64Transformation</code> and the algorithm URIs match,
+ * otherwise <code>false</code>.
* @see java.lang.Object#equals(Object)
- */
+ */
+ @Override
public boolean equals(Object other) {
if (other instanceof Base64Transformation) {
- Base64Transformation transform = (Base64Transformation) other;
+ final Base64Transformation transform = (Base64Transformation) other;
return getAlgorithmURI().equals(transform.getAlgorithmURI());
}
return false;
}
-
+
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteArrayDataObjectImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteArrayDataObjectImpl.java
index 4d627d7..e498842 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteArrayDataObjectImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteArrayDataObjectImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import java.io.ByteArrayInputStream;
@@ -31,22 +30,21 @@ import iaik.server.modules.xml.BinaryDataObject;
/**
* A <code>BinaryDataObject</code> encapsulating Base64 data.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class ByteArrayDataObjectImpl
- extends DataObjectImpl
- implements BinaryDataObject {
+ extends DataObjectImpl
+ implements BinaryDataObject {
/** The binary data contained in this <code>BinaryDataObject</code>. */
private byte[] bytes;
/**
* Create a new <code>ByteArrayDataObjectImpl</code>.
- *
- * @param bytes The binary data contained in this
- * <code>BinaryDataObject</code>.
+ *
+ * @param bytes The binary data contained in this <code>BinaryDataObject</code>.
*/
public ByteArrayDataObjectImpl(byte[] bytes) {
setBytes(bytes);
@@ -54,23 +52,22 @@ public class ByteArrayDataObjectImpl
/**
* Set the Base64 data.
- *
- * @param bytes The binary data contained in this
- * <code>BinaryDataObject</code>.
+ *
+ * @param bytes The binary data contained in this <code>BinaryDataObject</code>.
*/
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
/**
- * Return the binary data encoded in the Base64 <code>String</code> as a
- * stream.
- *
+ * Return the binary data encoded in the Base64 <code>String</code> as a stream.
+ *
* @return The binary data contained in this object, as a
- * <code>InputStream</code>. Repeated calls to this function will return a
- * new stream to the Base64 data.
+ * <code>InputStream</code>. Repeated calls to this function will return
+ * a new stream to the Base64 data.
* @see iaik.server.modules.xml.BinaryDataObject#getInputStream()
*/
+ @Override
public InputStream getInputStream() {
return new ByteArrayInputStream(bytes);
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteStreamDataObjectImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteStreamDataObjectImpl.java
index b982c8e..af8ee66 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteStreamDataObjectImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ByteStreamDataObjectImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import java.io.InputStream;
@@ -29,21 +28,21 @@ import java.io.InputStream;
import iaik.server.modules.xml.BinaryDataObject;
/**
- * A <code>BinaryDataObject</code> encapsulating binary data from a stream.
- *
+ * A <code>BinaryDataObject</code> encapsulating binary data from a stream.
+ *
* @author Patrick Peck
* @version $Id$
*/
public class ByteStreamDataObjectImpl
- extends DataObjectImpl
- implements BinaryDataObject {
+ extends DataObjectImpl
+ implements BinaryDataObject {
/** The <code>InputStream</code> containing the binary data. */
private InputStream inputStream;
/**
* Create a new <code>ByteStreamDataObjectImpl</code>.
- *
+ *
* @param inputStream The stream from which to read the binary data.
*/
public ByteStreamDataObjectImpl(InputStream inputStream) {
@@ -52,7 +51,7 @@ public class ByteStreamDataObjectImpl
/**
* Set the input stream from which to read the binary data.
- *
+ *
* @param inputStream The input stream from which to read the binary data.
*/
public void setInputStream(InputStream inputStream) {
@@ -61,11 +60,12 @@ public class ByteStreamDataObjectImpl
/**
* Return the binary data from this object as a stream.
- *
+ *
* @return The stream containing the binary data. Calling this function
- * repeatedly will always return the same <code>InputStream</code>.
+ * repeatedly will always return the same <code>InputStream</code>.
* @see iaik.server.modules.xml.BinaryDataObject#getInputStream()
*/
+ @Override
public InputStream getInputStream() {
return inputStream;
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/CanonicalizationImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/CanonicalizationImpl.java
index 0c3a8da..1e2a651 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/CanonicalizationImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/CanonicalizationImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import iaik.server.modules.xml.Canonicalization;
@@ -29,36 +28,36 @@ import iaik.server.modules.xml.Canonicalization;
/**
* An implementation of the <code>CanonicalizationTransform</code>
* <code>Transformation</code> type.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class CanonicalizationImpl
- extends TransformationImpl
- implements Canonicalization {
-
+ extends TransformationImpl
+ implements Canonicalization {
+
/**
* Create a new <code>CanonicalizationTransformImpl</code> object.
- *
+ *
* @param algorithmURI The canonicalization algorithm URI.
- */
+ */
public CanonicalizationImpl(String algorithmURI) {
setAlgorithmURI(algorithmURI);
}
-
+
/**
* Compare this object to another <code>Canonicalization</code>.
- *
- * @param other The object to compare this
- * <code>Canonicalization</code> to.
+ *
+ * @param other The object to compare this <code>Canonicalization</code> to.
* @return <code>true</code>, if <code>other</code> is a
- * <code>Canonicalization</code> and the algorithm URIs match, otherwise
- * <code>false</code>.
+ * <code>Canonicalization</code> and the algorithm URIs match, otherwise
+ * <code>false</code>.
* @see java.lang.Object#equals(Object)
*/
+ @Override
public boolean equals(Object other) {
if (other instanceof Canonicalization) {
- Canonicalization c14n = (Canonicalization) other;
+ final Canonicalization c14n = (Canonicalization) other;
return getAlgorithmURI().equals(c14n.getAlgorithmURI());
}
return false;
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/DataObjectImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/DataObjectImpl.java
index 702caaf..ac36875 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/DataObjectImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/DataObjectImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import iaik.server.modules.xml.DataObject;
@@ -29,12 +28,12 @@ import iaik.server.modules.xml.DataObject;
/**
* Abstract base implementation for the classes derived from
* <code>DataObject</code>.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public abstract class DataObjectImpl implements DataObject {
-
+
/** The MIME type of the data object. */
private String mimeType;
/** The refernce ID. */
@@ -43,33 +42,35 @@ public abstract class DataObjectImpl implements DataObject {
private String typeURI;
/** The URI identifying the data. */
private String URI;
-
+
/**
* @see iaik.server.modules.xml.DataObject#getMimeType()
*/
+ @Override
public String getMimeType() {
return mimeType;
}
/**
* Set the mime type.
- *
+ *
* @param mimeType The mime type to set.
*/
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
-
+
/**
* @see iaik.server.modules.xml.DataObject#getReferenceID()
*/
+ @Override
public String getReferenceID() {
return referenceID;
}
-
+
/**
* Set the reference ID.
- *
+ *
* @param referenceID The reference ID.
*/
public void setReferenceID(String referenceID) {
@@ -79,13 +80,14 @@ public abstract class DataObjectImpl implements DataObject {
/**
* @see iaik.server.modules.xml.DataObject#getTypeURI()
*/
+ @Override
public String getTypeURI() {
return typeURI;
}
/**
* Set the type URI.
- *
+ *
* @param typeURI The type URI.
*/
public void setTypeURI(String typeURI) {
@@ -95,13 +97,14 @@ public abstract class DataObjectImpl implements DataObject {
/**
* @see iaik.server.modules.xml.DataObject#getURI()
*/
+ @Override
public String getURI() {
return URI;
}
-
+
/**
* Set the URI.
- *
+ *
* @param URI The URI.
*/
public void setURI(String URI) {
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/EnvelopedSignatureTransformationImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/EnvelopedSignatureTransformationImpl.java
index d582594..2c9f0e3 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/EnvelopedSignatureTransformationImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/EnvelopedSignatureTransformationImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import iaik.server.modules.xml.EnvelopedSignatureTransformation;
@@ -29,13 +28,13 @@ import iaik.server.modules.xml.EnvelopedSignatureTransformation;
/**
* An implementation of the <code>EnvelopedSignatureTransformation</code>
* <code>Transformation</code> type.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class EnvelopedSignatureTransformationImpl
- extends TransformationImpl
- implements EnvelopedSignatureTransformation {
+ extends TransformationImpl
+ implements EnvelopedSignatureTransformation {
/**
* Create a new <code>EnvelopedSignatureTransformationImpl</code>.
@@ -46,18 +45,19 @@ public class EnvelopedSignatureTransformationImpl
/**
* Compare this object to another <code>EnvelopedSignatureTransformation</code>.
- *
- * @param other The object to compare this
- * <code>EnvelopedSignatureTransformation</code> to.
+ *
+ * @param other The object to compare this
+ * <code>EnvelopedSignatureTransformation</code> to.
* @return <code>true</code>, if <code>other</code> is a
- * <code>EnvelopedSignatureTransformation</code>, otherwise
- * <code>false</code>.
+ * <code>EnvelopedSignatureTransformation</code>, otherwise
+ * <code>false</code>.
* @see java.lang.Object#equals(Object)
*/
+ @Override
public boolean equals(Object other) {
if (other instanceof EnvelopedSignatureTransformation) {
- EnvelopedSignatureTransformation transform =
- (EnvelopedSignatureTransformation) other;
+ final EnvelopedSignatureTransformation transform =
+ (EnvelopedSignatureTransformation) other;
return getAlgorithmURI().equals(transform.getAlgorithmURI());
}
return false;
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ExclusiveCanonicalizationImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ExclusiveCanonicalizationImpl.java
index dfadf0c..ce98e7f 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ExclusiveCanonicalizationImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/ExclusiveCanonicalizationImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import java.util.List;
@@ -29,38 +28,39 @@ import java.util.List;
import iaik.server.modules.xml.ExclusiveCanonicalization;
/**
- * An implementation of the <code>ExclusiveCanonicalization</code> type
- * of <code>Transformation</code>.
- *
+ * An implementation of the <code>ExclusiveCanonicalization</code> type of
+ * <code>Transformation</code>.
+ *
* @author Patrick Peck
* @version $Id$
*/
public class ExclusiveCanonicalizationImpl
- extends TransformationImpl
- implements ExclusiveCanonicalization {
+ extends TransformationImpl
+ implements ExclusiveCanonicalization {
/** The prefixes of the namespaces to treat according to canonical XML. */
private List inclusiveNamespacePrefixes;
/**
* Create a new <code>ExclusiveCanonicalizationImpl</code> object.
- *
- * @param algorithmURI The exclusive canonicalization algorithm URI.
+ *
+ * @param algorithmURI The exclusive canonicalization algorithm
+ * URI.
* @param inclusiveNamespacePrefixes The namespace prefixes to be processed
- * according to canonical XML.
+ * according to canonical XML.
*/
public ExclusiveCanonicalizationImpl(
- String algorithmURI,
- List inclusiveNamespacePrefixes) {
+ String algorithmURI,
+ List inclusiveNamespacePrefixes) {
setAlgorithmURI(algorithmURI);
setInclusiveNamespacePrefixes(inclusiveNamespacePrefixes);
}
/**
* Sets the namespace prefixes to be processed according to canonical XML.
- *
+ *
* @param inclusiveNamespacePrefixes The prefixes of the namespaces to treat
- * according to canonical XML.
+ * according to canonical XML.
*/
protected void setInclusiveNamespacePrefixes(List inclusiveNamespacePrefixes) {
this.inclusiveNamespacePrefixes = inclusiveNamespacePrefixes;
@@ -69,29 +69,32 @@ public class ExclusiveCanonicalizationImpl
/**
* @see iaik.server.modules.xml.ExclusiveCanonicalization#getInclusiveNamespacePrefixes()
*/
+ @Override
public List getInclusiveNamespacePrefixes() {
return inclusiveNamespacePrefixes;
}
/**
* Compare this object to another <code>CanonicalizationTransform</code>.
- *
- * @param other The object to compare this
- * <code>ExclusiveCanonicalization</code> to.
+ *
+ * @param other The object to compare this
+ * <code>ExclusiveCanonicalization</code> to.
* @return <code>true</code>, if <code>other</code> is a
- * <code>ExclusiveCanonicalization</code> and the algorithm URIs match,
- * otherwise <code>false</code>.
+ * <code>ExclusiveCanonicalization</code> and the algorithm URIs match,
+ * otherwise <code>false</code>.
* @see java.lang.Object#equals(Object)
*/
+ @Override
public boolean equals(Object other) {
if (other instanceof ExclusiveCanonicalization) {
- ExclusiveCanonicalization eC14n =
- (ExclusiveCanonicalization) other;
- boolean algURIEquals = getAlgorithmURI().equals(eC14n.getAlgorithmURI());
- boolean inclNSPrefs =
- (getInclusiveNamespacePrefixes() == null || getInclusiveNamespacePrefixes().isEmpty())
- ? eC14n.getInclusiveNamespacePrefixes() == null || eC14n.getInclusiveNamespacePrefixes().isEmpty()
- : getInclusiveNamespacePrefixes().equals(eC14n.getInclusiveNamespacePrefixes());
+ final ExclusiveCanonicalization eC14n =
+ (ExclusiveCanonicalization) other;
+ final boolean algURIEquals = getAlgorithmURI().equals(eC14n.getAlgorithmURI());
+ final boolean inclNSPrefs =
+ getInclusiveNamespacePrefixes() == null || getInclusiveNamespacePrefixes().isEmpty()
+ ? eC14n.getInclusiveNamespacePrefixes() == null || eC14n.getInclusiveNamespacePrefixes()
+ .isEmpty()
+ : getInclusiveNamespacePrefixes().equals(eC14n.getInclusiveNamespacePrefixes());
return algURIEquals && inclNSPrefs;
}
return false;
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/SigningTimeImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/SigningTimeImpl.java
index 9026d33..9f4e22d 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/SigningTimeImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/SigningTimeImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import java.util.Date;
@@ -30,18 +29,18 @@ import iaik.server.modules.xml.SigningTime;
/**
* An implementation of the <code>SigningTime</code> <code>Property</code>.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class SigningTimeImpl implements SigningTime {
-
+
/** The signing time. */
- private Date signingTime;
-
+ private final Date signingTime;
+
/**
* Create a new <code>SigningTimeImpl</code>.
- *
+ *
* @param signingTime The signing time.
*/
public SigningTimeImpl(Date signingTime) {
@@ -51,6 +50,7 @@ public class SigningTimeImpl implements SigningTime {
/**
* @see iaik.server.modules.xml.SigningTime#getSigningTime()
*/
+ @Override
public Date getSigningTime() {
return signingTime;
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/TransformationImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/TransformationImpl.java
index 1595446..fa3401e 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/TransformationImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/TransformationImpl.java
@@ -21,14 +21,13 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import iaik.server.modules.xml.Transformation;
/**
* Base implementation class for <code>Transformation</code> derived classes.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -36,32 +35,34 @@ public abstract class TransformationImpl implements Transformation {
/** The algorithm URI identifying the transformation algorithm. */
private String algorithmURI;
-
+
/**
* @see iaik.server.modules.xml.Transformation#getAlgorithmURI()
*/
+ @Override
public String getAlgorithmURI() {
return algorithmURI;
}
/**
* Sets the algorithm URI.
- *
+ *
* @param algorithmURI The algorithm URI to set.
*/
protected void setAlgorithmURI(String algorithmURI) {
this.algorithmURI = algorithmURI;
}
-
+
/**
* Returns the hash code of the algorithm URI. Should be overridden if a
* transformation distinguishes itself from others by more than just the
* algorithm URI.
- *
+ *
* @see java.lang.Object#hashCode()
*/
+ @Override
public int hashCode() {
return getAlgorithmURI().hashCode();
}
-
+
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLDataObjectImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLDataObjectImpl.java
index e8444b9..0688d0e 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLDataObjectImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLDataObjectImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import org.w3c.dom.Element;
@@ -30,22 +29,21 @@ import iaik.server.modules.xml.XMLDataObject;
/**
* A <code>DataObject</code> containing a single DOM element.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class XMLDataObjectImpl
- extends DataObjectImpl
- implements XMLDataObject {
-
- /** The XML data contained in this <code>XMLDataObject</code>. */
+ extends DataObjectImpl
+ implements XMLDataObject {
+
+ /** The XML data contained in this <code>XMLDataObject</code>. */
private Element element;
-
+
/**
* Create a new <code>XMLDataObjectImpl</code>.
- *
- * @param element The DOM element contained in this
- * <code>XMLDataObject</code>.
+ *
+ * @param element The DOM element contained in this <code>XMLDataObject</code>.
*/
public XMLDataObjectImpl(Element element) {
setElement(element);
@@ -54,13 +52,14 @@ public class XMLDataObjectImpl
/**
* @see iaik.server.modules.xml.XMLDataObject#getElement()
*/
+ @Override
public Element getElement() {
return element;
}
/**
* Set the DOM element contained in this <code>XMLDataObject</code>.
- *
+ *
* @param element The DOM element to set.
*/
public void setElement(Element element) {
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLNodeListDataObjectImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLNodeListDataObjectImpl.java
index 2fb9df9..51f96f0 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLNodeListDataObjectImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLNodeListDataObjectImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import org.w3c.dom.NodeList;
@@ -30,22 +29,22 @@ import iaik.server.modules.xml.XMLNodeListDataObject;
/**
* A <code>DataObject</code> containing a list of DOM nodes.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class XMLNodeListDataObjectImpl
- extends DataObjectImpl
- implements XMLNodeListDataObject {
+ extends DataObjectImpl
+ implements XMLNodeListDataObject {
/** The nodes contained in this <code>XMLNodeListDataObject</code>. */
private NodeList nodeList;
/**
* Create a new <code>XMLNodeListDataObjectImpl</code>.
- *
+ *
* @param nodeList The list of DOM nodes contained in this
- * <code>XMLNodeListDataObject</code>.
+ * <code>XMLNodeListDataObject</code>.
*/
public XMLNodeListDataObjectImpl(NodeList nodeList) {
setNodeList(nodeList);
@@ -54,7 +53,7 @@ public class XMLNodeListDataObjectImpl
/**
* Set the list of DOM nodes contained in this
* <code>XMLNodeListDataObject</code>.
- *
+ *
* @param nodeList The list of DOM nodes to set.
*/
public void setNodeList(NodeList nodeList) {
@@ -64,6 +63,7 @@ public class XMLNodeListDataObjectImpl
/**
* @see iaik.server.modules.xml.XMLNodeListDataObject#getNodeList()
*/
+ @Override
public NodeList getNodeList() {
return nodeList;
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLSignatureImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLSignatureImpl.java
index 0774726..1844780 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLSignatureImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XMLSignatureImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import org.w3c.dom.Element;
@@ -29,28 +28,28 @@ import org.w3c.dom.Element;
import iaik.server.modules.xml.XMLSignature;
/**
- * An object containing an XMLDsig signature in the form of a
+ * An object containing an XMLDsig signature in the form of a
* <code>dsig:Signature</code> DOM element.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class XMLSignatureImpl implements XMLSignature {
/** The signature DOM element. */
private Element element;
-
+
/**
* Create a new <code>XMLSignatureImpl</code>.
- *
+ *
* @param element The <code>dsig:Signature</code> DOM element.
*/
public XMLSignatureImpl(Element element) {
setElement(element);
}
-
+
/**
* Set the <code>dsig:Signature</code> DOM element.
- *
+ *
* @param element The <code>dsig:Signature</code> element to set.
*/
public void setElement(Element element) {
@@ -60,6 +59,7 @@ public class XMLSignatureImpl implements XMLSignature {
/**
* @see iaik.server.modules.xml.XMLSignature#getElement()
*/
+ @Override
public Element getElement() {
return element;
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2FilterImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2FilterImpl.java
index d309302..a44196a 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2FilterImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2FilterImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import java.util.Map;
@@ -31,7 +30,7 @@ import iaik.server.modules.xml.XPath2Transformation.XPath2Filter;
/**
* An object encapsulating an XPath-Filter2 expression.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -46,17 +45,18 @@ public class XPath2FilterImpl implements XPath2Filter {
/**
* Create a new <code>XPath2FilterImpl</code> object.
- *
- * @param filterType The type of filter. Must be one of the filter type
- * constants declared in <code>iaik.server.modules.xml.XPath2Transformation.XPath2Filter</code>
- * @param xPathExpression The XPath expression belonging to this filter.
+ *
+ * @param filterType The type of filter. Must be one of the filter
+ * type constants declared in
+ * <code>iaik.server.modules.xml.XPath2Transformation.XPath2Filter</code>
+ * @param xPathExpression The XPath expression belonging to this filter.
* @param namespaceDeclarations The namespace declarations visible for this
- * XPath2Filter.
+ * XPath2Filter.
*/
public XPath2FilterImpl(
- String filterType,
- String xPathExpression,
- Map namespaceDeclarations) {
+ String filterType,
+ String xPathExpression,
+ Map namespaceDeclarations) {
setFilterType(filterType);
setXPathExpression(xPathExpression);
@@ -66,13 +66,14 @@ public class XPath2FilterImpl implements XPath2Filter {
/**
* @see iaik.server.modules.xml.XPath2Transformation.XPath2Filter#getFilterType()
*/
+ @Override
public String getFilterType() {
return filterType;
}
/**
* Set the filter type.
- *
+ *
* @param filterType The filter type to set.
*/
protected void setFilterType(String filterType) {
@@ -82,13 +83,14 @@ public class XPath2FilterImpl implements XPath2Filter {
/**
* @see iaik.server.modules.xml.XPath2Transformation.XPath2Filter#getXPathExpression()
*/
+ @Override
public String getXPathExpression() {
return xPathExpression;
}
/**
* Set the XPath expression.
- *
+ *
* @param xPathExpression The XPath expression to set.
*/
protected void setXPathExpression(String xPathExpression) {
@@ -98,15 +100,16 @@ public class XPath2FilterImpl implements XPath2Filter {
/**
* @see iaik.server.modules.xml.XPath2Transformation.XPath2Filter#getNamespaceDeclarations()
*/
+ @Override
public Map getNamespaceDeclarations() {
return namespaceDeclarations;
}
/**
* Set the namespace declarations.
- *
- * @param namespaceDeclarations The mapping between namespace prefixes and
- * their associated URI.
+ *
+ * @param namespaceDeclarations The mapping between namespace prefixes and their
+ * associated URI.
*/
protected void setNamespaceDeclarations(Map namespaceDeclarations) {
this.namespaceDeclarations = namespaceDeclarations;
@@ -114,18 +117,19 @@ public class XPath2FilterImpl implements XPath2Filter {
/**
* Compare this object to another.
- *
+ *
* @param other The object to compare this <code>XPath2Filter</code> to.
* @return <code>true</code>, if <code>other</code> is a
- * <code>XPath2Filter</code> and the filter types match and the XPath
- * expressions match. Otherwise <code>false</code> is returned.
+ * <code>XPath2Filter</code> and the filter types match and the XPath
+ * expressions match. Otherwise <code>false</code> is returned.
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals(Object other) {
if (other instanceof XPath2Transformation.XPath2Filter) {
- XPath2Filter filter = (XPath2Transformation.XPath2Filter) other;
+ final XPath2Filter filter = (XPath2Transformation.XPath2Filter) other;
return getFilterType().equals(filter.getFilterType())
- && getXPathExpression().equals(filter.getXPathExpression());
+ && getXPathExpression().equals(filter.getXPathExpression());
}
return false;
}
@@ -133,6 +137,7 @@ public class XPath2FilterImpl implements XPath2Filter {
/**
* @see java.lang.Object#hashCode()
*/
+ @Override
public int hashCode() {
return getXPathExpression().hashCode() * 31 + getFilterType().hashCode();
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2TransformationImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2TransformationImpl.java
index f483b18..b49bd64 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2TransformationImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPath2TransformationImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import java.util.ArrayList;
@@ -33,20 +32,20 @@ import iaik.server.modules.xml.XPath2Transformation;
/**
* An object encapsulating a <code>Transformation</code> containing several
* XPath-Filter2 expressions.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class XPath2TransformationImpl
- extends TransformationImpl
- implements XPath2Transformation {
+ extends TransformationImpl
+ implements XPath2Transformation {
/** The filters contained in this <code>XPath2Transformation</code> */
- private List xPathFilters = new ArrayList();
+ private final List xPathFilters = new ArrayList();
/**
* Create a new <code>XPath2TransformationImpl</code>.
- *
+ *
* The list of XPath-Filter2 expression is initially empty.
*/
public XPath2TransformationImpl() {
@@ -56,13 +55,14 @@ public class XPath2TransformationImpl
/**
* @see iaik.server.modules.xml.XPath2Transformation#getXPathFilters()
*/
+ @Override
public List getXPathFilters() {
return xPathFilters;
}
/**
* Add an XPath-Filter2 expression to the list of filters.
- *
+ *
* @param filter The filter to add.
*/
public void addXPathFilter(XPath2Filter filter) {
@@ -71,18 +71,18 @@ public class XPath2TransformationImpl
/**
* Compare this <code>XPath2Transformation</code> to another.
- *
- * @param other The object to compare this
- * <code>XPath2Transformation</code> to.
+ *
+ * @param other The object to compare this <code>XPath2Transformation</code> to.
* @return <code>true</code>, if <code>other</code> is an
- * <code>XPath2Transformation</code> and <code>getXPathFilters()</code> equals
- * <code>other.getXPathFilters()</code>. Otherwise <code>false</code> is
- * returned.
+ * <code>XPath2Transformation</code> and <code>getXPathFilters()</code>
+ * equals <code>other.getXPathFilters()</code>. Otherwise
+ * <code>false</code> is returned.
* @see java.lang.Object#equals(Object)
*/
+ @Override
public boolean equals(Object other) {
if (other instanceof XPath2Transformation) {
- XPath2Transformation transform = (XPath2Transformation) other;
+ final XPath2Transformation transform = (XPath2Transformation) other;
return getXPathFilters().equals(transform.getXPathFilters());
}
@@ -92,8 +92,9 @@ public class XPath2TransformationImpl
/**
* @see java.lang.Object#hashCode()
*/
+ @Override
public int hashCode() {
- Iterator iter = getXPathFilters().iterator();
+ final Iterator iter = getXPathFilters().iterator();
int hashCode = 0;
while (iter.hasNext()) {
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPathTransformationImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPathTransformationImpl.java
index 06cc319..65b33f4 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPathTransformationImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XPathTransformationImpl.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.server.iaik.xml;
import java.util.Map;
@@ -30,13 +29,13 @@ import iaik.server.modules.xml.XPathTransformation;
/**
* A <code>Transformation</code> containing an XPath expression.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class XPathTransformationImpl
- extends TransformationImpl
- implements XPathTransformation {
+ extends TransformationImpl
+ implements XPathTransformation {
/** The XPath expression. */
private String xPathExpression;
@@ -45,16 +44,16 @@ public class XPathTransformationImpl
/**
* Create a new <code>XPathTransformationImpl</code>.
- *
+ *
* The namespace declarations are initialized empty.
- *
- * @param xPathExpression The XPath expression this object will contain.
+ *
+ * @param xPathExpression The XPath expression this object will contain.
* @param namespaceDeclarations The namespace declarations visible for this
- * XPath.
+ * XPath.
*/
public XPathTransformationImpl(
- String xPathExpression,
- Map namespaceDeclarations) {
+ String xPathExpression,
+ Map namespaceDeclarations) {
setAlgorithmURI(XPathTransformation.XPATH);
setXPathExpression(xPathExpression);
@@ -63,7 +62,7 @@ public class XPathTransformationImpl
/**
* Set the XPath expression.
- *
+ *
* @param xPathExpression The XPath expression.
*/
protected void setXPathExpression(String xPathExpression) {
@@ -73,6 +72,7 @@ public class XPathTransformationImpl
/**
* @see iaik.server.modules.xml.XPathTransformation#getXPathExpression()
*/
+ @Override
public String getXPathExpression() {
return xPathExpression;
}
@@ -80,15 +80,16 @@ public class XPathTransformationImpl
/**
* @see iaik.server.modules.xml.XPathTransformation#getNamespaceDeclarations()
*/
+ @Override
public Map getNamespaceDeclarations() {
return namespaceDeclarations;
}
/**
* Set the namespace declarations.
- *
- * @param namespaceDeclarations The mapping between namespace prefixes and
- * their associated URI.
+ *
+ * @param namespaceDeclarations The mapping between namespace prefixes and their
+ * associated URI.
*/
protected void setNamespaceDeclarations(Map namespaceDeclarations) {
this.namespaceDeclarations = namespaceDeclarations;
@@ -96,17 +97,18 @@ public class XPathTransformationImpl
/**
* Compare this <code>XPathTransformation</code> to another.
- *
- * @param other The object to compare this
- * <code>XPathTransformation</code> to.
+ *
+ * @param other The object to compare this <code>XPathTransformation</code> to.
* @return <code>true</code>, if <code>other</code> is an
- * <code>XPathTransformation</code> and if this object contains the same XPath
- * expression as <code>other</code>. Otherwise <code>false</code> is returned.
+ * <code>XPathTransformation</code> and if this object contains the same
+ * XPath expression as <code>other</code>. Otherwise <code>false</code>
+ * is returned.
* @see java.lang.Object#equals(Object)
*/
+ @Override
public boolean equals(Object other) {
if (other instanceof XPathTransformation) {
- XPathTransformation transform = (XPathTransformation) other;
+ final XPathTransformation transform = (XPathTransformation) other;
return getXPathExpression().equals(transform.getXPathExpression());
}
return false;
@@ -115,6 +117,7 @@ public class XPathTransformationImpl
/**
* @see java.lang.Object#hashCode()
*/
+ @Override
public int hashCode() {
return getXPathExpression().hashCode();
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XSLTTransformationImpl.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XSLTTransformationImpl.java
index 9dc45fc..6c71f42 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XSLTTransformationImpl.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/iaik/xml/XSLTTransformationImpl.java
@@ -45,204 +45,194 @@ import at.gv.egovernment.moaspss.util.XPathException;
import at.gv.egovernment.moaspss.util.XPathUtils;
import iaik.server.modules.xml.MOAXSecProvider;
import iaik.server.modules.xml.XSLTTransformation;
-import iaik.xml.crypto.dsig.XMLSignatureFactory;
-import iaik.xml.filter.impl.dsig.CanonInputStream;
-import iaik.xml.filter.impl.dsig.Canonicalizer;
-import iaik.xml.filter.impl.dsig.Traverser;
/**
* A <code>Transformation</code> containing an XSLT transformation.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class XSLTTransformationImpl extends TransformationImpl implements XSLTTransformation {
- /** The XSLT stylesheet. */
- private Element styleSheetElement;
- /**
- * The hash code of the canonicalized stylesheet. If calculated, this value
- * should be != 0.
- */
- private int hashCode;
-
- /**
- * Create a new <code>XSLTTransformationImpl</code> object.
- *
- * @param styleSheetElement
- * The XSLT stylesheet element.
- */
- public XSLTTransformationImpl(Element styleSheetElement) {
- setAlgorithmURI(XSLTTransformation.XSLT);
- setStyleSheetElement(styleSheetElement);
- }
-
- /**
- * Set the XSLT stylesheet element.
- *
- * @param styleSheetElement
- * The XSLT stylesheet element to set.
- */
- protected void setStyleSheetElement(Element styleSheetElement) {
- this.styleSheetElement = styleSheetElement;
- this.hashCode = 0;
- }
-
- /**
- * @see iaik.server.modules.xml.XSLTTransformation#getStylesheetElement()
- */
- public Element getStylesheetElement() {
- return styleSheetElement;
- }
-
- /**
- * Compare this <code>XSLTTransformation</code> to another.
- *
- * @param other
- * The object to compare this <code>XSLTTransformation</code> to.
- * @return <code>true</code>, if <code>other</code> is an
- * <code>XSLTTransformation</code> and if the canonicalized
- * representations of the stylesheets contained in <code>this</code>
- * and <code>other</code> match. Otherwise, <code>false</code> is
- * returned.
- * @see java.lang.Object#equals(Object)
- */
- public boolean equals(Object other) {
- if (other instanceof XSLTTransformation) {
- XSLTTransformation xslt = (XSLTTransformation) other;
-
- return compareElements(getStylesheetElement(), xslt.getStylesheetElement());
- }
- return false;
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- if (hashCode == 0) {
- hashCode = calculateHashCode(getStylesheetElement());
- }
- return hashCode;
- }
-
- /**
- * Calculate the hash code for a DOM element by canonicalizing it.
- *
- * @param element
- * The DOM element for which the hash code is to be calculated.
- * @return int The hash code, or <code>0</code>, if it could not be
- * calculated.
- */
- private static int calculateHashCode(Element element) {
- try {
- InputStream is = canonicalize(element);
- byte[] buf = new byte[256];
- int hashCode = 1;
- int length;
- int i;
-
- while ((length = is.read(buf)) > 0) {
- for (i = 0; i < length; i++) {
- hashCode += buf[i] * 31 + i;
- }
- }
- is.close();
- return hashCode;
- } catch (IOException e) {
- return 0;
- } catch (NoSuchAlgorithmException e) {
- return 0;
- } catch (InvalidAlgorithmParameterException e) {
- return 0;
- } catch (TransformException e) {
- return 0;
- }
- }
-
- /**
- * Compare two DOM elements by canonicalizing their contents and comparing
- * the resulting byte stream.
- *
- * @param elem1
- * The 1st element to compare.
- * @param elem2
- * The 2nd element to compare.
- * @return boolean <code>true</code>, if the elements are considered equal
- * after canonicalization. Otherwise <code>false</code> is returned.
- */
- private static boolean compareElements(Element elem1, Element elem2) {
- try {
- InputStream is1 = canonicalize(elem1);
- InputStream is2 = canonicalize(elem2);
- return StreamUtils.compareStreams(is1, is2);
- } catch (IOException e) {
- return false;
- } catch (NoSuchAlgorithmException e) {
- return false;
- } catch (InvalidAlgorithmParameterException e) {
- return false;
- } catch (TransformException e) {
- return false;
- }
- }
-
- /**
- * Canonicalize a DOM element.
+ /** The XSLT stylesheet. */
+ private Element styleSheetElement;
+ /**
+ * The hash code of the canonicalized stylesheet. If calculated, this value
+ * should be != 0.
+ */
+ private int hashCode;
+
+ /**
+ * Create a new <code>XSLTTransformationImpl</code> object.
+ *
+ * @param styleSheetElement The XSLT stylesheet element.
+ */
+ public XSLTTransformationImpl(Element styleSheetElement) {
+ setAlgorithmURI(XSLTTransformation.XSLT);
+ setStyleSheetElement(styleSheetElement);
+ }
+
+ /**
+ * Set the XSLT stylesheet element.
+ *
+ * @param styleSheetElement The XSLT stylesheet element to set.
+ */
+ protected void setStyleSheetElement(Element styleSheetElement) {
+ this.styleSheetElement = styleSheetElement;
+ this.hashCode = 0;
+ }
+
+ /**
+ * @see iaik.server.modules.xml.XSLTTransformation#getStylesheetElement()
+ */
+ @Override
+ public Element getStylesheetElement() {
+ return styleSheetElement;
+ }
+
+ /**
+ * Compare this <code>XSLTTransformation</code> to another.
+ *
+ * @param other The object to compare this <code>XSLTTransformation</code> to.
+ * @return <code>true</code>, if <code>other</code> is an
+ * <code>XSLTTransformation</code> and if the canonicalized
+ * representations of the stylesheets contained in <code>this</code> and
+ * <code>other</code> match. Otherwise, <code>false</code> is returned.
+ * @see java.lang.Object#equals(Object)
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof XSLTTransformation) {
+ final XSLTTransformation xslt = (XSLTTransformation) other;
+
+ return compareElements(getStylesheetElement(), xslt.getStylesheetElement());
+ }
+ return false;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ if (hashCode == 0) {
+ hashCode = calculateHashCode(getStylesheetElement());
+ }
+ return hashCode;
+ }
+
+ /**
+ * Calculate the hash code for a DOM element by canonicalizing it.
*
+ * @param element The DOM element for which the hash code is to be calculated.
+ * @return int The hash code, or <code>0</code>, if it could not be calculated.
+ */
+ private static int calculateHashCode(Element element) {
+ try {
+ final InputStream is = canonicalize(element);
+ final byte[] buf = new byte[256];
+ int hashCode = 1;
+ int length;
+ int i;
+
+ while ((length = is.read(buf)) > 0) {
+ for (i = 0; i < length; i++) {
+ hashCode += buf[i] * 31 + i;
+ }
+ }
+ is.close();
+ return hashCode;
+ } catch (final IOException e) {
+ return 0;
+ } catch (final NoSuchAlgorithmException e) {
+ return 0;
+ } catch (final InvalidAlgorithmParameterException e) {
+ return 0;
+ } catch (final TransformException e) {
+ return 0;
+ }
+ }
+
+ /**
+ * Compare two DOM elements by canonicalizing their contents and comparing the
+ * resulting byte stream.
+ *
+ * @param elem1 The 1st element to compare.
+ * @param elem2 The 2nd element to compare.
+ * @return boolean <code>true</code>, if the elements are considered equal after
+ * canonicalization. Otherwise <code>false</code> is returned.
+ */
+ private static boolean compareElements(Element elem1, Element elem2) {
+ try {
+ final InputStream is1 = canonicalize(elem1);
+ final InputStream is2 = canonicalize(elem2);
+ return StreamUtils.compareStreams(is1, is2);
+ } catch (final IOException e) {
+ return false;
+ } catch (final NoSuchAlgorithmException e) {
+ return false;
+ } catch (final InvalidAlgorithmParameterException e) {
+ return false;
+ } catch (final TransformException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Canonicalize a DOM element.
+ *
* @param element The element to canonicalize.
* @return InputStream A stream with the canonicalized data.
- * @throws InvalidAlgorithmParameterException
- * @throws IOException
- * @throws TransformException
- * @throws AlgorithmException An error occurred canonicalizing the element.
+ * @throws InvalidAlgorithmParameterException
+ * @throws IOException
+ * @throws TransformException
+ * @throws AlgorithmException An error occurred canonicalizing
+ * the element.
*/
private static InputStream canonicalize(Element element)
- throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException, TransformException {
- // CanonicalizationMethod canonicalizationMethod =
- // MOAXSecProvider.getXMLSignatureFactory().newCanonicalizationMethod(
- // CanonicalizationMethod.EXCLUSIVE, new ExcC14NParameterSpec());
-
- //CanonicalizationAlgorithm c14n =
- // new CanonicalizationAlgorithmImplExclusiveCanonicalXML();
- //Traverser traverser = new Traverser(element, true, true);
- //Canonicalizer canonicalizer = new Canonicalizer(traverser, false, true, null);
-
- //return new CanonInputStream(canonicalizer);
-
- CanonicalizationMethod canonicalizationMethod =
- MOAXSecProvider.getXMLSignatureFactory().newCanonicalizationMethod(
- CanonicalizationMethod.EXCLUSIVE, new ExcC14NParameterSpec());
-
- //CanonicalizationAlgorithm c14n =
- // new CanonicalizationAlgorithmImplExclusiveCanonicalXML();
- NodeList nodeList;
-
- try {
- nodeList = XPathUtils.selectNodeList(element,
- XPathUtils.ALL_NODES_XPATH);
- } catch (XPathException e) {
- nodeList = new NodeListAdapter(Collections.EMPTY_LIST);
- }
- //c14n.setInput(nodeList);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- canonicalizationMethod.transform(new
- NodeListToNodeSetDataAdapter(nodeList), null, baos);
- baos.close();
- return new ByteArrayInputStream(baos.toByteArray());
- /*
- NodeList nodeList;
-
+ throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException, TransformException {
+ // CanonicalizationMethod canonicalizationMethod =
+ // MOAXSecProvider.getXMLSignatureFactory().newCanonicalizationMethod(
+ // CanonicalizationMethod.EXCLUSIVE, new ExcC14NParameterSpec());
+
+ // CanonicalizationAlgorithm c14n =
+ // new CanonicalizationAlgorithmImplExclusiveCanonicalXML();
+ // Traverser traverser = new Traverser(element, true, true);
+ // Canonicalizer canonicalizer = new Canonicalizer(traverser, false, true,
+ // null);
+
+ // return new CanonInputStream(canonicalizer);
+
+ final CanonicalizationMethod canonicalizationMethod =
+ MOAXSecProvider.getXMLSignatureFactory().newCanonicalizationMethod(
+ CanonicalizationMethod.EXCLUSIVE, new ExcC14NParameterSpec());
+
+ // CanonicalizationAlgorithm c14n =
+ // new CanonicalizationAlgorithmImplExclusiveCanonicalXML();
+ NodeList nodeList;
+
try {
- nodeList = XPathUtils.selectNodeList(element, XPathUtils.ALL_NODES_XPATH);
- } catch (XPathException e) {
+ nodeList = XPathUtils.selectNodeList(element,
+ XPathUtils.ALL_NODES_XPATH);
+ } catch (final XPathException e) {
nodeList = new NodeListAdapter(Collections.EMPTY_LIST);
}
- //c14n.setInput(nodeList);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ // c14n.setInput(nodeList);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
canonicalizationMethod.transform(new NodeListToNodeSetDataAdapter(nodeList), null, baos);
baos.close();
- return new ByteArrayInputStream(baos.toByteArray());*/
+ return new ByteArrayInputStream(baos.toByteArray());
+ /*
+ * NodeList nodeList;
+ *
+ * try { nodeList = XPathUtils.selectNodeList(element,
+ * XPathUtils.ALL_NODES_XPATH); } catch (XPathException e) { nodeList = new
+ * NodeListAdapter(Collections.EMPTY_LIST); } //c14n.setInput(nodeList);
+ * ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ * canonicalizationMethod.transform(new NodeListToNodeSetDataAdapter(nodeList),
+ * null, baos); baos.close(); return new
+ * ByteArrayInputStream(baos.toByteArray());
+ */
}
}