[maven-release-plugin] copy for tag xmlsec-2.1.3
git-svn-id: https://svn.apache.org/repos/asf/santuario/xml-security-java/tags/xmlsec-2.1.3@1856302 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/etc/santuario-pmd-ruleset.xml b/etc/santuario-pmd-ruleset.xml
index e2ea275..43553ee 100644
--- a/etc/santuario-pmd-ruleset.xml
+++ b/etc/santuario-pmd-ruleset.xml
@@ -24,103 +24,21 @@
A PMD ruleset for Apache Santuario
</description>
- <rule ref="category/java/bestpractices.xml">
- <exclude name="AbstractClassWithoutAbstractMethod" />
- <exclude name="AccessorMethodGeneration" />
- <exclude name="ArrayIsStoredDirectly" />
- <exclude name="AvoidReassigningParameters" />
+ <rule ref="rulesets/java/basic.xml">
<exclude name="AvoidUsingHardCodedIP" />
- <exclude name="ConstantsInInterface" />
- <exclude name="ForLoopCanBeForeach" />
- <exclude name="GuardLogStatement" />
- <exclude name="JUnitAssertionsShouldIncludeMessage"/>
- <exclude name="JUnitTestContainsTooManyAsserts" />
- <exclude name="JUnitTestsShouldIncludeAssert" />
- <exclude name="JUnitUseExpected" />
- <exclude name="MethodReturnsInternalArray" />
- <exclude name="MissingOverride" />
- <exclude name="OneDeclarationPerLine" />
- <exclude name="PreserveStackTrace" />
- <exclude name="SwitchStmtsShouldHaveDefault" />
- <exclude name="SystemPrintln" />
- <exclude name="UnusedPrivateMethod" />
- <exclude name="UseAssertSameInsteadOfAssertTrue" />
- <exclude name="UseVarargs" />
+ <exclude name="SimplifiedTernary" />
</rule>
+ <rule ref="rulesets/java/unusedcode.xml"/>
+ <rule ref="rulesets/java/imports.xml"/>
+ <rule ref="rulesets/java/braces.xml"/>
+ <rule ref="rulesets/java/empty.xml">
+ <exclude name="EmptyCatchBlock" />
+ </rule>
+ <rule ref="rulesets/java/migrating.xml">
+ <exclude name="JUnit4TestShouldUseAfterAnnotation" />
+ <exclude name="JUnit4TestShouldUseTestAnnotation" />
+ <exclude name="JUnitUseExpected" />
+ </rule>
+ <rule ref="rulesets/java/unnecessary.xml"/>
- <rule ref="category/java/design.xml" >
- <exclude name="AvoidCatchingGenericException" />
- <exclude name="AvoidDeeplyNestedIfStmts" />
- <exclude name="AvoidRethrowingException" />
- <exclude name="AvoidThrowingNullPointerException" />
- <exclude name="AvoidThrowingRawExceptionTypes" />
- <exclude name="CouplingBetweenObjects" />
- <exclude name="CyclomaticComplexity" />
- <exclude name="DataClass" />
- <exclude name="ExceptionAsFlowControl" />
- <exclude name="ExcessiveClassLength" />
- <exclude name="ExcessiveImports" />
- <exclude name="ExcessiveMethodLength" />
- <exclude name="ExcessivePublicCount" />
- <exclude name="GodClass" />
- <exclude name="ImmutableField" />
- <exclude name="LawOfDemeter" />
- <exclude name="NcssCount" />
- <exclude name="NPathComplexity" />
- <exclude name="SignatureDeclareThrowsException" />
- <exclude name="SingularField" />
- <exclude name="SwitchDensity" />
- <exclude name="TooManyFields" />
- <exclude name="TooManyMethods" />
- <exclude name="UseObjectForClearerAPI" />
- <exclude name="UseUtilityClass" />
- </rule>
-
- <rule ref="category/java/errorprone.xml">
- <exclude name="AssignmentInOperand" />
- <exclude name="AssignmentToNonFinalStatic" />
- <exclude name="AvoidCatchingNPE" />
- <exclude name="AvoidCatchingThrowable" />
- <exclude name="AvoidDuplicateLiterals" />
- <exclude name="AvoidFieldNameMatchingMethodName" />
- <exclude name="AvoidLiteralsInIfCondition" />
- <exclude name="BeanMembersShouldSerialize" />
- <exclude name="CompareObjectsWithEquals" />
- <exclude name="ConstructorCallsOverridableMethod" />
- <exclude name="DataflowAnomalyAnalysis" />
- <exclude name="DoNotCallGarbageCollectionExplicitly" />
- <exclude name="EmptyCatchBlock" />
- <exclude name="InvalidSlf4jMessageFormat" />
- <exclude name="JUnitSpelling" />
- <exclude name="MissingSerialVersionUID" />
- <exclude name="NullAssignment" />
- <exclude name="SingletonClassReturningNewInstance" />
- <exclude name="SingleMethodSingleton" />
- <exclude name="SuspiciousEqualsMethodName" />
- <exclude name="UseLocaleWithCaseConversions" />
- <exclude name="UseProperClassLoader" />
- </rule>
-
- <rule ref="category/java/multithreading.xml">
- <exclude name="AvoidSynchronizedAtMethodLevel" />
- <exclude name="AvoidUsingVolatile" />
- <exclude name="DoNotUseThreads" />
- <exclude name="UseConcurrentHashMap" />
- </rule>
-
- <rule ref="category/java/performance.xml">
- <exclude name="AddEmptyString" />
- <exclude name="AvoidInstantiatingObjectsInLoops" />
- <exclude name="AvoidFileStream" />
- <exclude name="ConsecutiveAppendsShouldReuse" />
- <exclude name="InefficientEmptyStringCheck" />
- <exclude name="OptimizableToArrayCall" />
- <exclude name="RedundantFieldInitializer" />
- <exclude name="UseStringBufferForStringAppends" />
- </rule>
-
- <rule ref="category/java/security.xml" >
- <exclude name="HardCodedCryptoKey" />
- </rule>
-
</ruleset>
diff --git a/pom.xml b/pom.xml
index 18a5ada..97501c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
<artifactId>xmlsec</artifactId>
<packaging>bundle</packaging>
<name>Apache XML Security for Java</name>
- <version>2.2.0-SNAPSHOT</version>
+ <version>2.1.3</version>
<description>
Apache XML Security for Java supports XML-Signature Syntax and Processing,
W3C Recommendation 12 February 2002, and XML Encryption Syntax and
@@ -57,12 +57,12 @@
</licenses>
<scm>
<connection>
- scm:svn:http://svn.apache.org/repos/asf/santuario/xml-security-java/trunk/
+ scm:svn:http://svn.apache.org/repos/asf/santuario/xml-security-java/tags/xmlsec-2.1.3
</connection>
<developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk/
+ scm:svn:https://svn.apache.org/repos/asf/santuario/xml-security-java/tags/xmlsec-2.1.3
</developerConnection>
- <url>http://svn.apache.org/repos/asf/santuario/xml-security-java/trunk/</url>
+ <url>http://svn.apache.org/repos/asf/santuario/xml-security-java/tags/xmlsec-2.1.3</url>
</scm>
<organization>
<name>The Apache Software Foundation</name>
@@ -111,7 +111,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
- <version>3.11.0</version>
+ <version>3.7</version>
<configuration>
<rulesets>
<ruleset>${basedir}/etc/santuario-pmd-ruleset.xml</ruleset>
@@ -157,18 +157,23 @@
<configuration>
<source>${targetJdk}</source>
<target>${targetJdk}</target>
- <compilerArgs>
- <arg>-XDcompilePolicy=simple</arg>
- <arg>-Xplugin:ErrorProne</arg>
- </compilerArgs>
- <annotationProcessorPaths>
- <path>
- <groupId>com.google.errorprone</groupId>
- <artifactId>error_prone_core</artifactId>
- <version>2.3.2</version>
- </path>
- </annotationProcessorPaths>
+ <compilerId>javac-with-errorprone</compilerId>
+ <forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-javac-errorprone</artifactId>
+ <version>2.8</version>
+ </dependency>
+ <!-- override plexus-compiler-javac-errorprone's dependency on
+ Error Prone with the latest version -->
+ <dependency>
+ <groupId>com.google.errorprone</groupId>
+ <artifactId>error_prone_core</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
@@ -193,7 +198,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>4.1.0</version>
+ <version>3.2.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
@@ -223,10 +228,15 @@
</configuration>
</plugin>
+ <!--
+ TODO when maven-jaxb2-plugin supports Java 9 properly then
+ uncomment this and remove the code:
+ src/main/java/org/apache/xml/security/binding/
+ src/main/java/org/apache/xml/security/configuration/
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
- <version>0.14.0</version>
+ <version>0.13.2</version>
<executions>
<execution>
<id>bindings</id>
@@ -254,15 +264,14 @@
<bindingInclude>xenc.xjb</bindingInclude>
<bindingInclude>xenc11.xjb</bindingInclude>
<bindingInclude>security-config.xjb</bindingInclude>
- <bindingInclude>xop.xjb</bindingInclude>
</bindingIncludes>
<catalog>${basedir}/src/main/resources/bindings/bindings.cat</catalog>
<forceRegenerate>false</forceRegenerate>
<episode>true</episode>
<specVersion>2.1</specVersion>
<extension>true</extension>
- <!-- disable schema validation since the validation code
- doesn't respect the catalog and will do online lookups :-( -->
+ disable schema validation since the validation code
+ doesn't respect the catalog and will do online lookups :-(
<strict>false</strict>
<args>
<arg>-npa</arg>
@@ -271,6 +280,7 @@
</execution>
</executions>
</plugin>
+ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
@@ -332,19 +342,6 @@
<minSeverity>${minSeverity}</minSeverity>
</configuration>
</plugin>
- <plugin>
- <groupId>org.owasp</groupId>
- <artifactId>dependency-check-maven</artifactId>
- <version>${maven-owasp-plugin-version}</version>
- <executions>
- <execution>
- <phase>validate</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</pluginManagement>
@@ -406,16 +403,6 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <fork>true</fork>
- <compilerArgs combine.children="append">
- <arg>-J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/9+181-r4173-1/javac-9+181-r4173-1.jar</arg>
- </compilerArgs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
@@ -454,6 +441,8 @@
<configuration>
<additionalJOptions>
<additionalJOption>-Xdoclint:none</additionalJOption>
+ <additionalJOption>--add-modules</additionalJOption>
+ <additionalJOption>java.xml.bind</additionalJOption>
</additionalJOptions>
</configuration>
</plugin>
@@ -472,7 +461,7 @@
<exclude>**/PerformanceMemoryTest.java</exclude>
<exclude>**/PerformanceTimingTest.java</exclude>
</excludes>
- <argLine>-Xmx2000m --add-opens java.base/java.lang.reflect=ALL-UNNAMED</argLine>
+ <argLine>-Xmx2000m --add-modules java.xml.bind --add-opens java.base/java.lang.reflect=ALL-UNNAMED</argLine>
<systemPropertyVariables>
<product.version>${project.version}</product.version>
<log4j.configuration>log4j-xmlsec.xml</log4j.configuration>
@@ -483,24 +472,6 @@
</plugins>
</pluginManagement>
</build>
- <dependencies>
- <dependency>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>jakarta.xml.bind</groupId>
- <artifactId>jakarta.xml.bind-api</artifactId>
- <version>2.3.2</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jaxb</groupId>
- <artifactId>jaxb-runtime</artifactId>
- <version>2.3.2</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
</profile>
<profile>
<!-- Profile for testing with EclipseLink MOXy based JAXB implementation -->
@@ -532,18 +503,6 @@
</repository>
</repositories>
</profile>
- <profile>
- <id>dependencycheck</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.owasp</groupId>
- <artifactId>dependency-check-maven</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
-
</profiles>
<properties>
@@ -556,13 +515,12 @@
<bcprov.version>1.60</bcprov.version>
<xmlunit.version>1.6</xmlunit.version>
<commons.codec.version>1.12</commons.codec.version>
- <woodstox.core.version>5.2.0</woodstox.core.version>
+ <woodstox.core.version>5.0.3</woodstox.core.version>
<jetty.version>9.4.8.v20171121</jetty.version>
<xmlsec.jaxb.context.class />
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<targetJdk>1.8</targetJdk>
<clirr.version>2.8</clirr.version>
- <maven-owasp-plugin-version>4.0.2</maven-owasp-plugin-version>
<!-- Allow Clirr severity to be overriden by the command-line option -DminSeverity=level -->
<minSeverity>info</minSeverity>
@@ -576,18 +534,18 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>com.fasterxml.woodstox</groupId>
+ <artifactId>woodstox-core</artifactId>
+ <version>${woodstox.core.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons.codec.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>com.fasterxml.woodstox</groupId>
- <artifactId>woodstox-core</artifactId>
- <version>${woodstox.core.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
@@ -682,11 +640,6 @@
<minSeverity>${minSeverity}</minSeverity>
</configuration>
</plugin>
- <plugin>
- <groupId>org.owasp</groupId>
- <artifactId>dependency-check-maven</artifactId>
- <version>${maven-owasp-plugin-version}</version>
- </plugin>
</plugins>
</reporting>
</project>
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
index 91c5a6d..1150372 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
@@ -53,7 +53,7 @@
private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(ApacheCanonicalizer.class);
- protected Canonicalizer canonicalizer;
+ protected Canonicalizer apacheCanonicalizer;
private Transform apacheTransform;
protected String inclusiveNamespaces;
protected C14NMethodParameterSpec params;
@@ -110,11 +110,11 @@
public Data canonicalize(Data data, XMLCryptoContext xc, OutputStream os)
throws TransformException
{
- if (canonicalizer == null) {
+ if (apacheCanonicalizer == null) {
try {
- canonicalizer = Canonicalizer.getInstance(getAlgorithm());
+ apacheCanonicalizer = Canonicalizer.getInstance(getAlgorithm());
boolean secVal = Utils.secureValidation(xc);
- canonicalizer.setSecureValidation(secVal);
+ apacheCanonicalizer.setSecureValidation(secVal);
LOG.debug("Created canonicalizer for algorithm: {}", getAlgorithm());
} catch (InvalidCanonicalizerException ice) {
throw new TransformException
@@ -124,9 +124,9 @@
}
if (os != null) {
- canonicalizer.setWriter(os);
+ apacheCanonicalizer.setWriter(os);
} else {
- canonicalizer.setWriter(new ByteArrayOutputStream());
+ apacheCanonicalizer.setWriter(new ByteArrayOutputStream());
}
try {
@@ -137,29 +137,29 @@
if (in.isElement()) {
if (inclusiveNamespaces != null) {
return new OctetStreamData(new ByteArrayInputStream
- (canonicalizer.canonicalizeSubtree
+ (apacheCanonicalizer.canonicalizeSubtree
(in.getSubNode(), inclusiveNamespaces)));
} else {
return new OctetStreamData(new ByteArrayInputStream
- (canonicalizer.canonicalizeSubtree
+ (apacheCanonicalizer.canonicalizeSubtree
(in.getSubNode())));
}
} else if (in.isNodeSet()) {
nodeSet = in.getNodeSet();
} else {
return new OctetStreamData(new ByteArrayInputStream(
- canonicalizer.canonicalize(
+ apacheCanonicalizer.canonicalize(
Utils.readBytesFromStream(in.getOctetStream()))));
}
} else if (data instanceof DOMSubTreeData) {
DOMSubTreeData subTree = (DOMSubTreeData)data;
if (inclusiveNamespaces != null) {
return new OctetStreamData(new ByteArrayInputStream
- (canonicalizer.canonicalizeSubtree
+ (apacheCanonicalizer.canonicalizeSubtree
(subTree.getRoot(), inclusiveNamespaces)));
} else {
return new OctetStreamData(new ByteArrayInputStream
- (canonicalizer.canonicalizeSubtree
+ (apacheCanonicalizer.canonicalizeSubtree
(subTree.getRoot())));
}
} else if (data instanceof NodeSetData) {
@@ -171,17 +171,17 @@
LOG.debug("Canonicalizing {} nodes", nodeSet.size());
} else {
return new OctetStreamData(new ByteArrayInputStream(
- canonicalizer.canonicalize(
+ apacheCanonicalizer.canonicalize(
Utils.readBytesFromStream(
((OctetStreamData)data).getOctetStream()))));
}
if (inclusiveNamespaces != null) {
return new OctetStreamData(new ByteArrayInputStream(
- canonicalizer.canonicalizeXPathNodeSet
+ apacheCanonicalizer.canonicalizeXPathNodeSet
(nodeSet, inclusiveNamespaces)));
} else {
return new OctetStreamData(new ByteArrayInputStream(
- canonicalizer.canonicalizeXPathNodeSet(nodeSet)));
+ apacheCanonicalizer.canonicalizeXPathNodeSet(nodeSet)));
}
} catch (Exception e) {
throw new TransformException(e);
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
index 77dc7df..dbb7231 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
@@ -68,10 +68,10 @@
(XMLUtils.getOwnerDocument(xi.getSubNode()));
}
- Set<Node> inputSet = new LinkedHashSet<>();
+ Set<Node> inputSet = new LinkedHashSet<Node>();
XMLUtils.getSet(xi.getSubNode(), inputSet,
null, !xi.isExcludeComments());
- Set<Node> nodeSet = new LinkedHashSet<>();
+ Set<Node> nodeSet = new LinkedHashSet<Node>();
for (Node currentNode : inputSet) {
Iterator<NodeFilter> it = nodeFilters.iterator();
boolean skipNode = false;
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheTransform.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheTransform.java
index 747858c..ae584c4 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheTransform.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheTransform.java
@@ -54,7 +54,7 @@
private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(ApacheTransform.class);
- private Transform transform;
+ private Transform apacheTransform;
protected Document ownerDoc;
protected Element transformElem;
protected TransformParameterSpec params;
@@ -128,13 +128,13 @@
throw new TransformException("transform must be marshalled");
}
- if (transform == null) {
+ if (apacheTransform == null) {
try {
- transform =
+ apacheTransform =
new Transform(ownerDoc, getAlgorithm(), transformElem.getChildNodes());
- transform.setElement(transformElem, xc.getBaseURI());
+ apacheTransform.setElement(transformElem, xc.getBaseURI());
boolean secVal = Utils.secureValidation(xc);
- transform.setSecureValidation(secVal);
+ apacheTransform.setSecureValidation(secVal);
LOG.debug("Created transform for algorithm: {}", getAlgorithm());
} catch (Exception ex) {
throw new TransformException("Couldn't find Transform for: " +
@@ -182,12 +182,12 @@
try {
if (os != null) {
- in = transform.performTransform(in, os);
+ in = apacheTransform.performTransform(in, os);
if (!in.isNodeSet() && !in.isElement()) {
return null;
}
} else {
- in = transform.performTransform(in);
+ in = apacheTransform.performTransform(in);
}
if (in.isOctetStream()) {
return new ApacheOctetStreamData(in);
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java
index 5fa2318..ca2d61b 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java
@@ -62,9 +62,9 @@
DOMSubTreeData subTree = (DOMSubTreeData) data;
if (subTree.excludeComments()) {
try {
- canonicalizer = Canonicalizer.getInstance(C14N_11);
+ apacheCanonicalizer = Canonicalizer.getInstance(C14N_11);
boolean secVal = Utils.secureValidation(xc);
- canonicalizer.setSecureValidation(secVal);
+ apacheCanonicalizer.setSecureValidation(secVal);
} catch (InvalidCanonicalizerException ice) {
throw new TransformException
("Couldn't find Canonicalizer for: " +
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
index 4372cff..f8d7921 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
@@ -58,10 +58,10 @@
DOMSubTreeData subTree = (DOMSubTreeData) data;
if (subTree.excludeComments()) {
try {
- canonicalizer = Canonicalizer.getInstance
+ apacheCanonicalizer = Canonicalizer.getInstance
(CanonicalizationMethod.INCLUSIVE);
boolean secVal = Utils.secureValidation(xc);
- canonicalizer.setSecureValidation(secVal);
+ apacheCanonicalizer.setSecureValidation(secVal);
} catch (InvalidCanonicalizerException ice) {
throw new TransformException
("Couldn't find Canonicalizer for: " +
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
index 883564c..10c4ee6 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
@@ -124,7 +124,7 @@
for (int i = 0, size = prefixList.size(); i < size; i++) {
prefixListAttr.append(prefixList.get(i));
if (i < size - 1) {
- prefixListAttr.append(' ');
+ prefixListAttr.append(" ");
}
}
DOMUtils.setAttribute(eElem, "PrefixList", prefixListAttr.toString());
@@ -146,10 +146,10 @@
DOMSubTreeData subTree = (DOMSubTreeData)data;
if (subTree.excludeComments()) {
try {
- canonicalizer = Canonicalizer.getInstance
+ apacheCanonicalizer = Canonicalizer.getInstance
(CanonicalizationMethod.EXCLUSIVE);
boolean secVal = Utils.secureValidation(xc);
- canonicalizer.setSecureValidation(secVal);
+ apacheCanonicalizer.setSecureValidation(secVal);
} catch (InvalidCanonicalizerException ice) {
throw new TransformException
("Couldn't find Canonicalizer for: " +
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyValue.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyValue.java
index d873df1..5311613 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyValue.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMKeyValue.java
@@ -89,11 +89,11 @@
}
String namespace = kvtElem.getNamespaceURI();
- if ("DSAKeyValue".equals(kvtElem.getLocalName()) && XMLSignature.XMLNS.equals(namespace)) {
+ if (kvtElem.getLocalName().equals("DSAKeyValue") && XMLSignature.XMLNS.equals(namespace)) {
return new DSA(kvtElem);
- } else if ("RSAKeyValue".equals(kvtElem.getLocalName()) && XMLSignature.XMLNS.equals(namespace)) {
+ } else if (kvtElem.getLocalName().equals("RSAKeyValue") && XMLSignature.XMLNS.equals(namespace)) {
return new RSA(kvtElem);
- } else if ("ECKeyValue".equals(kvtElem.getLocalName()) && XMLDSIG_11_XMLNS.equals(namespace)) {
+ } else if (kvtElem.getLocalName().equals("ECKeyValue") && XMLDSIG_11_XMLNS.equals(namespace)) {
return new EC(kvtElem);
} else {
return new Unknown(kvtElem);
@@ -306,7 +306,7 @@
// check for P and Q
BigInteger p = null;
BigInteger q = null;
- if ("P".equals(curElem.getLocalName()) && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) {
+ if (curElem.getLocalName().equals("P") && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) {
p = decode(curElem);
curElem = DOMUtils.getNextSiblingElement(curElem, "Q", XMLSignature.XMLNS);
q = decode(curElem);
@@ -314,7 +314,7 @@
}
BigInteger g = null;
if (curElem != null
- && "G".equals(curElem.getLocalName()) && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) {
+ && curElem.getLocalName().equals("G") && XMLSignature.XMLNS.equals(curElem.getNamespaceURI())) {
g = decode(curElem);
curElem = DOMUtils.getNextSiblingElement(curElem, "Y", XMLSignature.XMLNS);
}
@@ -323,7 +323,7 @@
y = decode(curElem);
curElem = DOMUtils.getNextSiblingElement(curElem);
}
- //if (curElem != null && "J".equals(curElem.getLocalName())) {
+ //if (curElem != null && curElem.getLocalName().equals("J")) {
//j = new DOMCryptoBinary(curElem.getFirstChild());
// curElem = DOMUtils.getNextSiblingElement(curElem);
//}
@@ -465,11 +465,15 @@
private static boolean matchCurve(ECParameterSpec params, Curve curve) {
int fieldSize = params.getCurve().getField().getFieldSize();
- return curve.getCurve().getField().getFieldSize() == fieldSize
+ if (curve.getCurve().getField().getFieldSize() == fieldSize
&& curve.getCurve().equals(params.getCurve())
&& curve.getGenerator().equals(params.getGenerator())
&& curve.getOrder().equals(params.getOrder())
- && curve.getCofactor() == params.getCofactor();
+ && curve.getCofactor() == params.getCofactor()) {
+ return true;
+ } else {
+ return false;
+ }
}
@Override
@@ -492,7 +496,7 @@
throw new MarshalException("Invalid ECParameterSpec");
}
DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid);
- String qname = (prefix == null || prefix.length() == 0)
+ String qname = prefix == null || prefix.length() == 0
? "xmlns" : "xmlns:" + prefix;
namedCurveElem.setAttributeNS("http://www.w3.org/2000/xmlns/",
qname, XMLDSIG_11_XMLNS);
@@ -522,11 +526,11 @@
throw new MarshalException("KeyValue must contain at least one type");
}
- if ("ECParameters".equals(curElem.getLocalName())
+ if (curElem.getLocalName().equals("ECParameters")
&& XMLDSIG_11_XMLNS.equals(curElem.getNamespaceURI())) {
throw new UnsupportedOperationException
("ECParameters not supported");
- } else if ("NamedCurve".equals(curElem.getLocalName())
+ } else if (curElem.getLocalName().equals("NamedCurve")
&& XMLDSIG_11_XMLNS.equals(curElem.getNamespaceURI())) {
String uri = DOMUtils.getAttributeValue(curElem, "URI");
// strip off "urn:oid"
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java
index 43ee065..e308e2c 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMReference.java
@@ -162,7 +162,7 @@
}
this.digestMethod = dm;
this.uri = uri;
- if (uri != null && !uri.isEmpty()) {
+ if (uri != null && !uri.equals("")) {
try {
new URI(uri);
} catch (URISyntaxException e) {
@@ -193,7 +193,7 @@
// unmarshal Transforms, if specified
Element nextSibling = DOMUtils.getFirstChildElement(refElem);
List<Transform> newTransforms = new ArrayList<>(MAXIMUM_TRANSFORM_COUNT);
- if ("Transforms".equals(nextSibling.getLocalName())
+ if (nextSibling.getLocalName().equals("Transforms")
&& XMLSignature.XMLNS.equals(nextSibling.getNamespaceURI())) {
Element transformElem = DOMUtils.getFirstChildElement(nextSibling,
"Transform",
@@ -219,7 +219,7 @@
}
nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
}
- if (!"DigestMethod".equals(nextSibling.getLocalName())
+ if (!nextSibling.getLocalName().equals("DigestMethod")
&& XMLSignature.XMLNS.equals(nextSibling.getNamespaceURI())) {
throw new MarshalException("Invalid element name: " +
nextSibling.getLocalName() +
@@ -545,7 +545,7 @@
throw new XMLSignatureException(e);
} catch (org.apache.xml.security.c14n.CanonicalizationException e) {
throw new XMLSignatureException(e);
- } finally { //NOPMD
+ } finally {
if (dos != null) {
try {
dos.close();
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
index a519bc1..d294e30 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
@@ -53,6 +53,7 @@
import javax.xml.crypto.dsig.Transform;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Attr;
@@ -108,7 +109,7 @@
}
}
this.uri = uri;
- if (!uri.isEmpty()) {
+ if (!uri.equals("")) {
try {
new URI(uri);
} catch (URISyntaxException e) {
@@ -268,12 +269,14 @@
public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context)
throws URIReferenceException
{
+ DocumentBuilder db = null;
boolean secVal = Utils.secureValidation(context);
ApacheData data = (ApacheData)dereference(context);
try (InputStream is = new ByteArrayInputStream(data.getXMLSignatureInput().getBytes())) {
- Document doc = XMLUtils.read(is, secVal);
+ db = XMLUtils.createDocumentBuilder(false, secVal);
+ Document doc = db.parse(is);
Element kiElem = doc.getDocumentElement();
- if ("X509Data".equals(kiElem.getLocalName())
+ if (kiElem.getLocalName().equals("X509Data")
&& XMLSignature.XMLNS.equals(kiElem.getNamespaceURI())) {
return new DOMX509Data(kiElem);
} else {
@@ -281,6 +284,10 @@
}
} catch (Exception e) {
throw new URIReferenceException(e);
+ } finally {
+ if (db != null) {
+ XMLUtils.repoolDocumentBuilder(db);
+ }
}
}
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMUtils.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMUtils.java
index 590b3d3..8357805 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMUtils.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMUtils.java
@@ -24,30 +24,19 @@
*/
package org.apache.jcp.xml.dsig.internal.dom;
+import java.util.*;
import java.security.spec.AlgorithmParameterSpec;
-import java.util.AbstractSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import javax.xml.XMLConstants;
-import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.XMLCryptoContext;
-import javax.xml.crypto.XMLStructure;
-import javax.xml.crypto.dsig.XMLSignature;
-import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec;
-import javax.xml.crypto.dsig.spec.XPathFilter2ParameterSpec;
-import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec;
-import javax.xml.crypto.dsig.spec.XPathType;
-import javax.xml.crypto.dsig.spec.XSLTTransformParameterSpec;
-
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import javax.xml.XMLConstants;
+import javax.xml.crypto.*;
+import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dsig.spec.*;
+
/**
* Useful static DOM utility methods.
*
@@ -99,7 +88,7 @@
public static Element createElement(Document doc, String tag,
String nsURI, String prefix)
{
- String qName = (prefix == null || prefix.length() == 0)
+ String qName = prefix == null || prefix.length() == 0
? tag : prefix + ":" + tag;
return doc.createElementNS(nsURI, qName);
}
@@ -156,6 +145,23 @@
/**
* Returns the first child element of the specified node and checks that
+ * the local name is equal to {@code localName}.
+ *
+ * @param node the node
+ * @return the first child element of the specified node
+ * @throws NullPointerException if {@code node == null}
+ * @throws MarshalException if no such element or the local name is not
+ * equal to {@code localName}
+ */
+ @Deprecated
+ public static Element getFirstChildElement(Node node, String localName)
+ throws MarshalException
+ {
+ return verifyElement(getFirstChildElement(node), localName);
+ }
+
+ /**
+ * Returns the first child element of the specified node and checks that
* the local name is equal to {@code localName} and the namespace is equal to
* {@code namespaceURI}
*
@@ -171,6 +177,20 @@
return verifyElement(getFirstChildElement(node), localName, namespaceURI);
}
+ private static Element verifyElement(Element elem, String localName)
+ throws MarshalException
+ {
+ if (elem == null) {
+ throw new MarshalException("Missing " + localName + " element");
+ }
+ String name = elem.getLocalName();
+ if (!name.equals(localName)) {
+ throw new MarshalException("Invalid element name: " +
+ name + ", expected " + localName);
+ }
+ return elem;
+ }
+
private static Element verifyElement(Element elem, String localName, String namespaceURI)
throws MarshalException
{
@@ -223,6 +243,23 @@
/**
* Returns the next sibling element of the specified node and checks that
+ * the local name is equal to {@code localName}.
+ *
+ * @param node the node
+ * @return the next sibling element of the specified node
+ * @throws NullPointerException if {@code node == null}
+ * @throws MarshalException if no such element or the local name is not
+ * equal to {@code localName}
+ */
+ @Deprecated
+ public static Element getNextSiblingElement(Node node, String localName)
+ throws MarshalException
+ {
+ return verifyElement(getNextSiblingElement(node), localName);
+ }
+
+ /**
+ * Returns the next sibling element of the specified node and checks that
* the local name is equal to {@code localName} and the namespace is equal to
* {@code namespaceURI}
*
@@ -366,9 +403,11 @@
if (thisNode == otherNode) {
return true;
}
-
+ if (thisNode.getNodeType() != otherNode.getNodeType()) {
+ return false;
+ }
// FIXME - test content, etc
- return thisNode.getNodeType() == otherNode.getNodeType();
+ return true;
}
/**
@@ -467,7 +506,8 @@
public static boolean isNamespace(Node node)
{
- if (Node.ATTRIBUTE_NODE == node.getNodeType()) {
+ final short nodeType = node.getNodeType();
+ if (nodeType == Node.ATTRIBUTE_NODE) {
final String namespaceURI = node.getNamespaceURI();
return XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI);
}
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMX509Data.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMX509Data.java
index 80599ae..15a8ae8 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMX509Data.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMX509Data.java
@@ -26,16 +26,8 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.security.cert.CRLException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509CRL;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
+import java.security.cert.*;
+import java.util.*;
import javax.security.auth.x500.X500Principal;
import javax.xml.crypto.MarshalException;
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXMLSignature.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
index 568b5bf..64f8a13 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
@@ -147,7 +147,7 @@
// unmarshal KeyInfo, if specified
Element nextSibling = DOMUtils.getNextSiblingElement(sigValElem);
- if (nextSibling != null && "KeyInfo".equals(nextSibling.getLocalName())
+ if (nextSibling != null && nextSibling.getLocalName().equals("KeyInfo")
&& XMLSignature.XMLNS.equals(nextSibling.getNamespaceURI())) {
ki = new DOMKeyInfo(nextSibling, context, provider);
nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java
index 686ddc8..57188fb 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java
@@ -31,21 +31,17 @@
*/
package org.apache.jcp.xml.dsig.internal.dom;
+import javax.xml.crypto.*;
+import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dsig.spec.TransformParameterSpec;
+import javax.xml.crypto.dsig.spec.XPathType;
+import javax.xml.crypto.dsig.spec.XPathFilter2ParameterSpec;
import java.security.InvalidAlgorithmParameterException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
-import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.XMLCryptoContext;
-import javax.xml.crypto.XMLStructure;
-import javax.xml.crypto.dsig.Transform;
-import javax.xml.crypto.dsig.spec.TransformParameterSpec;
-import javax.xml.crypto.dsig.spec.XPathFilter2ParameterSpec;
-import javax.xml.crypto.dsig.spec.XPathType;
-
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXPathTransform.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXPathTransform.java
index e2e37f5..34e4905 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXPathTransform.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMXPathTransform.java
@@ -24,18 +24,14 @@
*/
package org.apache.jcp.xml.dsig.internal.dom;
+import javax.xml.crypto.*;
+import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dsig.spec.TransformParameterSpec;
+import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec;
import java.security.InvalidAlgorithmParameterException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-
-import javax.xml.crypto.MarshalException;
-import javax.xml.crypto.XMLCryptoContext;
-import javax.xml.crypto.XMLStructure;
-import javax.xml.crypto.dsig.XMLSignature;
-import javax.xml.crypto.dsig.spec.TransformParameterSpec;
-import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec;
-
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
diff --git a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/XMLDSigRI.java b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/XMLDSigRI.java
index d3f3f56..395f82e 100644
--- a/src/main/java/org/apache/jcp/xml/dsig/internal/dom/XMLDSigRI.java
+++ b/src/main/java/org/apache/jcp/xml/dsig/internal/dom/XMLDSigRI.java
@@ -63,13 +63,13 @@
ProviderService(Provider p, String type, String algo, String cn,
String[] aliases) {
super(p, type, algo, cn,
- aliases == null ? null : Arrays.asList(aliases), null);
+ (aliases == null? null : Arrays.asList(aliases)), null);
}
ProviderService(Provider p, String type, String algo, String cn,
- String[] aliases, Map<String, String> attrs) {
+ String[] aliases, HashMap<String, String> attrs) {
super(p, type, algo, cn,
- aliases == null ? null : Arrays.asList(aliases), attrs);
+ (aliases == null? null : Arrays.asList(aliases)), attrs);
}
@Override
@@ -83,20 +83,20 @@
String algo = getAlgorithm();
try {
- if ("XMLSignatureFactory".equals(type)) {
- if ("DOM".equals(algo)) {
+ if (type.equals("XMLSignatureFactory")) {
+ if (algo.equals("DOM")) {
return new DOMXMLSignatureFactory();
}
- } else if ("KeyInfoFactory".equals(type)) {
- if ("DOM".equals(algo)) {
+ } else if (type.equals("KeyInfoFactory")) {
+ if (algo.equals("DOM")) {
return new DOMKeyInfoFactory();
}
- } else if ("TransformService".equals(type)) {
+ } else if (type.equals("TransformService")) {
if (algo.equals(CanonicalizationMethod.INCLUSIVE) ||
algo.equals(CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS)) {
return new DOMCanonicalXMLC14NMethod();
- } else if ("http://www.w3.org/2006/12/xml-c14n11".equals(algo) ||
- "http://www.w3.org/2006/12/xml-c14n11#WithComments".equals(algo)) {
+ } else if (algo.equals("http://www.w3.org/2006/12/xml-c14n11") ||
+ algo.equals("http://www.w3.org/2006/12/xml-c14n11#WithComments")) {
return new DOMCanonicalXMLC14N11Method();
} else if (algo.equals(CanonicalizationMethod.EXCLUSIVE) ||
algo.equals(CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS)) {
@@ -124,12 +124,12 @@
public XMLDSigRI() {
/* We are the ApacheXMLDSig provider */
- super("ApacheXMLDSig", 2.20, INFO);
+ super("ApacheXMLDSig", 2.13, INFO);
final Provider p = this;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
- Map<String, String> MECH_TYPE = new HashMap<>();
+ HashMap<String, String> MECH_TYPE = new HashMap<>();
MECH_TYPE.put("MechanismType", "DOM");
putService(new ProviderService(p, "XMLSignatureFactory",
diff --git a/src/main/java/org/apache/xml/security/Init.java b/src/main/java/org/apache/xml/security/Init.java
index 0d2f55d..5e65229 100644
--- a/src/main/java/org/apache/xml/security/Init.java
+++ b/src/main/java/org/apache/xml/security/Init.java
@@ -18,13 +18,14 @@
*/
package org.apache.xml.security;
-import java.io.IOException;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.algorithms.JCEMapper;
import org.apache.xml.security.algorithms.SignatureAlgorithm;
import org.apache.xml.security.c14n.Canonicalizer;
@@ -91,11 +92,6 @@
dynamicInit();
} else {
fileInit(is);
- try {
- is.close();
- } catch (IOException ex) {
- LOG.warn(ex.getMessage());
- }
}
alreadyInitialized = true;
@@ -159,7 +155,14 @@
private static void fileInit(InputStream is) {
try {
/* read library configuration file */
- Document doc = XMLUtils.read(is, false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc;
+ try {
+ doc = db.parse(is);
+ } finally {
+ XMLUtils.repoolDocumentBuilder(db);
+ db = null;
+ }
Node config = doc.getFirstChild();
for (; config != null; config = config.getNextSibling()) {
if ("Configuration".equals(config.getLocalName())) {
@@ -199,7 +202,7 @@
Canonicalizer.register(uri, javaClass);
LOG.debug("Canonicalizer.register({}, {})", uri, javaClass);
} catch (ClassNotFoundException e) {
- Object[] exArgs = { uri, javaClass };
+ Object exArgs[] = { uri, javaClass };
LOG.error(I18n.translate("algorithm.classDoesNotExist", exArgs));
}
}
@@ -217,7 +220,7 @@
Transform.register(uri, javaClass);
LOG.debug("Transform.register({}, {})", uri, javaClass);
} catch (ClassNotFoundException e) {
- Object[] exArgs = { uri, javaClass };
+ Object exArgs[] = { uri, javaClass };
LOG.error(I18n.translate("algorithm.classDoesNotExist", exArgs));
} catch (NoClassDefFoundError ex) {
@@ -253,7 +256,7 @@
SignatureAlgorithm.register(uri, javaClass);
LOG.debug("SignatureAlgorithm.register({}, {})", uri, javaClass);
} catch (ClassNotFoundException e) {
- Object[] exArgs = { uri, javaClass };
+ Object exArgs[] = { uri, javaClass };
LOG.error(I18n.translate("algorithm.classDoesNotExist", exArgs));
}
diff --git a/src/main/java/org/apache/xml/security/algorithms/JCEMapper.java b/src/main/java/org/apache/xml/security/algorithms/JCEMapper.java
index 75339b4..878f37d 100644
--- a/src/main/java/org/apache/xml/security/algorithms/JCEMapper.java
+++ b/src/main/java/org/apache/xml/security/algorithms/JCEMapper.java
@@ -35,7 +35,8 @@
private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(JCEMapper.class);
- private static Map<String, Algorithm> algorithmsMap = new ConcurrentHashMap<>();
+ private static Map<String, Algorithm> algorithmsMap =
+ new ConcurrentHashMap<String, Algorithm>();
private static String providerName;
diff --git a/src/main/java/org/apache/xml/security/algorithms/MessageDigestAlgorithm.java b/src/main/java/org/apache/xml/security/algorithms/MessageDigestAlgorithm.java
index 894a3d7..e431cf4 100644
--- a/src/main/java/org/apache/xml/security/algorithms/MessageDigestAlgorithm.java
+++ b/src/main/java/org/apache/xml/security/algorithms/MessageDigestAlgorithm.java
@@ -33,7 +33,7 @@
* MessageDigestAlgorithm.getInstance()
* </pre>
*/
-public final class MessageDigestAlgorithm extends Algorithm {
+public class MessageDigestAlgorithm extends Algorithm {
/** Message Digest - NOT RECOMMENDED MD5*/
public static final String ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5 =
@@ -165,7 +165,7 @@
* @param input
* @return the result of the {@link java.security.MessageDigest#digest(byte[])} method
*/
- public byte[] digest(byte[] input) {
+ public byte[] digest(byte input[]) {
return algorithm.digest(input);
}
@@ -179,7 +179,7 @@
* @return the result of the {@link java.security.MessageDigest#digest(byte[], int, int)} method
* @throws java.security.DigestException
*/
- public int digest(byte[] buf, int offset, int len) throws java.security.DigestException {
+ public int digest(byte buf[], int offset, int len) throws java.security.DigestException {
return algorithm.digest(buf, offset, len);
}
@@ -250,7 +250,7 @@
* @param offset
* @param len
*/
- public void update(byte[] buf, int offset, int len) {
+ public void update(byte buf[], int offset, int len) {
algorithm.update(buf, offset, len);
}
diff --git a/src/main/java/org/apache/xml/security/algorithms/SignatureAlgorithm.java b/src/main/java/org/apache/xml/security/algorithms/SignatureAlgorithm.java
index 36716923..05259d7 100644
--- a/src/main/java/org/apache/xml/security/algorithms/SignatureAlgorithm.java
+++ b/src/main/java/org/apache/xml/security/algorithms/SignatureAlgorithm.java
@@ -51,10 +51,10 @@
/** All available algorithm classes are registered here */
private static Map<String, Class<? extends SignatureAlgorithmSpi>> algorithmHash =
- new ConcurrentHashMap<>();
+ new ConcurrentHashMap<String, Class<? extends SignatureAlgorithmSpi>>();
/** Field signatureAlgorithm */
- private final SignatureAlgorithmSpi signatureAlgorithmSpi;
+ private final SignatureAlgorithmSpi signatureAlgorithm;
private final String algorithmURI;
@@ -69,8 +69,8 @@
super(doc, algorithmURI);
this.algorithmURI = algorithmURI;
- signatureAlgorithmSpi = getSignatureAlgorithmSpi(algorithmURI);
- signatureAlgorithmSpi.engineGetContextFromElement(getElement());
+ signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
+ signatureAlgorithm.engineGetContextFromElement(getElement());
}
/**
@@ -87,11 +87,11 @@
super(doc, algorithmURI);
this.algorithmURI = algorithmURI;
- signatureAlgorithmSpi = getSignatureAlgorithmSpi(algorithmURI);
- signatureAlgorithmSpi.engineGetContextFromElement(getElement());
+ signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
+ signatureAlgorithm.engineGetContextFromElement(getElement());
- signatureAlgorithmSpi.engineSetHMACOutputLength(hmacOutputLength);
- ((IntegrityHmac)signatureAlgorithmSpi).engineAddContextToElement(getElement());
+ signatureAlgorithm.engineSetHMACOutputLength(hmacOutputLength);
+ ((IntegrityHmac)signatureAlgorithm).engineAddContextToElement(getElement());
}
/**
@@ -126,13 +126,13 @@
if (secureValidation && (XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(algorithmURI)
|| XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(algorithmURI))) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new XMLSecurityException("signature.signatureAlgorithm", exArgs);
}
- signatureAlgorithmSpi = getSignatureAlgorithmSpi(algorithmURI);
- signatureAlgorithmSpi.engineGetContextFromElement(getElement());
+ signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
+ signatureAlgorithm.engineGetContextFromElement(getElement());
}
/**
@@ -145,12 +145,12 @@
algorithmHash.get(algorithmURI);
LOG.debug("Create URI \"{}\" class \"{}\"", algorithmURI, implementingClass);
if (implementingClass == null) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new XMLSignatureException("algorithms.NoSuchAlgorithmNoEx", exArgs);
}
return implementingClass.newInstance();
} catch (IllegalAccessException | InstantiationException | NullPointerException ex) {
- Object[] exArgs = { algorithmURI, ex.getMessage() };
+ Object exArgs[] = { algorithmURI, ex.getMessage() };
throw new XMLSignatureException(ex, "algorithms.NoSuchAlgorithm", exArgs);
}
}
@@ -164,7 +164,7 @@
* @throws XMLSignatureException
*/
public byte[] sign() throws XMLSignatureException {
- return signatureAlgorithmSpi.engineSign();
+ return signatureAlgorithm.engineSign();
}
/**
@@ -174,7 +174,7 @@
* @return the result of the {@link java.security.Signature#getAlgorithm} method
*/
public String getJCEAlgorithmString() {
- return signatureAlgorithmSpi.engineGetJCEAlgorithmString();
+ return signatureAlgorithm.engineGetJCEAlgorithmString();
}
/**
@@ -183,7 +183,7 @@
* @return The Provider of this Signature Algorithm
*/
public String getJCEProviderName() {
- return signatureAlgorithmSpi.engineGetJCEProviderName();
+ return signatureAlgorithm.engineGetJCEProviderName();
}
/**
@@ -194,7 +194,7 @@
* @throws XMLSignatureException
*/
public void update(byte[] input) throws XMLSignatureException {
- signatureAlgorithmSpi.engineUpdate(input);
+ signatureAlgorithm.engineUpdate(input);
}
/**
@@ -205,7 +205,7 @@
* @throws XMLSignatureException
*/
public void update(byte input) throws XMLSignatureException {
- signatureAlgorithmSpi.engineUpdate(input);
+ signatureAlgorithm.engineUpdate(input);
}
/**
@@ -217,8 +217,8 @@
* @param len
* @throws XMLSignatureException
*/
- public void update(byte[] buf, int offset, int len) throws XMLSignatureException {
- signatureAlgorithmSpi.engineUpdate(buf, offset, len);
+ public void update(byte buf[], int offset, int len) throws XMLSignatureException {
+ signatureAlgorithm.engineUpdate(buf, offset, len);
}
/**
@@ -229,7 +229,7 @@
* @throws XMLSignatureException
*/
public void initSign(Key signingKey) throws XMLSignatureException {
- signatureAlgorithmSpi.engineInitSign(signingKey);
+ signatureAlgorithm.engineInitSign(signingKey);
}
/**
@@ -242,7 +242,7 @@
* @throws XMLSignatureException
*/
public void initSign(Key signingKey, SecureRandom secureRandom) throws XMLSignatureException {
- signatureAlgorithmSpi.engineInitSign(signingKey, secureRandom);
+ signatureAlgorithm.engineInitSign(signingKey, secureRandom);
}
/**
@@ -256,7 +256,7 @@
public void initSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
- signatureAlgorithmSpi.engineInitSign(signingKey, algorithmParameterSpec);
+ signatureAlgorithm.engineInitSign(signingKey, algorithmParameterSpec);
}
/**
@@ -268,7 +268,7 @@
* @throws XMLSignatureException
*/
public void setParameter(AlgorithmParameterSpec params) throws XMLSignatureException {
- signatureAlgorithmSpi.engineSetParameter(params);
+ signatureAlgorithm.engineSetParameter(params);
}
/**
@@ -279,7 +279,7 @@
* @throws XMLSignatureException
*/
public void initVerify(Key verificationKey) throws XMLSignatureException {
- signatureAlgorithmSpi.engineInitVerify(verificationKey);
+ signatureAlgorithm.engineInitVerify(verificationKey);
}
/**
@@ -292,7 +292,7 @@
* @throws XMLSignatureException
*/
public boolean verify(byte[] signature) throws XMLSignatureException {
- return signatureAlgorithmSpi.engineVerify(signature);
+ return signatureAlgorithm.engineVerify(signature);
}
/**
@@ -325,7 +325,7 @@
// are we already registered?
Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
if (registeredClass != null) {
- Object[] exArgs = { algorithmURI, registeredClass };
+ Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException(
"algorithm.alreadyRegistered", exArgs
);
@@ -336,7 +336,7 @@
ClassLoaderUtils.loadClass(implementingClass, SignatureAlgorithm.class);
algorithmHash.put(algorithmURI, clazz);
} catch (NullPointerException ex) {
- Object[] exArgs = { algorithmURI, ex.getMessage() };
+ Object exArgs[] = { algorithmURI, ex.getMessage() };
throw new XMLSignatureException(ex, "algorithms.NoSuchAlgorithm", exArgs);
}
}
@@ -361,7 +361,7 @@
// are we already registered?
Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
if (registeredClass != null) {
- Object[] exArgs = { algorithmURI, registeredClass };
+ Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException(
"algorithm.alreadyRegistered", exArgs
);
diff --git a/src/main/java/org/apache/xml/security/algorithms/SignatureAlgorithmSpi.java b/src/main/java/org/apache/xml/security/algorithms/SignatureAlgorithmSpi.java
index 679e9bf..c1921fc 100644
--- a/src/main/java/org/apache/xml/security/algorithms/SignatureAlgorithmSpi.java
+++ b/src/main/java/org/apache/xml/security/algorithms/SignatureAlgorithmSpi.java
@@ -76,7 +76,7 @@
* @param len
* @throws XMLSignatureException
*/
- protected abstract void engineUpdate(byte[] buf, int offset, int len)
+ protected abstract void engineUpdate(byte buf[], int offset, int len)
throws XMLSignatureException;
/**
diff --git a/src/main/java/org/apache/xml/security/algorithms/implementations/ECDSAUtils.java b/src/main/java/org/apache/xml/security/algorithms/implementations/ECDSAUtils.java
index 2523540..c541c71 100644
--- a/src/main/java/org/apache/xml/security/algorithms/implementations/ECDSAUtils.java
+++ b/src/main/java/org/apache/xml/security/algorithms/implementations/ECDSAUtils.java
@@ -44,7 +44,7 @@
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
- public static byte[] convertASN1toXMLDSIG(byte[] asn1Bytes) throws IOException {
+ public static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException {
if (asn1Bytes.length < 8 || asn1Bytes[0] != 48) {
throw new IOException("Invalid ASN.1 format of ECDSA signature");
@@ -76,7 +76,7 @@
|| asn1Bytes[offset + 2 + rLength] != 2) {
throw new IOException("Invalid ASN.1 format of ECDSA signature");
}
- byte[] xmldsigBytes = new byte[2 * rawLen];
+ byte xmldsigBytes[] = new byte[2 * rawLen];
System.arraycopy(asn1Bytes, offset + 2 + rLength - i, xmldsigBytes, rawLen - i, i);
System.arraycopy(asn1Bytes, offset + 2 + rLength + 2 + sLength - j, xmldsigBytes,
@@ -97,7 +97,7 @@
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
- public static byte[] convertXMLDSIGtoASN1(byte[] xmldsigBytes) throws IOException {
+ public static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException {
int rawLen = xmldsigBytes.length / 2;
@@ -126,7 +126,7 @@
throw new IOException("Invalid XMLDSIG format of ECDSA signature");
}
int offset;
- byte[] asn1Bytes;
+ byte asn1Bytes[];
if (len < 128) {
asn1Bytes = new byte[2 + 2 + j + 2 + l];
offset = 1;
@@ -873,9 +873,9 @@
public static byte[] encodePoint(ECPoint ecPoint, EllipticCurve ellipticCurve) {
int size = (ellipticCurve.getField().getFieldSize() + 7) / 8;
- byte[] affineXBytes = stripLeadingZeros(ecPoint.getAffineX().toByteArray());
- byte[] affineYBytes = stripLeadingZeros(ecPoint.getAffineY().toByteArray());
- byte[] encodedBytes = new byte[size * 2 + 1];
+ byte affineXBytes[] = stripLeadingZeros(ecPoint.getAffineX().toByteArray());
+ byte affineYBytes[] = stripLeadingZeros(ecPoint.getAffineY().toByteArray());
+ byte encodedBytes[] = new byte[size * 2 + 1];
encodedBytes[0] = 0x04; //uncompressed
System.arraycopy(affineXBytes, 0, encodedBytes, size - affineXBytes.length + 1, affineXBytes.length);
System.arraycopy(affineYBytes, 0, encodedBytes, encodedBytes.length - affineYBytes.length, affineYBytes.length);
@@ -888,8 +888,8 @@
}
int size = (elliptiCcurve.getField().getFieldSize() + 7) / 8;
- byte[] affineXBytes = new byte[size];
- byte[] affineYBytes = new byte[size];
+ byte affineXBytes[] = new byte[size];
+ byte affineYBytes[] = new byte[size];
System.arraycopy(encodedBytes, 1, affineXBytes, 0, size);
System.arraycopy(encodedBytes, size + 1, affineYBytes, 0, size);
return new ECPoint(new BigInteger(1, affineXBytes), new BigInteger(1, affineYBytes));
@@ -906,7 +906,7 @@
if (i == 0) {
return bytes;
} else {
- byte[] stripped = new byte[bytes.length - i];
+ byte stripped[] = new byte[bytes.length - i];
System.arraycopy(bytes, i, stripped, 0, stripped.length);
return stripped;
}
diff --git a/src/main/java/org/apache/xml/security/algorithms/implementations/IntegrityHmac.java b/src/main/java/org/apache/xml/security/algorithms/implementations/IntegrityHmac.java
index 282cb05..c6b6dd6 100644
--- a/src/main/java/org/apache/xml/security/algorithms/implementations/IntegrityHmac.java
+++ b/src/main/java/org/apache/xml/security/algorithms/implementations/IntegrityHmac.java
@@ -136,7 +136,7 @@
supplied = secretKey.getClass().getName();
}
String needed = SecretKey.class.getName();
- Object[] exArgs = { supplied, needed };
+ Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
@@ -205,7 +205,7 @@
supplied = secretKey.getClass().getName();
}
String needed = SecretKey.class.getName();
- Object[] exArgs = { supplied, needed };
+ Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
@@ -274,7 +274,7 @@
* @param len
* @throws XMLSignatureException
*/
- protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
+ protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
try {
this.macAlgorithm.update(buf, offset, len);
} catch (IllegalStateException ex) {
diff --git a/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureBaseRSA.java b/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureBaseRSA.java
index ee089c5..9d21945 100644
--- a/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureBaseRSA.java
+++ b/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureBaseRSA.java
@@ -99,7 +99,7 @@
supplied = publicKey.getClass().getName();
}
String needed = PublicKey.class.getName();
- Object[] exArgs = { supplied, needed };
+ Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
@@ -140,7 +140,7 @@
supplied = privateKey.getClass().getName();
}
String needed = PrivateKey.class.getName();
- Object[] exArgs = { supplied, needed };
+ Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
@@ -180,7 +180,7 @@
}
/** {@inheritDoc} */
- protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
+ protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
diff --git a/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureDSA.java b/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureDSA.java
index c22f755..476765f 100644
--- a/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureDSA.java
+++ b/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureDSA.java
@@ -129,7 +129,7 @@
supplied = publicKey.getClass().getName();
}
String needed = PublicKey.class.getName();
- Object[] exArgs = { supplied, needed };
+ Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
@@ -158,7 +158,7 @@
*/
protected byte[] engineSign() throws XMLSignatureException {
try {
- byte[] jcebytes = this.signatureAlgorithm.sign();
+ byte jcebytes[] = this.signatureAlgorithm.sign();
return JavaUtils.convertDsaASN1toXMLDSIG(jcebytes, size/8);
} catch (IOException ex) {
@@ -179,7 +179,7 @@
supplied = privateKey.getClass().getName();
}
String needed = PrivateKey.class.getName();
- Object[] exArgs = { supplied, needed };
+ Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
@@ -228,7 +228,7 @@
/**
* {@inheritDoc}
*/
- protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
+ protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
diff --git a/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureECDSA.java b/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureECDSA.java
index 0b79e11..b68ed1d 100644
--- a/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureECDSA.java
+++ b/src/main/java/org/apache/xml/security/algorithms/implementations/SignatureECDSA.java
@@ -63,7 +63,7 @@
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
- public static byte[] convertASN1toXMLDSIG(byte[] asn1Bytes) throws IOException {
+ public static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException {
return ECDSAUtils.convertASN1toXMLDSIG(asn1Bytes);
}
@@ -80,7 +80,7 @@
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
- public static byte[] convertXMLDSIGtoASN1(byte[] xmldsigBytes) throws IOException {
+ public static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException {
return ECDSAUtils.convertXMLDSIGtoASN1(xmldsigBytes);
}
@@ -148,7 +148,7 @@
supplied = publicKey.getClass().getName();
}
String needed = PublicKey.class.getName();
- Object[] exArgs = { supplied, needed };
+ Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
@@ -174,7 +174,7 @@
/** {@inheritDoc} */
protected byte[] engineSign() throws XMLSignatureException {
try {
- byte[] jcebytes = this.signatureAlgorithm.sign();
+ byte jcebytes[] = this.signatureAlgorithm.sign();
return SignatureECDSA.convertASN1toXMLDSIG(jcebytes);
} catch (SignatureException ex) {
@@ -193,7 +193,7 @@
supplied = privateKey.getClass().getName();
}
String needed = PrivateKey.class.getName();
- Object[] exArgs = { supplied, needed };
+ Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
@@ -233,7 +233,7 @@
}
/** {@inheritDoc} */
- protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
+ protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
diff --git a/src/main/java/org/apache/xml/security/binding/excc14n/InclusiveNamespaces.java b/src/main/java/org/apache/xml/security/binding/excc14n/InclusiveNamespaces.java
new file mode 100644
index 0000000..7094128
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/excc14n/InclusiveNamespaces.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.excc14n;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for InclusiveNamespaces complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="InclusiveNamespaces">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="PrefixList">
+ * <simpleType>
+ * <list itemType="{http://www.w3.org/2001/XMLSchema}string" />
+ * </simpleType>
+ * </attribute>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "InclusiveNamespaces", namespace = "http://www.w3.org/2001/10/xml-exc-c14n#")
+public class InclusiveNamespaces {
+
+ @XmlAttribute(name = "PrefixList")
+ protected List<String> prefixList;
+
+ /**
+ * Gets the value of the prefixList property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the prefixList property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getPrefixList().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getPrefixList() {
+ if (prefixList == null) {
+ prefixList = new ArrayList<String>();
+ }
+ return this.prefixList;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/excc14n/ObjectFactory.java b/src/main/java/org/apache/xml/security/binding/excc14n/ObjectFactory.java
new file mode 100644
index 0000000..7dcc0aa
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/excc14n/ObjectFactory.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.excc14n;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.xml.security.binding.excc14n package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _InclusiveNamespaces_QNAME = new QName("http://www.w3.org/2001/10/xml-exc-c14n#", "InclusiveNamespaces");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.xml.security.binding.excc14n
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link InclusiveNamespaces }
+ *
+ */
+ public InclusiveNamespaces createInclusiveNamespaces() {
+ return new InclusiveNamespaces();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link InclusiveNamespaces }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/10/xml-exc-c14n#", name = "InclusiveNamespaces")
+ public JAXBElement<InclusiveNamespaces> createInclusiveNamespaces(InclusiveNamespaces value) {
+ return new JAXBElement<InclusiveNamespaces>(_InclusiveNamespaces_QNAME, InclusiveNamespaces.class, null, value);
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/CanonicalizationMethodType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/CanonicalizationMethodType.java
new file mode 100644
index 0000000..b7f5618
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/CanonicalizationMethodType.java
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CanonicalizationMethodType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CanonicalizationMethodType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <any maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CanonicalizationMethodType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class CanonicalizationMethodType {
+
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link Object }
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/DSAKeyValueType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/DSAKeyValueType.java
new file mode 100644
index 0000000..cb6a91b
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/DSAKeyValueType.java
@@ -0,0 +1,245 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for DSAKeyValueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="DSAKeyValueType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <sequence minOccurs="0">
+ * <element name="P" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * <element name="Q" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * </sequence>
+ * <element name="G" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary" minOccurs="0"/>
+ * <element name="Y" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * <element name="J" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary" minOccurs="0"/>
+ * <sequence minOccurs="0">
+ * <element name="Seed" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * <element name="PgenCounter" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * </sequence>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "DSAKeyValueType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "p",
+ "q",
+ "g",
+ "y",
+ "j",
+ "seed",
+ "pgenCounter"
+})
+public class DSAKeyValueType {
+
+ @XmlElement(name = "P", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected byte[] p;
+ @XmlElement(name = "Q", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected byte[] q;
+ @XmlElement(name = "G", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected byte[] g;
+ @XmlElement(name = "Y", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected byte[] y;
+ @XmlElement(name = "J", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected byte[] j;
+ @XmlElement(name = "Seed", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected byte[] seed;
+ @XmlElement(name = "PgenCounter", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected byte[] pgenCounter;
+
+ /**
+ * Gets the value of the p property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getP() {
+ return p;
+ }
+
+ /**
+ * Sets the value of the p property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setP(byte[] value) {
+ this.p = value;
+ }
+
+ /**
+ * Gets the value of the q property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getQ() {
+ return q;
+ }
+
+ /**
+ * Sets the value of the q property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setQ(byte[] value) {
+ this.q = value;
+ }
+
+ /**
+ * Gets the value of the g property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getG() {
+ return g;
+ }
+
+ /**
+ * Sets the value of the g property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setG(byte[] value) {
+ this.g = value;
+ }
+
+ /**
+ * Gets the value of the y property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getY() {
+ return y;
+ }
+
+ /**
+ * Sets the value of the y property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setY(byte[] value) {
+ this.y = value;
+ }
+
+ /**
+ * Gets the value of the j property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getJ() {
+ return j;
+ }
+
+ /**
+ * Sets the value of the j property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setJ(byte[] value) {
+ this.j = value;
+ }
+
+ /**
+ * Gets the value of the seed property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getSeed() {
+ return seed;
+ }
+
+ /**
+ * Sets the value of the seed property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setSeed(byte[] value) {
+ this.seed = value;
+ }
+
+ /**
+ * Gets the value of the pgenCounter property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getPgenCounter() {
+ return pgenCounter;
+ }
+
+ /**
+ * Sets the value of the pgenCounter property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setPgenCounter(byte[] value) {
+ this.pgenCounter = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/DigestMethodType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/DigestMethodType.java
new file mode 100644
index 0000000..509cdc6
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/DigestMethodType.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for DigestMethodType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="DigestMethodType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "DigestMethodType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class DigestMethodType {
+
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link Object }
+ * {@link Element }
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/KeyInfoType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/KeyInfoType.java
new file mode 100644
index 0000000..7cb25ed
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/KeyInfoType.java
@@ -0,0 +1,160 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for KeyInfoType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="KeyInfoType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded">
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}KeyName"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}KeyValue"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}RetrievalMethod"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}X509Data"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}PGPData"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}SPKIData"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}MgmtData"/>
+ * <any processContents='lax' namespace='##other'/>
+ * </choice>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "KeyInfoType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class KeyInfoType {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "X509Data", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "KeyValue", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "RetrievalMethod", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "MgmtData", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "PGPData", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "SPKIData", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "KeyName", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class)
+ })
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link X509DataType }{@code >}
+ * {@link Element }
+ * {@link JAXBElement }{@code <}{@link KeyValueType }{@code >}
+ * {@link JAXBElement }{@code <}{@link RetrievalMethodType }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link PGPDataType }{@code >}
+ * {@link String }
+ * {@link Object }
+ * {@link JAXBElement }{@code <}{@link SPKIDataType }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/KeyValueType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/KeyValueType.java
new file mode 100644
index 0000000..d6c423f
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/KeyValueType.java
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for KeyValueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="KeyValueType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}DSAKeyValue"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}RSAKeyValue"/>
+ * <any processContents='lax' namespace='##other'/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "KeyValueType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class KeyValueType {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "RSAKeyValue", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "DSAKeyValue", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class)
+ })
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link Object }
+ * {@link Element }
+ * {@link JAXBElement }{@code <}{@link RSAKeyValueType }{@code >}
+ * {@link JAXBElement }{@code <}{@link DSAKeyValueType }{@code >}
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/ManifestType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/ManifestType.java
new file mode 100644
index 0000000..2946819
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/ManifestType.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for ManifestType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ManifestType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}Reference" maxOccurs="unbounded"/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ManifestType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "reference"
+})
+public class ManifestType {
+
+ @XmlElement(name = "Reference", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected List<ReferenceType> reference;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the reference property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the reference property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getReference().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link ReferenceType }
+ *
+ *
+ */
+ public List<ReferenceType> getReference() {
+ if (reference == null) {
+ reference = new ArrayList<ReferenceType>();
+ }
+ return this.reference;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/ObjectFactory.java b/src/main/java/org/apache/xml/security/binding/xmldsig/ObjectFactory.java
new file mode 100644
index 0000000..174a8b3
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/ObjectFactory.java
@@ -0,0 +1,577 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.math.BigInteger;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.xml.security.binding.xmldsig package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _Signature_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "Signature");
+ private final static QName _SignatureValue_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "SignatureValue");
+ private final static QName _SignedInfo_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "SignedInfo");
+ private final static QName _CanonicalizationMethod_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "CanonicalizationMethod");
+ private final static QName _SignatureMethod_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "SignatureMethod");
+ private final static QName _Reference_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "Reference");
+ private final static QName _Transforms_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "Transforms");
+ private final static QName _Transform_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "Transform");
+ private final static QName _DigestMethod_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "DigestMethod");
+ private final static QName _DigestValue_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "DigestValue");
+ private final static QName _KeyInfo_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "KeyInfo");
+ private final static QName _KeyName_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "KeyName");
+ private final static QName _MgmtData_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "MgmtData");
+ private final static QName _KeyValue_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "KeyValue");
+ private final static QName _RetrievalMethod_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "RetrievalMethod");
+ private final static QName _X509Data_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "X509Data");
+ private final static QName _PGPData_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "PGPData");
+ private final static QName _SPKIData_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "SPKIData");
+ private final static QName _Object_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "Object");
+ private final static QName _Manifest_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "Manifest");
+ private final static QName _SignatureProperties_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "SignatureProperties");
+ private final static QName _SignatureProperty_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "SignatureProperty");
+ private final static QName _DSAKeyValue_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "DSAKeyValue");
+ private final static QName _RSAKeyValue_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "RSAKeyValue");
+ private final static QName _SPKIDataTypeSPKISexp_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "SPKISexp");
+ private final static QName _PGPDataTypePGPKeyID_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "PGPKeyID");
+ private final static QName _PGPDataTypePGPKeyPacket_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "PGPKeyPacket");
+ private final static QName _X509DataTypeX509IssuerSerial_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "X509IssuerSerial");
+ private final static QName _X509DataTypeX509SKI_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "X509SKI");
+ private final static QName _X509DataTypeX509SubjectName_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "X509SubjectName");
+ private final static QName _X509DataTypeX509Certificate_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "X509Certificate");
+ private final static QName _X509DataTypeX509CRL_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "X509CRL");
+ private final static QName _TransformTypeXPath_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "XPath");
+ private final static QName _SignatureMethodTypeHMACOutputLength_QNAME = new QName("http://www.w3.org/2000/09/xmldsig#", "HMACOutputLength");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.xml.security.binding.xmldsig
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link SignatureType }
+ *
+ */
+ public SignatureType createSignatureType() {
+ return new SignatureType();
+ }
+
+ /**
+ * Create an instance of {@link SignatureValueType }
+ *
+ */
+ public SignatureValueType createSignatureValueType() {
+ return new SignatureValueType();
+ }
+
+ /**
+ * Create an instance of {@link SignedInfoType }
+ *
+ */
+ public SignedInfoType createSignedInfoType() {
+ return new SignedInfoType();
+ }
+
+ /**
+ * Create an instance of {@link CanonicalizationMethodType }
+ *
+ */
+ public CanonicalizationMethodType createCanonicalizationMethodType() {
+ return new CanonicalizationMethodType();
+ }
+
+ /**
+ * Create an instance of {@link SignatureMethodType }
+ *
+ */
+ public SignatureMethodType createSignatureMethodType() {
+ return new SignatureMethodType();
+ }
+
+ /**
+ * Create an instance of {@link ReferenceType }
+ *
+ */
+ public ReferenceType createReferenceType() {
+ return new ReferenceType();
+ }
+
+ /**
+ * Create an instance of {@link TransformsType }
+ *
+ */
+ public TransformsType createTransformsType() {
+ return new TransformsType();
+ }
+
+ /**
+ * Create an instance of {@link TransformType }
+ *
+ */
+ public TransformType createTransformType() {
+ return new TransformType();
+ }
+
+ /**
+ * Create an instance of {@link DigestMethodType }
+ *
+ */
+ public DigestMethodType createDigestMethodType() {
+ return new DigestMethodType();
+ }
+
+ /**
+ * Create an instance of {@link KeyInfoType }
+ *
+ */
+ public KeyInfoType createKeyInfoType() {
+ return new KeyInfoType();
+ }
+
+ /**
+ * Create an instance of {@link KeyValueType }
+ *
+ */
+ public KeyValueType createKeyValueType() {
+ return new KeyValueType();
+ }
+
+ /**
+ * Create an instance of {@link RetrievalMethodType }
+ *
+ */
+ public RetrievalMethodType createRetrievalMethodType() {
+ return new RetrievalMethodType();
+ }
+
+ /**
+ * Create an instance of {@link X509DataType }
+ *
+ */
+ public X509DataType createX509DataType() {
+ return new X509DataType();
+ }
+
+ /**
+ * Create an instance of {@link PGPDataType }
+ *
+ */
+ public PGPDataType createPGPDataType() {
+ return new PGPDataType();
+ }
+
+ /**
+ * Create an instance of {@link SPKIDataType }
+ *
+ */
+ public SPKIDataType createSPKIDataType() {
+ return new SPKIDataType();
+ }
+
+ /**
+ * Create an instance of {@link ObjectType }
+ *
+ */
+ public ObjectType createObjectType() {
+ return new ObjectType();
+ }
+
+ /**
+ * Create an instance of {@link ManifestType }
+ *
+ */
+ public ManifestType createManifestType() {
+ return new ManifestType();
+ }
+
+ /**
+ * Create an instance of {@link SignaturePropertiesType }
+ *
+ */
+ public SignaturePropertiesType createSignaturePropertiesType() {
+ return new SignaturePropertiesType();
+ }
+
+ /**
+ * Create an instance of {@link SignaturePropertyType }
+ *
+ */
+ public SignaturePropertyType createSignaturePropertyType() {
+ return new SignaturePropertyType();
+ }
+
+ /**
+ * Create an instance of {@link DSAKeyValueType }
+ *
+ */
+ public DSAKeyValueType createDSAKeyValueType() {
+ return new DSAKeyValueType();
+ }
+
+ /**
+ * Create an instance of {@link RSAKeyValueType }
+ *
+ */
+ public RSAKeyValueType createRSAKeyValueType() {
+ return new RSAKeyValueType();
+ }
+
+ /**
+ * Create an instance of {@link X509IssuerSerialType }
+ *
+ */
+ public X509IssuerSerialType createX509IssuerSerialType() {
+ return new X509IssuerSerialType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SignatureType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Signature")
+ public JAXBElement<SignatureType> createSignature(SignatureType value) {
+ return new JAXBElement<SignatureType>(_Signature_QNAME, SignatureType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SignatureValueType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureValue")
+ public JAXBElement<SignatureValueType> createSignatureValue(SignatureValueType value) {
+ return new JAXBElement<SignatureValueType>(_SignatureValue_QNAME, SignatureValueType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SignedInfoType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignedInfo")
+ public JAXBElement<SignedInfoType> createSignedInfo(SignedInfoType value) {
+ return new JAXBElement<SignedInfoType>(_SignedInfo_QNAME, SignedInfoType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CanonicalizationMethodType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "CanonicalizationMethod")
+ public JAXBElement<CanonicalizationMethodType> createCanonicalizationMethod(CanonicalizationMethodType value) {
+ return new JAXBElement<CanonicalizationMethodType>(_CanonicalizationMethod_QNAME, CanonicalizationMethodType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SignatureMethodType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureMethod")
+ public JAXBElement<SignatureMethodType> createSignatureMethod(SignatureMethodType value) {
+ return new JAXBElement<SignatureMethodType>(_SignatureMethod_QNAME, SignatureMethodType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ReferenceType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Reference")
+ public JAXBElement<ReferenceType> createReference(ReferenceType value) {
+ return new JAXBElement<ReferenceType>(_Reference_QNAME, ReferenceType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link TransformsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Transforms")
+ public JAXBElement<TransformsType> createTransforms(TransformsType value) {
+ return new JAXBElement<TransformsType>(_Transforms_QNAME, TransformsType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link TransformType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Transform")
+ public JAXBElement<TransformType> createTransform(TransformType value) {
+ return new JAXBElement<TransformType>(_Transform_QNAME, TransformType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link DigestMethodType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "DigestMethod")
+ public JAXBElement<DigestMethodType> createDigestMethod(DigestMethodType value) {
+ return new JAXBElement<DigestMethodType>(_DigestMethod_QNAME, DigestMethodType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "DigestValue")
+ public JAXBElement<byte[]> createDigestValue(byte[] value) {
+ return new JAXBElement<byte[]>(_DigestValue_QNAME, byte[].class, null, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link KeyInfoType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "KeyInfo")
+ public JAXBElement<KeyInfoType> createKeyInfo(KeyInfoType value) {
+ return new JAXBElement<KeyInfoType>(_KeyInfo_QNAME, KeyInfoType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "KeyName")
+ public JAXBElement<String> createKeyName(String value) {
+ return new JAXBElement<String>(_KeyName_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "MgmtData")
+ public JAXBElement<String> createMgmtData(String value) {
+ return new JAXBElement<String>(_MgmtData_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link KeyValueType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "KeyValue")
+ public JAXBElement<KeyValueType> createKeyValue(KeyValueType value) {
+ return new JAXBElement<KeyValueType>(_KeyValue_QNAME, KeyValueType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link RetrievalMethodType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "RetrievalMethod")
+ public JAXBElement<RetrievalMethodType> createRetrievalMethod(RetrievalMethodType value) {
+ return new JAXBElement<RetrievalMethodType>(_RetrievalMethod_QNAME, RetrievalMethodType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link X509DataType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509Data")
+ public JAXBElement<X509DataType> createX509Data(X509DataType value) {
+ return new JAXBElement<X509DataType>(_X509Data_QNAME, X509DataType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link PGPDataType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "PGPData")
+ public JAXBElement<PGPDataType> createPGPData(PGPDataType value) {
+ return new JAXBElement<PGPDataType>(_PGPData_QNAME, PGPDataType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SPKIDataType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SPKIData")
+ public JAXBElement<SPKIDataType> createSPKIData(SPKIDataType value) {
+ return new JAXBElement<SPKIDataType>(_SPKIData_QNAME, SPKIDataType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ObjectType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Object")
+ public JAXBElement<ObjectType> createObject(ObjectType value) {
+ return new JAXBElement<ObjectType>(_Object_QNAME, ObjectType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ManifestType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Manifest")
+ public JAXBElement<ManifestType> createManifest(ManifestType value) {
+ return new JAXBElement<ManifestType>(_Manifest_QNAME, ManifestType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SignaturePropertiesType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureProperties")
+ public JAXBElement<SignaturePropertiesType> createSignatureProperties(SignaturePropertiesType value) {
+ return new JAXBElement<SignaturePropertiesType>(_SignatureProperties_QNAME, SignaturePropertiesType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SignaturePropertyType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureProperty")
+ public JAXBElement<SignaturePropertyType> createSignatureProperty(SignaturePropertyType value) {
+ return new JAXBElement<SignaturePropertyType>(_SignatureProperty_QNAME, SignaturePropertyType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link DSAKeyValueType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "DSAKeyValue")
+ public JAXBElement<DSAKeyValueType> createDSAKeyValue(DSAKeyValueType value) {
+ return new JAXBElement<DSAKeyValueType>(_DSAKeyValue_QNAME, DSAKeyValueType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link RSAKeyValueType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "RSAKeyValue")
+ public JAXBElement<RSAKeyValueType> createRSAKeyValue(RSAKeyValueType value) {
+ return new JAXBElement<RSAKeyValueType>(_RSAKeyValue_QNAME, RSAKeyValueType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SPKISexp", scope = SPKIDataType.class)
+ public JAXBElement<byte[]> createSPKIDataTypeSPKISexp(byte[] value) {
+ return new JAXBElement<byte[]>(_SPKIDataTypeSPKISexp_QNAME, byte[].class, SPKIDataType.class, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "PGPKeyID", scope = PGPDataType.class)
+ public JAXBElement<byte[]> createPGPDataTypePGPKeyID(byte[] value) {
+ return new JAXBElement<byte[]>(_PGPDataTypePGPKeyID_QNAME, byte[].class, PGPDataType.class, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "PGPKeyPacket", scope = PGPDataType.class)
+ public JAXBElement<byte[]> createPGPDataTypePGPKeyPacket(byte[] value) {
+ return new JAXBElement<byte[]>(_PGPDataTypePGPKeyPacket_QNAME, byte[].class, PGPDataType.class, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link X509IssuerSerialType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509IssuerSerial", scope = X509DataType.class)
+ public JAXBElement<X509IssuerSerialType> createX509DataTypeX509IssuerSerial(X509IssuerSerialType value) {
+ return new JAXBElement<X509IssuerSerialType>(_X509DataTypeX509IssuerSerial_QNAME, X509IssuerSerialType.class, X509DataType.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509SKI", scope = X509DataType.class)
+ public JAXBElement<byte[]> createX509DataTypeX509SKI(byte[] value) {
+ return new JAXBElement<byte[]>(_X509DataTypeX509SKI_QNAME, byte[].class, X509DataType.class, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509SubjectName", scope = X509DataType.class)
+ public JAXBElement<String> createX509DataTypeX509SubjectName(String value) {
+ return new JAXBElement<String>(_X509DataTypeX509SubjectName_QNAME, String.class, X509DataType.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509Certificate", scope = X509DataType.class)
+ public JAXBElement<byte[]> createX509DataTypeX509Certificate(byte[] value) {
+ return new JAXBElement<byte[]>(_X509DataTypeX509Certificate_QNAME, byte[].class, X509DataType.class, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509CRL", scope = X509DataType.class)
+ public JAXBElement<byte[]> createX509DataTypeX509CRL(byte[] value) {
+ return new JAXBElement<byte[]>(_X509DataTypeX509CRL_QNAME, byte[].class, X509DataType.class, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "XPath", scope = TransformType.class)
+ public JAXBElement<String> createTransformTypeXPath(String value) {
+ return new JAXBElement<String>(_TransformTypeXPath_QNAME, String.class, TransformType.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link BigInteger }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "HMACOutputLength", scope = SignatureMethodType.class)
+ public JAXBElement<BigInteger> createSignatureMethodTypeHMACOutputLength(BigInteger value) {
+ return new JAXBElement<BigInteger>(_SignatureMethodTypeHMACOutputLength_QNAME, BigInteger.class, SignatureMethodType.class, value);
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/ObjectType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/ObjectType.java
new file mode 100644
index 0000000..727a36a
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/ObjectType.java
@@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for ObjectType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ObjectType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence maxOccurs="unbounded" minOccurs="0">
+ * <any processContents='lax'/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * <attribute name="MimeType" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="Encoding" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ObjectType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class ObjectType {
+
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+ @XmlAttribute(name = "MimeType")
+ protected String mimeType;
+ @XmlAttribute(name = "Encoding")
+ @XmlSchemaType(name = "anyURI")
+ protected String encoding;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link Object }
+ * {@link Element }
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+ /**
+ * Gets the value of the mimeType property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMimeType() {
+ return mimeType;
+ }
+
+ /**
+ * Sets the value of the mimeType property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMimeType(String value) {
+ this.mimeType = value;
+ }
+
+ /**
+ * Gets the value of the encoding property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getEncoding() {
+ return encoding;
+ }
+
+ /**
+ * Sets the value of the encoding property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setEncoding(String value) {
+ this.encoding = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/PGPDataType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/PGPDataType.java
new file mode 100644
index 0000000..ac72a2b
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/PGPDataType.java
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for PGPDataType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="PGPDataType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice>
+ * <sequence>
+ * <element name="PGPKeyID" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * <element name="PGPKeyPacket" type="{http://www.w3.org/2001/XMLSchema}base64Binary" minOccurs="0"/>
+ * <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <sequence>
+ * <element name="PGPKeyPacket" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "PGPDataType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class PGPDataType {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "PGPKeyID", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "PGPKeyPacket", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class)
+ })
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+
+ /**
+ * Gets the rest of the content model.
+ *
+ * <p>
+ * You are getting this "catch-all" property because of the following reason:
+ * The field name "PGPKeyPacket" is used by two different parts of a schema. See:
+ * line 218 of file:/home/colm/src/apache/santuario-java/src/main/resources/bindings/schemas/xmldsig-core-schema.xsd
+ * line 213 of file:/home/colm/src/apache/santuario-java/src/main/resources/bindings/schemas/xmldsig-core-schema.xsd
+ * <p>
+ * To get rid of this property, apply a property customization to one
+ * of both of the following declarations to change their names:
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Object }
+ * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
+ * {@link Element }
+ * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/RSAKeyValueType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/RSAKeyValueType.java
new file mode 100644
index 0000000..4d0a1c8
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/RSAKeyValueType.java
@@ -0,0 +1,111 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for RSAKeyValueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="RSAKeyValueType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Modulus" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * <element name="Exponent" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "RSAKeyValueType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "modulus",
+ "exponent"
+})
+public class RSAKeyValueType {
+
+ @XmlElement(name = "Modulus", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected byte[] modulus;
+ @XmlElement(name = "Exponent", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected byte[] exponent;
+
+ /**
+ * Gets the value of the modulus property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getModulus() {
+ return modulus;
+ }
+
+ /**
+ * Sets the value of the modulus property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setModulus(byte[] value) {
+ this.modulus = value;
+ }
+
+ /**
+ * Gets the value of the exponent property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getExponent() {
+ return exponent;
+ }
+
+ /**
+ * Sets the value of the exponent property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setExponent(byte[] value) {
+ this.exponent = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/ReferenceType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/ReferenceType.java
new file mode 100644
index 0000000..1053951
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/ReferenceType.java
@@ -0,0 +1,232 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for ReferenceType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ReferenceType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}Transforms" minOccurs="0"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}DigestMethod"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}DigestValue"/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * <attribute name="URI" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * <attribute name="Type" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ReferenceType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "transforms",
+ "digestMethod",
+ "digestValue"
+})
+public class ReferenceType {
+
+ @XmlElement(name = "Transforms", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected TransformsType transforms;
+ @XmlElement(name = "DigestMethod", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected DigestMethodType digestMethod;
+ @XmlElement(name = "DigestValue", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected byte[] digestValue;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+ @XmlAttribute(name = "URI")
+ @XmlSchemaType(name = "anyURI")
+ protected String uri;
+ @XmlAttribute(name = "Type")
+ @XmlSchemaType(name = "anyURI")
+ protected String type;
+
+ /**
+ * Gets the value of the transforms property.
+ *
+ * @return
+ * possible object is
+ * {@link TransformsType }
+ *
+ */
+ public TransformsType getTransforms() {
+ return transforms;
+ }
+
+ /**
+ * Sets the value of the transforms property.
+ *
+ * @param value
+ * allowed object is
+ * {@link TransformsType }
+ *
+ */
+ public void setTransforms(TransformsType value) {
+ this.transforms = value;
+ }
+
+ /**
+ * Gets the value of the digestMethod property.
+ *
+ * @return
+ * possible object is
+ * {@link DigestMethodType }
+ *
+ */
+ public DigestMethodType getDigestMethod() {
+ return digestMethod;
+ }
+
+ /**
+ * Sets the value of the digestMethod property.
+ *
+ * @param value
+ * allowed object is
+ * {@link DigestMethodType }
+ *
+ */
+ public void setDigestMethod(DigestMethodType value) {
+ this.digestMethod = value;
+ }
+
+ /**
+ * Gets the value of the digestValue property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getDigestValue() {
+ return digestValue;
+ }
+
+ /**
+ * Sets the value of the digestValue property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setDigestValue(byte[] value) {
+ this.digestValue = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setType(String value) {
+ this.type = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/RetrievalMethodType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/RetrievalMethodType.java
new file mode 100644
index 0000000..b0553a8
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/RetrievalMethodType.java
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for RetrievalMethodType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="RetrievalMethodType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}Transforms" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="URI" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * <attribute name="Type" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "RetrievalMethodType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "transforms"
+})
+public class RetrievalMethodType {
+
+ @XmlElement(name = "Transforms", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected TransformsType transforms;
+ @XmlAttribute(name = "URI")
+ @XmlSchemaType(name = "anyURI")
+ protected String uri;
+ @XmlAttribute(name = "Type")
+ @XmlSchemaType(name = "anyURI")
+ protected String type;
+
+ /**
+ * Gets the value of the transforms property.
+ *
+ * @return
+ * possible object is
+ * {@link TransformsType }
+ *
+ */
+ public TransformsType getTransforms() {
+ return transforms;
+ }
+
+ /**
+ * Sets the value of the transforms property.
+ *
+ * @param value
+ * allowed object is
+ * {@link TransformsType }
+ *
+ */
+ public void setTransforms(TransformsType value) {
+ this.transforms = value;
+ }
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setType(String value) {
+ this.type = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/SPKIDataType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/SPKIDataType.java
new file mode 100644
index 0000000..cbdaeb0
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/SPKIDataType.java
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for SPKIDataType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="SPKIDataType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence maxOccurs="unbounded">
+ * <element name="SPKISexp" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * <any processContents='lax' namespace='##other' minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "SPKIDataType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "spkiSexpAndAny"
+})
+public class SPKIDataType {
+
+ @XmlElementRef(name = "SPKISexp", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class)
+ @XmlAnyElement(lax = true)
+ protected List<Object> spkiSexpAndAny;
+
+ /**
+ * Gets the value of the spkiSexpAndAny property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the spkiSexpAndAny property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getSPKISexpAndAny().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
+ * {@link Object }
+ * {@link Element }
+ *
+ *
+ */
+ public List<Object> getSPKISexpAndAny() {
+ if (spkiSexpAndAny == null) {
+ spkiSexpAndAny = new ArrayList<Object>();
+ }
+ return this.spkiSexpAndAny;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureMethodType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureMethodType.java
new file mode 100644
index 0000000..57e2801
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureMethodType.java
@@ -0,0 +1,133 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for SignatureMethodType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="SignatureMethodType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="HMACOutputLength" type="{http://www.w3.org/2000/09/xmldsig#}HMACOutputLengthType" minOccurs="0"/>
+ * <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "SignatureMethodType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class SignatureMethodType {
+
+ @XmlElementRef(name = "HMACOutputLength", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class)
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
+ * {@link Object }
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/SignaturePropertiesType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/SignaturePropertiesType.java
new file mode 100644
index 0000000..72c28d5
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/SignaturePropertiesType.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for SignaturePropertiesType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="SignaturePropertiesType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}SignatureProperty" maxOccurs="unbounded"/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "SignaturePropertiesType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "signatureProperty"
+})
+public class SignaturePropertiesType {
+
+ @XmlElement(name = "SignatureProperty", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected List<SignaturePropertyType> signatureProperty;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the signatureProperty property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the signatureProperty property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getSignatureProperty().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link SignaturePropertyType }
+ *
+ *
+ */
+ public List<SignaturePropertyType> getSignatureProperty() {
+ if (signatureProperty == null) {
+ signatureProperty = new ArrayList<SignaturePropertyType>();
+ }
+ return this.signatureProperty;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/SignaturePropertyType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/SignaturePropertyType.java
new file mode 100644
index 0000000..159692e
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/SignaturePropertyType.java
@@ -0,0 +1,162 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for SignaturePropertyType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="SignaturePropertyType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded">
+ * <any processContents='lax' namespace='##other'/>
+ * </choice>
+ * <attribute name="Target" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "SignaturePropertyType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class SignaturePropertyType {
+
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Target", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String target;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link Object }
+ * {@link Element }
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the target property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTarget() {
+ return target;
+ }
+
+ /**
+ * Sets the value of the target property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTarget(String value) {
+ this.target = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureType.java
new file mode 100644
index 0000000..adcec30
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureType.java
@@ -0,0 +1,213 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for SignatureType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="SignatureType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}SignedInfo"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}SignatureValue"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}KeyInfo" minOccurs="0"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}Object" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "SignatureType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "signedInfo",
+ "signatureValue",
+ "keyInfo",
+ "object"
+})
+public class SignatureType {
+
+ @XmlElement(name = "SignedInfo", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected SignedInfoType signedInfo;
+ @XmlElement(name = "SignatureValue", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected SignatureValueType signatureValue;
+ @XmlElement(name = "KeyInfo", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected KeyInfoType keyInfo;
+ @XmlElement(name = "Object", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected List<ObjectType> object;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the signedInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link SignedInfoType }
+ *
+ */
+ public SignedInfoType getSignedInfo() {
+ return signedInfo;
+ }
+
+ /**
+ * Sets the value of the signedInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link SignedInfoType }
+ *
+ */
+ public void setSignedInfo(SignedInfoType value) {
+ this.signedInfo = value;
+ }
+
+ /**
+ * Gets the value of the signatureValue property.
+ *
+ * @return
+ * possible object is
+ * {@link SignatureValueType }
+ *
+ */
+ public SignatureValueType getSignatureValue() {
+ return signatureValue;
+ }
+
+ /**
+ * Sets the value of the signatureValue property.
+ *
+ * @param value
+ * allowed object is
+ * {@link SignatureValueType }
+ *
+ */
+ public void setSignatureValue(SignatureValueType value) {
+ this.signatureValue = value;
+ }
+
+ /**
+ * Gets the value of the keyInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link KeyInfoType }
+ *
+ */
+ public KeyInfoType getKeyInfo() {
+ return keyInfo;
+ }
+
+ /**
+ * Sets the value of the keyInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link KeyInfoType }
+ *
+ */
+ public void setKeyInfo(KeyInfoType value) {
+ this.keyInfo = value;
+ }
+
+ /**
+ * Gets the value of the object property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the object property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getObject().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link ObjectType }
+ *
+ *
+ */
+ public List<ObjectType> getObject() {
+ if (object == null) {
+ object = new ArrayList<ObjectType>();
+ }
+ return this.object;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureValueType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureValueType.java
new file mode 100644
index 0000000..206efea9
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/SignatureValueType.java
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for SignatureValueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="SignatureValueType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>base64Binary">
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "SignatureValueType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "value"
+})
+public class SignatureValueType {
+
+ @XmlValue
+ protected byte[] value;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setValue(byte[] value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/SignedInfoType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/SignedInfoType.java
new file mode 100644
index 0000000..a44bf83
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/SignedInfoType.java
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for SignedInfoType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="SignedInfoType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}SignatureMethod"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}Reference" maxOccurs="unbounded"/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "SignedInfoType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "canonicalizationMethod",
+ "signatureMethod",
+ "reference"
+})
+public class SignedInfoType {
+
+ @XmlElement(name = "CanonicalizationMethod", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected CanonicalizationMethodType canonicalizationMethod;
+ @XmlElement(name = "SignatureMethod", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected SignatureMethodType signatureMethod;
+ @XmlElement(name = "Reference", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected List<ReferenceType> reference;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the canonicalizationMethod property.
+ *
+ * @return
+ * possible object is
+ * {@link CanonicalizationMethodType }
+ *
+ */
+ public CanonicalizationMethodType getCanonicalizationMethod() {
+ return canonicalizationMethod;
+ }
+
+ /**
+ * Sets the value of the canonicalizationMethod property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CanonicalizationMethodType }
+ *
+ */
+ public void setCanonicalizationMethod(CanonicalizationMethodType value) {
+ this.canonicalizationMethod = value;
+ }
+
+ /**
+ * Gets the value of the signatureMethod property.
+ *
+ * @return
+ * possible object is
+ * {@link SignatureMethodType }
+ *
+ */
+ public SignatureMethodType getSignatureMethod() {
+ return signatureMethod;
+ }
+
+ /**
+ * Sets the value of the signatureMethod property.
+ *
+ * @param value
+ * allowed object is
+ * {@link SignatureMethodType }
+ *
+ */
+ public void setSignatureMethod(SignatureMethodType value) {
+ this.signatureMethod = value;
+ }
+
+ /**
+ * Gets the value of the reference property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the reference property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getReference().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link ReferenceType }
+ *
+ *
+ */
+ public List<ReferenceType> getReference() {
+ if (reference == null) {
+ reference = new ArrayList<ReferenceType>();
+ }
+ return this.reference;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/TransformType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/TransformType.java
new file mode 100644
index 0000000..3fac2fb
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/TransformType.java
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for TransformType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="TransformType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded" minOccurs="0">
+ * <any processContents='lax' namespace='##other'/>
+ * <element name="XPath" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * </choice>
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TransformType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "content"
+})
+public class TransformType {
+
+ @XmlElementRef(name = "XPath", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class)
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link Object }
+ * {@link Element }
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/TransformsType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/TransformsType.java
new file mode 100644
index 0000000..d185055
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/TransformsType.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for TransformsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="TransformsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}Transform" maxOccurs="unbounded"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TransformsType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "transform"
+})
+public class TransformsType {
+
+ @XmlElement(name = "Transform", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected List<TransformType> transform;
+
+ /**
+ * Gets the value of the transform property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the transform property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getTransform().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link TransformType }
+ *
+ *
+ */
+ public List<TransformType> getTransform() {
+ if (transform == null) {
+ transform = new ArrayList<TransformType>();
+ }
+ return this.transform;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/X509DataType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/X509DataType.java
new file mode 100644
index 0000000..f55a377
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/X509DataType.java
@@ -0,0 +1,118 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for X509DataType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="X509DataType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence maxOccurs="unbounded">
+ * <choice>
+ * <element name="X509IssuerSerial" type="{http://www.w3.org/2000/09/xmldsig#}X509IssuerSerialType"/>
+ * <element name="X509SKI" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * <element name="X509SubjectName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="X509Certificate" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * <element name="X509CRL" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * <any processContents='lax' namespace='##other'/>
+ * </choice>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "X509DataType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "x509IssuerSerialOrX509SKIOrX509SubjectName"
+})
+public class X509DataType {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "X509Certificate", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "X509IssuerSerial", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "X509CRL", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "X509SKI", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class),
+ @XmlElementRef(name = "X509SubjectName", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class)
+ })
+ @XmlAnyElement(lax = true)
+ protected List<Object> x509IssuerSerialOrX509SKIOrX509SubjectName;
+
+ /**
+ * Gets the value of the x509IssuerSerialOrX509SKIOrX509SubjectName property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the x509IssuerSerialOrX509SKIOrX509SubjectName property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getX509IssuerSerialOrX509SKIOrX509SubjectName().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
+ * {@link Element }
+ * {@link JAXBElement }{@code <}{@link X509IssuerSerialType }{@code >}
+ * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
+ * {@link Object }
+ * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ *
+ */
+ public List<Object> getX509IssuerSerialOrX509SKIOrX509SubjectName() {
+ if (x509IssuerSerialOrX509SKIOrX509SubjectName == null) {
+ x509IssuerSerialOrX509SKIOrX509SubjectName = new ArrayList<Object>();
+ }
+ return this.x509IssuerSerialOrX509SKIOrX509SubjectName;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig/X509IssuerSerialType.java b/src/main/java/org/apache/xml/security/binding/xmldsig/X509IssuerSerialType.java
new file mode 100644
index 0000000..9d82f2f
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig/X509IssuerSerialType.java
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig;
+
+import java.math.BigInteger;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for X509IssuerSerialType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="X509IssuerSerialType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="X509IssuerName" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * <element name="X509SerialNumber" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "X509IssuerSerialType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
+ "x509IssuerName",
+ "x509SerialNumber"
+})
+public class X509IssuerSerialType {
+
+ @XmlElement(name = "X509IssuerName", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected String x509IssuerName;
+ @XmlElement(name = "X509SerialNumber", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected BigInteger x509SerialNumber;
+
+ /**
+ * Gets the value of the x509IssuerName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getX509IssuerName() {
+ return x509IssuerName;
+ }
+
+ /**
+ * Sets the value of the x509IssuerName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setX509IssuerName(String value) {
+ this.x509IssuerName = value;
+ }
+
+ /**
+ * Gets the value of the x509SerialNumber property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getX509SerialNumber() {
+ return x509SerialNumber;
+ }
+
+ /**
+ * Sets the value of the x509SerialNumber property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setX509SerialNumber(BigInteger value) {
+ this.x509SerialNumber = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/CharTwoFieldParamsType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/CharTwoFieldParamsType.java
new file mode 100644
index 0000000..81eb6b0
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/CharTwoFieldParamsType.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import java.math.BigInteger;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CharTwoFieldParamsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CharTwoFieldParamsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="M" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CharTwoFieldParamsType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "m"
+})
+@XmlSeeAlso({
+ TnBFieldParamsType.class,
+ PnBFieldParamsType.class
+})
+public class CharTwoFieldParamsType {
+
+ @XmlElement(name = "M", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ @XmlSchemaType(name = "positiveInteger")
+ protected BigInteger m;
+
+ /**
+ * Gets the value of the m property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getM() {
+ return m;
+ }
+
+ /**
+ * Sets the value of the m property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setM(BigInteger value) {
+ this.m = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/CurveType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/CurveType.java
new file mode 100644
index 0000000..4944fdd
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/CurveType.java
@@ -0,0 +1,111 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CurveType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CurveType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="A" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * <element name="B" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CurveType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "a",
+ "b"
+})
+public class CurveType {
+
+ @XmlElement(name = "A", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected byte[] a;
+ @XmlElement(name = "B", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected byte[] b;
+
+ /**
+ * Gets the value of the a property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getA() {
+ return a;
+ }
+
+ /**
+ * Sets the value of the a property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setA(byte[] value) {
+ this.a = value;
+ }
+
+ /**
+ * Gets the value of the b property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getB() {
+ return b;
+ }
+
+ /**
+ * Sets the value of the b property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setB(byte[] value) {
+ this.b = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/DEREncodedKeyValueType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/DEREncodedKeyValueType.java
new file mode 100644
index 0000000..eb04919
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/DEREncodedKeyValueType.java
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for DEREncodedKeyValueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="DEREncodedKeyValueType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>base64Binary">
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "DEREncodedKeyValueType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "value"
+})
+public class DEREncodedKeyValueType {
+
+ @XmlValue
+ protected byte[] value;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setValue(byte[] value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/ECKeyValueType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/ECKeyValueType.java
new file mode 100644
index 0000000..0e4b975
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/ECKeyValueType.java
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for ECKeyValueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ECKeyValueType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <choice>
+ * <element name="ECParameters" type="{http://www.w3.org/2009/xmldsig11#}ECParametersType"/>
+ * <element name="NamedCurve" type="{http://www.w3.org/2009/xmldsig11#}NamedCurveType"/>
+ * </choice>
+ * <element name="PublicKey" type="{http://www.w3.org/2009/xmldsig11#}ECPointType"/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ECKeyValueType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "ecParameters",
+ "namedCurve",
+ "publicKey"
+})
+public class ECKeyValueType {
+
+ @XmlElement(name = "ECParameters", namespace = "http://www.w3.org/2009/xmldsig11#")
+ protected ECParametersType ecParameters;
+ @XmlElement(name = "NamedCurve", namespace = "http://www.w3.org/2009/xmldsig11#")
+ protected NamedCurveType namedCurve;
+ @XmlElement(name = "PublicKey", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected byte[] publicKey;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the ecParameters property.
+ *
+ * @return
+ * possible object is
+ * {@link ECParametersType }
+ *
+ */
+ public ECParametersType getECParameters() {
+ return ecParameters;
+ }
+
+ /**
+ * Sets the value of the ecParameters property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ECParametersType }
+ *
+ */
+ public void setECParameters(ECParametersType value) {
+ this.ecParameters = value;
+ }
+
+ /**
+ * Gets the value of the namedCurve property.
+ *
+ * @return
+ * possible object is
+ * {@link NamedCurveType }
+ *
+ */
+ public NamedCurveType getNamedCurve() {
+ return namedCurve;
+ }
+
+ /**
+ * Sets the value of the namedCurve property.
+ *
+ * @param value
+ * allowed object is
+ * {@link NamedCurveType }
+ *
+ */
+ public void setNamedCurve(NamedCurveType value) {
+ this.namedCurve = value;
+ }
+
+ /**
+ * Gets the value of the publicKey property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getPublicKey() {
+ return publicKey;
+ }
+
+ /**
+ * Sets the value of the publicKey property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setPublicKey(byte[] value) {
+ this.publicKey = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/ECParametersType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/ECParametersType.java
new file mode 100644
index 0000000..1286bd0
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/ECParametersType.java
@@ -0,0 +1,224 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import java.math.BigInteger;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ECParametersType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ECParametersType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="FieldID" type="{http://www.w3.org/2009/xmldsig11#}FieldIDType"/>
+ * <element name="Curve" type="{http://www.w3.org/2009/xmldsig11#}CurveType"/>
+ * <element name="Base" type="{http://www.w3.org/2009/xmldsig11#}ECPointType"/>
+ * <element name="Order" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * <element name="CoFactor" type="{http://www.w3.org/2001/XMLSchema}integer" minOccurs="0"/>
+ * <element name="ValidationData" type="{http://www.w3.org/2009/xmldsig11#}ECValidationDataType" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ECParametersType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "fieldID",
+ "curve",
+ "base",
+ "order",
+ "coFactor",
+ "validationData"
+})
+public class ECParametersType {
+
+ @XmlElement(name = "FieldID", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected FieldIDType fieldID;
+ @XmlElement(name = "Curve", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected CurveType curve;
+ @XmlElement(name = "Base", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected byte[] base;
+ @XmlElement(name = "Order", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected byte[] order;
+ @XmlElement(name = "CoFactor", namespace = "http://www.w3.org/2009/xmldsig11#")
+ protected BigInteger coFactor;
+ @XmlElement(name = "ValidationData", namespace = "http://www.w3.org/2009/xmldsig11#")
+ protected ECValidationDataType validationData;
+
+ /**
+ * Gets the value of the fieldID property.
+ *
+ * @return
+ * possible object is
+ * {@link FieldIDType }
+ *
+ */
+ public FieldIDType getFieldID() {
+ return fieldID;
+ }
+
+ /**
+ * Sets the value of the fieldID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link FieldIDType }
+ *
+ */
+ public void setFieldID(FieldIDType value) {
+ this.fieldID = value;
+ }
+
+ /**
+ * Gets the value of the curve property.
+ *
+ * @return
+ * possible object is
+ * {@link CurveType }
+ *
+ */
+ public CurveType getCurve() {
+ return curve;
+ }
+
+ /**
+ * Sets the value of the curve property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CurveType }
+ *
+ */
+ public void setCurve(CurveType value) {
+ this.curve = value;
+ }
+
+ /**
+ * Gets the value of the base property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getBase() {
+ return base;
+ }
+
+ /**
+ * Sets the value of the base property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setBase(byte[] value) {
+ this.base = value;
+ }
+
+ /**
+ * Gets the value of the order property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getOrder() {
+ return order;
+ }
+
+ /**
+ * Sets the value of the order property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setOrder(byte[] value) {
+ this.order = value;
+ }
+
+ /**
+ * Gets the value of the coFactor property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getCoFactor() {
+ return coFactor;
+ }
+
+ /**
+ * Sets the value of the coFactor property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setCoFactor(BigInteger value) {
+ this.coFactor = value;
+ }
+
+ /**
+ * Gets the value of the validationData property.
+ *
+ * @return
+ * possible object is
+ * {@link ECValidationDataType }
+ *
+ */
+ public ECValidationDataType getValidationData() {
+ return validationData;
+ }
+
+ /**
+ * Sets the value of the validationData property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ECValidationDataType }
+ *
+ */
+ public void setValidationData(ECValidationDataType value) {
+ this.validationData = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/ECValidationDataType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/ECValidationDataType.java
new file mode 100644
index 0000000..5146d04
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/ECValidationDataType.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ECValidationDataType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ECValidationDataType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="seed" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * </sequence>
+ * <attribute name="hashAlgorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ECValidationDataType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "seed"
+})
+public class ECValidationDataType {
+
+ @XmlElement(namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected byte[] seed;
+ @XmlAttribute(name = "hashAlgorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String hashAlgorithm;
+
+ /**
+ * Gets the value of the seed property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getSeed() {
+ return seed;
+ }
+
+ /**
+ * Sets the value of the seed property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setSeed(byte[] value) {
+ this.seed = value;
+ }
+
+ /**
+ * Gets the value of the hashAlgorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getHashAlgorithm() {
+ return hashAlgorithm;
+ }
+
+ /**
+ * Sets the value of the hashAlgorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setHashAlgorithm(String value) {
+ this.hashAlgorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/FieldIDType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/FieldIDType.java
new file mode 100644
index 0000000..f5b40d0
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/FieldIDType.java
@@ -0,0 +1,203 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for FieldIDType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="FieldIDType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice>
+ * <element ref="{http://www.w3.org/2009/xmldsig11#}Prime"/>
+ * <element ref="{http://www.w3.org/2009/xmldsig11#}TnB"/>
+ * <element ref="{http://www.w3.org/2009/xmldsig11#}PnB"/>
+ * <element ref="{http://www.w3.org/2009/xmldsig11#}GnB"/>
+ * <any processContents='lax' namespace='##other'/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "FieldIDType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "prime",
+ "tnB",
+ "pnB",
+ "gnB",
+ "any"
+})
+public class FieldIDType {
+
+ @XmlElement(name = "Prime", namespace = "http://www.w3.org/2009/xmldsig11#")
+ protected PrimeFieldParamsType prime;
+ @XmlElement(name = "TnB", namespace = "http://www.w3.org/2009/xmldsig11#")
+ protected TnBFieldParamsType tnB;
+ @XmlElement(name = "PnB", namespace = "http://www.w3.org/2009/xmldsig11#")
+ protected PnBFieldParamsType pnB;
+ @XmlElement(name = "GnB", namespace = "http://www.w3.org/2009/xmldsig11#")
+ protected CharTwoFieldParamsType gnB;
+ @XmlAnyElement(lax = true)
+ protected Object any;
+
+ /**
+ * Gets the value of the prime property.
+ *
+ * @return
+ * possible object is
+ * {@link PrimeFieldParamsType }
+ *
+ */
+ public PrimeFieldParamsType getPrime() {
+ return prime;
+ }
+
+ /**
+ * Sets the value of the prime property.
+ *
+ * @param value
+ * allowed object is
+ * {@link PrimeFieldParamsType }
+ *
+ */
+ public void setPrime(PrimeFieldParamsType value) {
+ this.prime = value;
+ }
+
+ /**
+ * Gets the value of the tnB property.
+ *
+ * @return
+ * possible object is
+ * {@link TnBFieldParamsType }
+ *
+ */
+ public TnBFieldParamsType getTnB() {
+ return tnB;
+ }
+
+ /**
+ * Sets the value of the tnB property.
+ *
+ * @param value
+ * allowed object is
+ * {@link TnBFieldParamsType }
+ *
+ */
+ public void setTnB(TnBFieldParamsType value) {
+ this.tnB = value;
+ }
+
+ /**
+ * Gets the value of the pnB property.
+ *
+ * @return
+ * possible object is
+ * {@link PnBFieldParamsType }
+ *
+ */
+ public PnBFieldParamsType getPnB() {
+ return pnB;
+ }
+
+ /**
+ * Sets the value of the pnB property.
+ *
+ * @param value
+ * allowed object is
+ * {@link PnBFieldParamsType }
+ *
+ */
+ public void setPnB(PnBFieldParamsType value) {
+ this.pnB = value;
+ }
+
+ /**
+ * Gets the value of the gnB property.
+ *
+ * @return
+ * possible object is
+ * {@link CharTwoFieldParamsType }
+ *
+ */
+ public CharTwoFieldParamsType getGnB() {
+ return gnB;
+ }
+
+ /**
+ * Sets the value of the gnB property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CharTwoFieldParamsType }
+ *
+ */
+ public void setGnB(CharTwoFieldParamsType value) {
+ this.gnB = value;
+ }
+
+ /**
+ * Gets the value of the any property.
+ *
+ * @return
+ * possible object is
+ * {@link Object }
+ * {@link Element }
+ *
+ */
+ public Object getAny() {
+ return any;
+ }
+
+ /**
+ * Sets the value of the any property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Object }
+ * {@link Element }
+ *
+ */
+ public void setAny(Object value) {
+ this.any = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/KeyInfoReferenceType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/KeyInfoReferenceType.java
new file mode 100644
index 0000000..278b880
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/KeyInfoReferenceType.java
@@ -0,0 +1,118 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for KeyInfoReferenceType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="KeyInfoReferenceType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="URI" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "KeyInfoReferenceType", namespace = "http://www.w3.org/2009/xmldsig11#")
+public class KeyInfoReferenceType {
+
+ @XmlAttribute(name = "URI", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String uri;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/NamedCurveType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/NamedCurveType.java
new file mode 100644
index 0000000..5e6cd2f
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/NamedCurveType.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for NamedCurveType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="NamedCurveType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="URI" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "NamedCurveType", namespace = "http://www.w3.org/2009/xmldsig11#")
+public class NamedCurveType {
+
+ @XmlAttribute(name = "URI", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String uri;
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/ObjectFactory.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/ObjectFactory.java
new file mode 100644
index 0000000..a89a5fd
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/ObjectFactory.java
@@ -0,0 +1,254 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.xml.security.binding.xmldsig11 package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _ECKeyValue_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "ECKeyValue");
+ private final static QName _Prime_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "Prime");
+ private final static QName _GnB_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "GnB");
+ private final static QName _TnB_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "TnB");
+ private final static QName _PnB_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "PnB");
+ private final static QName _OCSPResponse_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "OCSPResponse");
+ private final static QName _DEREncodedKeyValue_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "DEREncodedKeyValue");
+ private final static QName _KeyInfoReference_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "KeyInfoReference");
+ private final static QName _X509Digest_QNAME = new QName("http://www.w3.org/2009/xmldsig11#", "X509Digest");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.xml.security.binding.xmldsig11
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link ECKeyValueType }
+ *
+ */
+ public ECKeyValueType createECKeyValueType() {
+ return new ECKeyValueType();
+ }
+
+ /**
+ * Create an instance of {@link PrimeFieldParamsType }
+ *
+ */
+ public PrimeFieldParamsType createPrimeFieldParamsType() {
+ return new PrimeFieldParamsType();
+ }
+
+ /**
+ * Create an instance of {@link CharTwoFieldParamsType }
+ *
+ */
+ public CharTwoFieldParamsType createCharTwoFieldParamsType() {
+ return new CharTwoFieldParamsType();
+ }
+
+ /**
+ * Create an instance of {@link TnBFieldParamsType }
+ *
+ */
+ public TnBFieldParamsType createTnBFieldParamsType() {
+ return new TnBFieldParamsType();
+ }
+
+ /**
+ * Create an instance of {@link PnBFieldParamsType }
+ *
+ */
+ public PnBFieldParamsType createPnBFieldParamsType() {
+ return new PnBFieldParamsType();
+ }
+
+ /**
+ * Create an instance of {@link DEREncodedKeyValueType }
+ *
+ */
+ public DEREncodedKeyValueType createDEREncodedKeyValueType() {
+ return new DEREncodedKeyValueType();
+ }
+
+ /**
+ * Create an instance of {@link KeyInfoReferenceType }
+ *
+ */
+ public KeyInfoReferenceType createKeyInfoReferenceType() {
+ return new KeyInfoReferenceType();
+ }
+
+ /**
+ * Create an instance of {@link X509DigestType }
+ *
+ */
+ public X509DigestType createX509DigestType() {
+ return new X509DigestType();
+ }
+
+ /**
+ * Create an instance of {@link NamedCurveType }
+ *
+ */
+ public NamedCurveType createNamedCurveType() {
+ return new NamedCurveType();
+ }
+
+ /**
+ * Create an instance of {@link ECParametersType }
+ *
+ */
+ public ECParametersType createECParametersType() {
+ return new ECParametersType();
+ }
+
+ /**
+ * Create an instance of {@link FieldIDType }
+ *
+ */
+ public FieldIDType createFieldIDType() {
+ return new FieldIDType();
+ }
+
+ /**
+ * Create an instance of {@link CurveType }
+ *
+ */
+ public CurveType createCurveType() {
+ return new CurveType();
+ }
+
+ /**
+ * Create an instance of {@link ECValidationDataType }
+ *
+ */
+ public ECValidationDataType createECValidationDataType() {
+ return new ECValidationDataType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ECKeyValueType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "ECKeyValue")
+ public JAXBElement<ECKeyValueType> createECKeyValue(ECKeyValueType value) {
+ return new JAXBElement<ECKeyValueType>(_ECKeyValue_QNAME, ECKeyValueType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link PrimeFieldParamsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "Prime")
+ public JAXBElement<PrimeFieldParamsType> createPrime(PrimeFieldParamsType value) {
+ return new JAXBElement<PrimeFieldParamsType>(_Prime_QNAME, PrimeFieldParamsType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CharTwoFieldParamsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "GnB")
+ public JAXBElement<CharTwoFieldParamsType> createGnB(CharTwoFieldParamsType value) {
+ return new JAXBElement<CharTwoFieldParamsType>(_GnB_QNAME, CharTwoFieldParamsType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link TnBFieldParamsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "TnB")
+ public JAXBElement<TnBFieldParamsType> createTnB(TnBFieldParamsType value) {
+ return new JAXBElement<TnBFieldParamsType>(_TnB_QNAME, TnBFieldParamsType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link PnBFieldParamsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "PnB")
+ public JAXBElement<PnBFieldParamsType> createPnB(PnBFieldParamsType value) {
+ return new JAXBElement<PnBFieldParamsType>(_PnB_QNAME, PnBFieldParamsType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "OCSPResponse")
+ public JAXBElement<byte[]> createOCSPResponse(byte[] value) {
+ return new JAXBElement<byte[]>(_OCSPResponse_QNAME, byte[].class, null, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link DEREncodedKeyValueType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "DEREncodedKeyValue")
+ public JAXBElement<DEREncodedKeyValueType> createDEREncodedKeyValue(DEREncodedKeyValueType value) {
+ return new JAXBElement<DEREncodedKeyValueType>(_DEREncodedKeyValue_QNAME, DEREncodedKeyValueType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link KeyInfoReferenceType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "KeyInfoReference")
+ public JAXBElement<KeyInfoReferenceType> createKeyInfoReference(KeyInfoReferenceType value) {
+ return new JAXBElement<KeyInfoReferenceType>(_KeyInfoReference_QNAME, KeyInfoReferenceType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link X509DigestType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmldsig11#", name = "X509Digest")
+ public JAXBElement<X509DigestType> createX509Digest(X509DigestType value) {
+ return new JAXBElement<X509DigestType>(_X509Digest_QNAME, X509DigestType.class, null, value);
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/PnBFieldParamsType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/PnBFieldParamsType.java
new file mode 100644
index 0000000..06de062
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/PnBFieldParamsType.java
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import java.math.BigInteger;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for PnBFieldParamsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="PnBFieldParamsType">
+ * <complexContent>
+ * <extension base="{http://www.w3.org/2009/xmldsig11#}CharTwoFieldParamsType">
+ * <sequence>
+ * <element name="K1" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
+ * <element name="K2" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
+ * <element name="K3" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
+ * </sequence>
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "PnBFieldParamsType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "k1",
+ "k2",
+ "k3"
+})
+public class PnBFieldParamsType
+ extends CharTwoFieldParamsType
+{
+
+ @XmlElement(name = "K1", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ @XmlSchemaType(name = "positiveInteger")
+ protected BigInteger k1;
+ @XmlElement(name = "K2", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ @XmlSchemaType(name = "positiveInteger")
+ protected BigInteger k2;
+ @XmlElement(name = "K3", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ @XmlSchemaType(name = "positiveInteger")
+ protected BigInteger k3;
+
+ /**
+ * Gets the value of the k1 property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getK1() {
+ return k1;
+ }
+
+ /**
+ * Sets the value of the k1 property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setK1(BigInteger value) {
+ this.k1 = value;
+ }
+
+ /**
+ * Gets the value of the k2 property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getK2() {
+ return k2;
+ }
+
+ /**
+ * Sets the value of the k2 property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setK2(BigInteger value) {
+ this.k2 = value;
+ }
+
+ /**
+ * Gets the value of the k3 property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getK3() {
+ return k3;
+ }
+
+ /**
+ * Sets the value of the k3 property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setK3(BigInteger value) {
+ this.k3 = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/PrimeFieldParamsType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/PrimeFieldParamsType.java
new file mode 100644
index 0000000..8be5a40
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/PrimeFieldParamsType.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for PrimeFieldParamsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="PrimeFieldParamsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="P" type="{http://www.w3.org/2000/09/xmldsig#}CryptoBinary"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "PrimeFieldParamsType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "p"
+})
+public class PrimeFieldParamsType {
+
+ @XmlElement(name = "P", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ protected byte[] p;
+
+ /**
+ * Gets the value of the p property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getP() {
+ return p;
+ }
+
+ /**
+ * Sets the value of the p property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setP(byte[] value) {
+ this.p = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/TnBFieldParamsType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/TnBFieldParamsType.java
new file mode 100644
index 0000000..5dcb666
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/TnBFieldParamsType.java
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import java.math.BigInteger;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for TnBFieldParamsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="TnBFieldParamsType">
+ * <complexContent>
+ * <extension base="{http://www.w3.org/2009/xmldsig11#}CharTwoFieldParamsType">
+ * <sequence>
+ * <element name="K" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
+ * </sequence>
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TnBFieldParamsType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "k"
+})
+public class TnBFieldParamsType
+ extends CharTwoFieldParamsType
+{
+
+ @XmlElement(name = "K", namespace = "http://www.w3.org/2009/xmldsig11#", required = true)
+ @XmlSchemaType(name = "positiveInteger")
+ protected BigInteger k;
+
+ /**
+ * Gets the value of the k property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getK() {
+ return k;
+ }
+
+ /**
+ * Sets the value of the k property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setK(BigInteger value) {
+ this.k = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmldsig11/X509DigestType.java b/src/main/java/org/apache/xml/security/binding/xmldsig11/X509DigestType.java
new file mode 100644
index 0000000..6936763
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmldsig11/X509DigestType.java
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmldsig11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * <p>Java class for X509DigestType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="X509DigestType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>base64Binary">
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "X509DigestType", namespace = "http://www.w3.org/2009/xmldsig11#", propOrder = {
+ "value"
+})
+public class X509DigestType {
+
+ @XmlValue
+ protected byte[] value;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setValue(byte[] value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/AgreementMethodType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/AgreementMethodType.java
new file mode 100644
index 0000000..2cd2058
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/AgreementMethodType.java
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import org.apache.xml.security.binding.xmldsig.KeyInfoType;
+
+
+/**
+ * <p>Java class for AgreementMethodType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="AgreementMethodType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="KA-Nonce" type="{http://www.w3.org/2001/XMLSchema}base64Binary" minOccurs="0"/>
+ * <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * <element name="OriginatorKeyInfo" type="{http://www.w3.org/2000/09/xmldsig#}KeyInfoType" minOccurs="0"/>
+ * <element name="RecipientKeyInfo" type="{http://www.w3.org/2000/09/xmldsig#}KeyInfoType" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "AgreementMethodType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "content"
+})
+public class AgreementMethodType {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "KA-Nonce", namespace = "http://www.w3.org/2001/04/xmlenc#", type = JAXBElement.class),
+ @XmlElementRef(name = "RecipientKeyInfo", namespace = "http://www.w3.org/2001/04/xmlenc#", type = JAXBElement.class),
+ @XmlElementRef(name = "OriginatorKeyInfo", namespace = "http://www.w3.org/2001/04/xmlenc#", type = JAXBElement.class)
+ })
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
+ * {@link String }
+ * {@link Object }
+ * {@link JAXBElement }{@code <}{@link KeyInfoType }{@code >}
+ * {@link JAXBElement }{@code <}{@link KeyInfoType }{@code >}
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/CipherDataType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/CipherDataType.java
new file mode 100644
index 0000000..94586da
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/CipherDataType.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2018.04.30 at 04:55:04 PM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CipherDataType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CipherDataType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice>
+ * <element ref="{http://www.w3.org/2001/04/xmlenc#}CipherValue"/>
+ * <element ref="{http://www.w3.org/2001/04/xmlenc#}CipherReference"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CipherDataType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "cipherValue",
+ "cipherReference"
+})
+public class CipherDataType {
+
+ @XmlElement(name = "CipherValue", namespace = "http://www.w3.org/2001/04/xmlenc#")
+ protected CipherValueType cipherValue;
+ @XmlElement(name = "CipherReference", namespace = "http://www.w3.org/2001/04/xmlenc#")
+ protected CipherReferenceType cipherReference;
+
+ /**
+ * Gets the value of the cipherValue property.
+ *
+ * @return
+ * possible object is
+ * {@link CipherValueType }
+ *
+ */
+ public CipherValueType getCipherValue() {
+ return cipherValue;
+ }
+
+ /**
+ * Sets the value of the cipherValue property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CipherValueType }
+ *
+ */
+ public void setCipherValue(CipherValueType value) {
+ this.cipherValue = value;
+ }
+
+ /**
+ * Gets the value of the cipherReference property.
+ *
+ * @return
+ * possible object is
+ * {@link CipherReferenceType }
+ *
+ */
+ public CipherReferenceType getCipherReference() {
+ return cipherReference;
+ }
+
+ /**
+ * Sets the value of the cipherReference property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CipherReferenceType }
+ *
+ */
+ public void setCipherReference(CipherReferenceType value) {
+ this.cipherReference = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/CipherReferenceType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/CipherReferenceType.java
new file mode 100644
index 0000000..7dfbcb1
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/CipherReferenceType.java
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for CipherReferenceType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CipherReferenceType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice>
+ * <element name="Transforms" type="{http://www.w3.org/2001/04/xmlenc#}TransformsType" minOccurs="0"/>
+ * </choice>
+ * <attribute name="URI" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CipherReferenceType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "transforms"
+})
+public class CipherReferenceType {
+
+ @XmlElement(name = "Transforms", namespace = "http://www.w3.org/2001/04/xmlenc#")
+ protected TransformsType transforms;
+ @XmlAttribute(name = "URI", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String uri;
+
+ /**
+ * Gets the value of the transforms property.
+ *
+ * @return
+ * possible object is
+ * {@link TransformsType }
+ *
+ */
+ public TransformsType getTransforms() {
+ return transforms;
+ }
+
+ /**
+ * Sets the value of the transforms property.
+ *
+ * @param value
+ * allowed object is
+ * {@link TransformsType }
+ *
+ */
+ public void setTransforms(TransformsType value) {
+ this.transforms = value;
+ }
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/CipherValueType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/CipherValueType.java
new file mode 100644
index 0000000..ff714ba
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/CipherValueType.java
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2018.04.30 at 05:36:51 PM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlType;
+import org.apache.xml.security.binding.xop.Include;
+
+
+/**
+ * <p>Java class for CipherValueType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="CipherValueType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2004/08/xop/include}Include" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "CipherValueType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "content"
+})
+public class CipherValueType {
+
+ @XmlElementRef(name = "Include", namespace = "http://www.w3.org/2004/08/xop/include", type = JAXBElement.class)
+ @XmlMixed
+ protected List<Serializable> content;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link JAXBElement }{@code <}{@link Include }{@code >}
+ *
+ *
+ */
+ public List<Serializable> getContent() {
+ if (content == null) {
+ content = new ArrayList<Serializable>();
+ }
+ return this.content;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedDataType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedDataType.java
new file mode 100644
index 0000000..17211eb
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedDataType.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for EncryptedDataType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="EncryptedDataType">
+ * <complexContent>
+ * <extension base="{http://www.w3.org/2001/04/xmlenc#}EncryptedType">
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "EncryptedDataType", namespace = "http://www.w3.org/2001/04/xmlenc#")
+public class EncryptedDataType
+ extends EncryptedType
+{
+
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedKeyType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedKeyType.java
new file mode 100644
index 0000000..4914aaa
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedKeyType.java
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for EncryptedKeyType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="EncryptedKeyType">
+ * <complexContent>
+ * <extension base="{http://www.w3.org/2001/04/xmlenc#}EncryptedType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2001/04/xmlenc#}ReferenceList" minOccurs="0"/>
+ * <element name="CarriedKeyName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Recipient" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "EncryptedKeyType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "referenceList",
+ "carriedKeyName"
+})
+public class EncryptedKeyType
+ extends EncryptedType
+{
+
+ @XmlElement(name = "ReferenceList", namespace = "http://www.w3.org/2001/04/xmlenc#")
+ protected ReferenceList referenceList;
+ @XmlElement(name = "CarriedKeyName", namespace = "http://www.w3.org/2001/04/xmlenc#")
+ protected String carriedKeyName;
+ @XmlAttribute(name = "Recipient")
+ protected String recipient;
+
+ /**
+ * Gets the value of the referenceList property.
+ *
+ * @return
+ * possible object is
+ * {@link ReferenceList }
+ *
+ */
+ public ReferenceList getReferenceList() {
+ return referenceList;
+ }
+
+ /**
+ * Sets the value of the referenceList property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ReferenceList }
+ *
+ */
+ public void setReferenceList(ReferenceList value) {
+ this.referenceList = value;
+ }
+
+ /**
+ * Gets the value of the carriedKeyName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getCarriedKeyName() {
+ return carriedKeyName;
+ }
+
+ /**
+ * Sets the value of the carriedKeyName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setCarriedKeyName(String value) {
+ this.carriedKeyName = value;
+ }
+
+ /**
+ * Gets the value of the recipient property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getRecipient() {
+ return recipient;
+ }
+
+ /**
+ * Sets the value of the recipient property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setRecipient(String value) {
+ this.recipient = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedType.java
new file mode 100644
index 0000000..dc79073
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptedType.java
@@ -0,0 +1,295 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.xml.security.binding.xmldsig.KeyInfoType;
+
+
+/**
+ * <p>Java class for EncryptedType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="EncryptedType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="EncryptionMethod" type="{http://www.w3.org/2001/04/xmlenc#}EncryptionMethodType" minOccurs="0"/>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}KeyInfo" minOccurs="0"/>
+ * <element ref="{http://www.w3.org/2001/04/xmlenc#}CipherData"/>
+ * <element ref="{http://www.w3.org/2001/04/xmlenc#}EncryptionProperties" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * <attribute name="Type" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * <attribute name="MimeType" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="Encoding" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "EncryptedType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "encryptionMethod",
+ "keyInfo",
+ "cipherData",
+ "encryptionProperties"
+})
+@XmlSeeAlso({
+ EncryptedDataType.class,
+ EncryptedKeyType.class
+})
+public abstract class EncryptedType {
+
+ @XmlElement(name = "EncryptionMethod", namespace = "http://www.w3.org/2001/04/xmlenc#")
+ protected EncryptionMethodType encryptionMethod;
+ @XmlElement(name = "KeyInfo", namespace = "http://www.w3.org/2000/09/xmldsig#")
+ protected KeyInfoType keyInfo;
+ @XmlElement(name = "CipherData", namespace = "http://www.w3.org/2001/04/xmlenc#", required = true)
+ protected CipherDataType cipherData;
+ @XmlElement(name = "EncryptionProperties", namespace = "http://www.w3.org/2001/04/xmlenc#")
+ protected EncryptionPropertiesType encryptionProperties;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+ @XmlAttribute(name = "Type")
+ @XmlSchemaType(name = "anyURI")
+ protected String type;
+ @XmlAttribute(name = "MimeType")
+ protected String mimeType;
+ @XmlAttribute(name = "Encoding")
+ @XmlSchemaType(name = "anyURI")
+ protected String encoding;
+
+ /**
+ * Gets the value of the encryptionMethod property.
+ *
+ * @return
+ * possible object is
+ * {@link EncryptionMethodType }
+ *
+ */
+ public EncryptionMethodType getEncryptionMethod() {
+ return encryptionMethod;
+ }
+
+ /**
+ * Sets the value of the encryptionMethod property.
+ *
+ * @param value
+ * allowed object is
+ * {@link EncryptionMethodType }
+ *
+ */
+ public void setEncryptionMethod(EncryptionMethodType value) {
+ this.encryptionMethod = value;
+ }
+
+ /**
+ * Gets the value of the keyInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link KeyInfoType }
+ *
+ */
+ public KeyInfoType getKeyInfo() {
+ return keyInfo;
+ }
+
+ /**
+ * Sets the value of the keyInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link KeyInfoType }
+ *
+ */
+ public void setKeyInfo(KeyInfoType value) {
+ this.keyInfo = value;
+ }
+
+ /**
+ * Gets the value of the cipherData property.
+ *
+ * @return
+ * possible object is
+ * {@link CipherDataType }
+ *
+ */
+ public CipherDataType getCipherData() {
+ return cipherData;
+ }
+
+ /**
+ * Sets the value of the cipherData property.
+ *
+ * @param value
+ * allowed object is
+ * {@link CipherDataType }
+ *
+ */
+ public void setCipherData(CipherDataType value) {
+ this.cipherData = value;
+ }
+
+ /**
+ * Gets the value of the encryptionProperties property.
+ *
+ * @return
+ * possible object is
+ * {@link EncryptionPropertiesType }
+ *
+ */
+ public EncryptionPropertiesType getEncryptionProperties() {
+ return encryptionProperties;
+ }
+
+ /**
+ * Sets the value of the encryptionProperties property.
+ *
+ * @param value
+ * allowed object is
+ * {@link EncryptionPropertiesType }
+ *
+ */
+ public void setEncryptionProperties(EncryptionPropertiesType value) {
+ this.encryptionProperties = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setType(String value) {
+ this.type = value;
+ }
+
+ /**
+ * Gets the value of the mimeType property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMimeType() {
+ return mimeType;
+ }
+
+ /**
+ * Sets the value of the mimeType property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMimeType(String value) {
+ this.mimeType = value;
+ }
+
+ /**
+ * Gets the value of the encoding property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getEncoding() {
+ return encoding;
+ }
+
+ /**
+ * Sets the value of the encoding property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setEncoding(String value) {
+ this.encoding = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionMethodType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionMethodType.java
new file mode 100644
index 0000000..a0629b3
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionMethodType.java
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for EncryptionMethodType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="EncryptionMethodType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="KeySize" type="{http://www.w3.org/2001/04/xmlenc#}KeySizeType" minOccurs="0"/>
+ * <element name="OAEPparams" type="{http://www.w3.org/2001/XMLSchema}base64Binary" minOccurs="0"/>
+ * <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "EncryptionMethodType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "content"
+})
+public class EncryptionMethodType {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "KeySize", namespace = "http://www.w3.org/2001/04/xmlenc#", type = JAXBElement.class),
+ @XmlElementRef(name = "OAEPparams", namespace = "http://www.w3.org/2001/04/xmlenc#", type = JAXBElement.class)
+ })
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
+ * {@link Object }
+ * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionPropertiesType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionPropertiesType.java
new file mode 100644
index 0000000..e83f13f
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionPropertiesType.java
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+
+/**
+ * <p>Java class for EncryptionPropertiesType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="EncryptionPropertiesType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2001/04/xmlenc#}EncryptionProperty" maxOccurs="unbounded"/>
+ * </sequence>
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "EncryptionPropertiesType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "encryptionProperty"
+})
+public class EncryptionPropertiesType {
+
+ @XmlElement(name = "EncryptionProperty", namespace = "http://www.w3.org/2001/04/xmlenc#", required = true)
+ protected List<EncryptionPropertyType> encryptionProperty;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+
+ /**
+ * Gets the value of the encryptionProperty property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the encryptionProperty property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getEncryptionProperty().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link EncryptionPropertyType }
+ *
+ *
+ */
+ public List<EncryptionPropertyType> getEncryptionProperty() {
+ if (encryptionProperty == null) {
+ encryptionProperty = new ArrayList<EncryptionPropertyType>();
+ }
+ return this.encryptionProperty;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionPropertyType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionPropertyType.java
new file mode 100644
index 0000000..fd9b02a
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/EncryptionPropertyType.java
@@ -0,0 +1,187 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.namespace.QName;
+import org.w3c.dom.Element;
+
+
+/**
+ * <p>Java class for EncryptionPropertyType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="EncryptionPropertyType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded">
+ * <any processContents='lax' namespace='##other'/>
+ * </choice>
+ * <attribute name="Target" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * <anyAttribute namespace='http://www.w3.org/XML/1998/namespace'/>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "EncryptionPropertyType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "content"
+})
+public class EncryptionPropertyType {
+
+ @XmlMixed
+ @XmlAnyElement(lax = true)
+ protected List<Object> content;
+ @XmlAttribute(name = "Target")
+ @XmlSchemaType(name = "anyURI")
+ protected String target;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+ @XmlAnyAttribute
+ private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ /**
+ * Gets the value of the content property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the content property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContent().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ * {@link Object }
+ * {@link Element }
+ *
+ *
+ */
+ public List<Object> getContent() {
+ if (content == null) {
+ content = new ArrayList<Object>();
+ }
+ return this.content;
+ }
+
+ /**
+ * Gets the value of the target property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTarget() {
+ return target;
+ }
+
+ /**
+ * Sets the value of the target property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTarget(String value) {
+ this.target = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+ /**
+ * Gets a map that contains attributes that aren't bound to any typed property on this class.
+ *
+ * <p>
+ * the map is keyed by the name of the attribute and
+ * the value is the string value of the attribute.
+ *
+ * the map returned by this method is live, and you can add new attribute
+ * by updating the map directly. Because of this design, there's no setter.
+ *
+ *
+ * @return
+ * always non-null
+ */
+ public Map<QName, String> getOtherAttributes() {
+ return otherAttributes;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/ObjectFactory.java b/src/main/java/org/apache/xml/security/binding/xmlenc/ObjectFactory.java
new file mode 100644
index 0000000..44f35fb
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/ObjectFactory.java
@@ -0,0 +1,308 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2018.04.30 at 05:36:51 PM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.math.BigInteger;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+import org.apache.xml.security.binding.xmldsig.KeyInfoType;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.xml.security.binding.xmlenc package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _CipherData_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "CipherData");
+ private final static QName _CipherValue_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "CipherValue");
+ private final static QName _CipherReference_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "CipherReference");
+ private final static QName _EncryptedData_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "EncryptedData");
+ private final static QName _EncryptedKey_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "EncryptedKey");
+ private final static QName _AgreementMethod_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "AgreementMethod");
+ private final static QName _EncryptionProperties_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "EncryptionProperties");
+ private final static QName _EncryptionProperty_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "EncryptionProperty");
+ private final static QName _ReferenceListDataReference_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "DataReference");
+ private final static QName _ReferenceListKeyReference_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "KeyReference");
+ private final static QName _EncryptionMethodTypeKeySize_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "KeySize");
+ private final static QName _EncryptionMethodTypeOAEPparams_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "OAEPparams");
+ private final static QName _AgreementMethodTypeKANonce_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "KA-Nonce");
+ private final static QName _AgreementMethodTypeOriginatorKeyInfo_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "OriginatorKeyInfo");
+ private final static QName _AgreementMethodTypeRecipientKeyInfo_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "RecipientKeyInfo");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.xml.security.binding.xmlenc
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link CipherDataType }
+ *
+ */
+ public CipherDataType createCipherDataType() {
+ return new CipherDataType();
+ }
+
+ /**
+ * Create an instance of {@link CipherValueType }
+ *
+ */
+ public CipherValueType createCipherValueType() {
+ return new CipherValueType();
+ }
+
+ /**
+ * Create an instance of {@link CipherReferenceType }
+ *
+ */
+ public CipherReferenceType createCipherReferenceType() {
+ return new CipherReferenceType();
+ }
+
+ /**
+ * Create an instance of {@link EncryptedDataType }
+ *
+ */
+ public EncryptedDataType createEncryptedDataType() {
+ return new EncryptedDataType();
+ }
+
+ /**
+ * Create an instance of {@link EncryptedKeyType }
+ *
+ */
+ public EncryptedKeyType createEncryptedKeyType() {
+ return new EncryptedKeyType();
+ }
+
+ /**
+ * Create an instance of {@link AgreementMethodType }
+ *
+ */
+ public AgreementMethodType createAgreementMethodType() {
+ return new AgreementMethodType();
+ }
+
+ /**
+ * Create an instance of {@link ReferenceList }
+ *
+ */
+ public ReferenceList createReferenceList() {
+ return new ReferenceList();
+ }
+
+ /**
+ * Create an instance of {@link ReferenceType }
+ *
+ */
+ public ReferenceType createReferenceType() {
+ return new ReferenceType();
+ }
+
+ /**
+ * Create an instance of {@link EncryptionPropertiesType }
+ *
+ */
+ public EncryptionPropertiesType createEncryptionPropertiesType() {
+ return new EncryptionPropertiesType();
+ }
+
+ /**
+ * Create an instance of {@link EncryptionPropertyType }
+ *
+ */
+ public EncryptionPropertyType createEncryptionPropertyType() {
+ return new EncryptionPropertyType();
+ }
+
+ /**
+ * Create an instance of {@link EncryptionMethodType }
+ *
+ */
+ public EncryptionMethodType createEncryptionMethodType() {
+ return new EncryptionMethodType();
+ }
+
+ /**
+ * Create an instance of {@link TransformsType }
+ *
+ */
+ public TransformsType createTransformsType() {
+ return new TransformsType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CipherDataType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "CipherData")
+ public JAXBElement<CipherDataType> createCipherData(CipherDataType value) {
+ return new JAXBElement<CipherDataType>(_CipherData_QNAME, CipherDataType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CipherValueType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "CipherValue")
+ public JAXBElement<CipherValueType> createCipherValue(CipherValueType value) {
+ return new JAXBElement<CipherValueType>(_CipherValue_QNAME, CipherValueType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link CipherReferenceType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "CipherReference")
+ public JAXBElement<CipherReferenceType> createCipherReference(CipherReferenceType value) {
+ return new JAXBElement<CipherReferenceType>(_CipherReference_QNAME, CipherReferenceType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link EncryptedDataType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "EncryptedData")
+ public JAXBElement<EncryptedDataType> createEncryptedData(EncryptedDataType value) {
+ return new JAXBElement<EncryptedDataType>(_EncryptedData_QNAME, EncryptedDataType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link EncryptedKeyType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "EncryptedKey")
+ public JAXBElement<EncryptedKeyType> createEncryptedKey(EncryptedKeyType value) {
+ return new JAXBElement<EncryptedKeyType>(_EncryptedKey_QNAME, EncryptedKeyType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link AgreementMethodType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "AgreementMethod")
+ public JAXBElement<AgreementMethodType> createAgreementMethod(AgreementMethodType value) {
+ return new JAXBElement<AgreementMethodType>(_AgreementMethod_QNAME, AgreementMethodType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link EncryptionPropertiesType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "EncryptionProperties")
+ public JAXBElement<EncryptionPropertiesType> createEncryptionProperties(EncryptionPropertiesType value) {
+ return new JAXBElement<EncryptionPropertiesType>(_EncryptionProperties_QNAME, EncryptionPropertiesType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link EncryptionPropertyType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "EncryptionProperty")
+ public JAXBElement<EncryptionPropertyType> createEncryptionProperty(EncryptionPropertyType value) {
+ return new JAXBElement<EncryptionPropertyType>(_EncryptionProperty_QNAME, EncryptionPropertyType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ReferenceType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "DataReference", scope = ReferenceList.class)
+ public JAXBElement<ReferenceType> createReferenceListDataReference(ReferenceType value) {
+ return new JAXBElement<ReferenceType>(_ReferenceListDataReference_QNAME, ReferenceType.class, ReferenceList.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ReferenceType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "KeyReference", scope = ReferenceList.class)
+ public JAXBElement<ReferenceType> createReferenceListKeyReference(ReferenceType value) {
+ return new JAXBElement<ReferenceType>(_ReferenceListKeyReference_QNAME, ReferenceType.class, ReferenceList.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link BigInteger }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "KeySize", scope = EncryptionMethodType.class)
+ public JAXBElement<BigInteger> createEncryptionMethodTypeKeySize(BigInteger value) {
+ return new JAXBElement<BigInteger>(_EncryptionMethodTypeKeySize_QNAME, BigInteger.class, EncryptionMethodType.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "OAEPparams", scope = EncryptionMethodType.class)
+ public JAXBElement<byte[]> createEncryptionMethodTypeOAEPparams(byte[] value) {
+ return new JAXBElement<byte[]>(_EncryptionMethodTypeOAEPparams_QNAME, byte[].class, EncryptionMethodType.class, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "KA-Nonce", scope = AgreementMethodType.class)
+ public JAXBElement<byte[]> createAgreementMethodTypeKANonce(byte[] value) {
+ return new JAXBElement<byte[]>(_AgreementMethodTypeKANonce_QNAME, byte[].class, AgreementMethodType.class, ((byte[]) value));
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link KeyInfoType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "OriginatorKeyInfo", scope = AgreementMethodType.class)
+ public JAXBElement<KeyInfoType> createAgreementMethodTypeOriginatorKeyInfo(KeyInfoType value) {
+ return new JAXBElement<KeyInfoType>(_AgreementMethodTypeOriginatorKeyInfo_QNAME, KeyInfoType.class, AgreementMethodType.class, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link KeyInfoType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2001/04/xmlenc#", name = "RecipientKeyInfo", scope = AgreementMethodType.class)
+ public JAXBElement<KeyInfoType> createAgreementMethodTypeRecipientKeyInfo(KeyInfoType value) {
+ return new JAXBElement<KeyInfoType>(_AgreementMethodTypeRecipientKeyInfo_QNAME, KeyInfoType.class, AgreementMethodType.class, value);
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/ReferenceList.java b/src/main/java/org/apache/xml/security/binding/xmlenc/ReferenceList.java
new file mode 100644
index 0000000..e7e54ce
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/ReferenceList.java
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded">
+ * <element name="DataReference" type="{http://www.w3.org/2001/04/xmlenc#}ReferenceType"/>
+ * <element name="KeyReference" type="{http://www.w3.org/2001/04/xmlenc#}ReferenceType"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "dataReferenceOrKeyReference"
+})
+@XmlRootElement(name = "ReferenceList", namespace = "http://www.w3.org/2001/04/xmlenc#")
+public class ReferenceList {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "DataReference", namespace = "http://www.w3.org/2001/04/xmlenc#", type = JAXBElement.class),
+ @XmlElementRef(name = "KeyReference", namespace = "http://www.w3.org/2001/04/xmlenc#", type = JAXBElement.class)
+ })
+ protected List<JAXBElement<ReferenceType>> dataReferenceOrKeyReference;
+
+ /**
+ * Gets the value of the dataReferenceOrKeyReference property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the dataReferenceOrKeyReference property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getDataReferenceOrKeyReference().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link ReferenceType }{@code >}
+ * {@link JAXBElement }{@code <}{@link ReferenceType }{@code >}
+ *
+ *
+ */
+ public List<JAXBElement<ReferenceType>> getDataReferenceOrKeyReference() {
+ if (dataReferenceOrKeyReference == null) {
+ dataReferenceOrKeyReference = new ArrayList<JAXBElement<ReferenceType>>();
+ }
+ return this.dataReferenceOrKeyReference;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/ReferenceType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/ReferenceType.java
new file mode 100644
index 0000000..774d0cc
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/ReferenceType.java
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ReferenceType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ReferenceType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="URI" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ReferenceType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "any"
+})
+public class ReferenceType {
+
+ @XmlAnyElement(lax = true)
+ protected List<Object> any;
+ @XmlAttribute(name = "URI", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String uri;
+
+ /**
+ * Gets the value of the any property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the any property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAny().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Object }
+ *
+ *
+ */
+ public List<Object> getAny() {
+ if (any == null) {
+ any = new ArrayList<Object>();
+ }
+ return this.any;
+ }
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc/TransformsType.java b/src/main/java/org/apache/xml/security/binding/xmlenc/TransformsType.java
new file mode 100644
index 0000000..77e85c9
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc/TransformsType.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import org.apache.xml.security.binding.xmldsig.TransformType;
+
+
+/**
+ * <p>Java class for TransformsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="TransformsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}Transform" maxOccurs="unbounded"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TransformsType", namespace = "http://www.w3.org/2001/04/xmlenc#", propOrder = {
+ "transform"
+})
+public class TransformsType {
+
+ @XmlElement(name = "Transform", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected List<TransformType> transform;
+
+ /**
+ * Gets the value of the transform property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the transform property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getTransform().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link TransformType }
+ *
+ *
+ */
+ public List<TransformType> getTransform() {
+ if (transform == null) {
+ transform = new ArrayList<TransformType>();
+ }
+ return this.transform;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc11/AlgorithmIdentifierType.java b/src/main/java/org/apache/xml/security/binding/xmlenc11/AlgorithmIdentifierType.java
new file mode 100644
index 0000000..a6b5f8c
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc11/AlgorithmIdentifierType.java
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for AlgorithmIdentifierType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="AlgorithmIdentifierType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Parameters" type="{http://www.w3.org/2001/XMLSchema}anyType" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "AlgorithmIdentifierType", namespace = "http://www.w3.org/2009/xmlenc11#", propOrder = {
+ "parameters"
+})
+@XmlSeeAlso({
+ MGFType.class,
+ PRFAlgorithmIdentifierType.class
+})
+public class AlgorithmIdentifierType {
+
+ @XmlElement(name = "Parameters", namespace = "http://www.w3.org/2009/xmlenc11#")
+ protected Object parameters;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the parameters property.
+ *
+ * @return
+ * possible object is
+ * {@link Object }
+ *
+ */
+ public Object getParameters() {
+ return parameters;
+ }
+
+ /**
+ * Sets the value of the parameters property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Object }
+ *
+ */
+ public void setParameters(Object value) {
+ this.parameters = value;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc11/ConcatKDFParamsType.java b/src/main/java/org/apache/xml/security/binding/xmlenc11/ConcatKDFParamsType.java
new file mode 100644
index 0000000..b9dcaf4
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc11/ConcatKDFParamsType.java
@@ -0,0 +1,237 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.xml.security.binding.xmldsig.DigestMethodType;
+
+
+/**
+ * <p>Java class for ConcatKDFParamsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ConcatKDFParamsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2000/09/xmldsig#}DigestMethod"/>
+ * </sequence>
+ * <attribute name="AlgorithmID" type="{http://www.w3.org/2001/XMLSchema}hexBinary" />
+ * <attribute name="PartyUInfo" type="{http://www.w3.org/2001/XMLSchema}hexBinary" />
+ * <attribute name="PartyVInfo" type="{http://www.w3.org/2001/XMLSchema}hexBinary" />
+ * <attribute name="SuppPubInfo" type="{http://www.w3.org/2001/XMLSchema}hexBinary" />
+ * <attribute name="SuppPrivInfo" type="{http://www.w3.org/2001/XMLSchema}hexBinary" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ConcatKDFParamsType", namespace = "http://www.w3.org/2009/xmlenc11#", propOrder = {
+ "digestMethod"
+})
+public class ConcatKDFParamsType {
+
+ @XmlElement(name = "DigestMethod", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
+ protected DigestMethodType digestMethod;
+ @XmlAttribute(name = "AlgorithmID")
+ @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+ @XmlSchemaType(name = "hexBinary")
+ protected byte[] algorithmID;
+ @XmlAttribute(name = "PartyUInfo")
+ @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+ @XmlSchemaType(name = "hexBinary")
+ protected byte[] partyUInfo;
+ @XmlAttribute(name = "PartyVInfo")
+ @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+ @XmlSchemaType(name = "hexBinary")
+ protected byte[] partyVInfo;
+ @XmlAttribute(name = "SuppPubInfo")
+ @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+ @XmlSchemaType(name = "hexBinary")
+ protected byte[] suppPubInfo;
+ @XmlAttribute(name = "SuppPrivInfo")
+ @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+ @XmlSchemaType(name = "hexBinary")
+ protected byte[] suppPrivInfo;
+
+ /**
+ * Gets the value of the digestMethod property.
+ *
+ * @return
+ * possible object is
+ * {@link DigestMethodType }
+ *
+ */
+ public DigestMethodType getDigestMethod() {
+ return digestMethod;
+ }
+
+ /**
+ * Sets the value of the digestMethod property.
+ *
+ * @param value
+ * allowed object is
+ * {@link DigestMethodType }
+ *
+ */
+ public void setDigestMethod(DigestMethodType value) {
+ this.digestMethod = value;
+ }
+
+ /**
+ * Gets the value of the algorithmID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public byte[] getAlgorithmID() {
+ return algorithmID;
+ }
+
+ /**
+ * Sets the value of the algorithmID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithmID(byte[] value) {
+ this.algorithmID = value;
+ }
+
+ /**
+ * Gets the value of the partyUInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public byte[] getPartyUInfo() {
+ return partyUInfo;
+ }
+
+ /**
+ * Sets the value of the partyUInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setPartyUInfo(byte[] value) {
+ this.partyUInfo = value;
+ }
+
+ /**
+ * Gets the value of the partyVInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public byte[] getPartyVInfo() {
+ return partyVInfo;
+ }
+
+ /**
+ * Sets the value of the partyVInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setPartyVInfo(byte[] value) {
+ this.partyVInfo = value;
+ }
+
+ /**
+ * Gets the value of the suppPubInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public byte[] getSuppPubInfo() {
+ return suppPubInfo;
+ }
+
+ /**
+ * Sets the value of the suppPubInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSuppPubInfo(byte[] value) {
+ this.suppPubInfo = value;
+ }
+
+ /**
+ * Gets the value of the suppPrivInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public byte[] getSuppPrivInfo() {
+ return suppPrivInfo;
+ }
+
+ /**
+ * Sets the value of the suppPrivInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSuppPrivInfo(byte[] value) {
+ this.suppPrivInfo = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc11/DerivedKeyType.java b/src/main/java/org/apache/xml/security/binding/xmlenc11/DerivedKeyType.java
new file mode 100644
index 0000000..5c746be
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc11/DerivedKeyType.java
@@ -0,0 +1,262 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.apache.xml.security.binding.xmlenc.ReferenceList;
+
+
+/**
+ * <p>Java class for DerivedKeyType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="DerivedKeyType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{http://www.w3.org/2009/xmlenc11#}KeyDerivationMethod" minOccurs="0"/>
+ * <element ref="{http://www.w3.org/2001/04/xmlenc#}ReferenceList" minOccurs="0"/>
+ * <element name="DerivedKeyName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * <element name="MasterKeyName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Recipient" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
+ * <attribute name="Type" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "DerivedKeyType", namespace = "http://www.w3.org/2009/xmlenc11#", propOrder = {
+ "keyDerivationMethod",
+ "referenceList",
+ "derivedKeyName",
+ "masterKeyName"
+})
+public class DerivedKeyType {
+
+ @XmlElement(name = "KeyDerivationMethod", namespace = "http://www.w3.org/2009/xmlenc11#")
+ protected KeyDerivationMethodType keyDerivationMethod;
+ @XmlElement(name = "ReferenceList", namespace = "http://www.w3.org/2001/04/xmlenc#")
+ protected ReferenceList referenceList;
+ @XmlElement(name = "DerivedKeyName", namespace = "http://www.w3.org/2009/xmlenc11#")
+ protected String derivedKeyName;
+ @XmlElement(name = "MasterKeyName", namespace = "http://www.w3.org/2009/xmlenc11#")
+ protected String masterKeyName;
+ @XmlAttribute(name = "Recipient")
+ protected String recipient;
+ @XmlAttribute(name = "Id")
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
+ @XmlSchemaType(name = "ID")
+ protected String id;
+ @XmlAttribute(name = "Type")
+ @XmlSchemaType(name = "anyURI")
+ protected String type;
+
+ /**
+ * Gets the value of the keyDerivationMethod property.
+ *
+ * @return
+ * possible object is
+ * {@link KeyDerivationMethodType }
+ *
+ */
+ public KeyDerivationMethodType getKeyDerivationMethod() {
+ return keyDerivationMethod;
+ }
+
+ /**
+ * Sets the value of the keyDerivationMethod property.
+ *
+ * @param value
+ * allowed object is
+ * {@link KeyDerivationMethodType }
+ *
+ */
+ public void setKeyDerivationMethod(KeyDerivationMethodType value) {
+ this.keyDerivationMethod = value;
+ }
+
+ /**
+ * Gets the value of the referenceList property.
+ *
+ * @return
+ * possible object is
+ * {@link ReferenceList }
+ *
+ */
+ public ReferenceList getReferenceList() {
+ return referenceList;
+ }
+
+ /**
+ * Sets the value of the referenceList property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ReferenceList }
+ *
+ */
+ public void setReferenceList(ReferenceList value) {
+ this.referenceList = value;
+ }
+
+ /**
+ * Gets the value of the derivedKeyName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getDerivedKeyName() {
+ return derivedKeyName;
+ }
+
+ /**
+ * Sets the value of the derivedKeyName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setDerivedKeyName(String value) {
+ this.derivedKeyName = value;
+ }
+
+ /**
+ * Gets the value of the masterKeyName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMasterKeyName() {
+ return masterKeyName;
+ }
+
+ /**
+ * Sets the value of the masterKeyName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMasterKeyName(String value) {
+ this.masterKeyName = value;
+ }
+
+ /**
+ * Gets the value of the recipient property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getRecipient() {
+ return recipient;
+ }
+
+ /**
+ * Sets the value of the recipient property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setRecipient(String value) {
+ this.recipient = value;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setId(String value) {
+ this.id = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setType(String value) {
+ this.type = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc11/KeyDerivationMethodType.java b/src/main/java/org/apache/xml/security/binding/xmlenc11/KeyDerivationMethodType.java
new file mode 100644
index 0000000..9242fdb
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc11/KeyDerivationMethodType.java
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc11;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for KeyDerivationMethodType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="KeyDerivationMethodType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <any maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "KeyDerivationMethodType", namespace = "http://www.w3.org/2009/xmlenc11#", propOrder = {
+ "any"
+})
+public class KeyDerivationMethodType {
+
+ @XmlAnyElement(lax = true)
+ protected List<Object> any;
+ @XmlAttribute(name = "Algorithm", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String algorithm;
+
+ /**
+ * Gets the value of the any property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the any property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAny().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Object }
+ *
+ *
+ */
+ public List<Object> getAny() {
+ if (any == null) {
+ any = new ArrayList<Object>();
+ }
+ return this.any;
+ }
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithm() {
+ return algorithm;
+ }
+
+ /**
+ * Sets the value of the algorithm property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithm(String value) {
+ this.algorithm = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc11/MGFType.java b/src/main/java/org/apache/xml/security/binding/xmlenc11/MGFType.java
new file mode 100644
index 0000000..dec10a4
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc11/MGFType.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for MGFType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="MGFType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2009/xmlenc11#}AlgorithmIdentifierType">
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "MGFType", namespace = "http://www.w3.org/2009/xmlenc11#")
+public class MGFType
+ extends AlgorithmIdentifierType
+{
+
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc11/ObjectFactory.java b/src/main/java/org/apache/xml/security/binding/xmlenc11/ObjectFactory.java
new file mode 100644
index 0000000..53b08fd
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc11/ObjectFactory.java
@@ -0,0 +1,174 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc11;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.xml.security.binding.xmlenc11 package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _ConcatKDFParams_QNAME = new QName("http://www.w3.org/2009/xmlenc11#", "ConcatKDFParams");
+ private final static QName _DerivedKey_QNAME = new QName("http://www.w3.org/2009/xmlenc11#", "DerivedKey");
+ private final static QName _KeyDerivationMethod_QNAME = new QName("http://www.w3.org/2009/xmlenc11#", "KeyDerivationMethod");
+ private final static QName _PBKDF2Params_QNAME = new QName("http://www.w3.org/2009/xmlenc11#", "PBKDF2-params");
+ private final static QName _MGF_QNAME = new QName("http://www.w3.org/2009/xmlenc11#", "MGF");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.xml.security.binding.xmlenc11
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link PBKDF2ParameterType }
+ *
+ */
+ public PBKDF2ParameterType createPBKDF2ParameterType() {
+ return new PBKDF2ParameterType();
+ }
+
+ /**
+ * Create an instance of {@link ConcatKDFParamsType }
+ *
+ */
+ public ConcatKDFParamsType createConcatKDFParamsType() {
+ return new ConcatKDFParamsType();
+ }
+
+ /**
+ * Create an instance of {@link DerivedKeyType }
+ *
+ */
+ public DerivedKeyType createDerivedKeyType() {
+ return new DerivedKeyType();
+ }
+
+ /**
+ * Create an instance of {@link KeyDerivationMethodType }
+ *
+ */
+ public KeyDerivationMethodType createKeyDerivationMethodType() {
+ return new KeyDerivationMethodType();
+ }
+
+ /**
+ * Create an instance of {@link MGFType }
+ *
+ */
+ public MGFType createMGFType() {
+ return new MGFType();
+ }
+
+ /**
+ * Create an instance of {@link AlgorithmIdentifierType }
+ *
+ */
+ public AlgorithmIdentifierType createAlgorithmIdentifierType() {
+ return new AlgorithmIdentifierType();
+ }
+
+ /**
+ * Create an instance of {@link PRFAlgorithmIdentifierType }
+ *
+ */
+ public PRFAlgorithmIdentifierType createPRFAlgorithmIdentifierType() {
+ return new PRFAlgorithmIdentifierType();
+ }
+
+ /**
+ * Create an instance of {@link PBKDF2ParameterType.Salt }
+ *
+ */
+ public PBKDF2ParameterType.Salt createPBKDF2ParameterTypeSalt() {
+ return new PBKDF2ParameterType.Salt();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ConcatKDFParamsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmlenc11#", name = "ConcatKDFParams")
+ public JAXBElement<ConcatKDFParamsType> createConcatKDFParams(ConcatKDFParamsType value) {
+ return new JAXBElement<ConcatKDFParamsType>(_ConcatKDFParams_QNAME, ConcatKDFParamsType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link DerivedKeyType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmlenc11#", name = "DerivedKey")
+ public JAXBElement<DerivedKeyType> createDerivedKey(DerivedKeyType value) {
+ return new JAXBElement<DerivedKeyType>(_DerivedKey_QNAME, DerivedKeyType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link KeyDerivationMethodType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmlenc11#", name = "KeyDerivationMethod")
+ public JAXBElement<KeyDerivationMethodType> createKeyDerivationMethod(KeyDerivationMethodType value) {
+ return new JAXBElement<KeyDerivationMethodType>(_KeyDerivationMethod_QNAME, KeyDerivationMethodType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link PBKDF2ParameterType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmlenc11#", name = "PBKDF2-params")
+ public JAXBElement<PBKDF2ParameterType> createPBKDF2Params(PBKDF2ParameterType value) {
+ return new JAXBElement<PBKDF2ParameterType>(_PBKDF2Params_QNAME, PBKDF2ParameterType.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link MGFType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2009/xmlenc11#", name = "MGF")
+ public JAXBElement<MGFType> createMGF(MGFType value) {
+ return new JAXBElement<MGFType>(_MGF_QNAME, MGFType.class, null, value);
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc11/PBKDF2ParameterType.java b/src/main/java/org/apache/xml/security/binding/xmlenc11/PBKDF2ParameterType.java
new file mode 100644
index 0000000..ae3495b
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc11/PBKDF2ParameterType.java
@@ -0,0 +1,267 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc11;
+
+import java.math.BigInteger;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for PBKDF2ParameterType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="PBKDF2ParameterType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Salt">
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice>
+ * <element name="Specified" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * <element name="OtherSource" type="{http://www.w3.org/2009/xmlenc11#}AlgorithmIdentifierType"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </element>
+ * <element name="IterationCount" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
+ * <element name="KeyLength" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
+ * <element name="PRF" type="{http://www.w3.org/2009/xmlenc11#}PRFAlgorithmIdentifierType"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "PBKDF2ParameterType", namespace = "http://www.w3.org/2009/xmlenc11#", propOrder = {
+ "salt",
+ "iterationCount",
+ "keyLength",
+ "prf"
+})
+public class PBKDF2ParameterType {
+
+ @XmlElement(name = "Salt", namespace = "http://www.w3.org/2009/xmlenc11#", required = true)
+ protected PBKDF2ParameterType.Salt salt;
+ @XmlElement(name = "IterationCount", namespace = "http://www.w3.org/2009/xmlenc11#", required = true)
+ @XmlSchemaType(name = "positiveInteger")
+ protected BigInteger iterationCount;
+ @XmlElement(name = "KeyLength", namespace = "http://www.w3.org/2009/xmlenc11#", required = true)
+ @XmlSchemaType(name = "positiveInteger")
+ protected BigInteger keyLength;
+ @XmlElement(name = "PRF", namespace = "http://www.w3.org/2009/xmlenc11#", required = true)
+ protected PRFAlgorithmIdentifierType prf;
+
+ /**
+ * Gets the value of the salt property.
+ *
+ * @return
+ * possible object is
+ * {@link PBKDF2ParameterType.Salt }
+ *
+ */
+ public PBKDF2ParameterType.Salt getSalt() {
+ return salt;
+ }
+
+ /**
+ * Sets the value of the salt property.
+ *
+ * @param value
+ * allowed object is
+ * {@link PBKDF2ParameterType.Salt }
+ *
+ */
+ public void setSalt(PBKDF2ParameterType.Salt value) {
+ this.salt = value;
+ }
+
+ /**
+ * Gets the value of the iterationCount property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getIterationCount() {
+ return iterationCount;
+ }
+
+ /**
+ * Sets the value of the iterationCount property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setIterationCount(BigInteger value) {
+ this.iterationCount = value;
+ }
+
+ /**
+ * Gets the value of the keyLength property.
+ *
+ * @return
+ * possible object is
+ * {@link BigInteger }
+ *
+ */
+ public BigInteger getKeyLength() {
+ return keyLength;
+ }
+
+ /**
+ * Sets the value of the keyLength property.
+ *
+ * @param value
+ * allowed object is
+ * {@link BigInteger }
+ *
+ */
+ public void setKeyLength(BigInteger value) {
+ this.keyLength = value;
+ }
+
+ /**
+ * Gets the value of the prf property.
+ *
+ * @return
+ * possible object is
+ * {@link PRFAlgorithmIdentifierType }
+ *
+ */
+ public PRFAlgorithmIdentifierType getPRF() {
+ return prf;
+ }
+
+ /**
+ * Sets the value of the prf property.
+ *
+ * @param value
+ * allowed object is
+ * {@link PRFAlgorithmIdentifierType }
+ *
+ */
+ public void setPRF(PRFAlgorithmIdentifierType value) {
+ this.prf = value;
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice>
+ * <element name="Specified" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ * <element name="OtherSource" type="{http://www.w3.org/2009/xmlenc11#}AlgorithmIdentifierType"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "specified",
+ "otherSource"
+ })
+ public static class Salt {
+
+ @XmlElement(name = "Specified", namespace = "http://www.w3.org/2009/xmlenc11#")
+ protected byte[] specified;
+ @XmlElement(name = "OtherSource", namespace = "http://www.w3.org/2009/xmlenc11#")
+ protected AlgorithmIdentifierType otherSource;
+
+ /**
+ * Gets the value of the specified property.
+ *
+ * @return
+ * possible object is
+ * byte[]
+ */
+ public byte[] getSpecified() {
+ return specified;
+ }
+
+ /**
+ * Sets the value of the specified property.
+ *
+ * @param value
+ * allowed object is
+ * byte[]
+ */
+ public void setSpecified(byte[] value) {
+ this.specified = value;
+ }
+
+ /**
+ * Gets the value of the otherSource property.
+ *
+ * @return
+ * possible object is
+ * {@link AlgorithmIdentifierType }
+ *
+ */
+ public AlgorithmIdentifierType getOtherSource() {
+ return otherSource;
+ }
+
+ /**
+ * Sets the value of the otherSource property.
+ *
+ * @param value
+ * allowed object is
+ * {@link AlgorithmIdentifierType }
+ *
+ */
+ public void setOtherSource(AlgorithmIdentifierType value) {
+ this.otherSource = value;
+ }
+
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xmlenc11/PRFAlgorithmIdentifierType.java b/src/main/java/org/apache/xml/security/binding/xmlenc11/PRFAlgorithmIdentifierType.java
new file mode 100644
index 0000000..7cfa4f4
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xmlenc11/PRFAlgorithmIdentifierType.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.binding.xmlenc11;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for PRFAlgorithmIdentifierType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="PRFAlgorithmIdentifierType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2009/xmlenc11#}AlgorithmIdentifierType">
+ * <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "PRFAlgorithmIdentifierType", namespace = "http://www.w3.org/2009/xmlenc11#")
+public class PRFAlgorithmIdentifierType
+ extends AlgorithmIdentifierType
+{
+
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xop/Include.java b/src/main/java/org/apache/xml/security/binding/xop/Include.java
new file mode 100644
index 0000000..40d9694
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xop/Include.java
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2018.03.28 at 11:22:27 AM IST
+//
+
+
+package org.apache.xml.security.binding.xop;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+
+
+/**
+ * <p>Java class for Include complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="Include">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="href" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * <anyAttribute namespace='##other'/>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Include", namespace = "http://www.w3.org/2004/08/xop/include", propOrder = {
+ "any"
+})
+public class Include {
+
+ @XmlAnyElement(lax = true)
+ protected List<Object> any;
+ @XmlAttribute(name = "href", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String href;
+ @XmlAnyAttribute
+ private Map<QName, String> otherAttributes = new HashMap<QName, String>();
+
+ /**
+ * Gets the value of the any property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the any property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAny().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Object }
+ *
+ *
+ */
+ public List<Object> getAny() {
+ if (any == null) {
+ any = new ArrayList<Object>();
+ }
+ return this.any;
+ }
+
+ /**
+ * Gets the value of the href property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getHref() {
+ return href;
+ }
+
+ /**
+ * Sets the value of the href property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setHref(String value) {
+ this.href = value;
+ }
+
+ /**
+ * Gets a map that contains attributes that aren't bound to any typed property on this class.
+ *
+ * <p>
+ * the map is keyed by the name of the attribute and
+ * the value is the string value of the attribute.
+ *
+ * the map returned by this method is live, and you can add new attribute
+ * by updating the map directly. Because of this design, there's no setter.
+ *
+ *
+ * @return
+ * always non-null
+ */
+ public Map<QName, String> getOtherAttributes() {
+ return otherAttributes;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/binding/xop/ObjectFactory.java b/src/main/java/org/apache/xml/security/binding/xop/ObjectFactory.java
new file mode 100644
index 0000000..60ed3cf
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/binding/xop/ObjectFactory.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2018.03.28 at 11:22:27 AM IST
+//
+
+
+package org.apache.xml.security.binding.xop;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.xml.security.binding.xop package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _Include_QNAME = new QName("http://www.w3.org/2004/08/xop/include", "Include");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.xml.security.binding.xop
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link Include }
+ *
+ */
+ public Include createInclude() {
+ return new Include();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link Include }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.w3.org/2004/08/xop/include", name = "Include")
+ public JAXBElement<Include> createInclude(Include value) {
+ return new JAXBElement<Include>(_Include_QNAME, Include.class, null, value);
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/c14n/CanonicalizationException.java b/src/main/java/org/apache/xml/security/c14n/CanonicalizationException.java
index f81e56b..79ea4e8 100644
--- a/src/main/java/org/apache/xml/security/c14n/CanonicalizationException.java
+++ b/src/main/java/org/apache/xml/security/c14n/CanonicalizationException.java
@@ -58,7 +58,7 @@
* @param msgID
* @param exArgs
*/
- public CanonicalizationException(String msgID, Object[] exArgs) {
+ public CanonicalizationException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -85,13 +85,13 @@
* @param exArgs
*/
public CanonicalizationException(
- Exception originalException, String msgID, Object[] exArgs
+ Exception originalException, String msgID, Object exArgs[]
) {
super(originalException, msgID, exArgs);
}
@Deprecated
- public CanonicalizationException(String msgID, Object[] exArgs, Exception originalException) {
+ public CanonicalizationException(String msgID, Object exArgs[], Exception originalException) {
this(originalException, msgID, exArgs);
}
}
diff --git a/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java b/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java
index a0397e0..80d29b6 100644
--- a/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java
+++ b/src/main/java/org/apache/xml/security/c14n/Canonicalizer.java
@@ -26,6 +26,8 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.c14n.implementations.Canonicalizer11_OmitComments;
import org.apache.xml.security.c14n.implementations.Canonicalizer11_WithComments;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315ExclOmitComments;
@@ -45,7 +47,7 @@
/**
*
*/
-public final class Canonicalizer {
+public class Canonicalizer {
/** The output encoding of canonicalized data */
public static final String ENCODING = StandardCharsets.UTF_8.name();
@@ -94,7 +96,7 @@
"http://santuario.apache.org/c14n/physical";
private static Map<String, Class<? extends CanonicalizerSpi>> canonicalizerHash =
- new ConcurrentHashMap<>();
+ new ConcurrentHashMap<String, Class<? extends CanonicalizerSpi>>();
private final CanonicalizerSpi canonicalizerSpi;
private boolean secureValidation;
@@ -113,7 +115,7 @@
canonicalizerSpi = implementingClass.newInstance();
canonicalizerSpi.reset = true;
} catch (Exception e) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new InvalidCanonicalizerException(
e, "signature.Canonicalizer.UnknownCanonicalizer", exArgs
);
@@ -150,7 +152,7 @@
canonicalizerHash.get(algorithmURI);
if (registeredClass != null) {
- Object[] exArgs = { algorithmURI, registeredClass };
+ Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
}
@@ -176,7 +178,7 @@
Class<? extends CanonicalizerSpi> registeredClass = canonicalizerHash.get(algorithmURI);
if (registeredClass != null) {
- Object[] exArgs = { algorithmURI, registeredClass };
+ Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
}
@@ -254,7 +256,17 @@
try (InputStream bais = new ByteArrayInputStream(inputBytes)) {
InputSource in = new InputSource(bais);
+ // needs to validate for ID attribute normalization
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(true, secureValidation);
+
/*
+ * for some of the test vectors from the specification,
+ * there has to be a validating parser for ID attributes, default
+ * attribute values, NMTOKENS, etc.
+ * Unfortunately, the test vectors do use different DTDs or
+ * even no DTD. So Xerces 1.3.1 fires many warnings about using
+ * ErrorHandlers.
+ *
* Text from the spec:
*
* The input octet stream MUST contain a well-formed XML document,
@@ -268,7 +280,13 @@
* though the document type declaration is not retained in the
* canonical form.
*/
- document = XMLUtils.read(in, secureValidation);
+ db.setErrorHandler(new org.apache.xml.security.utils.IgnoreAllErrorHandler());
+
+ try {
+ document = db.parse(in);
+ } finally {
+ XMLUtils.repoolDocumentBuilder(db);
+ }
}
return this.canonicalizeSubtree(document);
}
diff --git a/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java b/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java
index be193eb..9f7c218 100644
--- a/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java
+++ b/src/main/java/org/apache/xml/security/c14n/CanonicalizerSpi.java
@@ -22,6 +22,8 @@
import java.io.OutputStream;
import java.util.Set;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -57,7 +59,13 @@
try (java.io.InputStream bais = new ByteArrayInputStream(inputBytes)) {
InputSource in = new InputSource(bais);
- document = XMLUtils.read(in, secureValidation);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false, secureValidation);
+
+ try {
+ document = db.parse(in);
+ } finally {
+ XMLUtils.repoolDocumentBuilder(db);
+ }
}
return this.engineCanonicalizeSubTree(document);
}
diff --git a/src/main/java/org/apache/xml/security/c14n/InvalidCanonicalizerException.java b/src/main/java/org/apache/xml/security/c14n/InvalidCanonicalizerException.java
index 04870d0..d4490d9 100644
--- a/src/main/java/org/apache/xml/security/c14n/InvalidCanonicalizerException.java
+++ b/src/main/java/org/apache/xml/security/c14n/InvalidCanonicalizerException.java
@@ -50,7 +50,7 @@
* @param msgID
* @param exArgs
*/
- public InvalidCanonicalizerException(String msgID, Object[] exArgs) {
+ public InvalidCanonicalizerException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -77,7 +77,7 @@
* @param exArgs
*/
public InvalidCanonicalizerException(
- Exception originalException, String msgID, Object[] exArgs
+ Exception originalException, String msgID, Object exArgs[]
) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java b/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java
index 68c3a24..a3697bb 100644
--- a/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java
+++ b/src/main/java/org/apache/xml/security/c14n/helper/C14nHelper.java
@@ -101,7 +101,7 @@
if ((definesDefaultNS || definesNonDefaultNS) && namespaceIsRelative(attr)) {
String parentName = attr.getOwnerElement().getTagName();
String attrValue = attr.getValue();
- Object[] exArgs = { parentName, nodeAttrName, attrValue };
+ Object exArgs[] = { parentName, nodeAttrName, attrValue };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs
@@ -119,7 +119,7 @@
public static void checkTraversability(Document document)
throws CanonicalizationException {
if (!document.isSupported("Traversal", "2.0")) {
- Object[] exArgs = {document.getImplementation().getClass().getName() };
+ Object exArgs[] = {document.getImplementation().getClass().getName() };
throw new CanonicalizationException(
"c14n.Canonicalizer.TraversalNotSupported", exArgs
diff --git a/src/main/java/org/apache/xml/security/c14n/implementations/Canonicalizer20010315.java b/src/main/java/org/apache/xml/security/c14n/implementations/Canonicalizer20010315.java
index 506b098..8330d45 100644
--- a/src/main/java/org/apache/xml/security/c14n/implementations/Canonicalizer20010315.java
+++ b/src/main/java/org/apache/xml/security/c14n/implementations/Canonicalizer20010315.java
@@ -141,7 +141,7 @@
return;
}
// result will contain the attrs which have to be output
- SortedSet<Attr> result = new TreeSet<>(COMPARE);
+ SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
if (element.hasAttributes()) {
NamedNodeMap attrs = element.getAttributes();
@@ -164,7 +164,7 @@
//Render the ns definition
result.add((Attr)n);
if (C14nHelper.namespaceIsRelative(attribute)) {
- Object[] exArgs = { element.getTagName(), NName, attribute.getNodeValue() };
+ Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs
);
@@ -209,7 +209,7 @@
// result will contain the attrs which have to be output
xmlattrStack.push(ns.getLevel());
boolean isRealVisible = isVisibleDO(element, ns.getLevel()) == 1;
- SortedSet<Attr> result = new TreeSet<>(COMPARE);
+ SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
if (element.hasAttributes()) {
NamedNodeMap attrs = element.getAttributes();
@@ -249,7 +249,7 @@
if (n != null) {
result.add((Attr)n);
if (C14nHelper.namespaceIsRelative(attribute)) {
- Object[] exArgs = { element.getTagName(), NName, attribute.getNodeValue() };
+ Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs
);
@@ -335,7 +335,7 @@
String NName = e.getPrefix();
String NValue = e.getNamespaceURI();
String Name;
- if (NName == null || NName.isEmpty()) {
+ if (NName == null || NName.equals("")) {
NName = "xmlns";
Name = "xmlns";
} else {
diff --git a/src/main/java/org/apache/xml/security/c14n/implementations/Canonicalizer20010315Excl.java b/src/main/java/org/apache/xml/security/c14n/implementations/Canonicalizer20010315Excl.java
index fda565e..32aaac3 100644
--- a/src/main/java/org/apache/xml/security/c14n/implementations/Canonicalizer20010315Excl.java
+++ b/src/main/java/org/apache/xml/security/c14n/implementations/Canonicalizer20010315Excl.java
@@ -161,11 +161,11 @@
Map<String, byte[]> cache)
throws CanonicalizationException, DOMException, IOException {
// result will contain the attrs which have to be output
- SortedSet<Attr> result = new TreeSet<>(COMPARE);
+ SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
// The prefix visibly utilized (in the attribute or in the name) in
// the element
- SortedSet<String> visiblyUtilized = new TreeSet<>();
+ SortedSet<String> visiblyUtilized = new TreeSet<String>();
if (inclusiveNSSet != null && !inclusiveNSSet.isEmpty()) {
visiblyUtilized.addAll(inclusiveNSSet);
}
@@ -193,7 +193,7 @@
&& C14nHelper.namespaceIsRelative(NNodeValue)) {
// The default mapping for xml must not be output.
// New definition check if it is relative.
- Object[] exArgs = {element.getTagName(), NName, attribute.getNodeValue()};
+ Object exArgs[] = {element.getTagName(), NName, attribute.getNodeValue()};
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs
);
@@ -238,7 +238,7 @@
Map<String, byte[]> cache)
throws CanonicalizationException, DOMException, IOException {
// result will contain the attrs which have to be output
- SortedSet<Attr> result = new TreeSet<>(COMPARE);
+ SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
// The prefix visibly utilized (in the attribute or in the name) in
// the element
@@ -246,7 +246,7 @@
// It's the output selected.
boolean isOutputElement = isVisibleDO(element, ns.getLevel()) == 1;
if (isOutputElement) {
- visiblyUtilized = new TreeSet<>();
+ visiblyUtilized = new TreeSet<String>();
if (inclusiveNSSet != null && !inclusiveNSSet.isEmpty()) {
visiblyUtilized.addAll(inclusiveNSSet);
}
@@ -282,7 +282,7 @@
if (n != null) {
result.add((Attr)n);
if (C14nHelper.namespaceIsRelative(attribute)) {
- Object[] exArgs = { element.getTagName(), NName, attribute.getNodeValue() };
+ Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs
);
@@ -293,7 +293,7 @@
if (ns.addMapping(NName, NNodeValue, attribute)
&& C14nHelper.namespaceIsRelative(NNodeValue)) {
// New definition check if it is relative
- Object[] exArgs = { element.getTagName(), NName, attribute.getNodeValue() };
+ Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs
);
diff --git a/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java b/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java
index 11e0cac..8a329cf 100644
--- a/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java
+++ b/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java
@@ -562,8 +562,10 @@
}
}
}
-
- return this.xpathNodeSet == null || this.xpathNodeSet.contains(currentNode);
+ if (this.xpathNodeSet != null && !this.xpathNodeSet.contains(currentNode)) {
+ return false;
+ }
+ return true;
}
protected void handleParent(Element e, NameSpaceSymbTable ns) {
@@ -586,7 +588,7 @@
String NName = e.getPrefix();
String NValue = e.getNamespaceURI();
String Name;
- if (NName == null || NName.isEmpty()) {
+ if (NName == null || NName.equals("")) {
NName = XMLNS;
Name = XMLNS;
} else {
diff --git a/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerPhysical.java b/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerPhysical.java
index 5d88943..64304aa 100644
--- a/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerPhysical.java
+++ b/src/main/java/org/apache/xml/security/c14n/implementations/CanonicalizerPhysical.java
@@ -124,7 +124,7 @@
throws CanonicalizationException, DOMException, IOException {
if (element.hasAttributes()) {
// result will contain all the attrs declared directly on that element
- SortedSet<Attr> result = new TreeSet<>(COMPARE);
+ SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
NamedNodeMap attrs = element.getAttributes();
int attrsLength = attrs.getLength();
diff --git a/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java b/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java
index d87e6a9..4d98822 100644
--- a/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java
+++ b/src/main/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTable.java
@@ -34,9 +34,6 @@
*/
public class NameSpaceSymbTable {
- private static final org.slf4j.Logger LOG =
- org.slf4j.LoggerFactory.getLogger(NameSpaceSymbTable.class);
-
private static final String XMLNS = "xmlns";
private static final SymbMap initialMap = new SymbMap();
@@ -59,11 +56,7 @@
public NameSpaceSymbTable() {
level = new ArrayList<>();
//Insert the default binding for xmlns.
- try {
- symb = initialMap.clone();
- } catch (CloneNotSupportedException e) {
- LOG.error("Error cloning the initial map");
- }
+ symb = (SymbMap) initialMap.clone();
}
/**
@@ -77,7 +70,7 @@
NameSpaceSymbEntry n = it.next();
//put them rendered?
if (!n.rendered && n.n != null) {
- n = n.clone();
+ n = (NameSpaceSymbEntry) n.clone();
needsClone();
symb.put(n.prefix, n);
n.lastrendered = n.uri;
@@ -135,11 +128,7 @@
final void needsClone() {
if (!cloned) {
level.set(level.size() - 1, symb);
- try {
- symb = symb.clone();
- } catch (CloneNotSupportedException e) {
- LOG.error("Error cloning the symbol map");
- }
+ symb = (SymbMap) symb.clone();
cloned = true;
}
}
@@ -162,7 +151,7 @@
return null;
}
// Mark this entry as render.
- entry = entry.clone();
+ entry = (NameSpaceSymbEntry) entry.clone();
needsClone();
symb.put(prefix, entry);
entry.rendered = true;
@@ -230,7 +219,7 @@
if (ob != null && uri.equals(ob.uri)) {
if (!ob.rendered) {
- ob = ob.clone();
+ ob = (NameSpaceSymbEntry) ob.clone();
needsClone();
symb.put(prefix, ob);
ob.lastrendered = uri;
@@ -311,9 +300,9 @@
}
/** {@inheritDoc} */
- public NameSpaceSymbEntry clone() { //NOPMD
+ public Object clone() {
try {
- return (NameSpaceSymbEntry)super.clone();
+ return super.clone();
} catch (CloneNotSupportedException e) {
return null;
}
@@ -377,7 +366,7 @@
*/
protected void rehash(int newCapacity) {
int oldCapacity = keys.length;
- String[] oldKeys = keys;
+ String oldKeys[] = keys;
NameSpaceSymbEntry oldVals[] = entries;
keys = new String[newCapacity];
@@ -397,14 +386,18 @@
return entries[index(key)];
}
- @Override
- public SymbMap clone() throws CloneNotSupportedException {
- SymbMap copy = (SymbMap) super.clone();
- copy.entries = new NameSpaceSymbEntry[entries.length];
- System.arraycopy(entries, 0, copy.entries, 0, entries.length);
- copy.keys = new String[keys.length];
- System.arraycopy(keys, 0, copy.keys, 0, keys.length);
+ protected Object clone() {
+ try {
+ SymbMap copy = (SymbMap) super.clone();
+ copy.entries = new NameSpaceSymbEntry[entries.length];
+ System.arraycopy(entries, 0, copy.entries, 0, entries.length);
+ copy.keys = new String[keys.length];
+ System.arraycopy(keys, 0, copy.keys, 0, keys.length);
- return copy;
+ return copy;
+ } catch (CloneNotSupportedException e) {
+ e.printStackTrace();
+ }
+ return null;
}
}
diff --git a/src/main/java/org/apache/xml/security/c14n/implementations/UtfHelpper.java b/src/main/java/org/apache/xml/security/c14n/implementations/UtfHelpper.java
index 2ef5ffe..1220f00 100644
--- a/src/main/java/org/apache/xml/security/c14n/implementations/UtfHelpper.java
+++ b/src/main/java/org/apache/xml/security/c14n/implementations/UtfHelpper.java
@@ -114,6 +114,42 @@
}
}
+ @Deprecated
+ public static void writeCharToUtf8(final char c, final OutputStream out) throws IOException {
+ if (c < 0x80) {
+ out.write(c);
+ return;
+ }
+ if (c >= 0xD800 && c <= 0xDBFF || c >= 0xDC00 && c <= 0xDFFF) {
+ //No Surrogates in sun java
+ out.write(0x3f);
+ return;
+ }
+ int bias;
+ int write;
+ char ch;
+ if (c > 0x07FF) {
+ ch = (char)(c>>>12);
+ write = 0xE0;
+ if (ch > 0) {
+ write |= ch & 0x0F;
+ }
+ out.write(write);
+ write = 0x80;
+ bias = 0x3F;
+ } else {
+ write = 0xC0;
+ bias = 0x1F;
+ }
+ ch = (char)(c>>>6);
+ if (ch > 0) {
+ write |= ch & bias;
+ }
+ out.write(write);
+ out.write(0x80 | ((c) & 0x3F));
+
+ }
+
public static void writeStringToUtf8(
final String str, final OutputStream out
) throws IOException {
@@ -207,7 +243,7 @@
continue;
}
if (!expanded) {
- byte[] newResult = new byte[6*length];
+ byte newResult[] = new byte[6*length];
System.arraycopy(result, 0, newResult, 0, out);
result = newResult;
expanded = true;
@@ -252,7 +288,7 @@
}
}
if (expanded) {
- byte[] newResult = new byte[out];
+ byte newResult[] = new byte[out];
System.arraycopy(result, 0, newResult, 0, out);
result = newResult;
}
diff --git a/src/main/java/org/apache/xml/security/c14n/implementations/XmlAttrStack.java b/src/main/java/org/apache/xml/security/c14n/implementations/XmlAttrStack.java
index a0ae17d..8fa9179 100644
--- a/src/main/java/org/apache/xml/security/c14n/implementations/XmlAttrStack.java
+++ b/src/main/java/org/apache/xml/security/c14n/implementations/XmlAttrStack.java
@@ -116,7 +116,7 @@
Iterator<Attr> it = e.nodes.iterator();
while (it.hasNext() && successiveOmitted) {
Attr n = it.next();
- if ("base".equals(n.getLocalName()) && !e.rendered) {
+ if (n.getLocalName().equals("base") && !e.rendered) {
baseAttrs.add(n);
} else if (!loa.containsKey(n.getName())) {
loa.put(n.getName(), n);
@@ -129,7 +129,7 @@
Attr baseAttr = null;
while (it.hasNext()) {
Attr n = it.next();
- if ("base".equals(n.getLocalName())) {
+ if (n.getLocalName().equals("base")) {
base = n.getValue();
baseAttr = n;
break;
@@ -218,7 +218,7 @@
tquery = bquery;
}
} else {
- if (rpath.charAt(0) == '/') {
+ if (rpath.startsWith("/")) {
tpath = removeDotSegments(rpath);
} else {
if (bauthority != null && bpath.length() == 0) {
@@ -259,7 +259,7 @@
// If the input buffer starts with a root slash "/" then move this
// character to the output buffer.
if (input.charAt(0) == '/') {
- output.append('/');
+ output.append("/");
input = input.substring(1);
}
@@ -278,7 +278,7 @@
printStep("2A", output.toString(), input);
} else if (input.startsWith("../")) {
input = input.substring(3);
- if (!"/".equals(output.toString())) {
+ if (!output.toString().equals("/")) {
output.append("../");
}
printStep("2A", output.toString(), input);
@@ -288,7 +288,7 @@
} else if (input.startsWith("/./")) {
input = input.substring(2);
printStep("2B", output.toString(), input);
- } else if ("/.".equals(input)) {
+ } else if (input.equals("/.")) {
// FIXME: what is complete path segment?
input = input.replaceFirst("/.", "/");
printStep("2B", output.toString(), input);
@@ -305,7 +305,7 @@
} else if (input.startsWith("/../")) {
input = input.substring(3);
if (output.length() == 0) {
- output.append('/');
+ output.append("/");
} else if (output.toString().endsWith("../")) {
output.append("..");
} else if (output.toString().endsWith("..")) {
@@ -322,11 +322,11 @@
}
}
printStep("2C", output.toString(), input);
- } else if ("/..".equals(input)) {
+ } else if (input.equals("/..")) {
// FIXME: what is complete path segment?
input = input.replaceFirst("/..", "/");
if (output.length() == 0) {
- output.append('/');
+ output.append("/");
} else if (output.toString().endsWith("../")) {
output.append("..");
} else if (output.toString().endsWith("..")) {
@@ -348,11 +348,11 @@
// only of ".." and if the output buffer does not contain only
// the root slash "/", then move the ".." to the output buffer
// else delte it.; otherwise,
- } else if (".".equals(input)) {
+ } else if (input.equals(".")) {
input = "";
printStep("2D", output.toString(), input);
- } else if ("..".equals(input)) {
- if (!"/".equals(output.toString())) {
+ } else if (input.equals("..")) {
+ if (!output.toString().equals("/")) {
output.append("..");
}
input = "";
@@ -388,7 +388,7 @@
// then append a slash "/". The output buffer is returned as the result
// of remove_dot_segments
if (output.toString().endsWith("..")) {
- output.append('/');
+ output.append("/");
printStep("3 ", output.toString(), input);
}
diff --git a/src/main/java/org/apache/xml/security/configuration/AlgorithmType.java b/src/main/java/org/apache/xml/security/configuration/AlgorithmType.java
new file mode 100644
index 0000000..71a1fe1
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/AlgorithmType.java
@@ -0,0 +1,339 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * <p>Java class for AlgorithmType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="AlgorithmType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="URI" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ * <attribute name="Description" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="AlgorithmClass" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="RequirementLevel" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="SpecificationURL" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="JCEProvider" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="JCEName" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="KeyLength" type="{http://www.w3.org/2001/XMLSchema}int" />
+ * <attribute name="IVLength" type="{http://www.w3.org/2001/XMLSchema}int" />
+ * <attribute name="RequiredKey" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "AlgorithmType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "value"
+})
+public class AlgorithmType {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "URI", required = true)
+ @XmlSchemaType(name = "anyURI")
+ protected String uri;
+ @XmlAttribute(name = "Description", required = true)
+ protected String description;
+ @XmlAttribute(name = "AlgorithmClass", required = true)
+ protected String algorithmClass;
+ @XmlAttribute(name = "RequirementLevel", required = true)
+ protected String requirementLevel;
+ @XmlAttribute(name = "SpecificationURL")
+ protected String specificationURL;
+ @XmlAttribute(name = "JCEProvider")
+ protected String jceProvider;
+ @XmlAttribute(name = "JCEName", required = true)
+ protected String jceName;
+ @XmlAttribute(name = "KeyLength")
+ protected Integer keyLength;
+ @XmlAttribute(name = "IVLength")
+ protected Integer ivLength;
+ @XmlAttribute(name = "RequiredKey")
+ protected String requiredKey;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+ /**
+ * Gets the value of the description property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the value of the description property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setDescription(String value) {
+ this.description = value;
+ }
+
+ /**
+ * Gets the value of the algorithmClass property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getAlgorithmClass() {
+ return algorithmClass;
+ }
+
+ /**
+ * Sets the value of the algorithmClass property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setAlgorithmClass(String value) {
+ this.algorithmClass = value;
+ }
+
+ /**
+ * Gets the value of the requirementLevel property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getRequirementLevel() {
+ return requirementLevel;
+ }
+
+ /**
+ * Sets the value of the requirementLevel property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setRequirementLevel(String value) {
+ this.requirementLevel = value;
+ }
+
+ /**
+ * Gets the value of the specificationURL property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSpecificationURL() {
+ return specificationURL;
+ }
+
+ /**
+ * Sets the value of the specificationURL property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSpecificationURL(String value) {
+ this.specificationURL = value;
+ }
+
+ /**
+ * Gets the value of the jceProvider property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getJCEProvider() {
+ return jceProvider;
+ }
+
+ /**
+ * Sets the value of the jceProvider property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setJCEProvider(String value) {
+ this.jceProvider = value;
+ }
+
+ /**
+ * Gets the value of the jceName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getJCEName() {
+ return jceName;
+ }
+
+ /**
+ * Sets the value of the jceName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setJCEName(String value) {
+ this.jceName = value;
+ }
+
+ /**
+ * Gets the value of the keyLength property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public Integer getKeyLength() {
+ return keyLength;
+ }
+
+ /**
+ * Sets the value of the keyLength property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setKeyLength(Integer value) {
+ this.keyLength = value;
+ }
+
+ /**
+ * Gets the value of the ivLength property.
+ *
+ * @return
+ * possible object is
+ * {@link Integer }
+ *
+ */
+ public Integer getIVLength() {
+ return ivLength;
+ }
+
+ /**
+ * Sets the value of the ivLength property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Integer }
+ *
+ */
+ public void setIVLength(Integer value) {
+ this.ivLength = value;
+ }
+
+ /**
+ * Gets the value of the requiredKey property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getRequiredKey() {
+ return requiredKey;
+ }
+
+ /**
+ * Sets the value of the requiredKey property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setRequiredKey(String value) {
+ this.requiredKey = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/ConfigurationType.java b/src/main/java/org/apache/xml/security/configuration/ConfigurationType.java
new file mode 100644
index 0000000..e0df0e4
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/ConfigurationType.java
@@ -0,0 +1,209 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ConfigurationType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ConfigurationType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Properties" type="{http://www.xmlsecurity.org/NS/configuration}PropertiesType"/>
+ * <element name="SecurityHeaderHandlers" type="{http://www.xmlsecurity.org/NS/configuration}SecurityHeaderHandlersType"/>
+ * <element name="TransformAlgorithms" type="{http://www.xmlsecurity.org/NS/configuration}TransformAlgorithmsType"/>
+ * <element name="JCEAlgorithmMappings" type="{http://www.xmlsecurity.org/NS/configuration}JCEAlgorithmMappingsType"/>
+ * <element name="ResourceResolvers" type="{http://www.xmlsecurity.org/NS/configuration}ResourceResolversType"/>
+ * </sequence>
+ * <attribute name="target" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ConfigurationType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "properties",
+ "securityHeaderHandlers",
+ "transformAlgorithms",
+ "jceAlgorithmMappings",
+ "resourceResolvers"
+})
+public class ConfigurationType {
+
+ @XmlElement(name = "Properties", namespace = "http://www.xmlsecurity.org/NS/configuration", required = true)
+ protected PropertiesType properties;
+ @XmlElement(name = "SecurityHeaderHandlers", namespace = "http://www.xmlsecurity.org/NS/configuration", required = true)
+ protected SecurityHeaderHandlersType securityHeaderHandlers;
+ @XmlElement(name = "TransformAlgorithms", namespace = "http://www.xmlsecurity.org/NS/configuration", required = true)
+ protected TransformAlgorithmsType transformAlgorithms;
+ @XmlElement(name = "JCEAlgorithmMappings", namespace = "http://www.xmlsecurity.org/NS/configuration", required = true)
+ protected JCEAlgorithmMappingsType jceAlgorithmMappings;
+ @XmlElement(name = "ResourceResolvers", namespace = "http://www.xmlsecurity.org/NS/configuration", required = true)
+ protected ResourceResolversType resourceResolvers;
+ @XmlAttribute(name = "target")
+ protected String target;
+
+ /**
+ * Gets the value of the properties property.
+ *
+ * @return
+ * possible object is
+ * {@link PropertiesType }
+ *
+ */
+ public PropertiesType getProperties() {
+ return properties;
+ }
+
+ /**
+ * Sets the value of the properties property.
+ *
+ * @param value
+ * allowed object is
+ * {@link PropertiesType }
+ *
+ */
+ public void setProperties(PropertiesType value) {
+ this.properties = value;
+ }
+
+ /**
+ * Gets the value of the securityHeaderHandlers property.
+ *
+ * @return
+ * possible object is
+ * {@link SecurityHeaderHandlersType }
+ *
+ */
+ public SecurityHeaderHandlersType getSecurityHeaderHandlers() {
+ return securityHeaderHandlers;
+ }
+
+ /**
+ * Sets the value of the securityHeaderHandlers property.
+ *
+ * @param value
+ * allowed object is
+ * {@link SecurityHeaderHandlersType }
+ *
+ */
+ public void setSecurityHeaderHandlers(SecurityHeaderHandlersType value) {
+ this.securityHeaderHandlers = value;
+ }
+
+ /**
+ * Gets the value of the transformAlgorithms property.
+ *
+ * @return
+ * possible object is
+ * {@link TransformAlgorithmsType }
+ *
+ */
+ public TransformAlgorithmsType getTransformAlgorithms() {
+ return transformAlgorithms;
+ }
+
+ /**
+ * Sets the value of the transformAlgorithms property.
+ *
+ * @param value
+ * allowed object is
+ * {@link TransformAlgorithmsType }
+ *
+ */
+ public void setTransformAlgorithms(TransformAlgorithmsType value) {
+ this.transformAlgorithms = value;
+ }
+
+ /**
+ * Gets the value of the jceAlgorithmMappings property.
+ *
+ * @return
+ * possible object is
+ * {@link JCEAlgorithmMappingsType }
+ *
+ */
+ public JCEAlgorithmMappingsType getJCEAlgorithmMappings() {
+ return jceAlgorithmMappings;
+ }
+
+ /**
+ * Sets the value of the jceAlgorithmMappings property.
+ *
+ * @param value
+ * allowed object is
+ * {@link JCEAlgorithmMappingsType }
+ *
+ */
+ public void setJCEAlgorithmMappings(JCEAlgorithmMappingsType value) {
+ this.jceAlgorithmMappings = value;
+ }
+
+ /**
+ * Gets the value of the resourceResolvers property.
+ *
+ * @return
+ * possible object is
+ * {@link ResourceResolversType }
+ *
+ */
+ public ResourceResolversType getResourceResolvers() {
+ return resourceResolvers;
+ }
+
+ /**
+ * Sets the value of the resourceResolvers property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ResourceResolversType }
+ *
+ */
+ public void setResourceResolvers(ResourceResolversType value) {
+ this.resourceResolvers = value;
+ }
+
+ /**
+ * Gets the value of the target property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTarget() {
+ return target;
+ }
+
+ /**
+ * Sets the value of the target property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTarget(String value) {
+ this.target = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/HandlerType.java b/src/main/java/org/apache/xml/security/configuration/HandlerType.java
new file mode 100644
index 0000000..0566fa1
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/HandlerType.java
@@ -0,0 +1,148 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * <p>Java class for HandlerType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="HandlerType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="NAME" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="URI" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="JAVACLASS" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "HandlerType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "value"
+})
+public class HandlerType {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "NAME", required = true)
+ protected String name;
+ @XmlAttribute(name = "URI", required = true)
+ protected String uri;
+ @XmlAttribute(name = "JAVACLASS", required = true)
+ protected String javaclass;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getNAME() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setNAME(String value) {
+ this.name = value;
+ }
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+ /**
+ * Gets the value of the javaclass property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getJAVACLASS() {
+ return javaclass;
+ }
+
+ /**
+ * Sets the value of the javaclass property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setJAVACLASS(String value) {
+ this.javaclass = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/InOutAttrType.java b/src/main/java/org/apache/xml/security/configuration/InOutAttrType.java
new file mode 100644
index 0000000..d3d0494
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/InOutAttrType.java
@@ -0,0 +1,45 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for inOutAttrType.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * <simpleType name="inOutAttrType">
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ * <enumeration value="IN"/>
+ * <enumeration value="OUT"/>
+ * </restriction>
+ * </simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "inOutAttrType", namespace = "http://www.xmlsecurity.org/NS/configuration")
+@XmlEnum
+public enum InOutAttrType {
+
+ IN,
+ OUT;
+
+ public String value() {
+ return name();
+ }
+
+ public static InOutAttrType fromValue(String v) {
+ return valueOf(v);
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/JCEAlgorithmMappingsType.java b/src/main/java/org/apache/xml/security/configuration/JCEAlgorithmMappingsType.java
new file mode 100644
index 0000000..5ac246c
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/JCEAlgorithmMappingsType.java
@@ -0,0 +1,76 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for JCEAlgorithmMappingsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="JCEAlgorithmMappingsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Algorithm" type="{http://www.xmlsecurity.org/NS/configuration}AlgorithmType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "JCEAlgorithmMappingsType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "algorithm"
+})
+public class JCEAlgorithmMappingsType {
+
+ @XmlElement(name = "Algorithm", namespace = "http://www.xmlsecurity.org/NS/configuration")
+ protected List<AlgorithmType> algorithm;
+
+ /**
+ * Gets the value of the algorithm property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the algorithm property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAlgorithm().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link AlgorithmType }
+ *
+ *
+ */
+ public List<AlgorithmType> getAlgorithm() {
+ if (algorithm == null) {
+ algorithm = new ArrayList<AlgorithmType>();
+ }
+ return this.algorithm;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/ObjectFactory.java b/src/main/java/org/apache/xml/security/configuration/ObjectFactory.java
new file mode 100644
index 0000000..9572647
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/ObjectFactory.java
@@ -0,0 +1,140 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.xml.security.configuration package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _Configuration_QNAME = new QName("http://www.xmlsecurity.org/NS/configuration", "Configuration");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.xml.security.configuration
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link ConfigurationType }
+ *
+ */
+ public ConfigurationType createConfigurationType() {
+ return new ConfigurationType();
+ }
+
+ /**
+ * Create an instance of {@link AlgorithmType }
+ *
+ */
+ public AlgorithmType createAlgorithmType() {
+ return new AlgorithmType();
+ }
+
+ /**
+ * Create an instance of {@link TransformAlgorithmType }
+ *
+ */
+ public TransformAlgorithmType createTransformAlgorithmType() {
+ return new TransformAlgorithmType();
+ }
+
+ /**
+ * Create an instance of {@link ResolverType }
+ *
+ */
+ public ResolverType createResolverType() {
+ return new ResolverType();
+ }
+
+ /**
+ * Create an instance of {@link PropertyType }
+ *
+ */
+ public PropertyType createPropertyType() {
+ return new PropertyType();
+ }
+
+ /**
+ * Create an instance of {@link TransformAlgorithmsType }
+ *
+ */
+ public TransformAlgorithmsType createTransformAlgorithmsType() {
+ return new TransformAlgorithmsType();
+ }
+
+ /**
+ * Create an instance of {@link HandlerType }
+ *
+ */
+ public HandlerType createHandlerType() {
+ return new HandlerType();
+ }
+
+ /**
+ * Create an instance of {@link SecurityHeaderHandlersType }
+ *
+ */
+ public SecurityHeaderHandlersType createSecurityHeaderHandlersType() {
+ return new SecurityHeaderHandlersType();
+ }
+
+ /**
+ * Create an instance of {@link PropertiesType }
+ *
+ */
+ public PropertiesType createPropertiesType() {
+ return new PropertiesType();
+ }
+
+ /**
+ * Create an instance of {@link JCEAlgorithmMappingsType }
+ *
+ */
+ public JCEAlgorithmMappingsType createJCEAlgorithmMappingsType() {
+ return new JCEAlgorithmMappingsType();
+ }
+
+ /**
+ * Create an instance of {@link ResourceResolversType }
+ *
+ */
+ public ResourceResolversType createResourceResolversType() {
+ return new ResourceResolversType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ConfigurationType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://www.xmlsecurity.org/NS/configuration", name = "Configuration")
+ public JAXBElement<ConfigurationType> createConfiguration(ConfigurationType value) {
+ return new JAXBElement<ConfigurationType>(_Configuration_QNAME, ConfigurationType.class, null, value);
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/PropertiesType.java b/src/main/java/org/apache/xml/security/configuration/PropertiesType.java
new file mode 100644
index 0000000..22284f6
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/PropertiesType.java
@@ -0,0 +1,76 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for PropertiesType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="PropertiesType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Property" type="{http://www.xmlsecurity.org/NS/configuration}PropertyType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "PropertiesType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "property"
+})
+public class PropertiesType {
+
+ @XmlElement(name = "Property", namespace = "http://www.xmlsecurity.org/NS/configuration")
+ protected List<PropertyType> property;
+
+ /**
+ * Gets the value of the property property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the property property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getProperty().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link PropertyType }
+ *
+ *
+ */
+ public List<PropertyType> getProperty() {
+ if (property == null) {
+ property = new ArrayList<PropertyType>();
+ }
+ return this.property;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/PropertyType.java b/src/main/java/org/apache/xml/security/configuration/PropertyType.java
new file mode 100644
index 0000000..2ada391
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/PropertyType.java
@@ -0,0 +1,121 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * <p>Java class for PropertyType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="PropertyType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="NAME" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="VAL" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "PropertyType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "value"
+})
+public class PropertyType {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "NAME")
+ protected String name;
+ @XmlAttribute(name = "VAL")
+ protected String val;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getNAME() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setNAME(String value) {
+ this.name = value;
+ }
+
+ /**
+ * Gets the value of the val property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVAL() {
+ return val;
+ }
+
+ /**
+ * Sets the value of the val property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVAL(String value) {
+ this.val = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/ResolverType.java b/src/main/java/org/apache/xml/security/configuration/ResolverType.java
new file mode 100644
index 0000000..6f5b1d7
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/ResolverType.java
@@ -0,0 +1,121 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * <p>Java class for ResolverType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ResolverType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="JAVACLASS" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="DESCRIPTION" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ResolverType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "value"
+})
+public class ResolverType {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "JAVACLASS", required = true)
+ protected String javaclass;
+ @XmlAttribute(name = "DESCRIPTION", required = true)
+ protected String description;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the javaclass property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getJAVACLASS() {
+ return javaclass;
+ }
+
+ /**
+ * Sets the value of the javaclass property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setJAVACLASS(String value) {
+ this.javaclass = value;
+ }
+
+ /**
+ * Gets the value of the description property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getDESCRIPTION() {
+ return description;
+ }
+
+ /**
+ * Sets the value of the description property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setDESCRIPTION(String value) {
+ this.description = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/ResourceResolversType.java b/src/main/java/org/apache/xml/security/configuration/ResourceResolversType.java
new file mode 100644
index 0000000..4f6f3c6
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/ResourceResolversType.java
@@ -0,0 +1,76 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ResourceResolversType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="ResourceResolversType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Resolver" type="{http://www.xmlsecurity.org/NS/configuration}ResolverType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "ResourceResolversType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "resolver"
+})
+public class ResourceResolversType {
+
+ @XmlElement(name = "Resolver", namespace = "http://www.xmlsecurity.org/NS/configuration")
+ protected List<ResolverType> resolver;
+
+ /**
+ * Gets the value of the resolver property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the resolver property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getResolver().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link ResolverType }
+ *
+ *
+ */
+ public List<ResolverType> getResolver() {
+ if (resolver == null) {
+ resolver = new ArrayList<ResolverType>();
+ }
+ return this.resolver;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/SecurityHeaderHandlersType.java b/src/main/java/org/apache/xml/security/configuration/SecurityHeaderHandlersType.java
new file mode 100644
index 0000000..3a3d903
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/SecurityHeaderHandlersType.java
@@ -0,0 +1,76 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for SecurityHeaderHandlersType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="SecurityHeaderHandlersType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Handler" type="{http://www.xmlsecurity.org/NS/configuration}HandlerType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "SecurityHeaderHandlersType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "handler"
+})
+public class SecurityHeaderHandlersType {
+
+ @XmlElement(name = "Handler", namespace = "http://www.xmlsecurity.org/NS/configuration")
+ protected List<HandlerType> handler;
+
+ /**
+ * Gets the value of the handler property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the handler property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getHandler().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link HandlerType }
+ *
+ *
+ */
+ public List<HandlerType> getHandler() {
+ if (handler == null) {
+ handler = new ArrayList<HandlerType>();
+ }
+ return this.handler;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/TransformAlgorithmType.java b/src/main/java/org/apache/xml/security/configuration/TransformAlgorithmType.java
new file mode 100644
index 0000000..e9db9ac
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/TransformAlgorithmType.java
@@ -0,0 +1,148 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * <p>Java class for TransformAlgorithmType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="TransformAlgorithmType">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="URI" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="JAVACLASS" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="INOUT" type="{http://www.xmlsecurity.org/NS/configuration}inOutAttrType" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TransformAlgorithmType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "value"
+})
+public class TransformAlgorithmType {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "URI", required = true)
+ protected String uri;
+ @XmlAttribute(name = "JAVACLASS", required = true)
+ protected String javaclass;
+ @XmlAttribute(name = "INOUT")
+ protected InOutAttrType inout;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+ /**
+ * Gets the value of the javaclass property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getJAVACLASS() {
+ return javaclass;
+ }
+
+ /**
+ * Sets the value of the javaclass property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setJAVACLASS(String value) {
+ this.javaclass = value;
+ }
+
+ /**
+ * Gets the value of the inout property.
+ *
+ * @return
+ * possible object is
+ * {@link InOutAttrType }
+ *
+ */
+ public InOutAttrType getINOUT() {
+ return inout;
+ }
+
+ /**
+ * Sets the value of the inout property.
+ *
+ * @param value
+ * allowed object is
+ * {@link InOutAttrType }
+ *
+ */
+ public void setINOUT(InOutAttrType value) {
+ this.inout = value;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/configuration/TransformAlgorithmsType.java b/src/main/java/org/apache/xml/security/configuration/TransformAlgorithmsType.java
new file mode 100644
index 0000000..1b6e987
--- /dev/null
+++ b/src/main/java/org/apache/xml/security/configuration/TransformAlgorithmsType.java
@@ -0,0 +1,76 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2017.07.31 at 11:10:09 AM IST
+//
+
+
+package org.apache.xml.security.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for TransformAlgorithmsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="TransformAlgorithmsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="TransformAlgorithm" type="{http://www.xmlsecurity.org/NS/configuration}TransformAlgorithmType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TransformAlgorithmsType", namespace = "http://www.xmlsecurity.org/NS/configuration", propOrder = {
+ "transformAlgorithm"
+})
+public class TransformAlgorithmsType {
+
+ @XmlElement(name = "TransformAlgorithm", namespace = "http://www.xmlsecurity.org/NS/configuration")
+ protected List<TransformAlgorithmType> transformAlgorithm;
+
+ /**
+ * Gets the value of the transformAlgorithm property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the transformAlgorithm property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getTransformAlgorithm().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link TransformAlgorithmType }
+ *
+ *
+ */
+ public List<TransformAlgorithmType> getTransformAlgorithm() {
+ if (transformAlgorithm == null) {
+ transformAlgorithm = new ArrayList<TransformAlgorithmType>();
+ }
+ return this.transformAlgorithm;
+ }
+
+}
diff --git a/src/main/java/org/apache/xml/security/encryption/AbstractSerializer.java b/src/main/java/org/apache/xml/security/encryption/AbstractSerializer.java
index 99fb947..eaa8fba 100644
--- a/src/main/java/org/apache/xml/security/encryption/AbstractSerializer.java
+++ b/src/main/java/org/apache/xml/security/encryption/AbstractSerializer.java
@@ -226,7 +226,8 @@
protected static String createContext(String source, Node ctx) {
// Create the context to parse the document against
- StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?><dummy");
+ StringBuilder sb = new StringBuilder();
+ sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><dummy");
// Run through each node up to the document node and find any xmlns: nodes
Map<String, String> storedNamespaces = new HashMap<>();
@@ -239,18 +240,18 @@
String nodeName = att.getNodeName();
if (("xmlns".equals(nodeName) || nodeName.startsWith("xmlns:"))
&& !storedNamespaces.containsKey(att.getNodeName())) {
- sb.append(' ');
+ sb.append(" ");
sb.append(nodeName);
sb.append("=\"");
sb.append(att.getNodeValue());
- sb.append('\"');
+ sb.append("\"");
storedNamespaces.put(nodeName, att.getNodeValue());
}
}
}
wk = wk.getParentNode();
}
- sb.append('>');
+ sb.append(">");
sb.append(source);
sb.append("</dummy>");
return sb.toString();
diff --git a/src/main/java/org/apache/xml/security/encryption/DocumentSerializer.java b/src/main/java/org/apache/xml/security/encryption/DocumentSerializer.java
index a35ff71..3c7ce3c 100644
--- a/src/main/java/org/apache/xml/security/encryption/DocumentSerializer.java
+++ b/src/main/java/org/apache/xml/security/encryption/DocumentSerializer.java
@@ -23,6 +23,7 @@
import java.io.InputStream;
import java.io.StringReader;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xml.security.utils.XMLUtils;
@@ -69,8 +70,10 @@
* @throws XMLEncryptionException
*/
private Node deserialize(Node ctx, InputSource inputSource) throws XMLEncryptionException {
+ DocumentBuilder db = null;
try {
- Document d = XMLUtils.read(inputSource, secureValidation);
+ db = XMLUtils.createDocumentBuilder(false, secureValidation);
+ Document d = db.parse(inputSource);
Document contextDocument = null;
if (Node.DOCUMENT_NODE == ctx.getNodeType()) {
@@ -95,6 +98,10 @@
throw new XMLEncryptionException(pce);
} catch (IOException ioe) {
throw new XMLEncryptionException(ioe);
+ } finally {
+ if (db != null) {
+ XMLUtils.repoolDocumentBuilder(db);
+ }
}
}
diff --git a/src/main/java/org/apache/xml/security/encryption/XMLCipher.java b/src/main/java/org/apache/xml/security/encryption/XMLCipher.java
index c2ca9cd..51eab84 100644
--- a/src/main/java/org/apache/xml/security/encryption/XMLCipher.java
+++ b/src/main/java/org/apache/xml/security/encryption/XMLCipher.java
@@ -1864,12 +1864,14 @@
EncryptedData result = null;
CipherData data = null;
- if (CipherData.REFERENCE_TYPE == type) {
+ switch (type) {
+ case CipherData.REFERENCE_TYPE:
CipherReference cipherReference = factory.newCipherReference(value);
data = factory.newCipherData(type);
data.setCipherReference(cipherReference);
result = factory.newEncryptedData(data);
- } else if (CipherData.VALUE_TYPE == type) {
+ break;
+ case CipherData.VALUE_TYPE:
CipherValue cipherValue = factory.newCipherValue(value);
data = factory.newCipherData(type);
data.setCipherValue(cipherValue);
@@ -1917,12 +1919,14 @@
EncryptedKey result = null;
CipherData data = null;
- if (CipherData.REFERENCE_TYPE == type) {
+ switch (type) {
+ case CipherData.REFERENCE_TYPE:
CipherReference cipherReference = factory.newCipherReference(value);
data = factory.newCipherData(type);
data.setCipherReference(cipherReference);
result = factory.newEncryptedKey(data);
- } else if (CipherData.VALUE_TYPE == type) {
+ break;
+ case CipherData.VALUE_TYPE:
CipherValue cipherValue = factory.newCipherValue(value);
data = factory.newCipherData(type);
data.setCipherValue(cipherValue);
@@ -2478,7 +2482,8 @@
ReferenceList result = new ReferenceListImpl(type);
NodeList list = null;
- if (ReferenceList.DATA_REFERENCE == type) {
+ switch (type) {
+ case ReferenceList.DATA_REFERENCE:
list =
element.getElementsByTagNameNS(
EncryptionConstants.EncryptionSpecNS,
@@ -2488,7 +2493,8 @@
String uri = ((Element) list.item(i)).getAttributeNS(null, "URI");
result.add(result.newDataReference(uri));
}
- } else if (ReferenceList.KEY_REFERENCE == type) {
+ break;
+ case ReferenceList.KEY_REFERENCE:
list =
element.getElementsByTagNameNS(
EncryptionConstants.EncryptionSpecNS,
@@ -2538,7 +2544,7 @@
* @param algorithm
*/
public AgreementMethodImpl(String algorithm) {
- agreementMethodInformation = new LinkedList<>();
+ agreementMethodInformation = new LinkedList<Element>();
URI tmpAlgorithm = null;
try {
tmpAlgorithm = new URI(algorithm);
@@ -3086,7 +3092,7 @@
new IllegalArgumentException().initCause(ex);
}
this.algorithm = tmpAlgorithm.toString();
- encryptionMethodInformation = new LinkedList<>();
+ encryptionMethodInformation = new LinkedList<Element>();
}
/** {@inheritDoc} */
@@ -3211,7 +3217,7 @@
* Constructor.
*/
public EncryptionPropertiesImpl() {
- encryptionProperties = new LinkedList<>();
+ encryptionProperties = new LinkedList<EncryptionProperty>();
}
/** {@inheritDoc} */
@@ -3266,7 +3272,7 @@
* Constructor.
*/
public EncryptionPropertyImpl() {
- encryptionInformation = new LinkedList<>();
+ encryptionInformation = new LinkedList<Element>();
}
/** {@inheritDoc} */
@@ -3278,7 +3284,7 @@
public void setTarget(String target) {
if (target == null || target.length() == 0) {
this.target = null;
- } else if (target.charAt(0) == '#') {
+ } else if (target.startsWith("#")) {
/*
* This is a same document URI reference. Do not parse,
* because it has no scheme.
@@ -3440,7 +3446,7 @@
} else {
throw new IllegalArgumentException();
}
- references = new LinkedList<>();
+ references = new LinkedList<Reference>();
}
/** {@inheritDoc} */
@@ -3511,7 +3517,7 @@
ReferenceImpl(String uri) {
this.uri = uri;
- referenceInformation = new LinkedList<>();
+ referenceInformation = new LinkedList<Element>();
}
/** {@inheritDoc} */
diff --git a/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java b/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java
index feafe99..806bab8 100644
--- a/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java
+++ b/src/main/java/org/apache/xml/security/encryption/XMLCipherInput.java
@@ -96,7 +96,7 @@
* @throws XMLEncryptionException
* @return The decripted bytes.
*/
- public byte[] getBytes() throws XMLEncryptionException { //NOPMD
+ public byte[] getBytes() throws XMLEncryptionException {
if (mode == XMLCipher.DECRYPT_MODE) {
return getDecryptBytes();
}
diff --git a/src/main/java/org/apache/xml/security/encryption/XMLEncryptionException.java b/src/main/java/org/apache/xml/security/encryption/XMLEncryptionException.java
index 916207c..579cc9b 100644
--- a/src/main/java/org/apache/xml/security/encryption/XMLEncryptionException.java
+++ b/src/main/java/org/apache/xml/security/encryption/XMLEncryptionException.java
@@ -77,7 +77,7 @@
* @param msgID
* @param exArgs
*/
- public XMLEncryptionException(Exception originalException, String msgID, Object[] exArgs) {
+ public XMLEncryptionException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/exceptions/AlgorithmAlreadyRegisteredException.java b/src/main/java/org/apache/xml/security/exceptions/AlgorithmAlreadyRegisteredException.java
index 5c37ef6..c936cf6 100644
--- a/src/main/java/org/apache/xml/security/exceptions/AlgorithmAlreadyRegisteredException.java
+++ b/src/main/java/org/apache/xml/security/exceptions/AlgorithmAlreadyRegisteredException.java
@@ -47,7 +47,7 @@
* @param msgID
* @param exArgs
*/
- public AlgorithmAlreadyRegisteredException(String msgID, Object[] exArgs) {
+ public AlgorithmAlreadyRegisteredException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -74,7 +74,7 @@
* @param exArgs
*/
public AlgorithmAlreadyRegisteredException(
- Exception originalException, String msgID, Object[] exArgs
+ Exception originalException, String msgID, Object exArgs[]
) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/exceptions/Base64DecodingException.java b/src/main/java/org/apache/xml/security/exceptions/Base64DecodingException.java
index 29d96c7..77f3473 100644
--- a/src/main/java/org/apache/xml/security/exceptions/Base64DecodingException.java
+++ b/src/main/java/org/apache/xml/security/exceptions/Base64DecodingException.java
@@ -49,7 +49,7 @@
* @param msgID
* @param exArgs
*/
- public Base64DecodingException(String msgID, Object[] exArgs) {
+ public Base64DecodingException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -75,7 +75,7 @@
* @param msgID
* @param exArgs
*/
- public Base64DecodingException(Exception originalException, String msgID, Object[] exArgs) {
+ public Base64DecodingException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java b/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java
index 013c1a4..3c76df0 100644
--- a/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java
+++ b/src/main/java/org/apache/xml/security/exceptions/XMLSecurityException.java
@@ -34,7 +34,7 @@
* Usage in the Java source is:
* <pre>
* {
- * Object[] exArgs = { Constants._TAG_TRANSFORMS, "BadElement" };
+ * Object exArgs[] = { Constants._TAG_TRANSFORMS, "BadElement" };
*
* throw new XMLSecurityException("xml.WrongElement", exArgs);
* }
@@ -45,7 +45,7 @@
* try {
* ...
* } catch (Exception oldEx) {
- * Object[] exArgs = { Constants._TAG_TRANSFORMS, "BadElement" };
+ * Object exArgs[] = { Constants._TAG_TRANSFORMS, "BadElement" };
*
* throw new XMLSecurityException("xml.WrongElement", exArgs, oldEx);
* }
diff --git a/src/main/java/org/apache/xml/security/exceptions/XMLSecurityRuntimeException.java b/src/main/java/org/apache/xml/security/exceptions/XMLSecurityRuntimeException.java
index b889f77..5f63179 100644
--- a/src/main/java/org/apache/xml/security/exceptions/XMLSecurityRuntimeException.java
+++ b/src/main/java/org/apache/xml/security/exceptions/XMLSecurityRuntimeException.java
@@ -35,7 +35,7 @@
* Usage in the Java source is:
* <pre>
* {
- * Object[] exArgs = { Constants._TAG_TRANSFORMS, "BadElement" };
+ * Object exArgs[] = { Constants._TAG_TRANSFORMS, "BadElement" };
*
* throw new XMLSecurityException("xml.WrongElement", exArgs);
* }
@@ -46,7 +46,7 @@
* try {
* ...
* } catch (Exception oldEx) {
- * Object[] exArgs = { Constants._TAG_TRANSFORMS, "BadElement" };
+ * Object exArgs[] = { Constants._TAG_TRANSFORMS, "BadElement" };
*
* throw new XMLSecurityException("xml.WrongElement", exArgs, oldEx);
* }
@@ -88,7 +88,7 @@
* @param msgID
* @param exArgs
*/
- public XMLSecurityRuntimeException(String msgID, Object[] exArgs) {
+ public XMLSecurityRuntimeException(String msgID, Object exArgs[]) {
super(MessageFormat.format(I18n.getExceptionMessage(msgID), exArgs));
this.msgID = msgID;
@@ -126,7 +126,7 @@
* @param exArgs
* @param originalException
*/
- public XMLSecurityRuntimeException(String msgID, Object[] exArgs, Exception originalException) {
+ public XMLSecurityRuntimeException(String msgID, Object exArgs[], Exception originalException) {
super(MessageFormat.format(I18n.getExceptionMessage(msgID), exArgs), originalException);
this.msgID = msgID;
diff --git a/src/main/java/org/apache/xml/security/keys/ContentHandlerAlreadyRegisteredException.java b/src/main/java/org/apache/xml/security/keys/ContentHandlerAlreadyRegisteredException.java
index 0af58e1..2d3a8de 100644
--- a/src/main/java/org/apache/xml/security/keys/ContentHandlerAlreadyRegisteredException.java
+++ b/src/main/java/org/apache/xml/security/keys/ContentHandlerAlreadyRegisteredException.java
@@ -50,7 +50,7 @@
* @param msgID
* @param exArgs
*/
- public ContentHandlerAlreadyRegisteredException(String msgID, Object[] exArgs) {
+ public ContentHandlerAlreadyRegisteredException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -77,7 +77,7 @@
* @param exArgs
*/
public ContentHandlerAlreadyRegisteredException(
- Exception originalException, String msgID, Object[] exArgs
+ Exception originalException, String msgID, Object exArgs[]
) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/keys/content/DEREncodedKeyValue.java b/src/main/java/org/apache/xml/security/keys/content/DEREncodedKeyValue.java
index f2eeb61..ef55804 100644
--- a/src/main/java/org/apache/xml/security/keys/content/DEREncodedKeyValue.java
+++ b/src/main/java/org/apache/xml/security/keys/content/DEREncodedKeyValue.java
@@ -37,7 +37,7 @@
public class DEREncodedKeyValue extends Signature11ElementProxy implements KeyInfoContent {
/** JCA algorithm key types supported by this implementation. */
- private static final String[] supportedKeyTypes = { "RSA", "DSA", "EC"};
+ private static final String supportedKeyTypes[] = { "RSA", "DSA", "EC"};
/**
* Constructor DEREncodedKeyValue
@@ -137,10 +137,10 @@
X509EncodedKeySpec keySpec = keyFactory.getKeySpec(publicKey, X509EncodedKeySpec.class);
return keySpec.getEncoded();
} catch (NoSuchAlgorithmException e) {
- Object[] exArgs = { publicKey.getAlgorithm(), publicKey.getFormat(), publicKey.getClass().getName() };
+ Object exArgs[] = { publicKey.getAlgorithm(), publicKey.getFormat(), publicKey.getClass().getName() };
throw new XMLSecurityException(e, "DEREncodedKeyValue.UnsupportedPublicKey", exArgs);
} catch (InvalidKeySpecException e) {
- Object[] exArgs = { publicKey.getAlgorithm(), publicKey.getFormat(), publicKey.getClass().getName() };
+ Object exArgs[] = { publicKey.getAlgorithm(), publicKey.getFormat(), publicKey.getClass().getName() };
throw new XMLSecurityException(e, "DEREncodedKeyValue.UnsupportedPublicKey", exArgs);
}
}
diff --git a/src/main/java/org/apache/xml/security/keys/content/X509Data.java b/src/main/java/org/apache/xml/security/keys/content/X509Data.java
index bbeff11..76a5ae5 100644
--- a/src/main/java/org/apache/xml/security/keys/content/X509Data.java
+++ b/src/main/java/org/apache/xml/security/keys/content/X509Data.java
@@ -67,7 +67,7 @@
}
if (sibling == null || sibling.getNodeType() != Node.ELEMENT_NODE) {
/* No Elements found */
- Object[] exArgs = { "Elements", Constants._TAG_X509DATA };
+ Object exArgs[] = { "Elements", Constants._TAG_X509DATA };
throw new XMLSecurityException("xml.WrongContent", exArgs);
}
}
diff --git a/src/main/java/org/apache/xml/security/keys/content/keyvalues/DSAKeyValue.java b/src/main/java/org/apache/xml/security/keys/content/keyvalues/DSAKeyValue.java
index dbe6538..23a96e9 100644
--- a/src/main/java/org/apache/xml/security/keys/content/keyvalues/DSAKeyValue.java
+++ b/src/main/java/org/apache/xml/security/keys/content/keyvalues/DSAKeyValue.java
@@ -86,7 +86,7 @@
this.addBigIntegerElement(params.getG(), Constants._TAG_G);
this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
} else {
- Object[] exArgs = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };
+ Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };
throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
}
diff --git a/src/main/java/org/apache/xml/security/keys/content/keyvalues/RSAKeyValue.java b/src/main/java/org/apache/xml/security/keys/content/keyvalues/RSAKeyValue.java
index b0280bd..6be3dd7 100644
--- a/src/main/java/org/apache/xml/security/keys/content/keyvalues/RSAKeyValue.java
+++ b/src/main/java/org/apache/xml/security/keys/content/keyvalues/RSAKeyValue.java
@@ -82,7 +82,7 @@
((RSAPublicKey) key).getPublicExponent(), Constants._TAG_EXPONENT
);
} else {
- Object[] exArgs = { Constants._TAG_RSAKEYVALUE, key.getClass().getName() };
+ Object exArgs[] = { Constants._TAG_RSAKEYVALUE, key.getClass().getName() };
throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
}
diff --git a/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509Certificate.java b/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509Certificate.java
index 0b5e91f..878e69b 100644
--- a/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509Certificate.java
+++ b/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509Certificate.java
@@ -96,7 +96,7 @@
* @throws XMLSecurityException
*/
public X509Certificate getX509Certificate() throws XMLSecurityException {
- byte[] certbytes = this.getCertificateBytes();
+ byte certbytes[] = this.getCertificateBytes();
try (InputStream is = new ByteArrayInputStream(certbytes)) {
CertificateFactory certFact =
CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID);
diff --git a/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509Digest.java b/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509Digest.java
index 6a682da..e2fd8e8 100644
--- a/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509Digest.java
+++ b/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509Digest.java
@@ -113,7 +113,7 @@
public static byte[] getDigestBytesFromCert(X509Certificate cert, String algorithmURI) throws XMLSecurityException {
String jcaDigestAlgorithm = JCEMapper.translateURItoJCEID(algorithmURI);
if (jcaDigestAlgorithm == null) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new XMLSecurityException("XMLX509Digest.UnknownDigestAlgorithm", exArgs);
}
@@ -121,7 +121,7 @@
MessageDigest md = MessageDigest.getInstance(jcaDigestAlgorithm);
return md.digest(cert.getEncoded());
} catch (Exception e) {
- Object[] exArgs = { jcaDigestAlgorithm };
+ Object exArgs[] = { jcaDigestAlgorithm };
throw new XMLSecurityException("XMLX509Digest.FailedDigest", exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509SKI.java b/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509SKI.java
index c18922b..d188e5b 100644
--- a/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509SKI.java
+++ b/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509SKI.java
@@ -108,7 +108,7 @@
throws XMLSecurityException {
if (cert.getVersion() < 3) {
- Object[] exArgs = { cert.getVersion() };
+ Object exArgs[] = { cert.getVersion() };
throw new XMLSecurityException("certificate.noSki.lowVersion", exArgs);
}
@@ -129,7 +129,7 @@
* OCTET STRING, and the next two bytes are the tag and length of
* the ski OCTET STRING.
*/
- byte[] skidValue = new byte[extensionValue.length - 4];
+ byte skidValue[] = new byte[extensionValue.length - 4];
System.arraycopy(extensionValue, 4, skidValue, 0, skidValue.length);
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/InvalidKeyResolverException.java b/src/main/java/org/apache/xml/security/keys/keyresolver/InvalidKeyResolverException.java
index 5a9f856..324d399 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/InvalidKeyResolverException.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/InvalidKeyResolverException.java
@@ -50,7 +50,7 @@
* @param msgID
* @param exArgs
*/
- public InvalidKeyResolverException(String msgID, Object[] exArgs) {
+ public InvalidKeyResolverException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -76,7 +76,7 @@
* @param msgID
* @param exArgs
*/
- public InvalidKeyResolverException(Exception originalException, String msgID, Object[] exArgs) {
+ public InvalidKeyResolverException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java b/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java
index 82541e5..e123a0c 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java
@@ -54,7 +54,7 @@
org.slf4j.LoggerFactory.getLogger(KeyResolver.class);
/** Field resolverVector */
- private static List<KeyResolver> resolverVector = new CopyOnWriteArrayList<>();
+ private static List<KeyResolver> resolverVector = new CopyOnWriteArrayList<KeyResolver>();
/** Field resolverSpi */
private final KeyResolverSpi resolverSpi;
@@ -92,7 +92,7 @@
) throws KeyResolverException {
for (KeyResolver resolver : resolverVector) {
if (resolver == null) {
- Object[] exArgs = {
+ Object exArgs[] = {
element != null
&& element.getNodeType() == Node.ELEMENT_NODE
? element.getTagName() : "null"
@@ -108,7 +108,7 @@
}
}
- Object[] exArgs = {
+ Object exArgs[] = {
element != null && element.getNodeType() == Node.ELEMENT_NODE
? element.getTagName() : "null"
};
@@ -131,7 +131,7 @@
) throws KeyResolverException {
for (KeyResolver resolver : resolverVector) {
if (resolver == null) {
- Object[] exArgs = {
+ Object exArgs[] = {
element != null
&& element.getNodeType() == Node.ELEMENT_NODE
? element.getTagName() : "null"
@@ -147,7 +147,7 @@
}
}
- Object[] exArgs = {
+ Object exArgs[] = {
element != null && element.getNodeType() == Node.ELEMENT_NODE
? element.getTagName() : "null"
};
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverException.java b/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverException.java
index 7ed3ab4..accf56e 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverException.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverException.java
@@ -54,7 +54,7 @@
* @param msgID
* @param exArgs
*/
- public KeyResolverException(String msgID, Object[] exArgs) {
+ public KeyResolverException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -80,7 +80,7 @@
* @param msgID
* @param exArgs
*/
- public KeyResolverException(Exception originalException, String msgID, Object[] exArgs) {
+ public KeyResolverException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java b/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java
index f5456a6..7f96c65 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java
@@ -27,6 +27,7 @@
import java.util.HashMap;
import javax.crypto.SecretKey;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xml.security.keys.storage.StorageResolver;
@@ -270,8 +271,10 @@
* @throws KeyResolverException if something goes wrong
*/
protected static Element getDocFromBytes(byte[] bytes, boolean secureValidation) throws KeyResolverException {
+ DocumentBuilder db = null;
try (InputStream is = new ByteArrayInputStream(bytes)) {
- Document doc = XMLUtils.read(is, secureValidation);
+ db = XMLUtils.createDocumentBuilder(false, secureValidation);
+ Document doc = db.parse(is);
return doc.getDocumentElement();
} catch (SAXException ex) {
throw new KeyResolverException(ex);
@@ -279,6 +282,10 @@
throw new KeyResolverException(ex);
} catch (ParserConfigurationException ex) {
throw new KeyResolverException(ex);
+ } finally {
+ if (db != null) {
+ XMLUtils.repoolDocumentBuilder(db);
+ }
}
}
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/KeyInfoReferenceResolver.java b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/KeyInfoReferenceResolver.java
index 81727b2..4571cc3 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/KeyInfoReferenceResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/KeyInfoReferenceResolver.java
@@ -189,7 +189,7 @@
*/
private void validateReference(Element referentElement) throws XMLSecurityException {
if (!XMLUtils.elementIsInSignatureSpace(referentElement, Constants._TAG_KEYINFO)) {
- Object[] exArgs = { new QName(referentElement.getNamespaceURI(), referentElement.getLocalName()) };
+ Object exArgs[] = { new QName(referentElement.getNamespaceURI(), referentElement.getLocalName()) };
throw new XMLSecurityException("KeyInfoReferenceResolver.InvalidReferentElement.WrongType", exArgs);
}
@@ -245,7 +245,7 @@
return null;
} else {
// Retrieved resource is a byte stream
- byte[] inputBytes = resource.getBytes();
+ byte inputBytes[] = resource.getBytes();
e = getDocFromBytes(inputBytes, this.secureValidation);
}
return e;
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/PrivateKeyResolver.java b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/PrivateKeyResolver.java
index 8b627ac..3ef4458 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/PrivateKeyResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/PrivateKeyResolver.java
@@ -72,8 +72,12 @@
* @return whether the KeyResolverSpi is able to perform the requested action.
*/
public boolean engineCanResolve(Element element, String baseURI, StorageResolver storage) {
- return XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_X509DATA)
- || XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME);
+ if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_X509DATA)
+ || XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
+ return true;
+ }
+
+ return false;
}
/**
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
index 611e494..126cd09 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
@@ -243,7 +243,7 @@
e = getDocumentElement(resource.getNodeSet());
} else {
// Retrieved resource is an inputStream
- byte[] inputBytes = resource.getBytes();
+ byte inputBytes[] = resource.getBytes();
e = getDocFromBytes(inputBytes, secureValidation);
// otherwise, we parse the resource, create an Element and delegate
LOG.debug("we have to parse {} bytes", inputBytes.length);
@@ -253,7 +253,7 @@
private static X509Certificate getRawCertificate(XMLSignatureInput resource)
throws CanonicalizationException, IOException, CertificateException {
- byte[] inputBytes = resource.getBytes();
+ byte inputBytes[] = resource.getBytes();
// if the resource stores a raw certificate, we have to handle it
CertificateFactory certFact =
CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID);
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509DigestResolver.java b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509DigestResolver.java
index f82fe0b..ad1bd79 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509DigestResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509DigestResolver.java
@@ -158,7 +158,7 @@
*/
private void checkStorage(StorageResolver storage) throws KeyResolverException {
if (storage == null) {
- Object[] exArgs = { Constants._TAG_X509DIGEST };
+ Object exArgs[] = { Constants._TAG_X509DIGEST };
KeyResolverException ex = new KeyResolverException("KeyResolver.needStorageResolver", exArgs);
LOG.debug("", ex);
throw ex;
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java
index d7086dc..39dcca2 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java
@@ -76,7 +76,7 @@
}
try {
if (storage == null) {
- Object[] exArgs = { Constants._TAG_X509ISSUERSERIAL };
+ Object exArgs[] = { Constants._TAG_X509ISSUERSERIAL };
KeyResolverException ex =
new KeyResolverException("KeyResolver.needStorageResolver", exArgs);
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java
index 2c33c19..069bde5 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java
@@ -91,7 +91,7 @@
}
try {
if (storage == null) {
- Object[] exArgs = { Constants._TAG_X509SKI };
+ Object exArgs[] = { Constants._TAG_X509SKI };
KeyResolverException ex =
new KeyResolverException("KeyResolver.needStorageResolver", exArgs);
diff --git a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
index 8f78227..2b3cf06 100644
--- a/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
@@ -92,7 +92,7 @@
try {
if (storage == null) {
- Object[] exArgs = { Constants._TAG_X509SUBJECTNAME };
+ Object exArgs[] = { Constants._TAG_X509SUBJECTNAME };
KeyResolverException ex =
new KeyResolverException("KeyResolver.needStorageResolver", exArgs);
diff --git a/src/main/java/org/apache/xml/security/keys/storage/StorageResolverException.java b/src/main/java/org/apache/xml/security/keys/storage/StorageResolverException.java
index 1f7b1df..c17dafe 100644
--- a/src/main/java/org/apache/xml/security/keys/storage/StorageResolverException.java
+++ b/src/main/java/org/apache/xml/security/keys/storage/StorageResolverException.java
@@ -55,7 +55,7 @@
* @param msgID
* @param exArgs
*/
- public StorageResolverException(String msgID, Object[] exArgs) {
+ public StorageResolverException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -81,7 +81,7 @@
* @param msgID
* @param exArgs
*/
- public StorageResolverException(Exception originalException, String msgID, Object[] exArgs) {
+ public StorageResolverException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java b/src/main/java/org/apache/xml/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java
index fe7523d..e05d50f 100644
--- a/src/main/java/org/apache/xml/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java
+++ b/src/main/java/org/apache/xml/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java
@@ -36,6 +36,7 @@
import org.apache.xml.security.keys.storage.StorageResolverException;
import org.apache.xml.security.keys.storage.StorageResolverSpi;
+import org.apache.xml.security.utils.XMLUtils;
/**
* This {@link StorageResolverSpi} makes all raw (binary) {@link X509Certificate}s
@@ -183,4 +184,32 @@
}
}
+ /**
+ * Method main
+ *
+ * @param unused
+ * @throws Exception
+ */
+ public static void main(String unused[]) throws Exception {
+
+ CertsInFilesystemDirectoryResolver krs =
+ new CertsInFilesystemDirectoryResolver(
+ "data/ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/certs");
+
+ for (Iterator<Certificate> i = krs.getIterator(); i.hasNext(); ) {
+ X509Certificate cert = (X509Certificate) i.next();
+ byte[] ski =
+ org.apache.xml.security.keys.content.x509.XMLX509SKI.getSKIBytesFromCert(cert);
+
+ System.out.println();
+ System.out.println("Base64(SKI())= \""
+ + XMLUtils.encodeToString(ski) + "\"");
+ System.out.println("cert.getSerialNumber()= \""
+ + cert.getSerialNumber().toString() + "\"");
+ System.out.println("cert.getSubjectX500Principal().getName()= \""
+ + cert.getSubjectX500Principal().getName() + "\"");
+ System.out.println("cert.getIssuerX500Principal().getName()= \""
+ + cert.getIssuerX500Principal().getName() + "\"");
+ }
+ }
}
diff --git a/src/main/java/org/apache/xml/security/signature/InvalidDigestValueException.java b/src/main/java/org/apache/xml/security/signature/InvalidDigestValueException.java
index b5f2144..ee3caa8 100644
--- a/src/main/java/org/apache/xml/security/signature/InvalidDigestValueException.java
+++ b/src/main/java/org/apache/xml/security/signature/InvalidDigestValueException.java
@@ -54,7 +54,7 @@
* @param msgID
* @param exArgs
*/
- public InvalidDigestValueException(String msgID, Object[] exArgs) {
+ public InvalidDigestValueException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -80,7 +80,7 @@
* @param msgID
* @param exArgs
*/
- public InvalidDigestValueException(Exception originalException, String msgID, Object[] exArgs) {
+ public InvalidDigestValueException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/signature/InvalidSignatureValueException.java b/src/main/java/org/apache/xml/security/signature/InvalidSignatureValueException.java
index bbf8db1..e30c2a5 100644
--- a/src/main/java/org/apache/xml/security/signature/InvalidSignatureValueException.java
+++ b/src/main/java/org/apache/xml/security/signature/InvalidSignatureValueException.java
@@ -53,7 +53,7 @@
* @param msgID
* @param exArgs
*/
- public InvalidSignatureValueException(String msgID, Object[] exArgs) {
+ public InvalidSignatureValueException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -79,7 +79,7 @@
* @param msgID
* @param exArgs
*/
- public InvalidSignatureValueException(Exception originalException, String msgID, Object[] exArgs) {
+ public InvalidSignatureValueException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/signature/Manifest.java b/src/main/java/org/apache/xml/security/signature/Manifest.java
index aaac2d5..ea24e39 100644
--- a/src/main/java/org/apache/xml/security/signature/Manifest.java
+++ b/src/main/java/org/apache/xml/security/signature/Manifest.java
@@ -133,14 +133,14 @@
int le = this.referencesEl.length;
if (le == 0) {
// At least one Reference must be present. Bad.
- Object[] exArgs = { Constants._TAG_REFERENCE, Constants._TAG_MANIFEST };
+ Object exArgs[] = { Constants._TAG_REFERENCE, Constants._TAG_MANIFEST };
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
I18n.translate("xml.WrongContent", exArgs));
}
if (secureValidation && le > referenceCount) {
- Object[] exArgs = { le, referenceCount };
+ Object exArgs[] = { le, referenceCount };
throw new XMLSecurityException("signature.tooManyReferences", exArgs);
}
@@ -316,13 +316,13 @@
);
}
LOG.debug("verify {} References", referencesEl.length);
- LOG.debug("I am {} requested to follow nested Manifests", followManifests
- ? "" : "not");
+ LOG.debug("I am {} requested to follow nested Manifests", (followManifests
+ ? "" : "not"));
if (referencesEl.length == 0) {
throw new XMLSecurityException("empty", new Object[]{"References are empty"});
}
if (secureValidation && referencesEl.length > referenceCount) {
- Object[] exArgs = { referencesEl.length, referenceCount };
+ Object exArgs[] = { referencesEl.length, referenceCount };
throw new XMLSecurityException("signature.tooManyReferences", exArgs);
}
@@ -410,7 +410,7 @@
verificationResults.add(new VerifiedReference(currentRefVerified, currentRef.getURI(), manifestReferences));
} catch (ReferenceNotInitializedException ex) {
- Object[] exArgs = { currentRef.getURI() };
+ Object exArgs[] = { currentRef.getURI() };
throw new MissingResourceFailureException(
ex, currentRef, "signature.Verification.Reference.NoInput", exArgs
@@ -432,7 +432,7 @@
*/
public boolean getVerificationResult(int index) throws XMLSecurityException {
if (index < 0 || index > this.getLength() - 1) {
- Object[] exArgs = { Integer.toString(index), Integer.toString(this.getLength()) };
+ Object exArgs[] = { Integer.toString(index), Integer.toString(this.getLength()) };
Exception e =
new IndexOutOfBoundsException(
I18n.translate("signature.Verification.IndexOutOfBounds", exArgs)
diff --git a/src/main/java/org/apache/xml/security/signature/MissingResourceFailureException.java b/src/main/java/org/apache/xml/security/signature/MissingResourceFailureException.java
index 3b213d2..395708b 100644
--- a/src/main/java/org/apache/xml/security/signature/MissingResourceFailureException.java
+++ b/src/main/java/org/apache/xml/security/signature/MissingResourceFailureException.java
@@ -60,14 +60,14 @@
* @param exArgs
* @see #getReference
*/
- public MissingResourceFailureException(Reference reference, String msgID, Object[] exArgs) {
+ public MissingResourceFailureException(Reference reference, String msgID, Object exArgs[]) {
super(msgID, exArgs);
this.uninitializedReference = reference;
}
@Deprecated
- public MissingResourceFailureException(String msgID, Object[] exArgs, Reference reference) {
+ public MissingResourceFailureException(String msgID, Object exArgs[], Reference reference) {
this(reference, msgID, exArgs);
}
@@ -104,7 +104,7 @@
* @see #getReference
*/
public MissingResourceFailureException(
- Exception originalException, Reference reference, String msgID, Object[] exArgs
+ Exception originalException, Reference reference, String msgID, Object exArgs[]
) {
super(originalException, msgID, exArgs);
@@ -113,7 +113,7 @@
@Deprecated
public MissingResourceFailureException(
- String msgID, Object[] exArgs, Exception originalException, Reference reference
+ String msgID, Object exArgs[], Exception originalException, Reference reference
) {
this(originalException, reference, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/signature/Reference.java b/src/main/java/org/apache/xml/security/signature/Reference.java
index 4b94d5d..dd752fb 100644
--- a/src/main/java/org/apache/xml/security/signature/Reference.java
+++ b/src/main/java/org/apache/xml/security/signature/Reference.java
@@ -234,7 +234,7 @@
transforms = new Transforms(el, this.baseURI);
transforms.setSecureValidation(secureValidation);
if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
- Object[] exArgs = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };
+ Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };
throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
}
@@ -273,7 +273,7 @@
}
if (secureValidation && MessageDigestAlgorithm.ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5.equals(uri)) {
- Object[] exArgs = { uri };
+ Object exArgs[] = { uri };
throw new XMLSignatureException("signature.signatureAlgorithm", exArgs);
}
@@ -355,7 +355,11 @@
* <code>Object</code>
*/
public boolean typeIsReferenceToObject() {
- return Reference.OBJECT_URI.equals(this.getType());
+ if (Reference.OBJECT_URI.equals(this.getType())) {
+ return true;
+ }
+
+ return false;
}
/**
@@ -368,7 +372,11 @@
* {@link Manifest}
*/
public boolean typeIsReferenceToManifest() {
- return Reference.MANIFEST_URI.equals(this.getType());
+ if (Reference.MANIFEST_URI.equals(this.getType())) {
+ return true;
+ }
+
+ return false;
}
/**
diff --git a/src/main/java/org/apache/xml/security/signature/ReferenceNotInitializedException.java b/src/main/java/org/apache/xml/security/signature/ReferenceNotInitializedException.java
index 60f3356..b361765 100644
--- a/src/main/java/org/apache/xml/security/signature/ReferenceNotInitializedException.java
+++ b/src/main/java/org/apache/xml/security/signature/ReferenceNotInitializedException.java
@@ -57,7 +57,7 @@
* @param msgID
* @param exArgs
*/
- public ReferenceNotInitializedException(String msgID, Object[] exArgs) {
+ public ReferenceNotInitializedException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -83,7 +83,7 @@
* @param msgID
* @param exArgs
*/
- public ReferenceNotInitializedException(Exception originalException, String msgID, Object[] exArgs) {
+ public ReferenceNotInitializedException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/signature/SignedInfo.java b/src/main/java/org/apache/xml/security/signature/SignedInfo.java
index 918f90b..5105824 100644
--- a/src/main/java/org/apache/xml/security/signature/SignedInfo.java
+++ b/src/main/java/org/apache/xml/security/signature/SignedInfo.java
@@ -211,12 +211,16 @@
c14nizer.setSecureValidation(secureValidation);
byte[] c14nizedBytes = c14nizer.canonicalizeSubtree(element);
+ javax.xml.parsers.DocumentBuilder db =
+ XMLUtils.createDocumentBuilder(false, secureValidation);
try (InputStream is = new ByteArrayInputStream(c14nizedBytes)) {
- Document newdoc = XMLUtils.read(is, secureValidation);
+ Document newdoc = db.parse(is);
Node imported = element.getOwnerDocument().importNode(
newdoc.getDocumentElement(), true);
element.getParentNode().replaceChild(imported, element);
return (Element) imported;
+ } finally {
+ XMLUtils.repoolDocumentBuilder(db);
}
} catch (ParserConfigurationException ex) {
throw new XMLSecurityException(ex);
@@ -370,8 +374,8 @@
public String getInclusiveNamespaces() {
String c14nMethodURI = getCanonicalizationMethodURI();
- if (!("http://www.w3.org/2001/10/xml-exc-c14n#".equals(c14nMethodURI) ||
- "http://www.w3.org/2001/10/xml-exc-c14n#WithComments".equals(c14nMethodURI))) {
+ if (!(c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#") ||
+ c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
return null;
}
diff --git a/src/main/java/org/apache/xml/security/signature/XMLSignature.java b/src/main/java/org/apache/xml/security/signature/XMLSignature.java
index ce85ec9..08aac36 100644
--- a/src/main/java/org/apache/xml/security/signature/XMLSignature.java
+++ b/src/main/java/org/apache/xml/security/signature/XMLSignature.java
@@ -397,7 +397,7 @@
// check to see if it is there
if (signedInfoElem == null) {
- Object[] exArgs = { Constants._TAG_SIGNEDINFO, Constants._TAG_SIGNATURE };
+ Object exArgs[] = { Constants._TAG_SIGNEDINFO, Constants._TAG_SIGNATURE };
throw new XMLSignatureException("xml.WrongContent", exArgs);
}
@@ -412,7 +412,7 @@
// check to see if it exists
if (signatureValueElement == null) {
- Object[] exArgs = { Constants._TAG_SIGNATUREVALUE, Constants._TAG_SIGNATURE };
+ Object exArgs[] = { Constants._TAG_SIGNATUREVALUE, Constants._TAG_SIGNATURE };
throw new XMLSignatureException("xml.WrongContent", exArgs);
}
Attr signatureValueAttr = signatureValueElement.getAttributeNodeNS(null, "Id");
@@ -696,7 +696,7 @@
return this.checkSignatureValue(cert.getPublicKey());
}
- Object[] exArgs = { "Didn't get a certificate" };
+ Object exArgs[] = { "Didn't get a certificate" };
throw new XMLSignatureException("empty", exArgs);
}
@@ -714,7 +714,7 @@
//COMMENT: pk suggests it can only be a public key?
//check to see if the key is not null
if (pk == null) {
- Object[] exArgs = { "Didn't get a key" };
+ Object exArgs[] = { "Didn't get a key" };
throw new XMLSignatureException("empty", exArgs);
}
// all references inside the signedinfo need to be dereferenced and
@@ -732,7 +732,7 @@
LOG.debug("jceSigProvider = {}", sa.getJCEProviderName());
LOG.debug("PublicKey = {}", pk);
- byte[] sigBytes = null;
+ byte sigBytes[] = null;
try (SignerOutputStream so = new SignerOutputStream(sa);
OutputStream bos = new UnsyncBufferedOutputStream(so)) {
diff --git a/src/main/java/org/apache/xml/security/signature/XMLSignatureException.java b/src/main/java/org/apache/xml/security/signature/XMLSignatureException.java
index eef5627..774720d 100644
--- a/src/main/java/org/apache/xml/security/signature/XMLSignatureException.java
+++ b/src/main/java/org/apache/xml/security/signature/XMLSignatureException.java
@@ -59,7 +59,7 @@
* @param msgID
* @param exArgs
*/
- public XMLSignatureException(String msgID, Object[] exArgs) {
+ public XMLSignatureException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -85,7 +85,7 @@
* @param msgID
* @param exArgs
*/
- public XMLSignatureException(Exception originalException, String msgID, Object[] exArgs) {
+ public XMLSignatureException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/signature/XMLSignatureInput.java b/src/main/java/org/apache/xml/security/signature/XMLSignatureInput.java
index e8f82fa..c6f56bf 100644
--- a/src/main/java/org/apache/xml/security/signature/XMLSignatureInput.java
+++ b/src/main/java/org/apache/xml/security/signature/XMLSignatureInput.java
@@ -29,6 +29,7 @@
import java.util.List;
import java.util.Set;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xml.security.c14n.CanonicalizationException;
@@ -225,12 +226,12 @@
if (circumvent) {
XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(subNode));
}
- inputNodeSet = new LinkedHashSet<>();
+ inputNodeSet = new LinkedHashSet<Node>();
XMLUtils.getSet(subNode, inputNodeSet, excludeNode, excludeComments);
return inputNodeSet;
} else if (isOctetStream()) {
convertToNodes();
- Set<Node> result = new LinkedHashSet<>();
+ Set<Node> result = new LinkedHashSet<Node>();
XMLUtils.getSet(subNode, result, null, false);
return result;
}
@@ -569,9 +570,12 @@
void convertToNodes() throws CanonicalizationException,
ParserConfigurationException, IOException, SAXException {
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false, secureValidation);
// select all nodes, also the comments.
try {
- Document doc = XMLUtils.read(this.getOctetStream(), secureValidation);
+ db.setErrorHandler(new org.apache.xml.security.utils.IgnoreAllErrorHandler());
+
+ Document doc = db.parse(this.getOctetStream());
this.subNode = doc;
} catch (SAXException ex) {
byte[] result = null;
@@ -585,10 +589,11 @@
result = baos.toByteArray();
}
try (InputStream is = new ByteArrayInputStream(result)) {
- Document document = XMLUtils.read(is, secureValidation);
+ Document document = db.parse(is);
this.subNode = document.getDocumentElement().getFirstChild().getFirstChild();
}
} finally {
+ XMLUtils.repoolDocumentBuilder(db);
if (this.inputOctetStreamProxy != null) {
this.inputOctetStreamProxy.close();
}
diff --git a/src/main/java/org/apache/xml/security/signature/XMLSignatureInputDebugger.java b/src/main/java/org/apache/xml/security/signature/XMLSignatureInputDebugger.java
index 6cc0b0d..cf47d76 100644
--- a/src/main/java/org/apache/xml/security/signature/XMLSignatureInputDebugger.java
+++ b/src/main/java/org/apache/xml/security/signature/XMLSignatureInputDebugger.java
@@ -291,7 +291,7 @@
}
Arrays.sort(attrs2, ATTR_COMPARE);
- Object[] attrs3 = attrs2;
+ Object attrs3[] = attrs2;
for (int i = 0; i < attrsLength; i++) {
Attr a = (Attr) attrs3[i];
@@ -512,10 +512,15 @@
for (int i = 0; i < length; i++) {
char c = data.charAt(i);
- if (c == 0x0D) {
+ switch (c) {
+
+ case 0x0D:
this.writer.write("&#xD;");
- } else {
+ break;
+
+ default:
this.writer.write(c);
+ break;
}
}
}
diff --git a/src/main/java/org/apache/xml/security/stax/config/ConfigurationProperties.java b/src/main/java/org/apache/xml/security/stax/config/ConfigurationProperties.java
index 78f1f3c..fc3781b 100644
--- a/src/main/java/org/apache/xml/security/stax/config/ConfigurationProperties.java
+++ b/src/main/java/org/apache/xml/security/stax/config/ConfigurationProperties.java
@@ -28,7 +28,7 @@
* Configuration Properties
*
*/
-public final class ConfigurationProperties {
+public class ConfigurationProperties {
private static Properties properties;
private static Class<?> callingClass;
diff --git a/src/main/java/org/apache/xml/security/stax/config/Init.java b/src/main/java/org/apache/xml/security/stax/config/Init.java
index 0da7116..cacf54d 100644
--- a/src/main/java/org/apache/xml/security/stax/config/Init.java
+++ b/src/main/java/org/apache/xml/security/stax/config/Init.java
@@ -54,15 +54,12 @@
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- schemaFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
Schema schema = schemaFactory.newSchema(
ClassLoaderUtils.getResource("schemas/security-config.xsd", Init.class));
unmarshaller.setSchema(schema);
final UnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler();
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
- saxParserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
- saxParserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
saxParserFactory.setXIncludeAware(false);
saxParserFactory.setNamespaceAware(true);
SAXParser saxParser = saxParserFactory.newSAXParser();
diff --git a/src/main/java/org/apache/xml/security/stax/config/JCEAlgorithmMapper.java b/src/main/java/org/apache/xml/security/stax/config/JCEAlgorithmMapper.java
index febe3d1..d6d6fd6 100644
--- a/src/main/java/org/apache/xml/security/stax/config/JCEAlgorithmMapper.java
+++ b/src/main/java/org/apache/xml/security/stax/config/JCEAlgorithmMapper.java
@@ -27,7 +27,7 @@
/**
* Mapping between JCE id and xmlsec uri's for algorithms
*/
-public final class JCEAlgorithmMapper extends JCEMapper {
+public class JCEAlgorithmMapper extends JCEMapper {
private JCEAlgorithmMapper() {
}
diff --git a/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java b/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java
index 275894d..93d63e6 100644
--- a/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java
+++ b/src/main/java/org/apache/xml/security/stax/config/ResourceResolverMapper.java
@@ -30,7 +30,7 @@
/**
*/
-public final class ResourceResolverMapper {
+public class ResourceResolverMapper {
private static List<ResourceResolverLookup> resourceResolvers;
diff --git a/src/main/java/org/apache/xml/security/stax/config/SecurityHeaderHandlerMapper.java b/src/main/java/org/apache/xml/security/stax/config/SecurityHeaderHandlerMapper.java
index e46b969..d9b2062 100644
--- a/src/main/java/org/apache/xml/security/stax/config/SecurityHeaderHandlerMapper.java
+++ b/src/main/java/org/apache/xml/security/stax/config/SecurityHeaderHandlerMapper.java
@@ -32,7 +32,7 @@
* Security-header handler mapper
*
*/
-public final class SecurityHeaderHandlerMapper {
+public class SecurityHeaderHandlerMapper {
private static Map<QName, Class<?>> handlerClassMap;
diff --git a/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java b/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java
index f481096..474a911 100644
--- a/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java
+++ b/src/main/java/org/apache/xml/security/stax/config/TransformerAlgorithmMapper.java
@@ -32,7 +32,7 @@
* Mapping between JCE id and xmlsec uri's for algorithms
*
*/
-public final class TransformerAlgorithmMapper {
+public class TransformerAlgorithmMapper {
private static Map<String, Class<?>> algorithmsClassMapInOut;
private static Map<String, Class<?>> algorithmsClassMapIn;
@@ -68,10 +68,13 @@
public static Class<?> getTransformerClass(String algoURI, XMLSecurityConstants.DIRECTION direction) throws XMLSecurityException {
Class<?> clazz = null;
- if (XMLSecurityConstants.DIRECTION.IN == direction) {
- clazz = algorithmsClassMapIn.get(algoURI);
- } else if (XMLSecurityConstants.DIRECTION.OUT == direction) {
- clazz = algorithmsClassMapOut.get(algoURI);
+ switch (direction) {
+ case IN:
+ clazz = algorithmsClassMapIn.get(algoURI);
+ break;
+ case OUT:
+ clazz = algorithmsClassMapOut.get(algoURI);
+ break;
}
if (clazz == null) {
diff --git a/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java b/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java
index 21e446e..e823169 100644
--- a/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/ext/AbstractBufferingOutputProcessor.java
@@ -30,7 +30,7 @@
*/
public abstract class AbstractBufferingOutputProcessor extends AbstractOutputProcessor {
- private final ArrayDeque<XMLSecEvent> xmlSecEventBuffer = new ArrayDeque<>(100);
+ private final ArrayDeque<XMLSecEvent> xmlSecEventBuffer = new ArrayDeque<XMLSecEvent>(100);
protected AbstractBufferingOutputProcessor() throws XMLSecurityException {
super();
diff --git a/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java b/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java
index dd78de8..f71f1a4 100644
--- a/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/ext/AbstractOutputProcessor.java
@@ -285,10 +285,13 @@
createStartElementAndOutputAsEvent(outputProcessorChain, elementName, namespaces, attributes);
Node childNode = element.getFirstChild();
while (childNode != null) {
- if (Node.ELEMENT_NODE == childNode.getNodeType()) {
- outputDOMElement((Element) childNode, outputProcessorChain);
- } else if (Node.TEXT_NODE == childNode.getNodeType()) {
- createCharactersAndOutputAsEvent(outputProcessorChain, ((Text) childNode).getData());
+ switch (childNode.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ outputDOMElement((Element) childNode, outputProcessorChain);
+ break;
+ case Node.TEXT_NODE:
+ createCharactersAndOutputAsEvent(outputProcessorChain, ((Text) childNode).getData());
+ break;
}
childNode = childNode.getNextSibling();
}
diff --git a/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java b/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java
index a89bf71..d1aeddb 100644
--- a/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java
+++ b/src/main/java/org/apache/xml/security/stax/ext/OutboundXMLSec.java
@@ -115,7 +115,8 @@
configureSignatureKeys(outboundSecurityContext);
List<SecurePart> signatureParts = securityProperties.getSignatureSecureParts();
- for (SecurePart securePart : signatureParts) {
+ for (int j = 0; j < signatureParts.size(); j++) {
+ SecurePart securePart = signatureParts.get(j);
if (securePart.getIdToSign() == null && securePart.getName() != null) {
outputProcessorChain.getSecurityContext().putAsMap(
XMLSecurityConstants.SIGNATURE_PARTS,
@@ -139,7 +140,8 @@
configureEncryptionKeys(outboundSecurityContext);
List<SecurePart> encryptionParts = securityProperties.getEncryptionSecureParts();
- for (SecurePart securePart : encryptionParts) {
+ for (int j = 0; j < encryptionParts.size(); j++) {
+ SecurePart securePart = encryptionParts.get(j);
if (securePart.getIdToSign() == null && securePart.getName() != null) {
outputProcessorChain.getSecurityContext().putAsMap(
XMLSecurityConstants.ENCRYPTION_PARTS,
diff --git a/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java b/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java
index eec0e7f..679d4aa 100644
--- a/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java
+++ b/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java
@@ -38,7 +38,7 @@
private boolean skipDocumentEvents = false;
private boolean disableSchemaValidation = false;
- private List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ private List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
private X509Certificate encryptionUseThisCertificate;
private String encryptionSymAlgorithm;
@@ -46,7 +46,7 @@
private String encryptionKeyTransportDigestAlgorithm;
private String encryptionKeyTransportMGFAlgorithm;
private byte[] encryptionKeyTransportOAEPParams;
- private final List<SecurePart> encryptionParts = new LinkedList<>();
+ private final List<SecurePart> encryptionParts = new LinkedList<SecurePart>();
private Key encryptionKey;
private Key encryptionTransportKey;
private SecurityTokenConstants.KeyIdentifier encryptionKeyIdentifier;
@@ -54,7 +54,7 @@
private Key decryptionKey;
- private final List<SecurePart> signatureParts = new LinkedList<>();
+ private final List<SecurePart> signatureParts = new LinkedList<SecurePart>();
private String signatureAlgorithm;
private String signatureDigestAlgorithm;
private String signatureCanonicalizationAlgorithm;
@@ -409,7 +409,7 @@
public void addAction(XMLSecurityConstants.Action action) {
if (actions == null) {
- actions = new ArrayList<>();
+ actions = new ArrayList<XMLSecurityConstants.Action>();
}
actions.add(action);
}
diff --git a/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java b/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java
index 8f7591e..8c31311 100644
--- a/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java
+++ b/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java
@@ -18,22 +18,24 @@
*/
package org.apache.xml.security.stax.ext;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.math.BigInteger;
-import java.security.PublicKey;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.X509Certificate;
-import java.security.interfaces.DSAPublicKey;
-import java.security.interfaces.ECPublicKey;
-import java.security.interfaces.RSAPublicKey;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
+import org.apache.xml.security.algorithms.JCEMapper;
+import org.apache.xml.security.algorithms.implementations.ECDSAUtils;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.keys.content.x509.XMLX509SKI;
+import org.apache.xml.security.stax.config.TransformerAlgorithmMapper;
+import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import org.apache.xml.security.stax.impl.util.ConcreteLSInput;
+import org.apache.xml.security.stax.securityEvent.*;
+import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
+import org.apache.xml.security.utils.ClassLoaderUtils;
+import org.apache.xml.security.utils.XMLUtils;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.xml.sax.SAXException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
@@ -46,30 +48,17 @@
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
-import org.w3c.dom.ls.LSInput;
-import org.w3c.dom.ls.LSResourceResolver;
-import org.xml.sax.SAXException;
-
-import org.apache.xml.security.algorithms.JCEMapper;
-import org.apache.xml.security.algorithms.implementations.ECDSAUtils;
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.keys.content.x509.XMLX509SKI;
-import org.apache.xml.security.stax.config.TransformerAlgorithmMapper;
-import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.apache.xml.security.stax.impl.util.ConcreteLSInput;
-import org.apache.xml.security.stax.securityEvent.DefaultTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.EncryptedKeyTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.KeyNameTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.KeyValueTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.TokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.X509TokenSecurityEvent;
-import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
-import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
-import org.apache.xml.security.utils.ClassLoaderUtils;
-import org.apache.xml.security.utils.XMLUtils;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.math.BigInteger;
+import java.security.PublicKey;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.ECPublicKey;
+import java.security.interfaces.RSAPublicKey;
+import java.util.*;
/**
*/
@@ -509,7 +498,6 @@
public static Schema loadXMLSecuritySchemas() throws SAXException {
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- schemaFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
schemaFactory.setResourceResolver(new LSResourceResolver() {
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
diff --git a/src/main/java/org/apache/xml/security/stax/ext/stax/XMLSecEventFactory.java b/src/main/java/org/apache/xml/security/stax/ext/stax/XMLSecEventFactory.java
index d91d060..ff3f84d 100644
--- a/src/main/java/org/apache/xml/security/stax/ext/stax/XMLSecEventFactory.java
+++ b/src/main/java/org/apache/xml/security/stax/ext/stax/XMLSecEventFactory.java
@@ -18,33 +18,21 @@
*/
package org.apache.xml.security.stax.ext.stax;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
+import org.apache.xml.security.stax.impl.stax.*;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.EntityDeclaration;
-
-import org.apache.xml.security.stax.impl.stax.XMLSecAttributeImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecCharactersImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecCommentImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecDTDImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecEndDocumentImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecEndElementImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecEntityDeclarationImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecEntityReferenceImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecNamespaceImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecProcessingInstructionImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecStartDocumentImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecStartElementImpl;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
/**
*/
-public final class XMLSecEventFactory {
+public class XMLSecEventFactory {
private XMLSecEventFactory() {
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java b/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java
index 319cce6..adcd969 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/DocumentContextImpl.java
@@ -31,7 +31,7 @@
private String encoding;
private String baseURI;
- private final Map<Integer, XMLSecurityConstants.ContentType> contentTypeMap = new TreeMap<>();
+ private final Map<Integer, XMLSecurityConstants.ContentType> contentTypeMap = new TreeMap<Integer, XMLSecurityConstants.ContentType>();
private final Map<Object, Integer> processorToIndexMap = new HashMap<>();
@Override
@@ -101,8 +101,8 @@
}
@Override
- public DocumentContextImpl clone() throws CloneNotSupportedException {
- DocumentContextImpl documentContext = (DocumentContextImpl)super.clone();
+ protected DocumentContextImpl clone() throws CloneNotSupportedException {
+ DocumentContextImpl documentContext = new DocumentContextImpl();
documentContext.setEncoding(this.encoding);
documentContext.setBaseURI(this.baseURI);
documentContext.setContentTypeMap(getContentTypeMap());
diff --git a/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java b/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java
index 9f5b8a7..0e9ba67 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/InputProcessorChainImpl.java
@@ -18,20 +18,15 @@
*/
package org.apache.xml.security.stax.impl;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.DocumentContext;
-import org.apache.xml.security.stax.ext.InboundSecurityContext;
-import org.apache.xml.security.stax.ext.InputProcessor;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+
+import javax.xml.stream.XMLStreamException;
+import java.util.ArrayList;
+import java.util.List;
/**
* Implementation of a InputProcessorChain
diff --git a/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java b/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java
index 275c350..fb83ebe 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/OutputProcessorChainImpl.java
@@ -18,22 +18,17 @@
*/
package org.apache.xml.security.stax.impl;
-import java.util.ArrayList;
-import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.DocumentContext;
-import org.apache.xml.security.stax.ext.OutboundSecurityContext;
-import org.apache.xml.security.stax.ext.OutputProcessor;
-import org.apache.xml.security.stax.ext.OutputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
/**
* Implementation of a OutputProcessorChain
diff --git a/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityEventWriter.java b/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityEventWriter.java
index 346a646..f0089cd 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityEventWriter.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityEventWriter.java
@@ -18,29 +18,13 @@
*/
package org.apache.xml.security.stax.impl;
-import java.util.List;
+import org.apache.xml.security.stax.ext.stax.*;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLEventWriter;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.stream.events.Attribute;
-import javax.xml.stream.events.Comment;
-import javax.xml.stream.events.DTD;
-import javax.xml.stream.events.EntityReference;
-import javax.xml.stream.events.Namespace;
-import javax.xml.stream.events.ProcessingInstruction;
-import javax.xml.stream.events.StartDocument;
-import javax.xml.stream.events.XMLEvent;
-
-import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
-import org.apache.xml.security.stax.ext.stax.XMLSecCharacters;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import javax.xml.stream.*;
+import javax.xml.stream.events.*;
+import java.util.List;
/**
*/
diff --git a/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java b/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java
index bd0fda2..9c4f9d8 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/XMLSecurityStreamWriter.java
@@ -486,7 +486,7 @@
private NamespaceContext parentNamespaceContext;
private List<String> prefixNsList = Collections.emptyList();
- NSContext(NamespaceContext parentNamespaceContext) {
+ private NSContext(NamespaceContext parentNamespaceContext) {
this.parentNamespaceContext = parentNamespaceContext;
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/algorithms/DSAUtils.java b/src/main/java/org/apache/xml/security/stax/impl/algorithms/DSAUtils.java
index cf88666..11533db 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/algorithms/DSAUtils.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/algorithms/DSAUtils.java
@@ -33,7 +33,7 @@
* @throws java.io.IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
*/
- public static byte[] convertASN1toXMLDSIG(byte[] asn1Bytes) throws IOException {
+ public static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException {
return org.apache.xml.security.algorithms.implementations.ECDSAUtils.convertASN1toXMLDSIG(asn1Bytes);
}
@@ -47,7 +47,7 @@
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
*/
- public static byte[] convertXMLDSIGtoASN1(byte[] xmldsigBytes) throws IOException {
+ public static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException {
return org.apache.xml.security.algorithms.implementations.ECDSAUtils.convertXMLDSIGtoASN1(xmldsigBytes);
}
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/xml/security/stax/impl/algorithms/ECDSAUtils.java b/src/main/java/org/apache/xml/security/stax/impl/algorithms/ECDSAUtils.java
index dcc0f6b..a251369 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/algorithms/ECDSAUtils.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/algorithms/ECDSAUtils.java
@@ -41,7 +41,7 @@
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
- public static byte[] convertASN1toXMLDSIG(byte[] asn1Bytes) throws IOException {
+ public static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException {
return org.apache.xml.security.algorithms.implementations.ECDSAUtils.convertASN1toXMLDSIG(asn1Bytes);
}
@@ -57,7 +57,7 @@
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
- public static byte[] convertXMLDSIGtoASN1(byte[] xmldsigBytes) throws IOException {
+ public static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException {
return org.apache.xml.security.algorithms.implementations.ECDSAUtils.convertXMLDSIGtoASN1(xmldsigBytes);
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java b/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java
index bb975bc..aeab322 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithm.java
@@ -32,7 +32,7 @@
void engineUpdate(byte input) throws XMLSecurityException;
- void engineUpdate(byte[] buf, int offset, int len) throws XMLSecurityException;
+ void engineUpdate(byte buf[], int offset, int len) throws XMLSecurityException;
void engineInitSign(Key signingKey) throws XMLSecurityException;
diff --git a/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java b/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java
index a3570d3..a2fce72 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/algorithms/SignatureAlgorithmFactory.java
@@ -26,7 +26,7 @@
/**
*/
-public final class SignatureAlgorithmFactory {
+public class SignatureAlgorithmFactory {
private static SignatureAlgorithmFactory instance;
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java
index d74608e..7deca4f 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java
@@ -18,33 +18,32 @@
*/
package org.apache.xml.security.stax.impl.processor.input;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import org.apache.commons.codec.binary.Base64OutputStream;
+import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
+import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
+import org.apache.xml.security.utils.UnsyncByteArrayInputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.xml.security.binding.xmldsig.KeyInfoType;
+import org.apache.xml.security.binding.xmlenc.EncryptedDataType;
+import org.apache.xml.security.binding.xmlenc.EncryptedKeyType;
+import org.apache.xml.security.binding.xmlenc.ReferenceList;
+import org.apache.xml.security.binding.xmlenc.ReferenceType;
+import org.apache.xml.security.binding.xop.Include;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.config.ConfigurationProperties;
+import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
+import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import org.apache.xml.security.stax.impl.XMLSecurityEventReader;
+import org.apache.xml.security.stax.securityToken.SecurityTokenFactory;
+import org.apache.xml.security.stax.impl.util.*;
-import javax.crypto.BadPaddingException;
-import javax.crypto.Cipher;
-import javax.crypto.CipherOutputStream;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.NoSuchPaddingException;
-import javax.security.auth.DestroyFailedException;
-import javax.security.auth.Destroyable;
+import javax.crypto.*;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
@@ -55,41 +54,13 @@
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.Attribute;
-import org.apache.commons.codec.binary.Base64OutputStream;
-import org.apache.xml.security.binding.xmldsig.KeyInfoType;
-import org.apache.xml.security.binding.xmlenc.EncryptedDataType;
-import org.apache.xml.security.binding.xmlenc.EncryptedKeyType;
-import org.apache.xml.security.binding.xmlenc.ReferenceList;
-import org.apache.xml.security.binding.xmlenc.ReferenceType;
-import org.apache.xml.security.binding.xop.Include;
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.config.ConfigurationProperties;
-import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
-import org.apache.xml.security.stax.ext.AbstractInputProcessor;
-import org.apache.xml.security.stax.ext.InboundSecurityContext;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.SecurePart;
-import org.apache.xml.security.stax.ext.UncheckedXMLSecurityException;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
-import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.apache.xml.security.stax.impl.XMLSecurityEventReader;
-import org.apache.xml.security.stax.impl.util.FullyBufferedOutputStream;
-import org.apache.xml.security.stax.impl.util.IDGenerator;
-import org.apache.xml.security.stax.impl.util.IVSplittingOutputStream;
-import org.apache.xml.security.stax.impl.util.MultiInputStream;
-import org.apache.xml.security.stax.impl.util.ReplaceableOuputStream;
-import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
-import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
-import org.apache.xml.security.stax.securityToken.SecurityTokenFactory;
-import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
-import org.apache.xml.security.utils.UnsyncByteArrayInputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.*;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.util.*;
/**
* Processor for decryption of EncryptedData XML structures
@@ -111,7 +82,7 @@
private final String uuid = IDGenerator.generateID(null);
private final QName wrapperElementName = new QName("http://dummy", "dummy", uuid);
- private final ArrayDeque<XMLSecEvent> tmpXmlEventList = new ArrayDeque<>();
+ private final ArrayDeque<XMLSecEvent> tmpXmlEventList = new ArrayDeque<XMLSecEvent>();
public AbstractDecryptInputProcessor(XMLSecurityProperties securityProperties) throws XMLSecurityException {
super(securityProperties);
@@ -286,7 +257,7 @@
if (nextEvent.isStartElement() && nextEvent.asStartElement().getName().equals(XMLSecurityConstants.TAG_XOP_INCLUDE)) {
try {
// Unmarshal the XOP Include Element
- Deque<XMLSecEvent> xmlSecEvents = new ArrayDeque<>();
+ Deque<XMLSecEvent> xmlSecEvents = new ArrayDeque<XMLSecEvent>();
xmlSecEvents.push(nextEvent);
xmlSecEvents.push(XMLSecEventFactory.createXmlSecEndElement(XMLSecurityConstants.TAG_XOP_INCLUDE));
@@ -378,7 +349,8 @@
stringBuilder.append(wrapperElementName.getPrefix());
stringBuilder.append(':');
stringBuilder.append(wrapperElementName.getLocalPart());
- stringBuilder.append(" xmlns:");
+ stringBuilder.append(' ');
+ stringBuilder.append("xmlns:");
stringBuilder.append(wrapperElementName.getPrefix());
stringBuilder.append("=\"");
stringBuilder.append(wrapperElementName.getNamespaceURI());
@@ -400,13 +372,13 @@
if (prefix == null || prefix.isEmpty()) {
stringBuilder.append("xmlns=\"");
stringBuilder.append(uri);
- stringBuilder.append('\"');
+ stringBuilder.append("\"");
} else {
stringBuilder.append("xmlns:");
stringBuilder.append(prefix);
stringBuilder.append("=\"");
stringBuilder.append(uri);
- stringBuilder.append('\"');
+ stringBuilder.append("\"");
}
}
}
@@ -495,7 +467,7 @@
boolean isSecurityHeaderEvent, XMLSecEvent xmlSecEvent, InputProcessorChain subInputProcessorChain)
throws XMLStreamException, XMLSecurityException {
- Deque<XMLSecEvent> xmlSecEvents = new ArrayDeque<>();
+ Deque<XMLSecEvent> xmlSecEvents = new ArrayDeque<XMLSecEvent>();
xmlSecEvents.push(xmlSecEvent);
XMLSecEvent encryptedDataXMLSecEvent;
int count = 0;
@@ -680,72 +652,75 @@
XMLSecEvent xmlSecEvent = XMLSecEventFactory.allocate(xmlStreamReader, parentXmlSecStartElement);
//here we request the next XMLEvent from the decryption thread
//instead from the processor-chain as we normally would do
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()) {
- currentXMLStructureDepth++;
- if (currentXMLStructureDepth > maximumAllowedXMLStructureDepth) {
- throw new XMLSecurityException(
- "secureProcessing.MaximumAllowedXMLStructureDepth",
- new Object[] {maximumAllowedXMLStructureDepth}
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ currentXMLStructureDepth++;
+ if (currentXMLStructureDepth > maximumAllowedXMLStructureDepth) {
+ throw new XMLSecurityException(
+ "secureProcessing.MaximumAllowedXMLStructureDepth",
+ new Object[] {maximumAllowedXMLStructureDepth}
);
- }
-
- parentXmlSecStartElement = xmlSecEvent.asStartElement();
- if (!rootElementProcessed) {
- handleEncryptedElement(inputProcessorChain, parentXmlSecStartElement, this.inboundSecurityToken, encryptedDataType);
- rootElementProcessed = true;
- }
- } else if (XMLStreamConstants.END_ELEMENT == xmlSecEvent.getEventType()) {
- currentXMLStructureDepth--;
-
- if (parentXmlSecStartElement != null) {
- parentXmlSecStartElement = parentXmlSecStartElement.getParentXMLSecStartElement();
- }
-
- if (xmlSecEvent.asEndElement().getName().equals(wrapperElementName)) {
- InputProcessorChain subInputProcessorChain = inputProcessorChain.createSubChain(this);
-
- //skip EncryptedHeader Element when we processed it.
- QName endElement;
- if (encryptedHeader) {
- endElement = XMLSecurityConstants.TAG_wsse11_EncryptedHeader;
- } else {
- endElement = XMLSecurityConstants.TAG_xenc_EncryptedData;
}
- //read and discard XMLEvents until the EncryptedData structure
- XMLSecEvent endEvent;
- do {
- subInputProcessorChain.reset();
- if (headerEvent) {
- endEvent = subInputProcessorChain.processHeaderEvent();
+ parentXmlSecStartElement = xmlSecEvent.asStartElement();
+ if (!rootElementProcessed) {
+ handleEncryptedElement(inputProcessorChain, parentXmlSecStartElement, this.inboundSecurityToken, encryptedDataType);
+ rootElementProcessed = true;
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ currentXMLStructureDepth--;
+
+ if (parentXmlSecStartElement != null) {
+ parentXmlSecStartElement = parentXmlSecStartElement.getParentXMLSecStartElement();
+ }
+
+ if (xmlSecEvent.asEndElement().getName().equals(wrapperElementName)) {
+ InputProcessorChain subInputProcessorChain = inputProcessorChain.createSubChain(this);
+
+ //skip EncryptedHeader Element when we processed it.
+ QName endElement;
+ if (encryptedHeader) {
+ endElement = XMLSecurityConstants.TAG_wsse11_EncryptedHeader;
} else {
- endEvent = subInputProcessorChain.processEvent();
+ endElement = XMLSecurityConstants.TAG_xenc_EncryptedData;
}
- }
- while (!(endEvent.getEventType() == XMLStreamConstants.END_ELEMENT
- && endEvent.asEndElement().getName().equals(endElement)));
- inputProcessorChain.getDocumentContext().unsetIsInEncryptedContent(this);
-
- //...fetch the next (unencrypted) event
- if (headerEvent) {
- xmlSecEvent = inputProcessorChain.processHeaderEvent();
- } else {
- xmlSecEvent = inputProcessorChain.processEvent();
- }
-
- if (decryptionThread != null) {
- //wait until the decryption thread dies...
- try {
- decryptionThread.join();
- } catch (InterruptedException e) {
- throw new XMLStreamException(e);
+ //read and discard XMLEvents until the EncryptedData structure
+ XMLSecEvent endEvent;
+ do {
+ subInputProcessorChain.reset();
+ if (headerEvent) {
+ endEvent = subInputProcessorChain.processHeaderEvent();
+ } else {
+ endEvent = subInputProcessorChain.processEvent();
+ }
}
- //...and test again for an exception in the decryption thread.
- testAndThrowUncaughtException();
+ while (!(endEvent.getEventType() == XMLStreamConstants.END_ELEMENT
+ && endEvent.asEndElement().getName().equals(endElement)));
+
+ inputProcessorChain.getDocumentContext().unsetIsInEncryptedContent(this);
+
+ //...fetch the next (unencrypted) event
+ if (headerEvent) {
+ xmlSecEvent = inputProcessorChain.processHeaderEvent();
+ } else {
+ xmlSecEvent = inputProcessorChain.processEvent();
+ }
+
+ if (decryptionThread != null) {
+ //wait until the decryption thread dies...
+ try {
+ decryptionThread.join();
+ } catch (InterruptedException e) {
+ throw new XMLStreamException(e);
+ }
+ //...and test again for an exception in the decryption thread.
+ testAndThrowUncaughtException();
+ }
+ inputProcessorChain.removeProcessor(this);
}
- inputProcessorChain.removeProcessor(this);
- }
+ break;
}
xmlStreamReader.next();
return xmlSecEvent;
@@ -887,16 +862,6 @@
//close to get Cipher.doFinal() called
outputStreamWriter.close();
-
- // Clean the secret key from memory now that we're done with it
- if (secretKey instanceof Destroyable) {
- try {
- ((Destroyable)secretKey).destroy();
- } catch (DestroyFailedException e) {
- LOG.debug("Error destroying key: {}", e.getMessage());
- }
- }
-
LOG.debug("Decryption thread finished");
} catch (Exception e) {
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java
index a679ed3..1454961 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureInputHandler.java
@@ -23,29 +23,18 @@
import org.apache.xml.security.binding.xmldsig.SignatureType;
import org.apache.xml.security.binding.xmldsig.SignedInfoType;
import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.ext.*;
import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl;
-import org.apache.xml.security.stax.impl.util.IDGenerator;
-import org.apache.xml.security.stax.impl.util.SignerOutputStream;
import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
import org.apache.xml.security.utils.UnsyncBufferedOutputStream;
import org.apache.xml.security.utils.UnsyncByteArrayInputStream;
import org.apache.xml.security.utils.UnsyncByteArrayOutputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.xml.security.stax.ext.AbstractInputSecurityHeaderHandler;
-import org.apache.xml.security.stax.ext.InboundSecurityContext;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.Transformer;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
import org.apache.xml.security.stax.impl.algorithms.SignatureAlgorithm;
import org.apache.xml.security.stax.impl.algorithms.SignatureAlgorithmFactory;
+import org.apache.xml.security.stax.impl.util.*;
-import javax.security.auth.DestroyFailedException;
-import javax.security.auth.Destroyable;
import javax.xml.bind.JAXBElement;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
@@ -63,8 +52,6 @@
*/
public abstract class AbstractSignatureInputHandler extends AbstractInputSecurityHeaderHandler {
- private static final transient Logger LOG = LoggerFactory.getLogger(AbstractSignatureInputHandler.class);
-
@Override
public void handle(final InputProcessorChain inputProcessorChain, final XMLSecurityProperties securityProperties,
Deque<XMLSecEvent> eventQueue, Integer index) throws XMLSecurityException {
@@ -127,19 +114,25 @@
loop:
while (iterator.hasNext()) {
XMLSecEvent xmlSecEvent = iterator.next();
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()
- && xmlSecEvent.asStartElement().getName().equals(XMLSecurityConstants.TAG_dsig_SignedInfo)) {
- signatureVerifier.processEvent(xmlSecEvent);
- break loop;
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ if (xmlSecEvent.asStartElement().getName().equals(XMLSecurityConstants.TAG_dsig_SignedInfo)) {
+ signatureVerifier.processEvent(xmlSecEvent);
+ break loop;
+ }
+ break;
}
}
loop:
while (iterator.hasNext()) {
XMLSecEvent xmlSecEvent = iterator.next();
signatureVerifier.processEvent(xmlSecEvent);
- if (XMLStreamConstants.END_ELEMENT == xmlSecEvent.getEventType()
- && xmlSecEvent.asEndElement().getName().equals(XMLSecurityConstants.TAG_dsig_SignedInfo)) {
- break loop;
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.END_ELEMENT:
+ if (xmlSecEvent.asEndElement().getName().equals(XMLSecurityConstants.TAG_dsig_SignedInfo)) {
+ break loop;
+ }
+ break;
}
}
} catch (XMLStreamException e) {
@@ -153,7 +146,7 @@
SignatureType signatureType, Deque<XMLSecEvent> eventDeque, int index
) throws XMLSecurityException {
- Deque<XMLSecEvent> signedInfoDeque = new ArrayDeque<>();
+ Deque<XMLSecEvent> signedInfoDeque = new ArrayDeque<XMLSecEvent>();
try (UnsyncByteArrayOutputStream unsynchronizedByteArrayOutputStream = new UnsyncByteArrayOutputStream()) {
Transformer transformer = XMLSecurityUtils.getTransformer(
@@ -174,10 +167,13 @@
loop:
while (iterator.hasNext()) {
XMLSecEvent xmlSecEvent = iterator.next();
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()
- && xmlSecEvent.asStartElement().getName().equals(XMLSecurityConstants.TAG_dsig_SignedInfo)) {
- transformer.transform(xmlSecEvent);
- break loop;
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ if (xmlSecEvent.asStartElement().getName().equals(XMLSecurityConstants.TAG_dsig_SignedInfo)) {
+ transformer.transform(xmlSecEvent);
+ break loop;
+ }
+ break;
}
}
@@ -185,9 +181,12 @@
while (iterator.hasNext()) {
XMLSecEvent xmlSecEvent = iterator.next();
transformer.transform(xmlSecEvent);
- if (XMLStreamConstants.END_ELEMENT == xmlSecEvent.getEventType()
- && xmlSecEvent.asEndElement().getName().equals(XMLSecurityConstants.TAG_dsig_SignedInfo)) {
- break loop;
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.END_ELEMENT:
+ if (xmlSecEvent.asEndElement().getName().equals(XMLSecurityConstants.TAG_dsig_SignedInfo)) {
+ break loop;
+ }
+ break;
}
}
@@ -336,15 +335,6 @@
} catch (NoSuchProviderException e) {
throw new XMLSecurityException(e);
}
-
- // Clean the secret key from memory now that we're done with it
- if (verifyKey instanceof Destroyable) {
- try {
- ((Destroyable)verifyKey).destroy();
- } catch (DestroyFailedException e) {
- LOG.debug("Error destroying key: {}", e.getMessage());
- }
- }
}
protected void processEvent(XMLSecEvent xmlSecEvent) throws XMLStreamException {
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureReferenceVerifyInputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureReferenceVerifyInputProcessor.java
index d1c6eda..0c679fb 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureReferenceVerifyInputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractSignatureReferenceVerifyInputProcessor.java
@@ -18,26 +18,12 @@
*/
package org.apache.xml.security.stax.impl.processor.input;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-
+import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl;
+import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
+import org.apache.xml.security.utils.UnsyncBufferedOutputStream;
+import org.apache.xml.security.utils.XMLUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.xml.security.binding.excc14n.InclusiveNamespaces;
import org.apache.xml.security.binding.xmldsig.ReferenceType;
import org.apache.xml.security.binding.xmldsig.SignatureType;
@@ -46,28 +32,26 @@
import org.apache.xml.security.stax.config.ConfigurationProperties;
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
import org.apache.xml.security.stax.config.ResourceResolverMapper;
-import org.apache.xml.security.stax.ext.AbstractInputProcessor;
-import org.apache.xml.security.stax.ext.InboundSecurityContext;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.ResourceResolver;
-import org.apache.xml.security.stax.ext.Transformer;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
+import org.apache.xml.security.stax.ext.*;
import org.apache.xml.security.stax.ext.stax.XMLSecEndElement;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl;
import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_OmitCommentsTransformer;
import org.apache.xml.security.stax.impl.util.DigestOutputStream;
import org.apache.xml.security.stax.impl.util.IDGenerator;
import org.apache.xml.security.stax.impl.util.KeyValue;
import org.apache.xml.security.stax.securityEvent.AlgorithmSuiteSecurityEvent;
-import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
-import org.apache.xml.security.utils.UnsyncBufferedOutputStream;
-import org.apache.xml.security.utils.XMLUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import java.io.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.util.*;
/**
*/
@@ -104,8 +88,8 @@
"secureProcessing.MaximumAllowedReferencesPerManifest",
new Object[] {referencesTypeList.size(), maximumAllowedReferencesPerManifest});
}
- sameDocumentReferences = new ArrayList<>(referencesTypeList.size());
- externalReferences = new ArrayList<>(referencesTypeList.size());
+ sameDocumentReferences = new ArrayList<KeyValue<ResourceResolver, ReferenceType>>(referencesTypeList.size());
+ externalReferences = new ArrayList<KeyValue<ResourceResolver, ReferenceType>>(referencesTypeList.size());
processedReferences = new ArrayList<>(referencesTypeList.size());
Iterator<ReferenceType> referenceTypeIterator = referencesTypeList.iterator();
@@ -162,33 +146,35 @@
throws XMLStreamException, XMLSecurityException {
XMLSecEvent xmlSecEvent = inputProcessorChain.processEvent();
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()) {
- XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
- List<ReferenceType> referenceTypes = resolvesResource(xmlSecStartElement);
- if (!referenceTypes.isEmpty()) {
- for (int i = 0; i < referenceTypes.size(); i++) {
- ReferenceType referenceType = referenceTypes.get(i);
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
+ List<ReferenceType> referenceTypes = resolvesResource(xmlSecStartElement);
+ if (!referenceTypes.isEmpty()) {
+ for (int i = 0; i < referenceTypes.size(); i++) {
+ ReferenceType referenceType = referenceTypes.get(i);
- if (processedReferences.contains(referenceType)) {
- throw new XMLSecurityException("signature.Verification.MultipleIDs",
- new Object[] {referenceType.getURI()});
- }
- InternalSignatureReferenceVerifier internalSignatureReferenceVerifier =
- getSignatureReferenceVerifier(getSecurityProperties(), inputProcessorChain,
- referenceType, xmlSecStartElement);
- if (!internalSignatureReferenceVerifier.isFinished()) {
- internalSignatureReferenceVerifier.processEvent(xmlSecEvent, inputProcessorChain);
- inputProcessorChain.addProcessor(internalSignatureReferenceVerifier);
- }
- processedReferences.add(referenceType);
- inputProcessorChain.getDocumentContext().setIsInSignedContent(
- inputProcessorChain.getProcessors().indexOf(internalSignatureReferenceVerifier),
- internalSignatureReferenceVerifier);
+ if (processedReferences.contains(referenceType)) {
+ throw new XMLSecurityException("signature.Verification.MultipleIDs",
+ new Object[] {referenceType.getURI()});
+ }
+ InternalSignatureReferenceVerifier internalSignatureReferenceVerifier =
+ getSignatureReferenceVerifier(getSecurityProperties(), inputProcessorChain,
+ referenceType, xmlSecStartElement);
+ if (!internalSignatureReferenceVerifier.isFinished()) {
+ internalSignatureReferenceVerifier.processEvent(xmlSecEvent, inputProcessorChain);
+ inputProcessorChain.addProcessor(internalSignatureReferenceVerifier);
+ }
+ processedReferences.add(referenceType);
+ inputProcessorChain.getDocumentContext().setIsInSignedContent(
+ inputProcessorChain.getProcessors().indexOf(internalSignatureReferenceVerifier),
+ internalSignatureReferenceVerifier);
- processElementPath(internalSignatureReferenceVerifier.getStartElementPath(), inputProcessorChain,
- internalSignatureReferenceVerifier.getStartElement(), referenceType);
+ processElementPath(internalSignatureReferenceVerifier.getStartElementPath(), inputProcessorChain,
+ internalSignatureReferenceVerifier.getStartElement(), referenceType);
+ }
}
- }
+ break;
}
return xmlSecEvent;
}
@@ -452,29 +438,32 @@
}
public void processEvent(XMLSecEvent xmlSecEvent, InputProcessorChain inputProcessorChain)
- throws XMLStreamException, XMLSecurityException {
+ throws XMLStreamException, XMLSecurityException {
getTransformer().transform(xmlSecEvent);
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()) {
- this.elementCounter++;
- } else if (XMLStreamConstants.END_ELEMENT == xmlSecEvent.getEventType()) {
- XMLSecEndElement xmlSecEndElement = xmlSecEvent.asEndElement();
- this.elementCounter--;
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ this.elementCounter++;
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ XMLSecEndElement xmlSecEndElement = xmlSecEvent.asEndElement();
+ this.elementCounter--;
- if (this.elementCounter == 0 && xmlSecEndElement.getName().equals(startElement.getName())) {
- getTransformer().doFinal();
- try {
- getBufferedDigestOutputStream().close();
- } catch (IOException e) {
- throw new XMLSecurityException(e);
+ if (this.elementCounter == 0 && xmlSecEndElement.getName().equals(startElement.getName())) {
+ getTransformer().doFinal();
+ try {
+ getBufferedDigestOutputStream().close();
+ } catch (IOException e) {
+ throw new XMLSecurityException(e);
+ }
+
+ compareDigest(this.getDigestOutputStream().getDigestValue(), getReferenceType());
+
+ inputProcessorChain.removeProcessor(this);
+ inputProcessorChain.getDocumentContext().unsetIsInSignedContent(this);
+ setFinished(true);
}
-
- compareDigest(this.getDigestOutputStream().getDigestValue(), getReferenceType());
-
- inputProcessorChain.removeProcessor(this);
- inputProcessorChain.getDocumentContext().unsetIsInSignedContent(this);
- setFinished(true);
- }
+ break;
}
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/LogInputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/LogInputProcessor.java
index 7001297..04618c0 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/LogInputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/LogInputProcessor.java
@@ -18,18 +18,14 @@
*/
package org.apache.xml.security.stax.impl.processor.input;
-import java.io.StringWriter;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.AbstractInputProcessor;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+
+import javax.xml.stream.XMLStreamException;
+import java.io.StringWriter;
/**
*/
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLDecryptInputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLDecryptInputProcessor.java
index 82cbce0..cb672bc 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLDecryptInputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLDecryptInputProcessor.java
@@ -26,18 +26,11 @@
import org.apache.xml.security.binding.xmlenc.EncryptedDataType;
import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.DocumentContext;
-import org.apache.xml.security.stax.ext.InboundSecurityContext;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.SecurePart;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.apache.xml.security.stax.securityEvent.ContentEncryptedElementSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.EncryptedElementSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.TokenSecurityEvent;
+import org.apache.xml.security.stax.ext.*;
import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import org.apache.xml.security.stax.securityEvent.*;
/**
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEncryptedKeyInputHandler.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEncryptedKeyInputHandler.java
index dd0cf3b..9c6beea 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEncryptedKeyInputHandler.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEncryptedKeyInputHandler.java
@@ -18,23 +18,12 @@
*/
package org.apache.xml.security.stax.impl.processor.input;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.spec.MGF1ParameterSpec;
-import java.util.Base64;
-import java.util.Deque;
-
-import javax.crypto.Cipher;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.spec.OAEPParameterSpec;
-import javax.crypto.spec.PSource;
-import javax.crypto.spec.SecretKeySpec;
-import javax.xml.bind.JAXBElement;
-
+import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
+import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
+import org.apache.xml.security.utils.XMLUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.xml.security.binding.xmldsig.DigestMethodType;
import org.apache.xml.security.binding.xmldsig.KeyInfoType;
import org.apache.xml.security.binding.xmlenc.CipherValueType;
@@ -43,24 +32,25 @@
import org.apache.xml.security.binding.xop.Include;
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
-import org.apache.xml.security.stax.ext.AbstractInputSecurityHeaderHandler;
-import org.apache.xml.security.stax.ext.InboundSecurityContext;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
+import org.apache.xml.security.stax.ext.*;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.impl.securityToken.AbstractInboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenFactory;
import org.apache.xml.security.stax.impl.util.IDGenerator;
import org.apache.xml.security.stax.securityEvent.AlgorithmSuiteSecurityEvent;
import org.apache.xml.security.stax.securityEvent.EncryptedKeyTokenSecurityEvent;
-import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
-import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
-import org.apache.xml.security.stax.securityToken.SecurityTokenFactory;
-import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
-import org.apache.xml.security.utils.XMLUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.OAEPParameterSpec;
+import javax.crypto.spec.PSource;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.bind.JAXBElement;
+
+import java.security.*;
+import java.security.spec.MGF1ParameterSpec;
+import java.util.Base64;
+import java.util.Deque;
/**
* An input handler for the EncryptedKey XML Structure
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEventReaderInputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEventReaderInputProcessor.java
index c8035ea..8edd61f 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEventReaderInputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLEventReaderInputProcessor.java
@@ -18,21 +18,17 @@
*/
package org.apache.xml.security.stax.impl.processor.input;
-import java.util.NoSuchElementException;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.config.ConfigurationProperties;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.config.ConfigurationProperties;
-import org.apache.xml.security.stax.ext.AbstractInputProcessor;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import java.util.NoSuchElementException;
/**
* The XMLEventReaderInputProcessor reads requested XMLEvents from the original XMLEventReader
@@ -68,23 +64,26 @@
private XMLSecEvent processNextEventInternal() throws XMLStreamException {
XMLSecEvent xmlSecEvent = XMLSecEventFactory.allocate(xmlStreamReader, parentXmlSecStartElement);
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()) {
- currentXMLStructureDepth++;
- if (currentXMLStructureDepth > maximumAllowedXMLStructureDepth) {
- XMLSecurityException xmlSecurityException = new XMLSecurityException(
- "secureProcessing.MaximumAllowedXMLStructureDepth",
- new Object[] {maximumAllowedXMLStructureDepth}
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ currentXMLStructureDepth++;
+ if (currentXMLStructureDepth > maximumAllowedXMLStructureDepth) {
+ XMLSecurityException xmlSecurityException = new XMLSecurityException(
+ "secureProcessing.MaximumAllowedXMLStructureDepth",
+ new Object[] {maximumAllowedXMLStructureDepth}
);
- throw new XMLStreamException(xmlSecurityException);
- }
+ throw new XMLStreamException(xmlSecurityException);
+ }
- parentXmlSecStartElement = (XMLSecStartElement) xmlSecEvent;
- } else if (XMLStreamConstants.END_ELEMENT == xmlSecEvent.getEventType()) {
- currentXMLStructureDepth--;
+ parentXmlSecStartElement = (XMLSecStartElement) xmlSecEvent;
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ currentXMLStructureDepth--;
- if (parentXmlSecStartElement != null) {
- parentXmlSecStartElement = parentXmlSecStartElement.getParentXMLSecStartElement();
- }
+ if (parentXmlSecStartElement != null) {
+ parentXmlSecStartElement = parentXmlSecStartElement.getParentXMLSecStartElement();
+ }
+ break;
}
if (xmlStreamReader.hasNext()) {
xmlStreamReader.next();
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSecurityInputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSecurityInputProcessor.java
index 969e3c3..3183655 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSecurityInputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSecurityInputProcessor.java
@@ -74,95 +74,98 @@
}
XMLSecEvent xmlSecEvent = inputProcessorChain.processEvent();
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()) {
- final XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ final XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
- if (!decryptOnly && xmlSecStartElement.getName().equals(XMLSecurityConstants.TAG_dsig_Signature)) {
- if (signatureElementFound) {
- throw new XMLSecurityException("stax.multipleSignaturesNotSupported");
+ if (!decryptOnly && xmlSecStartElement.getName().equals(XMLSecurityConstants.TAG_dsig_Signature)) {
+ if (signatureElementFound) {
+ throw new XMLSecurityException("stax.multipleSignaturesNotSupported");
+ }
+ signatureElementFound = true;
+ startIndexForProcessor = internalBufferProcessor.getXmlSecEventList().size() - 1;
+ } else if (xmlSecStartElement.getName().equals(XMLSecurityConstants.TAG_xenc_EncryptedData)) {
+ encryptedDataElementFound = true;
+
+ XMLDecryptInputProcessor decryptInputProcessor = new XMLDecryptInputProcessor(getSecurityProperties());
+ decryptInputProcessor.setPhase(XMLSecurityConstants.Phase.PREPROCESSING);
+ decryptInputProcessor.addAfterProcessor(XMLEventReaderInputProcessor.class.getName());
+ decryptInputProcessor.addBeforeProcessor(XMLSecurityInputProcessor.class.getName());
+ decryptInputProcessor.addBeforeProcessor(XMLSecurityInputProcessor.InternalBufferProcessor.class.getName());
+ inputProcessorChain.addProcessor(decryptInputProcessor);
+
+ if (!decryptOnly) {
+ final ArrayDeque<XMLSecEvent> xmlSecEventList = internalBufferProcessor.getXmlSecEventList();
+ //remove the last event (EncryptedData)
+ xmlSecEventList.pollFirst();
+ }
+
+ // temporary processor to return the EncryptedData element for the DecryptionProcessor
+ AbstractInputProcessor abstractInputProcessor = new AbstractInputProcessor(getSecurityProperties()) {
+ @Override
+ public XMLSecEvent processNextHeaderEvent(InputProcessorChain inputProcessorChain)
+ throws XMLStreamException, XMLSecurityException {
+ return processNextEvent(inputProcessorChain);
+ }
+
+ @Override
+ public XMLSecEvent processNextEvent(InputProcessorChain inputProcessorChain)
+ throws XMLStreamException, XMLSecurityException {
+ inputProcessorChain.removeProcessor(this);
+ return xmlSecStartElement;
+ }
+ };
+ abstractInputProcessor.setPhase(XMLSecurityConstants.Phase.PREPROCESSING);
+ abstractInputProcessor.addBeforeProcessor(decryptInputProcessor);
+ inputProcessorChain.addProcessor(abstractInputProcessor);
+
+ //fetch the next event from the original chain
+ inputProcessorChain.reset();
+ xmlSecEvent = inputProcessorChain.processEvent();
+
+ // no need to catch a possible signature element here because the decrypt processor
+ // is installed before this processor and therefore the decrypted signature element will
+ // flow as normal through this processor.
+ // for safety we do a check if this really true
+ //check if the decrypted element is a Signature element
+ if (!decryptOnly && xmlSecEvent.isStartElement() &&
+ xmlSecEvent.asStartElement().getName().equals(XMLSecurityConstants.TAG_dsig_Signature) &&
+ !signatureElementFound) {
+ throw new XMLSecurityException("Internal error");
+ }
}
- signatureElementFound = true;
- startIndexForProcessor = internalBufferProcessor.getXmlSecEventList().size() - 1;
- } else if (xmlSecStartElement.getName().equals(XMLSecurityConstants.TAG_xenc_EncryptedData)) {
- encryptedDataElementFound = true;
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ XMLSecEndElement xmlSecEndElement = xmlSecEvent.asEndElement();
+ // Handle the signature
+ if (signatureElementFound
+ && xmlSecEndElement.getName().equals(XMLSecurityConstants.TAG_dsig_Signature)) {
+ XMLSignatureInputHandler inputHandler = new XMLSignatureInputHandler();
- XMLDecryptInputProcessor decryptInputProcessor = new XMLDecryptInputProcessor(getSecurityProperties());
- decryptInputProcessor.setPhase(XMLSecurityConstants.Phase.PREPROCESSING);
- decryptInputProcessor.addAfterProcessor(XMLEventReaderInputProcessor.class.getName());
- decryptInputProcessor.addBeforeProcessor(XMLSecurityInputProcessor.class.getName());
- decryptInputProcessor.addBeforeProcessor(XMLSecurityInputProcessor.InternalBufferProcessor.class.getName());
- inputProcessorChain.addProcessor(decryptInputProcessor);
-
- if (!decryptOnly) {
final ArrayDeque<XMLSecEvent> xmlSecEventList = internalBufferProcessor.getXmlSecEventList();
- //remove the last event (EncryptedData)
- xmlSecEventList.pollFirst();
- }
+ inputHandler.handle(inputProcessorChain, getSecurityProperties(),
+ xmlSecEventList, startIndexForProcessor);
- // temporary processor to return the EncryptedData element for the DecryptionProcessor
- AbstractInputProcessor abstractInputProcessor = new AbstractInputProcessor(getSecurityProperties()) {
- @Override
- public XMLSecEvent processNextHeaderEvent(InputProcessorChain inputProcessorChain)
- throws XMLStreamException, XMLSecurityException {
- return processNextEvent(inputProcessorChain);
+ inputProcessorChain.removeProcessor(internalBufferProcessor);
+
+ //add the replay processor to the chain...
+ InternalReplayProcessor internalReplayProcessor =
+ new InternalReplayProcessor(getSecurityProperties(), xmlSecEventList);
+ internalReplayProcessor.addBeforeProcessor(XMLSignatureReferenceVerifyInputProcessor.class.getName());
+ inputProcessorChain.addProcessor(internalReplayProcessor);
+
+ //...and let the SignatureVerificationProcessor process the buffered events (enveloped signature).
+ InputProcessorChain subInputProcessorChain = inputProcessorChain.createSubChain(this, false);
+ while (!xmlSecEventList.isEmpty()) {
+ subInputProcessorChain.reset();
+ subInputProcessorChain.processEvent();
}
- @Override
- public XMLSecEvent processNextEvent(InputProcessorChain inputProcessorChain)
- throws XMLStreamException, XMLSecurityException {
- inputProcessorChain.removeProcessor(this);
- return xmlSecStartElement;
- }
- };
- abstractInputProcessor.setPhase(XMLSecurityConstants.Phase.PREPROCESSING);
- abstractInputProcessor.addBeforeProcessor(decryptInputProcessor);
- inputProcessorChain.addProcessor(abstractInputProcessor);
-
- //fetch the next event from the original chain
- inputProcessorChain.reset();
- xmlSecEvent = inputProcessorChain.processEvent();
-
- // no need to catch a possible signature element here because the decrypt processor
- // is installed before this processor and therefore the decrypted signature element will
- // flow as normal through this processor.
- // for safety we do a check if this really true
- //check if the decrypted element is a Signature element
- if (!decryptOnly && xmlSecEvent.isStartElement() &&
- xmlSecEvent.asStartElement().getName().equals(XMLSecurityConstants.TAG_dsig_Signature) &&
- !signatureElementFound) {
- throw new XMLSecurityException("Internal error");
+ // copy all processor back to main chain for finalization
+ inputProcessorChain.getProcessors().clear();
+ inputProcessorChain.getProcessors().addAll(subInputProcessorChain.getProcessors());
}
- }
- } else if (XMLStreamConstants.END_ELEMENT == xmlSecEvent.getEventType()) {
- XMLSecEndElement xmlSecEndElement = xmlSecEvent.asEndElement();
- // Handle the signature
- if (signatureElementFound
- && xmlSecEndElement.getName().equals(XMLSecurityConstants.TAG_dsig_Signature)) {
- XMLSignatureInputHandler inputHandler = new XMLSignatureInputHandler();
-
- final ArrayDeque<XMLSecEvent> xmlSecEventList = internalBufferProcessor.getXmlSecEventList();
- inputHandler.handle(inputProcessorChain, getSecurityProperties(),
- xmlSecEventList, startIndexForProcessor);
-
- inputProcessorChain.removeProcessor(internalBufferProcessor);
-
- //add the replay processor to the chain...
- InternalReplayProcessor internalReplayProcessor =
- new InternalReplayProcessor(getSecurityProperties(), xmlSecEventList);
- internalReplayProcessor.addBeforeProcessor(XMLSignatureReferenceVerifyInputProcessor.class.getName());
- inputProcessorChain.addProcessor(internalReplayProcessor);
-
- //...and let the SignatureVerificationProcessor process the buffered events (enveloped signature).
- InputProcessorChain subInputProcessorChain = inputProcessorChain.createSubChain(this, false);
- while (!xmlSecEventList.isEmpty()) {
- subInputProcessorChain.reset();
- subInputProcessorChain.processEvent();
- }
-
- // copy all processor back to main chain for finalization
- inputProcessorChain.getProcessors().clear();
- inputProcessorChain.getProcessors().addAll(subInputProcessorChain.getProcessors());
- }
+ break;
}
return xmlSecEvent;
@@ -181,7 +184,7 @@
*/
public class InternalBufferProcessor extends AbstractInputProcessor {
- private final ArrayDeque<XMLSecEvent> xmlSecEventList = new ArrayDeque<>();
+ private final ArrayDeque<XMLSecEvent> xmlSecEventList = new ArrayDeque<XMLSecEvent>();
InternalBufferProcessor(XMLSecurityProperties securityProperties) {
super(securityProperties);
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java
index d32138a..0c2d1ed 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java
@@ -20,17 +20,11 @@
import org.apache.xml.security.binding.xmldsig.SignatureType;
import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.InboundSecurityContext;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
-import org.apache.xml.security.stax.securityEvent.AlgorithmSuiteSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.SignatureValueSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.TokenSecurityEvent;
+import org.apache.xml.security.stax.ext.*;
import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
import org.apache.xml.security.stax.securityToken.SecurityTokenFactory;
+import org.apache.xml.security.stax.securityEvent.*;
/**
* An input handler for XML Signature.
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractEncryptOutputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractEncryptOutputProcessor.java
index 667f6d9..9996f97 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractEncryptOutputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractEncryptOutputProcessor.java
@@ -18,27 +18,6 @@
*/
package org.apache.xml.security.stax.impl.processor.output;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.AlgorithmParameterSpec;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.crypto.Cipher;
-import javax.crypto.CipherOutputStream;
-import javax.crypto.NoSuchPaddingException;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventWriter;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-
import org.apache.commons.codec.binary.Base64OutputStream;
import org.apache.xml.security.algorithms.JCEMapper;
import org.apache.xml.security.encryption.XMLCipherUtil;
@@ -48,17 +27,27 @@
import org.apache.xml.security.stax.ext.OutputProcessorChain;
import org.apache.xml.security.stax.ext.SecurePart;
import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
-import org.apache.xml.security.stax.ext.stax.XMLSecCharacters;
-import org.apache.xml.security.stax.ext.stax.XMLSecEndElement;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import org.apache.xml.security.stax.ext.stax.*;
import org.apache.xml.security.stax.impl.EncryptionPartDef;
import org.apache.xml.security.stax.impl.XMLSecurityEventWriter;
import org.apache.xml.security.stax.impl.util.TrimmerOutputStream;
import org.apache.xml.security.utils.XMLUtils;
+import javax.crypto.Cipher;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.NoSuchPaddingException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.*;
+
/**
* Processor to encrypt XML structures
*
@@ -224,16 +213,18 @@
if (this.elementCounter == 0 && xmlSecStartElement.getName().equals(this.getXmlSecStartElement().getName())) {
//if the user selected element encryption we have to encrypt the current element-event...
- if (SecurePart.Modifier.Element == getEncryptionPartDef().getModifier()) {
- OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
- processEventInternal(xmlSecStartElement, subOutputProcessorChain);
- //encrypt the current element event
- encryptEvent(xmlSecEvent);
- } else if (SecurePart.Modifier.Content == getEncryptionPartDef().getModifier()) {
- OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
- outputProcessorChain.processEvent(xmlSecEvent);
- subOutputProcessorChain = outputProcessorChain.createSubChain(this);
- processEventInternal(xmlSecStartElement, subOutputProcessorChain);
+ switch (getEncryptionPartDef().getModifier()) {
+ case Element:
+ OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
+ processEventInternal(xmlSecStartElement, subOutputProcessorChain);
+ //encrypt the current element event
+ encryptEvent(xmlSecEvent);
+ break;
+ case Content:
+ outputProcessorChain.processEvent(xmlSecEvent);
+ subOutputProcessorChain = outputProcessorChain.createSubChain(this);
+ processEventInternal(xmlSecStartElement, subOutputProcessorChain);
+ break;
}
} else {
encryptEvent(xmlSecEvent);
@@ -246,12 +237,15 @@
if (this.elementCounter == 0 && xmlSecEvent.asEndElement().getName().equals(this.getXmlSecStartElement().getName())) {
OutputProcessorChain subOutputProcessorChain = outputProcessorChain.createSubChain(this);
- if (SecurePart.Modifier.Element == getEncryptionPartDef().getModifier()) {
- encryptEvent(xmlSecEvent);
- doFinalInternal(subOutputProcessorChain);
- } else if (SecurePart.Modifier.Content == getEncryptionPartDef().getModifier()) {
- doFinalInternal(subOutputProcessorChain);
- outputAsEvent(subOutputProcessorChain, xmlSecEvent);
+ switch (getEncryptionPartDef().getModifier()) {
+ case Element:
+ encryptEvent(xmlSecEvent);
+ doFinalInternal(subOutputProcessorChain);
+ break;
+ case Content:
+ doFinalInternal(subOutputProcessorChain);
+ outputAsEvent(subOutputProcessorChain, xmlSecEvent);
+ break;
}
subOutputProcessorChain.removeProcessor(this);
//from now on encryption is possible again
@@ -386,7 +380,7 @@
*/
public class CharacterEventGeneratorOutputStream extends OutputStream {
- private final Deque<XMLSecCharacters> charactersBuffer = new ArrayDeque<>();
+ private final Deque<XMLSecCharacters> charactersBuffer = new ArrayDeque<XMLSecCharacters>();
public Deque<XMLSecCharacters> getCharactersBuffer() {
return charactersBuffer;
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureEndingOutputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureEndingOutputProcessor.java
index 7a1f091..5bea0ce 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureEndingOutputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureEndingOutputProcessor.java
@@ -25,8 +25,6 @@
import java.security.NoSuchProviderException;
import java.util.*;
-import javax.security.auth.DestroyFailedException;
-import javax.security.auth.Destroyable;
import javax.xml.stream.XMLStreamException;
import org.apache.xml.security.exceptions.XMLSecurityException;
@@ -50,15 +48,11 @@
import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
import org.apache.xml.security.utils.UnsyncBufferedOutputStream;
import org.apache.xml.security.utils.XMLUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*/
public abstract class AbstractSignatureEndingOutputProcessor extends AbstractBufferingOutputProcessor {
- private static final transient Logger LOG = LoggerFactory.getLogger(AbstractSignatureEndingOutputProcessor.class);
-
private List<SignaturePartDef> signaturePartDefList;
public AbstractSignatureEndingOutputProcessor(AbstractSignatureOutputProcessor signatureOutputProcessor)
@@ -226,15 +220,6 @@
createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_KeyInfo);
}
createEndElementAndOutputAsEvent(subOutputProcessorChain, XMLSecurityConstants.TAG_dsig_Signature);
-
- // Clean the secret key from memory now that we're done with it
- if (key instanceof Destroyable) {
- try {
- ((Destroyable)key).destroy();
- } catch (DestroyFailedException e) {
- LOG.debug("Error destroying key: {}", e.getMessage());
- }
- }
}
protected abstract SignedInfoProcessor newSignedInfoProcessor(
@@ -288,7 +273,7 @@
for (Iterator<String> iterator = prefixSet.iterator(); iterator.hasNext(); ) {
String prefix = iterator.next();
if (prefixes.length() != 0) {
- prefixes.append(' ');
+ prefixes.append(" ");
}
prefixes.append(prefix);
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureOutputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureOutputProcessor.java
index fe2e657..2fc1b75 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureOutputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/output/AbstractSignatureOutputProcessor.java
@@ -18,43 +18,30 @@
*/
package org.apache.xml.security.stax.impl.processor.output;
+import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
+import org.apache.xml.security.stax.config.ResourceResolverMapper;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import org.apache.xml.security.stax.impl.SignaturePartDef;
+import org.apache.xml.security.stax.impl.transformer.TransformIdentity;
+import org.apache.xml.security.stax.impl.util.DigestOutputStream;
+import org.apache.xml.security.utils.UnsyncBufferedOutputStream;
+import org.apache.xml.security.utils.XMLUtils;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
-import org.apache.xml.security.stax.config.ResourceResolverMapper;
-import org.apache.xml.security.stax.ext.AbstractOutputProcessor;
-import org.apache.xml.security.stax.ext.OutputProcessorChain;
-import org.apache.xml.security.stax.ext.ResourceResolver;
-import org.apache.xml.security.stax.ext.SecurePart;
-import org.apache.xml.security.stax.ext.Transformer;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.apache.xml.security.stax.impl.SignaturePartDef;
-import org.apache.xml.security.stax.impl.transformer.TransformIdentity;
-import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl;
-import org.apache.xml.security.stax.impl.util.DigestOutputStream;
-import org.apache.xml.security.utils.UnsyncBufferedOutputStream;
-import org.apache.xml.security.utils.XMLUtils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.*;
/**
*/
@@ -233,7 +220,7 @@
for (Iterator<String> iterator = prefixSet.iterator(); iterator.hasNext(); ) {
String prefix = iterator.next();
if (prefixes.length() != 0) {
- prefixes.append(' ');
+ prefixes.append(" ");
}
prefixes.append(prefix);
}
@@ -287,29 +274,32 @@
transformer.transform(xmlSecEvent);
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()) {
- elementCounter++;
- } else if (XMLStreamConstants.END_ELEMENT == xmlSecEvent.getEventType()) {
- elementCounter--;
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ elementCounter++;
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ elementCounter--;
- if (elementCounter == 0 &&
- xmlSecEvent.asEndElement().getName().equals(this.xmlSecStartElement.getName())) {
+ if (elementCounter == 0 &&
+ xmlSecEvent.asEndElement().getName().equals(this.xmlSecStartElement.getName())) {
- transformer.doFinal();
- try {
- bufferedDigestOutputStream.close();
- } catch (IOException e) {
- throw new XMLSecurityException(e);
+ transformer.doFinal();
+ try {
+ bufferedDigestOutputStream.close();
+ } catch (IOException e) {
+ throw new XMLSecurityException(e);
+ }
+ String calculatedDigest =
+ XMLUtils.encodeToString(this.digestOutputStream.getDigestValue());
+ LOG.debug("Calculated Digest: {}", calculatedDigest);
+ signaturePartDef.setDigestValue(calculatedDigest);
+
+ outputProcessorChain.removeProcessor(this);
+ //from now on signature is possible again
+ setActiveInternalSignatureOutputProcessor(null);
}
- String calculatedDigest =
- XMLUtils.encodeToString(this.digestOutputStream.getDigestValue());
- LOG.debug("Calculated Digest: {}", calculatedDigest);
- signaturePartDef.setDigestValue(calculatedDigest);
-
- outputProcessorChain.removeProcessor(this);
- //from now on signature is possible again
- setActiveInternalSignatureOutputProcessor(null);
- }
+ break;
}
outputProcessorChain.processEvent(xmlSecEvent);
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/processor/output/XMLEncryptOutputProcessor.java b/src/main/java/org/apache/xml/security/stax/impl/processor/output/XMLEncryptOutputProcessor.java
index 1264d24..b489ca8 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/processor/output/XMLEncryptOutputProcessor.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/processor/output/XMLEncryptOutputProcessor.java
@@ -18,16 +18,20 @@
*/
package org.apache.xml.security.stax.impl.processor.output;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.PublicKey;
-import java.security.cert.X509Certificate;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.MGF1ParameterSpec;
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
+import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
+import org.apache.xml.security.utils.XMLUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import org.apache.xml.security.stax.impl.EncryptionPartDef;
+import org.apache.xml.security.stax.securityToken.OutboundSecurityToken;
+import org.apache.xml.security.stax.impl.util.IDGenerator;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
@@ -37,23 +41,12 @@
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.config.JCEAlgorithmMapper;
-import org.apache.xml.security.stax.ext.OutputProcessorChain;
-import org.apache.xml.security.stax.ext.SecurePart;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
-import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
-import org.apache.xml.security.stax.impl.EncryptionPartDef;
-import org.apache.xml.security.stax.impl.util.IDGenerator;
-import org.apache.xml.security.stax.securityToken.OutboundSecurityToken;
-import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
-import org.apache.xml.security.stax.securityToken.SecurityTokenProvider;
-import org.apache.xml.security.utils.XMLUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.security.*;
+import java.security.cert.X509Certificate;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.MGF1ParameterSpec;
+import java.util.ArrayList;
+import java.util.List;
/**
* Processor to encrypt XML structures
diff --git a/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverSameDocument.java b/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverSameDocument.java
index 78413f7..2f3af6f 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverSameDocument.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverSameDocument.java
@@ -18,17 +18,13 @@
*/
package org.apache.xml.security.stax.impl.resourceResolvers;
-import java.io.InputStream;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
import javax.xml.namespace.QName;
import javax.xml.stream.events.Attribute;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.ResourceResolver;
-import org.apache.xml.security.stax.ext.ResourceResolverLookup;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import java.io.InputStream;
/**
* Resolver for references in the same document.
diff --git a/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverXPointer.java b/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverXPointer.java
index be2c4ca..d1f3ee5 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverXPointer.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/resourceResolvers/ResolverXPointer.java
@@ -106,7 +106,10 @@
}
//case #xpointer(id('ID')):
Attribute attribute = xmlSecStartElement.getAttributeByName(idAttributeNS);
- return attribute != null && attribute.getValue().equals(id);
+ if (attribute != null && attribute.getValue().equals(id)) {
+ return true;
+ }
+ return false;
}
@Override
diff --git a/src/main/java/org/apache/xml/security/stax/impl/securityToken/AbstractSecurityToken.java b/src/main/java/org/apache/xml/security/stax/impl/securityToken/AbstractSecurityToken.java
index 8da4153..6cf89f2 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/securityToken/AbstractSecurityToken.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/securityToken/AbstractSecurityToken.java
@@ -43,8 +43,8 @@
private boolean asymmetric = false;
private String sha1Identifier;
- protected final Map<String, Key> keyTable = new HashMap<>();
- protected final List<SecurityTokenConstants.TokenUsage> tokenUsages = new ArrayList<>();
+ protected final Map<String, Key> keyTable = new HashMap<String, Key>();
+ protected final List<SecurityTokenConstants.TokenUsage> tokenUsages = new ArrayList<SecurityTokenConstants.TokenUsage>();
public AbstractSecurityToken(String id) {
if (id == null || id.isEmpty()) {
diff --git a/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java b/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java
index 5378e19..8a0eeed 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java
@@ -18,6 +18,18 @@
*/
package org.apache.xml.security.stax.impl.securityToken;
+import org.apache.xml.security.binding.xmldsig.*;
+import org.apache.xml.security.binding.xmldsig11.ECKeyValueType;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.apache.xml.security.stax.securityToken.SecurityTokenConstants.TokenType;
+import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
+import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
+import org.apache.xml.security.stax.securityToken.SecurityTokenFactory;
+import org.apache.xml.security.utils.RFC2253Parser;
+import org.apache.xml.security.utils.UnsyncByteArrayInputStream;
+
import java.io.IOException;
import java.io.InputStream;
import java.security.Key;
@@ -27,26 +39,6 @@
import java.security.cert.X509Certificate;
import java.util.Map;
-import org.apache.xml.security.binding.xmldsig.DSAKeyValueType;
-import org.apache.xml.security.binding.xmldsig.KeyInfoType;
-import org.apache.xml.security.binding.xmldsig.KeyValueType;
-import org.apache.xml.security.binding.xmldsig.RSAKeyValueType;
-import org.apache.xml.security.binding.xmldsig.X509DataType;
-import org.apache.xml.security.binding.xmldsig.X509IssuerSerialType;
-import org.apache.xml.security.binding.xmldsig11.ECKeyValueType;
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.InboundSecurityContext;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.XMLSecurityUtils;
-import org.apache.xml.security.stax.impl.util.IDGenerator;
-import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
-import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
-import org.apache.xml.security.stax.securityToken.SecurityTokenConstants.TokenType;
-import org.apache.xml.security.stax.securityToken.SecurityTokenFactory;
-import org.apache.xml.security.utils.RFC2253Parser;
-import org.apache.xml.security.utils.UnsyncByteArrayInputStream;
-
/**
* Factory to create SecurityToken Objects from keys in XML
*
diff --git a/src/main/java/org/apache/xml/security/stax/impl/stax/XMLSecAttributeImpl.java b/src/main/java/org/apache/xml/security/stax/impl/stax/XMLSecAttributeImpl.java
index cf14530..b8a6182 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/stax/XMLSecAttributeImpl.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/stax/XMLSecAttributeImpl.java
@@ -134,14 +134,17 @@
int idx = 0;
while (i < length) {
char c = text.charAt(i);
- if (c == '&') {
- writer.write(text, idx, i - idx);
- writer.write("&");
- idx = i + 1;
- } else if (c == '"') {
- writer.write(text, idx, i - idx);
- writer.write(""");
- idx = i + 1;
+ switch (c) {
+ case '&':
+ writer.write(text, idx, i - idx);
+ writer.write("&");
+ idx = i + 1;
+ break;
+ case '"':
+ writer.write(text, idx, i - idx);
+ writer.write(""");
+ idx = i + 1;
+ break;
}
i++;
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/stax/XMLSecNamespaceImpl.java b/src/main/java/org/apache/xml/security/stax/impl/stax/XMLSecNamespaceImpl.java
index 7bba770..a4edc75 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/stax/XMLSecNamespaceImpl.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/stax/XMLSecNamespaceImpl.java
@@ -33,10 +33,10 @@
* Class to let XML-Namespaces be comparable how it is requested by C14N
*
*/
-public final class XMLSecNamespaceImpl extends XMLSecEventBaseImpl implements XMLSecNamespace {
+public class XMLSecNamespaceImpl extends XMLSecEventBaseImpl implements XMLSecNamespace {
private static final Map<String, Map<String, XMLSecNamespace>> xmlSecNamespaceMap =
- new WeakHashMap<>();
+ new WeakHashMap<String, Map<String, XMLSecNamespace>>();
private String prefix;
private final String uri;
@@ -68,7 +68,7 @@
return xmlSecNamespace;
}
} else {
- nsMap = new WeakHashMap<>();
+ nsMap = new WeakHashMap<String, XMLSecNamespace>();
XMLSecNamespace xmlSecNamespace = new XMLSecNamespaceImpl(prefixToUse, uriToUse);
nsMap.put(uriToUse, xmlSecNamespace);
xmlSecNamespaceMap.put(prefixToUse, nsMap);
@@ -174,14 +174,17 @@
int idx = 0;
while (i < length) {
char c = text.charAt(i);
- if (c == '&') {
- writer.write(text, idx, i - idx);
- writer.write("&");
- idx = i + 1;
- } else if (c == '"') {
- writer.write(text, idx, i - idx);
- writer.write(""");
- idx = i + 1;
+ switch (c) {
+ case '&':
+ writer.write(text, idx, i - idx);
+ writer.write("&");
+ idx = i + 1;
+ break;
+ case '"':
+ writer.write(text, idx, i - idx);
+ writer.write(""");
+ idx = i + 1;
+ break;
}
i++;
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformBase64Decode.java b/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformBase64Decode.java
index 0421839..8e2469b 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformBase64Decode.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformBase64Decode.java
@@ -66,103 +66,110 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
int eventType = xmlSecEvent.getEventType();
- if (XMLStreamConstants.CHARACTERS == eventType) {
- if (getOutputStream() != null) {
- //we have an output stream
- //encoding shouldn't matter here, because the data is Base64 encoded and is therefore in the ASCII range.
- try {
- getOutputStream().write(xmlSecEvent.asCharacters().getData().getBytes());
- } catch (IOException e) {
- throw new XMLStreamException(e);
- }
- } else {
- //we have a child transformer
- if (childOutputMethod == null) {
+ switch (eventType) {
+ case XMLStreamConstants.CHARACTERS:
+ if (getOutputStream() != null) {
+ //we have an output stream
+ //encoding shouldn't matter here, because the data is Base64 encoded and is therefore in the ASCII range.
+ try {
+ getOutputStream().write(xmlSecEvent.asCharacters().getData().getBytes());
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+ } else {
+ //we have a child transformer
+ if (childOutputMethod == null) {
- final XMLSecurityConstants.TransformMethod preferredChildTransformMethod =
- getTransformer().getPreferredTransformMethod(XMLSecurityConstants.TransformMethod.XMLSecEvent);
+ final XMLSecurityConstants.TransformMethod preferredChildTransformMethod =
+ getTransformer().getPreferredTransformMethod(XMLSecurityConstants.TransformMethod.XMLSecEvent);
- if (preferredChildTransformMethod == XMLSecurityConstants.TransformMethod.XMLSecEvent) {
- childOutputMethod = new ChildOutputMethod() {
+ switch (preferredChildTransformMethod) {
+ case XMLSecEvent: {
+ childOutputMethod = new ChildOutputMethod() {
- private UnsyncByteArrayOutputStream byteArrayOutputStream;
- private Base64OutputStream base64OutputStream;
+ private UnsyncByteArrayOutputStream byteArrayOutputStream;
+ private Base64OutputStream base64OutputStream;
- @Override
- public void transform(Object object) throws XMLStreamException {
- if (base64OutputStream == null) {
- byteArrayOutputStream = new UnsyncByteArrayOutputStream();
- base64OutputStream = new Base64OutputStream(byteArrayOutputStream, false);
- }
- try {
- base64OutputStream.write((byte[]) object);
- } catch (IOException e) {
- throw new XMLStreamException(e);
- }
+ @Override
+ public void transform(Object object) throws XMLStreamException {
+ if (base64OutputStream == null) {
+ byteArrayOutputStream = new UnsyncByteArrayOutputStream();
+ base64OutputStream = new Base64OutputStream(byteArrayOutputStream, false);
+ }
+ try {
+ base64OutputStream.write((byte[]) object);
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ @Override
+ public void doFinal() throws XMLStreamException {
+ try {
+ base64OutputStream.close();
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+
+ try (InputStream is = new UnsyncByteArrayInputStream(byteArrayOutputStream.toByteArray())) {
+ XMLEventReaderInputProcessor xmlEventReaderInputProcessor
+ = new XMLEventReaderInputProcessor(null,
+ getXmlInputFactory().createXMLStreamReader(is)
+ );
+ XMLSecEvent xmlSecEvent;
+ do {
+ xmlSecEvent = xmlEventReaderInputProcessor.processNextEvent(null);
+ getTransformer().transform(xmlSecEvent);
+ } while (xmlSecEvent.getEventType() != XMLStreamConstants.END_DOCUMENT);
+ } catch (XMLSecurityException | IOException e) {
+ throw new XMLStreamException(e);
+ }
+ getTransformer().doFinal();
+ }
+ };
+ break;
}
+ case InputStream: {
+ childOutputMethod = new ChildOutputMethod() {
- @Override
- public void doFinal() throws XMLStreamException {
- try {
- base64OutputStream.close();
- } catch (IOException e) {
- throw new XMLStreamException(e);
- }
+ private UnsyncByteArrayOutputStream byteArrayOutputStream;
+ private Base64OutputStream base64OutputStream;
- try (InputStream is = new UnsyncByteArrayInputStream(byteArrayOutputStream.toByteArray())) {
- XMLEventReaderInputProcessor xmlEventReaderInputProcessor
- = new XMLEventReaderInputProcessor(null,
- getXmlInputFactory().createXMLStreamReader(is)
- );
- XMLSecEvent xmlSecEvent;
- do {
- xmlSecEvent = xmlEventReaderInputProcessor.processNextEvent(null);
- getTransformer().transform(xmlSecEvent);
- } while (xmlSecEvent.getEventType() != XMLStreamConstants.END_DOCUMENT);
- } catch (XMLSecurityException | IOException e) {
- throw new XMLStreamException(e);
- }
- getTransformer().doFinal();
+ @Override
+ public void transform(Object object) throws XMLStreamException {
+ if (base64OutputStream == null) {
+ byteArrayOutputStream = new UnsyncByteArrayOutputStream();
+ base64OutputStream = new Base64OutputStream(byteArrayOutputStream, false);
+ }
+ try {
+ base64OutputStream.write((byte[]) object);
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ @Override
+ public void doFinal() throws XMLStreamException {
+ try {
+ base64OutputStream.close();
+ } catch (IOException e) {
+ throw new XMLStreamException(e);
+ }
+ try (InputStream is = new UnsyncByteArrayInputStream(byteArrayOutputStream.toByteArray())) {
+ getTransformer().transform(is);
+ getTransformer().doFinal();
+ } catch (IOException ex) {
+ throw new XMLStreamException(ex);
+ }
+ }
+ };
+ break;
}
- };
- } else if (preferredChildTransformMethod == XMLSecurityConstants.TransformMethod.InputStream) {
- childOutputMethod = new ChildOutputMethod() {
-
- private UnsyncByteArrayOutputStream byteArrayOutputStream;
- private Base64OutputStream base64OutputStream;
-
- @Override
- public void transform(Object object) throws XMLStreamException {
- if (base64OutputStream == null) {
- byteArrayOutputStream = new UnsyncByteArrayOutputStream();
- base64OutputStream = new Base64OutputStream(byteArrayOutputStream, false);
- }
- try {
- base64OutputStream.write((byte[]) object);
- } catch (IOException e) {
- throw new XMLStreamException(e);
- }
- }
-
- @Override
- public void doFinal() throws XMLStreamException {
- try {
- base64OutputStream.close();
- } catch (IOException e) {
- throw new XMLStreamException(e);
- }
- try (InputStream is = new UnsyncByteArrayInputStream(byteArrayOutputStream.toByteArray())) {
- getTransformer().transform(is);
- getTransformer().doFinal();
- } catch (IOException ex) {
- throw new XMLStreamException(ex);
- }
- }
- };
+ }
}
childOutputMethod.transform(xmlSecEvent.asCharacters().getData().getBytes());
}
- }
+ break;
}
}
diff --git a/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformEnvelopedSignature.java b/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformEnvelopedSignature.java
index b39c8bc..50e7477 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformEnvelopedSignature.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformEnvelopedSignature.java
@@ -48,20 +48,22 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()) {
- curLevel++;
- XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
- if (XMLSecurityConstants.TAG_dsig_Signature.equals(xmlSecStartElement.getName())) {
- sigElementLevel = curLevel;
- return;
- }
- } else if (XMLStreamConstants.END_ELEMENT == xmlSecEvent.getEventType()) {
- XMLSecEndElement xmlSecEndElement = xmlSecEvent.asEndElement();
- if (sigElementLevel == curLevel && XMLSecurityConstants.TAG_dsig_Signature.equals(xmlSecEndElement.getName())) {
- sigElementLevel = -1;
- return;
- }
- curLevel--;
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ curLevel++;
+ XMLSecStartElement xmlSecStartElement = xmlSecEvent.asStartElement();
+ if (XMLSecurityConstants.TAG_dsig_Signature.equals(xmlSecStartElement.getName())) {
+ sigElementLevel = curLevel;
+ return;
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ XMLSecEndElement xmlSecEndElement = xmlSecEvent.asEndElement();
+ if (sigElementLevel == curLevel && XMLSecurityConstants.TAG_dsig_Signature.equals(xmlSecEndElement.getName())) {
+ sigElementLevel = -1;
+ return;
+ }
+ curLevel--;
}
if (sigElementLevel == -1) {
super.transform(xmlSecEvent);
diff --git a/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformIdentity.java b/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformIdentity.java
index f88f2bb..866e02e 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformIdentity.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/transformer/TransformIdentity.java
@@ -123,46 +123,51 @@
final XMLSecurityConstants.TransformMethod preferredChildTransformMethod =
getTransformer().getPreferredTransformMethod(XMLSecurityConstants.TransformMethod.XMLSecEvent);
- if (preferredChildTransformMethod == XMLSecurityConstants.TransformMethod.XMLSecEvent) {
- childOutputMethod = new ChildOutputMethod() {
+ switch (preferredChildTransformMethod) {
+ case XMLSecEvent: {
+ childOutputMethod = new ChildOutputMethod() {
- @Override
- public void transform(Object object) throws XMLStreamException {
- getTransformer().transform((XMLSecEvent) object);
- }
-
- @Override
- public void doFinal() throws XMLStreamException {
- getTransformer().doFinal();
- }
- };
- } else if (preferredChildTransformMethod == XMLSecurityConstants.TransformMethod.InputStream) {
- childOutputMethod = new ChildOutputMethod() {
-
- private UnsyncByteArrayOutputStream baos;
- private XMLEventWriter xmlEventWriter;
-
- @Override
- public void transform(Object object) throws XMLStreamException {
- if (xmlEventWriter == null) {
- baos = new UnsyncByteArrayOutputStream();
- xmlEventWriter = getXmlOutputFactory().createXMLEventWriter(baos);
+ @Override
+ public void transform(Object object) throws XMLStreamException {
+ getTransformer().transform((XMLSecEvent) object);
}
- xmlEventWriter.add((XMLSecEvent) object);
- }
-
- @Override
- public void doFinal() throws XMLStreamException {
- xmlEventWriter.close();
- try (InputStream is = new UnsyncByteArrayInputStream(baos.toByteArray())) {
- getTransformer().transform(is);
+ @Override
+ public void doFinal() throws XMLStreamException {
getTransformer().doFinal();
- } catch (IOException ex) {
- throw new XMLStreamException(ex);
}
- }
- };
+ };
+ break;
+ }
+ case InputStream: {
+ childOutputMethod = new ChildOutputMethod() {
+
+ private UnsyncByteArrayOutputStream baos;
+ private XMLEventWriter xmlEventWriter;
+
+ @Override
+ public void transform(Object object) throws XMLStreamException {
+ if (xmlEventWriter == null) {
+ baos = new UnsyncByteArrayOutputStream();
+ xmlEventWriter = getXmlOutputFactory().createXMLEventWriter(baos);
+ }
+
+ xmlEventWriter.add((XMLSecEvent) object);
+ }
+
+ @Override
+ public void doFinal() throws XMLStreamException {
+ xmlEventWriter.close();
+ try (InputStream is = new UnsyncByteArrayInputStream(baos.toByteArray())) {
+ getTransformer().transform(is);
+ getTransformer().doFinal();
+ } catch (IOException ex) {
+ throw new XMLStreamException(ex);
+ }
+ }
+ };
+ break;
+ }
}
}
if (childOutputMethod != null) {
@@ -187,49 +192,54 @@
final XMLSecurityConstants.TransformMethod preferredChildTransformMethod =
getTransformer().getPreferredTransformMethod(XMLSecurityConstants.TransformMethod.InputStream);
- if (preferredChildTransformMethod == XMLSecurityConstants.TransformMethod.XMLSecEvent) {
- childOutputMethod = new ChildOutputMethod() {
+ switch (preferredChildTransformMethod) {
+ case XMLSecEvent: {
+ childOutputMethod = new ChildOutputMethod() {
- private XMLEventReaderInputProcessor xmlEventReaderInputProcessor;
+ private XMLEventReaderInputProcessor xmlEventReaderInputProcessor;
- @Override
- public void transform(Object object) throws XMLStreamException {
- if (xmlEventReaderInputProcessor == null) {
- xmlEventReaderInputProcessor = new XMLEventReaderInputProcessor(
- null,
- getXmlInputFactory().createXMLStreamReader(inputStream)
- );
+ @Override
+ public void transform(Object object) throws XMLStreamException {
+ if (xmlEventReaderInputProcessor == null) {
+ xmlEventReaderInputProcessor = new XMLEventReaderInputProcessor(
+ null,
+ getXmlInputFactory().createXMLStreamReader(inputStream)
+ );
+ }
+ try {
+ XMLSecEvent xmlSecEvent;
+ do {
+ xmlSecEvent = xmlEventReaderInputProcessor.processNextEvent(null);
+ getTransformer().transform(xmlSecEvent);
+ } while (xmlSecEvent.getEventType() != XMLStreamConstants.END_DOCUMENT);
+ } catch (XMLSecurityException e) {
+ throw new XMLStreamException(e);
+ }
}
- try {
- XMLSecEvent xmlSecEvent;
- do {
- xmlSecEvent = xmlEventReaderInputProcessor.processNextEvent(null);
- getTransformer().transform(xmlSecEvent);
- } while (xmlSecEvent.getEventType() != XMLStreamConstants.END_DOCUMENT);
- } catch (XMLSecurityException e) {
- throw new XMLStreamException(e);
+
+ @Override
+ public void doFinal() throws XMLStreamException {
+ getTransformer().doFinal();
}
- }
+ };
+ break;
+ }
+ case InputStream: {
+ childOutputMethod = new ChildOutputMethod() {
- @Override
- public void doFinal() throws XMLStreamException {
- getTransformer().doFinal();
- }
- };
- } else if (preferredChildTransformMethod == XMLSecurityConstants.TransformMethod.InputStream) {
- childOutputMethod = new ChildOutputMethod() {
+ @Override
+ public void transform(Object object) throws XMLStreamException {
+ getTransformer().transform(inputStream);
+ }
- @Override
- public void transform(Object object) throws XMLStreamException {
- getTransformer().transform(inputStream);
- }
+ @Override
+ public void doFinal() throws XMLStreamException {
+ getTransformer().doFinal();
+ }
- @Override
- public void doFinal() throws XMLStreamException {
- getTransformer().doFinal();
- }
-
- };
+ };
+ break;
+ }
}
}
if (childOutputMethod != null) {
diff --git a/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/Canonicalizer20010315_Excl.java b/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/Canonicalizer20010315_Excl.java
index 5701aa8..3073ec8 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/Canonicalizer20010315_Excl.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/Canonicalizer20010315_Excl.java
@@ -18,17 +18,10 @@
*/
package org.apache.xml.security.stax.impl.transformer.canonicalizer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
-import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import org.apache.xml.security.stax.ext.stax.*;
+
+import java.util.*;
/**
*/
diff --git a/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/CanonicalizerBase.java b/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/CanonicalizerBase.java
index 2bbc6ef..fb49d3b 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/CanonicalizerBase.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/transformer/canonicalizer/CanonicalizerBase.java
@@ -18,39 +18,22 @@
*/
package org.apache.xml.security.stax.impl.transformer.canonicalizer;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-
import org.apache.xml.security.c14n.implementations.UtfHelpper;
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.ext.Transformer;
import org.apache.xml.security.stax.ext.XMLSecurityConstants;
import org.apache.xml.security.stax.ext.XMLSecurityUtils;
-import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
-import org.apache.xml.security.stax.ext.stax.XMLSecComment;
-import org.apache.xml.security.stax.ext.stax.XMLSecEndElement;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
-import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
-import org.apache.xml.security.stax.ext.stax.XMLSecProcessingInstruction;
-import org.apache.xml.security.stax.ext.stax.XMLSecStartElement;
+import org.apache.xml.security.stax.ext.stax.*;
import org.apache.xml.security.stax.impl.processor.input.XMLEventReaderInputProcessor;
import org.apache.xml.security.stax.impl.transformer.TransformIdentity;
import org.apache.xml.security.utils.UnsyncByteArrayInputStream;
import org.apache.xml.security.utils.UnsyncByteArrayOutputStream;
+import javax.xml.namespace.QName;
+import javax.xml.stream.*;
+import java.io.*;
+import java.util.*;
+
/**
*/
public abstract class CanonicalizerBase extends TransformIdentity {
@@ -80,8 +63,8 @@
NODE_AFTER_DOCUMENT_ELEMENT
}
- private static final Map<String, byte[]> cache = new WeakHashMap<>();
- private final C14NStack<XMLSecEvent> outputStack = new C14NStack<>();
+ private static final Map<String, byte[]> cache = new WeakHashMap<String, byte[]>();
+ private final C14NStack<XMLSecEvent> outputStack = new C14NStack<XMLSecEvent>();
private boolean includeComments = false;
private DocumentLevel currentDocumentLevel = DocumentLevel.NODE_BEFORE_DOCUMENT_ELEMENT;
diff --git a/src/main/java/org/apache/xml/security/stax/impl/util/DigestOutputStream.java b/src/main/java/org/apache/xml/security/stax/impl/util/DigestOutputStream.java
index 84628cf..c7c4dfd 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/util/DigestOutputStream.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/util/DigestOutputStream.java
@@ -34,7 +34,7 @@
protected static final transient boolean isDebugEnabled = LOG.isDebugEnabled();
private final MessageDigest messageDigest;
- private StringBuilder stringBuilder; //NOPMD
+ private StringBuilder stringBuilder;
public DigestOutputStream(MessageDigest messageDigest) {
this.messageDigest = messageDigest;
diff --git a/src/main/java/org/apache/xml/security/stax/impl/util/SignerOutputStream.java b/src/main/java/org/apache/xml/security/stax/impl/util/SignerOutputStream.java
index 791db85..72ec26a 100644
--- a/src/main/java/org/apache/xml/security/stax/impl/util/SignerOutputStream.java
+++ b/src/main/java/org/apache/xml/security/stax/impl/util/SignerOutputStream.java
@@ -33,7 +33,7 @@
protected static final transient boolean isDebugEnabled = LOG.isDebugEnabled();
private final SignatureAlgorithm signatureAlgorithm;
- private StringBuilder stringBuilder; //NOPMD
+ private StringBuilder stringBuilder;
public SignerOutputStream(SignatureAlgorithm signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
diff --git a/src/main/java/org/apache/xml/security/stax/securityToken/SecurityTokenFactory.java b/src/main/java/org/apache/xml/security/stax/securityToken/SecurityTokenFactory.java
index 54cdbdb..871e137 100644
--- a/src/main/java/org/apache/xml/security/stax/securityToken/SecurityTokenFactory.java
+++ b/src/main/java/org/apache/xml/security/stax/securityToken/SecurityTokenFactory.java
@@ -31,10 +31,10 @@
*/
public abstract class SecurityTokenFactory {
- private static SecurityTokenFactory instance;
+ private static SecurityTokenFactory securityTokenFactory;
public static synchronized SecurityTokenFactory getInstance() throws XMLSecurityException {
- if (instance == null) {
+ if (securityTokenFactory == null) {
String stf = ConfigurationProperties.getProperty("securityTokenFactory");
if (stf == null) {
throw new XMLSecurityException("algorithm.ClassDoesNotExist",
@@ -49,7 +49,7 @@
@SuppressWarnings("unchecked")
Class<SecurityTokenFactory> securityTokenFactoryClass =
(Class<SecurityTokenFactory>) ClassLoaderUtils.loadClass(stf, callingClass);
- instance = securityTokenFactoryClass.newInstance();
+ securityTokenFactory = securityTokenFactoryClass.newInstance();
} catch (ClassNotFoundException e) {
throw new XMLSecurityException(e, "algorithm.ClassDoesNotExist", new Object[]{stf});
} catch (InstantiationException e) {
@@ -58,7 +58,7 @@
throw new XMLSecurityException(e, "algorithm.ClassDoesNotExist", new Object[]{stf});
}
}
- return instance;
+ return securityTokenFactory;
}
public abstract InboundSecurityToken getSecurityToken(
diff --git a/src/main/java/org/apache/xml/security/transforms/InvalidTransformException.java b/src/main/java/org/apache/xml/security/transforms/InvalidTransformException.java
index fb11f31..95b9ec0 100644
--- a/src/main/java/org/apache/xml/security/transforms/InvalidTransformException.java
+++ b/src/main/java/org/apache/xml/security/transforms/InvalidTransformException.java
@@ -53,7 +53,7 @@
* @param msgId
* @param exArgs
*/
- public InvalidTransformException(String msgId, Object[] exArgs) {
+ public InvalidTransformException(String msgId, Object exArgs[]) {
super(msgId, exArgs);
}
@@ -79,7 +79,7 @@
* @param exArgs
* @param originalException
*/
- public InvalidTransformException(Exception originalException, String msgId, Object[] exArgs) {
+ public InvalidTransformException(Exception originalException, String msgId, Object exArgs[]) {
super(originalException, msgId, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/transforms/Transform.java b/src/main/java/org/apache/xml/security/transforms/Transform.java
index 59a26ad..3200dfb 100644
--- a/src/main/java/org/apache/xml/security/transforms/Transform.java
+++ b/src/main/java/org/apache/xml/security/transforms/Transform.java
@@ -70,7 +70,7 @@
/** All available Transform classes are registered here */
private static Map<String, Class<? extends TransformSpi>> transformSpiHash =
- new ConcurrentHashMap<>();
+ new ConcurrentHashMap<String, Class<? extends TransformSpi>>();
private final TransformSpi transformSpi;
private boolean secureValidation;
@@ -146,24 +146,24 @@
String algorithmURI = element.getAttributeNS(null, Constants._ATT_ALGORITHM);
if (algorithmURI == null || algorithmURI.length() == 0) {
- Object[] exArgs = { Constants._ATT_ALGORITHM, Constants._TAG_TRANSFORM };
+ Object exArgs[] = { Constants._ATT_ALGORITHM, Constants._TAG_TRANSFORM };
throw new TransformationException("xml.WrongContent", exArgs);
}
Class<? extends TransformSpi> transformSpiClass = transformSpiHash.get(algorithmURI);
if (transformSpiClass == null) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new InvalidTransformException("signature.Transform.UnknownTransform", exArgs);
}
try {
transformSpi = transformSpiClass.newInstance();
} catch (InstantiationException ex) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new InvalidTransformException(
ex, "signature.Transform.UnknownTransform", exArgs
);
} catch (IllegalAccessException ex) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new InvalidTransformException(
ex, "signature.Transform.UnknownTransform", exArgs
);
@@ -189,7 +189,7 @@
// are we already registered?
Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
if (transformSpi != null) {
- Object[] exArgs = { algorithmURI, transformSpi };
+ Object exArgs[] = { algorithmURI, transformSpi };
throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
}
Class<? extends TransformSpi> transformSpiClass =
@@ -215,7 +215,7 @@
// are we already registered?
Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
if (transformSpi != null) {
- Object[] exArgs = { algorithmURI, transformSpi };
+ Object exArgs[] = { algorithmURI, transformSpi };
throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
}
transformSpiHash.put(algorithmURI, implementingClass);
@@ -310,11 +310,11 @@
transformSpi.secureValidation = secureValidation;
result = transformSpi.enginePerformTransform(input, os, this);
} catch (ParserConfigurationException ex) {
- Object[] exArgs = { this.getURI(), "ParserConfigurationException" };
+ Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
throw new CanonicalizationException(
ex, "signature.Transform.ErrorDuringTransform", exArgs);
} catch (SAXException ex) {
- Object[] exArgs = { this.getURI(), "SAXException" };
+ Object exArgs[] = { this.getURI(), "SAXException" };
throw new CanonicalizationException(
ex, "signature.Transform.ErrorDuringTransform", exArgs);
}
@@ -337,19 +337,19 @@
Class<? extends TransformSpi> transformSpiClass = transformSpiHash.get(algorithmURI);
if (transformSpiClass == null) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new InvalidTransformException("signature.Transform.UnknownTransform", exArgs);
}
TransformSpi newTransformSpi = null;
try {
newTransformSpi = transformSpiClass.newInstance();
} catch (InstantiationException ex) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new InvalidTransformException(
ex, "signature.Transform.UnknownTransform", exArgs
);
} catch (IllegalAccessException ex) {
- Object[] exArgs = { algorithmURI };
+ Object exArgs[] = { algorithmURI };
throw new InvalidTransformException(
ex, "signature.Transform.UnknownTransform", exArgs
);
diff --git a/src/main/java/org/apache/xml/security/transforms/TransformationException.java b/src/main/java/org/apache/xml/security/transforms/TransformationException.java
index 2a08051..ac3c6d6 100644
--- a/src/main/java/org/apache/xml/security/transforms/TransformationException.java
+++ b/src/main/java/org/apache/xml/security/transforms/TransformationException.java
@@ -56,7 +56,7 @@
* @param msgID
* @param exArgs
*/
- public TransformationException(String msgID, Object[] exArgs) {
+ public TransformationException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
@@ -82,7 +82,7 @@
* @param msgID
* @param exArgs
*/
- public TransformationException(Exception originalException, String msgID, Object[] exArgs) {
+ public TransformationException(Exception originalException, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/transforms/Transforms.java b/src/main/java/org/apache/xml/security/transforms/Transforms.java
index 64aaabd..a7641b9 100644
--- a/src/main/java/org/apache/xml/security/transforms/Transforms.java
+++ b/src/main/java/org/apache/xml/security/transforms/Transforms.java
@@ -99,7 +99,7 @@
private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(Transforms.class);
- private Element[] transformsElement;
+ private Element[] transforms;
protected Transforms() { }
@@ -137,7 +137,7 @@
if (numberOfTransformElems == 0) {
// At least one Transform element must be present. Bad.
- Object[] exArgs = { Constants._TAG_TRANSFORM, Constants._TAG_TRANSFORMS };
+ Object exArgs[] = { Constants._TAG_TRANSFORM, Constants._TAG_TRANSFORMS };
throw new TransformationException("xml.WrongContent", exArgs);
}
@@ -280,7 +280,7 @@
private void checkSecureValidation(Transform transform) throws TransformationException {
String uri = transform.getURI();
if (secureValidation && Transforms.TRANSFORM_XSLT.equals(uri)) {
- Object[] exArgs = { uri };
+ Object exArgs[] = { uri };
throw new TransformationException(
"signature.Transform.ForbiddenTransform", exArgs
@@ -296,7 +296,7 @@
*/
public int getLength() {
initTransforms();
- return transformsElement.length;
+ return transforms.length;
}
/**
@@ -310,15 +310,15 @@
public Transform item(int i) throws TransformationException {
try {
initTransforms();
- return new Transform(transformsElement[i], this.baseURI);
+ return new Transform(transforms[i], this.baseURI);
} catch (XMLSecurityException ex) {
throw new TransformationException(ex);
}
}
private void initTransforms() {
- if (transformsElement == null) {
- transformsElement = XMLUtils.selectDsNodes(getFirstChild(), "Transform");
+ if (transforms == null) {
+ transforms = XMLUtils.selectDsNodes(getFirstChild(), "Transform");
}
}
diff --git a/src/main/java/org/apache/xml/security/transforms/implementations/FuncHere.java b/src/main/java/org/apache/xml/security/transforms/implementations/FuncHere.java
index e7fc9a6..1c6a7f7 100644
--- a/src/main/java/org/apache/xml/security/transforms/implementations/FuncHere.java
+++ b/src/main/java/org/apache/xml/security/transforms/implementations/FuncHere.java
@@ -139,7 +139,7 @@
* @param vars
* @param globalsSize
*/
- public void fixupVariables(@SuppressWarnings("rawtypes") java.util.Vector vars, int globalsSize) { //NOPMD
+ public void fixupVariables(@SuppressWarnings("rawtypes") java.util.Vector vars, int globalsSize) {
// do nothing
}
}
diff --git a/src/main/java/org/apache/xml/security/transforms/implementations/TransformBase64Decode.java b/src/main/java/org/apache/xml/security/transforms/implementations/TransformBase64Decode.java
index 11f72d2..9c1f965 100644
--- a/src/main/java/org/apache/xml/security/transforms/implementations/TransformBase64Decode.java
+++ b/src/main/java/org/apache/xml/security/transforms/implementations/TransformBase64Decode.java
@@ -143,7 +143,7 @@
//Exceptional case there is current not text case testing this(Before it was a
//a common case).
Document doc =
- XMLUtils.read(input.getOctetStream(), secureValidation);
+ XMLUtils.createDocumentBuilder(false, secureValidation).parse(input.getOctetStream());
Element rootNode = doc.getDocumentElement();
StringBuilder sb = new StringBuilder();
@@ -162,9 +162,11 @@
void traverseElement(Element node, StringBuilder sb) {
Node sibling = node.getFirstChild();
while (sibling != null) {
- if (Node.ELEMENT_NODE == sibling.getNodeType()) {
+ switch (sibling.getNodeType()) {
+ case Node.ELEMENT_NODE:
traverseElement((Element)sibling, sb);
- } else if (Node.TEXT_NODE == sibling.getNodeType()) {
+ break;
+ case Node.TEXT_NODE:
sb.append(((Text)sibling).getData());
}
sibling = sibling.getNextSibling();
diff --git a/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java b/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java
index a0bd74d..d6cd2a8 100644
--- a/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java
+++ b/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java
@@ -87,7 +87,7 @@
transformObject.getElement().getFirstChild(), Constants._TAG_XPATH, 0);
if (xpathElement == null) {
- Object[] exArgs = { "ds:XPath", "Transform" };
+ Object exArgs[] = { "ds:XPath", "Transform" };
throw new TransformationException("xml.WrongContent", exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java b/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java
index 9844670..20b8193 100644
--- a/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java
+++ b/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java
@@ -90,7 +90,7 @@
XPath2FilterContainer._TAG_XPATH2
);
if (xpathElements.length == 0) {
- Object[] exArgs = { Transforms.TRANSFORM_XPATH2FILTER, "XPath" };
+ Object exArgs[] = { Transforms.TRANSFORM_XPATH2FILTER, "XPath" };
throw new TransformationException("xml.WrongContent", exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPointer.java b/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPointer.java
index 7df5e8e..78ddc6f 100644
--- a/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPointer.java
+++ b/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPointer.java
@@ -53,7 +53,7 @@
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
- Object[] exArgs = { implementedTransformURI };
+ Object exArgs[] = { implementedTransformURI };
throw new TransformationException("signature.Transform.NotYetImplemented", exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/transforms/implementations/TransformXSLT.java b/src/main/java/org/apache/xml/security/transforms/implementations/TransformXSLT.java
index b2be495..370041b 100644
--- a/src/main/java/org/apache/xml/security/transforms/implementations/TransformXSLT.java
+++ b/src/main/java/org/apache/xml/security/transforms/implementations/TransformXSLT.java
@@ -85,7 +85,7 @@
XMLUtils.selectNode(transformElement.getFirstChild(), XSLTSpecNS, "transform", 0);
}
if (xsltElement == null) {
- Object[] exArgs = { "xslt:stylesheet", "Transform" };
+ Object exArgs[] = { "xslt:stylesheet", "Transform" };
throw new TransformationException("xml.WrongContent", exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java b/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java
index e645b5e..a92ff74 100644
--- a/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java
+++ b/src/main/java/org/apache/xml/security/transforms/params/InclusiveNamespaces.java
@@ -72,7 +72,7 @@
if (prefixes instanceof SortedSet<?>) {
prefixList = (SortedSet<String>)prefixes;
} else {
- prefixList = new TreeSet<>(prefixes);
+ prefixList = new TreeSet<String>(prefixes);
}
StringBuilder sb = new StringBuilder();
@@ -81,7 +81,7 @@
sb.append("#default ");
} else {
sb.append(prefix);
- sb.append(' ');
+ sb.append(" ");
}
}
@@ -127,7 +127,7 @@
* @return A set to string
*/
public static SortedSet<String> prefixStr2Set(String inclusiveNamespaces) {
- SortedSet<String> prefixes = new TreeSet<>();
+ SortedSet<String> prefixes = new TreeSet<String>();
if (inclusiveNamespaces == null || inclusiveNamespaces.length() == 0) {
return prefixes;
@@ -135,7 +135,7 @@
String[] tokens = inclusiveNamespaces.split("\\s");
for (String prefix : tokens) {
- if ("#default".equals(prefix)) {
+ if (prefix.equals("#default")) {
prefixes.add("xmlns");
} else {
prefixes.add(prefix);
diff --git a/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java b/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java
index bea6751..8079fa7 100644
--- a/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java
+++ b/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer.java
@@ -34,7 +34,7 @@
*
* @see <A HREF="http://www.w3.org/TR/xmldsig-filter2/">XPath Filter v2.0 (TR)</A>
*/
-public final class XPath2FilterContainer extends ElementProxy implements TransformParam {
+public class XPath2FilterContainer extends ElementProxy implements TransformParam {
/** Field _ATT_FILTER */
private static final String _ATT_FILTER = "Filter";
@@ -105,7 +105,7 @@
if (!filterStr.equals(XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT)
&& !filterStr.equals(XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT)
&& !filterStr.equals(XPath2FilterContainer._ATT_FILTER_VALUE_UNION)) {
- Object[] exArgs = { XPath2FilterContainer._ATT_FILTER, filterStr,
+ Object exArgs[] = { XPath2FilterContainer._ATT_FILTER, filterStr,
XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT
+ ", "
+ XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT
diff --git a/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java b/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java
index 21e6350..82b208d 100644
--- a/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java
+++ b/src/main/java/org/apache/xml/security/transforms/params/XPath2FilterContainer04.java
@@ -31,7 +31,7 @@
*
* @see <A HREF="http://www.w3.org/TR/xmldsig-filter2/">XPath Filter v2.0 (TR)</A>
*/
-public final class XPath2FilterContainer04 extends ElementProxy implements TransformParam {
+public class XPath2FilterContainer04 extends ElementProxy implements TransformParam {
/** Field _ATT_FILTER */
private static final String _ATT_FILTER = "Filter";
@@ -100,7 +100,7 @@
if (!filterStr.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT)
&& !filterStr.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT)
&& !filterStr.equals(XPath2FilterContainer04._ATT_FILTER_VALUE_UNION)) {
- Object[] exArgs = { XPath2FilterContainer04._ATT_FILTER, filterStr,
+ Object exArgs[] = { XPath2FilterContainer04._ATT_FILTER, filterStr,
XPath2FilterContainer04._ATT_FILTER_VALUE_INTERSECT
+ ", "
+ XPath2FilterContainer04._ATT_FILTER_VALUE_SUBTRACT
diff --git a/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java b/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java
index 4782b0f..ae58bbc 100644
--- a/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java
+++ b/src/main/java/org/apache/xml/security/transforms/params/XPathFilterCHGPContainer.java
@@ -33,7 +33,7 @@
* than the xfilter2.
*
*/
-public final class XPathFilterCHGPContainer extends ElementProxy implements TransformParam {
+public class XPathFilterCHGPContainer extends ElementProxy implements TransformParam {
public static final String TRANSFORM_XPATHFILTERCHGP =
"http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/#xpathFilter";
@@ -237,7 +237,7 @@
* @return the string
*/
public boolean getIncludeSlashPolicy() {
- return "true".equals(getLocalAttribute(XPathFilterCHGPContainer._ATT_INCLUDESLASH));
+ return getLocalAttribute(XPathFilterCHGPContainer._ATT_INCLUDESLASH).equals("true");
}
/**
diff --git a/src/main/java/org/apache/xml/security/utils/Base64.java b/src/main/java/org/apache/xml/security/utils/Base64.java
index 9f9b4bf..ceb5e7d 100644
--- a/src/main/java/org/apache/xml/security/utils/Base64.java
+++ b/src/main/java/org/apache/xml/security/utils/Base64.java
@@ -39,7 +39,7 @@
* @see org.apache.xml.security.transforms.implementations.TransformBase64Decode
*/
@Deprecated
-public final class Base64 {
+public class Base64 {
/** Field BASE64DEFAULTLENGTH */
public static final int BASE64DEFAULTLENGTH = 76;
@@ -373,12 +373,12 @@
return "";
}
- long fewerThan24bits = lengthDataBits % (TWENTYFOURBITGROUP);
+ long fewerThan24bits = lengthDataBits % ((long) TWENTYFOURBITGROUP);
int numberTriplets = (int) (lengthDataBits / TWENTYFOURBITGROUP);
int numberQuartet = fewerThan24bits != 0L ? numberTriplets + 1 : numberTriplets;
int quartesPerLine = length / 4;
int numberLines = (numberQuartet - 1) / quartesPerLine;
- char[] encodedData = null;
+ char encodedData[] = null;
encodedData = new char[numberQuartet * 4 + numberLines * 2];
@@ -509,7 +509,7 @@
return new byte[0];
}
- byte[] decodedData = null;
+ byte decodedData[] = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
int i = 0;
@@ -624,7 +624,7 @@
return;
}
- //byte[] decodedData = null;
+ //byte decodedData[] = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
int i = 0;
@@ -691,7 +691,7 @@
*/
public static final void decode(InputStream is, OutputStream os)
throws Base64DecodingException, IOException {
- //byte[] decodedData = null;
+ //byte decodedData[] = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
int index = 0;
diff --git a/src/main/java/org/apache/xml/security/utils/ClassLoaderUtils.java b/src/main/java/org/apache/xml/security/utils/ClassLoaderUtils.java
index abffe8e..3534d46 100644
--- a/src/main/java/org/apache/xml/security/utils/ClassLoaderUtils.java
+++ b/src/main/java/org/apache/xml/security/utils/ClassLoaderUtils.java
@@ -54,7 +54,7 @@
*/
public static URL getResource(String resourceName, Class<?> callingClass) {
URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
- if (url == null && resourceName.charAt(0) == '/') {
+ if (url == null && resourceName.startsWith("/")) {
//certain classloaders need it without the leading /
url =
Thread.currentThread().getContextClassLoader().getResource(
@@ -69,7 +69,7 @@
if (url == null) {
url = cluClassloader.getResource(resourceName);
}
- if (url == null && resourceName.charAt(0) == '/') {
+ if (url == null && resourceName.startsWith("/")) {
//certain classloaders need it without the leading /
url = cluClassloader.getResource(resourceName.substring(1));
}
@@ -122,7 +122,7 @@
LOG.debug(e.getMessage(), e);
//ignore
}
- if (!urls.hasMoreElements() && resourceName.charAt(0) == '/') {
+ if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
//certain classloaders need it without the leading /
try {
urls =
@@ -147,7 +147,7 @@
// ignore
}
}
- if (!urls.hasMoreElements() && resourceName.charAt(0) == '/') {
+ if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
//certain classloaders need it without the leading /
try {
urls = cluClassloader.getResources(resourceName.substring(1));
diff --git a/src/main/java/org/apache/xml/security/utils/ElementProxy.java b/src/main/java/org/apache/xml/security/utils/ElementProxy.java
index 5b02f05..31368da 100644
--- a/src/main/java/org/apache/xml/security/utils/ElementProxy.java
+++ b/src/main/java/org/apache/xml/security/utils/ElementProxy.java
@@ -51,7 +51,7 @@
private Document wrappedDoc;
/** Field prefixMappings */
- private static Map<String, String> prefixMappings = new ConcurrentHashMap<>();
+ private static Map<String, String> prefixMappings = new ConcurrentHashMap<String, String>();
/**
* Constructor ElementProxy
@@ -245,7 +245,7 @@
if(!expectedNamespaceUri.equals(actualNamespaceUri)
&& !expectedLocalName.equals(actualLocalName)) {
- Object[] exArgs = { actualNamespaceUri + ":" + actualLocalName,
+ Object exArgs[] = { actualNamespaceUri + ":" + actualLocalName,
expectedNamespaceUri + ":" + expectedLocalName};
throw new XMLSecurityException("xml.WrongElement", exArgs);
}
@@ -455,7 +455,7 @@
if (a != null) {
if (!a.getNodeValue().equals(uri)) {
- Object[] exArgs = { ns, getElement().getAttributeNS(null, ns) };
+ Object exArgs[] = { ns, getElement().getAttributeNS(null, ns) };
throw new XMLSecurityException("namespacePrefixAlreadyUsedByOtherURI", exArgs);
}
@@ -485,7 +485,7 @@
if (prefixMappings.containsValue(prefix)) {
String storedPrefix = prefixMappings.get(namespace);
if (!storedPrefix.equals(prefix)) {
- Object[] exArgs = { prefix, namespace, storedPrefix };
+ Object exArgs[] = { prefix, namespace, storedPrefix };
throw new XMLSecurityException("prefix.AlreadyAssigned", exArgs);
}
diff --git a/src/main/java/org/apache/xml/security/utils/I18n.java b/src/main/java/org/apache/xml/security/utils/I18n.java
index c9bb1b6..8585278 100644
--- a/src/main/java/org/apache/xml/security/utils/I18n.java
+++ b/src/main/java/org/apache/xml/security/utils/I18n.java
@@ -26,7 +26,7 @@
* The Internationalization (I18N) pack.
*
*/
-public final class I18n {
+public class I18n {
/** Field NOT_INITIALIZED_MSG */
public static final String NOT_INITIALIZED_MSG =
@@ -107,7 +107,7 @@
*/
public static String getExceptionMessage(String msgID, Exception originalException) {
try {
- Object[] exArgs = { originalException.getMessage() };
+ Object exArgs[] = { originalException.getMessage() };
return MessageFormat.format(resourceBundle.getString(msgID), exArgs);
} catch (Throwable t) {
if (org.apache.xml.security.Init.isInitialized()) {
@@ -129,7 +129,7 @@
* @param exArgs
* @return message translated
*/
- public static String getExceptionMessage(String msgID, Object[] exArgs) {
+ public static String getExceptionMessage(String msgID, Object exArgs[]) {
try {
return MessageFormat.format(resourceBundle.getString(msgID), exArgs);
} catch (Throwable t) {
diff --git a/src/main/java/org/apache/xml/security/utils/IdResolver.java b/src/main/java/org/apache/xml/security/utils/IdResolver.java
index 6787d72..34b7f63 100644
--- a/src/main/java/org/apache/xml/security/utils/IdResolver.java
+++ b/src/main/java/org/apache/xml/security/utils/IdResolver.java
@@ -30,7 +30,7 @@
* @deprecated
*/
@Deprecated
-public final class IdResolver {
+public class IdResolver {
private IdResolver() {
// we don't allow instantiation
diff --git a/src/main/java/org/apache/xml/security/utils/JavaUtils.java b/src/main/java/org/apache/xml/security/utils/JavaUtils.java
index cde9669..a7ca00d 100644
--- a/src/main/java/org/apache/xml/security/utils/JavaUtils.java
+++ b/src/main/java/org/apache/xml/security/utils/JavaUtils.java
@@ -53,11 +53,11 @@
public static byte[] getBytesFromFile(String fileName)
throws FileNotFoundException, IOException {
- byte[] refBytes = null;
+ byte refBytes[] = null;
try (InputStream inputStream = Files.newInputStream(Paths.get(fileName));
UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream()) {
- byte[] buf = new byte[1024];
+ byte buf[] = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
@@ -100,7 +100,7 @@
*/
public static byte[] getBytesFromStream(InputStream inputStream) throws IOException {
try (UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream()) {
- byte[] buf = new byte[4 * 1024];
+ byte buf[] = new byte[4 * 1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
baos.write(buf, 0, len);
diff --git a/src/main/java/org/apache/xml/security/utils/RFC2253Parser.java b/src/main/java/org/apache/xml/security/utils/RFC2253Parser.java
index 83e9692..4100648 100644
--- a/src/main/java/org/apache/xml/security/utils/RFC2253Parser.java
+++ b/src/main/java/org/apache/xml/security/utils/RFC2253Parser.java
@@ -68,7 +68,7 @@
*/
public static String normalize(String dn, boolean toXml) {
//if empty string
- if (dn == null || dn.isEmpty()) {
+ if (dn == null || dn.equals("")) {
return "";
}
@@ -84,7 +84,7 @@
l += countQuotes(DN, j, k);
if (k > 0 && DN.charAt(k - 1) != '\\' && (l % 2) == 0) {
- sb.append(parseRDN(DN.substring(i, k).trim(), toXml)).append(',');
+ sb.append(parseRDN(DN.substring(i, k).trim(), toXml)).append(",");
i = k + 1;
l = 0;
@@ -117,7 +117,7 @@
l += countQuotes(str, j, k);
if (k > 0 && str.charAt(k - 1) != '\\' && (l % 2) == 0) {
- sb.append(parseATAV(trim(str.substring(i, k)), toXml)).append('+');
+ sb.append(parseATAV(trim(str.substring(i, k)), toXml)).append("+");
i = k + 1;
l = 0;
@@ -206,7 +206,7 @@
}
if (toXml) {
- if (value.length() > 0 && value.charAt(0) == '#') {
+ if (value.startsWith("#")) {
value = '\\' + value;
}
} else {
diff --git a/src/main/java/org/apache/xml/security/utils/UnsyncByteArrayInputStream.java b/src/main/java/org/apache/xml/security/utils/UnsyncByteArrayInputStream.java
index ff6cd1e..4782e91 100644
--- a/src/main/java/org/apache/xml/security/utils/UnsyncByteArrayInputStream.java
+++ b/src/main/java/org/apache/xml/security/utils/UnsyncByteArrayInputStream.java
@@ -55,7 +55,7 @@
* @param buf
* the byte array to stream over.
*/
- public UnsyncByteArrayInputStream(byte[] buf) {
+ public UnsyncByteArrayInputStream(byte buf[]) {
this.mark = 0;
this.buf = buf;
this.count = buf.length;
@@ -73,7 +73,7 @@
* @param length
* the number of bytes available for streaming.
*/
- public UnsyncByteArrayInputStream(byte[] buf, int offset, int length) {
+ public UnsyncByteArrayInputStream(byte buf[], int offset, int length) {
this.buf = buf;
pos = offset;
mark = offset;
@@ -166,7 +166,7 @@
* if {@code b} is {@code null}.
*/
@Override
- public int read(byte[] b, int offset, int length) {
+ public int read(byte b[], int offset, int length) {
if (b == null) {
throw new NullPointerException();
}
diff --git a/src/main/java/org/apache/xml/security/utils/UnsyncByteArrayOutputStream.java b/src/main/java/org/apache/xml/security/utils/UnsyncByteArrayOutputStream.java
index d6ff16e..f70feba 100644
--- a/src/main/java/org/apache/xml/security/utils/UnsyncByteArrayOutputStream.java
+++ b/src/main/java/org/apache/xml/security/utils/UnsyncByteArrayOutputStream.java
@@ -76,7 +76,7 @@
}
public byte[] toByteArray() {
- byte[] result = new byte[pos];
+ byte result[] = new byte[pos];
System.arraycopy(buf, 0, result, 0, pos);
return result;
}
@@ -107,7 +107,7 @@
newSize = VM_ARRAY_INDEX_MAX_VALUE;
}
}
- byte[] newBuf = new byte[newSize];
+ byte newBuf[] = new byte[newSize];
System.arraycopy(buf, 0, newBuf, 0, pos);
buf = newBuf;
size = newSize;
diff --git a/src/main/java/org/apache/xml/security/utils/WeakObjectPool.java b/src/main/java/org/apache/xml/security/utils/WeakObjectPool.java
index adf3dba..967da95 100644
--- a/src/main/java/org/apache/xml/security/utils/WeakObjectPool.java
+++ b/src/main/java/org/apache/xml/security/utils/WeakObjectPool.java
@@ -56,7 +56,7 @@
protected WeakObjectPool() {
//alternative implementations: ArrayBlockingQueue has a fixed size
// PriorityBlockingQueue: requires a dummy comparator; less memory but more overhead
- available = new LinkedBlockingDeque<>();
+ available = new LinkedBlockingDeque<WeakReference<T>>();
this.onLoan = Collections.synchronizedMap(new WeakHashMap<T, Integer>());
}
diff --git a/src/main/java/org/apache/xml/security/utils/XMLUtils.java b/src/main/java/org/apache/xml/security/utils/XMLUtils.java
index b70aab3..1eb48f6 100644
--- a/src/main/java/org/apache/xml/security/utils/XMLUtils.java
+++ b/src/main/java/org/apache/xml/security/utils/XMLUtils.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.utils;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -35,17 +36,21 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.validation.Schema;
import org.apache.xml.security.c14n.CanonicalizationException;
import org.apache.xml.security.c14n.Canonicalizer;
import org.apache.xml.security.c14n.InvalidCanonicalizerException;
import org.w3c.dom.Attr;
+import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -60,10 +65,12 @@
(PrivilegedAction<Boolean>) () -> Boolean.getBoolean("org.apache.xml.security.ignoreLineBreaks"));
@SuppressWarnings("unchecked")
- private static final WeakObjectPool<DocumentBuilder, ParserConfigurationException> pools[] = new WeakObjectPool[2];
+ private static final WeakObjectPool<DocumentBuilder, ParserConfigurationException> pools[] = new WeakObjectPool[4];
static {
- pools[0] = new DocumentBuilderPool(false);
- pools[1] = new DocumentBuilderPool(true);
+ pools[0] = new DocumentBuilderPool(false, false);
+ pools[1] = new DocumentBuilderPool(false, true);
+ pools[2] = new DocumentBuilderPool(true, false);
+ pools[3] = new DocumentBuilderPool(true, true);
}
private static volatile String dsPrefix = "ds";
@@ -154,7 +161,7 @@
if (rootNode == exclude) {
return;
}
- switch (rootNode.getNodeType()) { //NOPMD
+ switch (rootNode.getNodeType()) {
case Node.ELEMENT_NODE:
result.add(rootNode);
Element el = (Element)rootNode;
@@ -179,14 +186,14 @@
}
getSetRec(r, result, exclude, com);
}
- break;
+ return;
case Node.COMMENT_NODE:
if (com) {
result.add(rootNode);
}
- break;
+ return;
case Node.DOCUMENT_TYPE_NODE:
- break;
+ return;
default:
result.add(rootNode);
}
@@ -261,6 +268,11 @@
}
}
+ @Deprecated
+ public static String getFullTextChildrenFromElement(Element element) {
+ return getFullTextChildrenFromNode(element);
+ }
+
/**
* Method getFullTextChildrenFromNode
*
@@ -719,6 +731,62 @@
return null;
}
+
+ /**
+ * @param sibling
+ * @param nodeName
+ * @param number
+ * @return nodes with the constrain
+ */
+ public static Text selectDsNodeText(Node sibling, String nodeName, int number) {
+ Node n = selectDsNode(sibling, nodeName, number);
+ if (n == null) {
+ return null;
+ }
+ n = n.getFirstChild();
+ while (n != null && n.getNodeType() != Node.TEXT_NODE) {
+ n = n.getNextSibling();
+ }
+ return (Text)n;
+ }
+
+ /**
+ * @param sibling
+ * @param nodeName
+ * @param number
+ * @return nodes with the constrain
+ */
+ public static Text selectDs11NodeText(Node sibling, String nodeName, int number) {
+ Node n = selectDs11Node(sibling, nodeName, number);
+ if (n == null) {
+ return null;
+ }
+ n = n.getFirstChild();
+ while (n != null && n.getNodeType() != Node.TEXT_NODE) {
+ n = n.getNextSibling();
+ }
+ return (Text)n;
+ }
+
+ /**
+ * @param sibling
+ * @param uri
+ * @param nodeName
+ * @param number
+ * @return nodes with the constrain
+ */
+ public static Text selectNodeText(Node sibling, String uri, String nodeName, int number) {
+ Node n = selectNode(sibling, uri, nodeName, number);
+ if (n == null) {
+ return null;
+ }
+ n = n.getFirstChild();
+ while (n != null && n.getNodeType() != Node.TEXT_NODE) {
+ n = n.getNextSibling();
+ }
+ return (Text)n;
+ }
+
/**
* @param sibling
* @param uri
@@ -1003,55 +1071,31 @@
return true;
}
- public static Document newDocument() throws ParserConfigurationException {
- DocumentBuilder documentBuilder = createDocumentBuilder(true);
- Document doc = documentBuilder.newDocument();
- repoolDocumentBuilder(documentBuilder, true);
- return doc;
+ public static DocumentBuilder createDocumentBuilder(boolean validating) throws ParserConfigurationException {
+ return createDocumentBuilder(validating, true);
}
- public static Document read(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException {
- return read(inputStream, true);
- }
-
- public static Document read(InputStream inputStream, boolean disAllowDocTypeDeclarations) throws ParserConfigurationException, SAXException, IOException {
- DocumentBuilder documentBuilder = createDocumentBuilder(disAllowDocTypeDeclarations);
- Document doc = documentBuilder.parse(inputStream);
- repoolDocumentBuilder(documentBuilder, disAllowDocTypeDeclarations);
- return doc;
- }
-
- public static Document read(String uri, boolean disAllowDocTypeDeclarations)
- throws ParserConfigurationException, SAXException, IOException {
- DocumentBuilder documentBuilder = createDocumentBuilder(disAllowDocTypeDeclarations);
- Document doc = documentBuilder.parse(uri);
- repoolDocumentBuilder(documentBuilder, disAllowDocTypeDeclarations);
- return doc;
- }
-
- public static Document read(InputSource inputSource) throws ParserConfigurationException, SAXException, IOException {
- return read(inputSource, true);
- }
-
- public static Document read(InputSource inputSource, boolean disAllowDocTypeDeclarations)
- throws ParserConfigurationException, SAXException, IOException {
- DocumentBuilder documentBuilder = createDocumentBuilder(disAllowDocTypeDeclarations);
- Document doc = documentBuilder.parse(inputSource);
- repoolDocumentBuilder(documentBuilder, disAllowDocTypeDeclarations);
- return doc;
- }
-
- private static DocumentBuilder createDocumentBuilder(
- boolean disAllowDocTypeDeclarations
+ public static DocumentBuilder createDocumentBuilder(
+ boolean validating, boolean disAllowDocTypeDeclarations
) throws ParserConfigurationException {
- int idx = getPoolsIndex(disAllowDocTypeDeclarations);
+ int idx = getPoolsIndex(validating, disAllowDocTypeDeclarations);
return pools[idx].getObject();
}
- private static boolean repoolDocumentBuilder(DocumentBuilder db, boolean disAllowDocTypeDeclarations) {
+ /**
+ * Return this document builder to be reused
+ * @param db DocumentBuilder returned from any of {@link #createDocumentBuilder} methods.
+ * @return whether it was successfully returned to the pool
+ */
+ public static boolean repoolDocumentBuilder(DocumentBuilder db) {
+ if (!(db instanceof DocumentBuilderProxy)) {
+ return false;
+ }
db.reset();
- int idx = getPoolsIndex(disAllowDocTypeDeclarations);
+ boolean disAllowDocTypeDeclarations =
+ ((DocumentBuilderProxy)db).disAllowDocTypeDeclarations();
+ int idx = getPoolsIndex(db.isValidating(), disAllowDocTypeDeclarations);
return pools[idx].repool(db);
}
@@ -1100,12 +1144,97 @@
return resizedBytes;
}
+ /**
+ * We need this proxy wrapping DocumentBuilder to record the value
+ * passed to disAllowDoctypeDeclarations. It's needed to figure out
+ * on which pool to return.
+ */
+ private static class DocumentBuilderProxy extends DocumentBuilder {
+ private final DocumentBuilder delegate;
+ private final boolean disAllowDocTypeDeclarations;
+
+ private DocumentBuilderProxy(DocumentBuilder actual, boolean disAllowDocTypeDeclarations) {
+ delegate = actual;
+ this.disAllowDocTypeDeclarations = disAllowDocTypeDeclarations;
+ }
+
+ boolean disAllowDocTypeDeclarations() {
+ return disAllowDocTypeDeclarations;
+ }
+
+ public void reset() {
+ delegate.reset();
+ }
+
+ public Document parse(InputStream is) throws SAXException, IOException {
+ return delegate.parse(is);
+ }
+
+ public Document parse(InputStream is, String systemId)
+ throws SAXException, IOException {
+ return delegate.parse(is, systemId);
+ }
+
+ public Document parse(String uri) throws SAXException, IOException {
+ return delegate.parse(uri);
+ }
+
+ public Document parse(File f) throws SAXException, IOException {
+ return delegate.parse(f);
+ }
+
+ public Schema getSchema() {
+ return delegate.getSchema();
+ }
+
+ public boolean isXIncludeAware() {
+ return delegate.isXIncludeAware();
+ }
+
+ @Override
+ public Document parse(InputSource is) throws SAXException, IOException {
+ return delegate.parse(is);
+ }
+
+ @Override
+ public boolean isNamespaceAware() {
+ return delegate.isNamespaceAware();
+ }
+
+ @Override
+ public boolean isValidating() {
+ return delegate.isValidating();
+ }
+
+ @Override
+ public void setEntityResolver(EntityResolver er) {
+ delegate.setEntityResolver(er);
+ }
+
+ @Override
+ public void setErrorHandler(ErrorHandler eh) {
+ delegate.setErrorHandler(eh);
+ }
+
+ @Override
+ public Document newDocument() {
+ return delegate.newDocument();
+ }
+
+ @Override
+ public DOMImplementation getDOMImplementation() {
+ return delegate.getDOMImplementation();
+ }
+
+ }
+
private static final class DocumentBuilderPool
extends WeakObjectPool<DocumentBuilder, ParserConfigurationException> {
- private final boolean disAllowDocTypeDeclarations;
+ private final boolean validating, disAllowDocTypeDeclarations;
- public DocumentBuilderPool(boolean disAllowDocTypeDeclarations) {
+ public DocumentBuilderPool(boolean validating, boolean disAllowDocTypeDeclarations) {
+ this.validating = validating;
this.disAllowDocTypeDeclarations = disAllowDocTypeDeclarations;
}
@@ -1116,18 +1245,20 @@
if (disAllowDocTypeDeclarations) {
dfactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
}
+ dfactory.setValidating(validating);
dfactory.setNamespaceAware(true);
- return dfactory.newDocumentBuilder();
+ return new DocumentBuilderProxy(dfactory.newDocumentBuilder(), disAllowDocTypeDeclarations);
}
}
/**
- * Maps the boolean configuration options for the factories to the array index for the WeakObjectPool
+ * Maps the two boolean configuration options for the factories to the array index for the WeakObjectPool
+ * @param validating
* @param disAllowDocTypeDeclarations
* @return the index to the {@link #pools}
*/
- private static int getPoolsIndex(boolean disAllowDocTypeDeclarations) {
- return disAllowDocTypeDeclarations ? 1 : 0;
+ private static int getPoolsIndex(boolean validating, boolean disAllowDocTypeDeclarations) {
+ return (validating ? 2 : 0) + (disAllowDocTypeDeclarations ? 1 : 0);
}
}
diff --git a/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java b/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java
index 31204b1..ba42dd2 100644
--- a/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java
+++ b/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java
@@ -97,7 +97,7 @@
if (context.secureValidation
&& (resolverTmp.resolverSpi instanceof ResolverLocalFilesystem
|| resolverTmp.resolverSpi instanceof ResolverDirectHTTP)) {
- Object[] exArgs = { resolverTmp.resolverSpi.getClass().getName() };
+ Object exArgs[] = { resolverTmp.resolverSpi.getClass().getName() };
throw new ResourceResolverException(
"signature.Reference.ForbiddenResolver", exArgs, context.uriToResolve, context.baseUri
);
@@ -107,7 +107,7 @@
}
}
- Object[] exArgs = { context.uriToResolve != null
+ Object exArgs[] = { context.uriToResolve != null
? context.uriToResolve : "null", context.baseUri };
throw new ResourceResolverException("utils.resolver.noClass", exArgs, context.uriToResolve, context.baseUri);
@@ -145,7 +145,7 @@
) throws ResourceResolverException {
LOG.debug(
"I was asked to create a ResourceResolver and got {}",
- individualResolvers == null ? 0 : individualResolvers.size()
+ (individualResolvers == null ? 0 : individualResolvers.size())
);
ResourceResolverContext context = new ResourceResolverContext(uri, baseURI, secureValidation);
diff --git a/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java b/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java
index b302efd..34d43b1 100644
--- a/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java
+++ b/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolverException.java
@@ -55,7 +55,7 @@
* @param uri
* @param baseURI
*/
- public ResourceResolverException(String msgID, Object[] exArgs, String uri,
+ public ResourceResolverException(String msgID, Object exArgs[], String uri,
String baseURI) {
super(msgID, exArgs);
@@ -95,7 +95,7 @@
* @param exArgs
*/
public ResourceResolverException(Exception originalException, String uri,
- String baseURI, String msgID, Object[] exArgs) {
+ String baseURI, String msgID, Object exArgs[]) {
super(originalException, msgID, exArgs);
this.uri = uri;
@@ -103,7 +103,7 @@
}
@Deprecated
- public ResourceResolverException(String msgID, Object[] exArgs,
+ public ResourceResolverException(String msgID, Object exArgs[],
Exception originalException, String uri,
String baseURI) {
this(originalException, uri, baseURI, msgID, exArgs);
diff --git a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverAnonymous.java b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverAnonymous.java
index ad7c779..df3fe3f 100644
--- a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverAnonymous.java
+++ b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverAnonymous.java
@@ -69,7 +69,10 @@
*/
@Override
public boolean engineCanResolveURI(ResourceResolverContext context) {
- return context.uriToResolve == null;
+ if (context.uriToResolve == null) {
+ return true;
+ }
+ return false;
}
/** {@inheritDoc} */
diff --git a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
index 6bdc29f..a2d88c9 100644
--- a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
+++ b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
@@ -62,7 +62,7 @@
org.slf4j.LoggerFactory.getLogger(ResolverDirectHTTP.class);
/** Field properties[] */
- private static final String[] properties = {
+ private static final String properties[] = {
"http.proxy.host", "http.proxy.port",
"http.proxy.username", "http.proxy.password",
"http.basic.username", "http.basic.password"
@@ -206,7 +206,7 @@
return false;
}
- if (context.uriToResolve.isEmpty() || context.uriToResolve.charAt(0) == '#') {
+ if (context.uriToResolve.equals("") || context.uriToResolve.charAt(0) == '#') {
LOG.debug("quick fail for empty URIs and local ones");
return false;
}
diff --git a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java
index 1c26e5b..3f4b71a 100644
--- a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java
+++ b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java
@@ -54,7 +54,7 @@
Document doc = context.attr.getOwnerElement().getOwnerDocument();
Node selectedElem = null;
- if (context.uriToResolve.isEmpty()) {
+ if (context.uriToResolve.equals("")) {
/*
* Identifies the node-set (minus any comment nodes) of the XML
* resource containing the signature
@@ -74,7 +74,7 @@
selectedElem = doc.getElementById(id);
if (selectedElem == null) {
- Object[] exArgs = { id };
+ Object exArgs[] = { id };
throw new ResourceResolverException(
"signature.Verification.MissingID", exArgs, context.uriToResolve, context.baseUri
);
@@ -82,7 +82,7 @@
if (context.secureValidation) {
Element start = context.attr.getOwnerDocument().getDocumentElement();
if (!XMLUtils.protectAgainstWrappingAttack(start, id)) {
- Object[] exArgs = { id };
+ Object exArgs[] = { id };
throw new ResourceResolverException(
"signature.Verification.MultipleIDs", exArgs, context.uriToResolve, context.baseUri
);
@@ -117,7 +117,7 @@
return false;
}
- if (context.uriToResolve.isEmpty() ||
+ if (context.uriToResolve.equals("") ||
context.uriToResolve.charAt(0) == '#' && !context.uriToResolve.startsWith("#xpointer(")
) {
LOG.debug("State I can resolve reference: \"{}\"", context.uriToResolve);
diff --git a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java
index fc03ec5..1d71444 100644
--- a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java
+++ b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java
@@ -111,7 +111,7 @@
return false;
}
- if (context.uriToResolve.isEmpty() || context.uriToResolve.charAt(0) == '#' ||
+ if (context.uriToResolve.equals("") || context.uriToResolve.charAt(0) == '#' ||
context.uriToResolve.startsWith("http:")) {
return false;
}
diff --git a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java
index eae8d1b..2aa8982 100644
--- a/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java
+++ b/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java
@@ -73,7 +73,7 @@
if (context.secureValidation) {
Element start = context.attr.getOwnerDocument().getDocumentElement();
if (!XMLUtils.protectAgainstWrappingAttack(start, id)) {
- Object[] exArgs = { id };
+ Object exArgs[] = { id };
throw new ResourceResolverException(
"signature.Verification.MultipleIDs", exArgs, context.uriToResolve, context.baseUri
);
@@ -81,7 +81,7 @@
}
if (resultNode == null) {
- Object[] exArgs = { id };
+ Object exArgs[] = { id };
throw new ResourceResolverException(
"signature.Verification.MissingID", exArgs, context.uriToResolve, context.baseUri
@@ -109,7 +109,11 @@
if (context.uriToResolve == null) {
return false;
}
- return isXPointerSlash(context.uriToResolve) || isXPointerId(context.uriToResolve);
+ if (isXPointerSlash(context.uriToResolve) || isXPointerId(context.uriToResolve)) {
+ return true;
+ }
+
+ return false;
}
/**
@@ -119,7 +123,11 @@
* @return true if begins with xpointer
*/
private static boolean isXPointerSlash(String uri) {
- return "#xpointer(/)".equals(uri);
+ if (uri.equals("#xpointer(/)")) {
+ return true;
+ }
+
+ return false;
}
/**
diff --git a/src/test/java/javax/xml/crypto/test/KeySelectorExceptionTest.java b/src/test/java/javax/xml/crypto/test/KeySelectorExceptionTest.java
index c51011d..c3e5005 100644
--- a/src/test/java/javax/xml/crypto/test/KeySelectorExceptionTest.java
+++ b/src/test/java/javax/xml/crypto/test/KeySelectorExceptionTest.java
@@ -21,17 +21,13 @@
*/
package javax.xml.crypto.test;
+import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Arrays;
import javax.xml.crypto.KeySelectorException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
/**
* Unit test for javax.xml.crypto.KeySelectorException
*
@@ -90,4 +86,4 @@
}
return result;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/KeySelectorTest.java b/src/test/java/javax/xml/crypto/test/KeySelectorTest.java
index 6aedeb6..39e166d 100644
--- a/src/test/java/javax/xml/crypto/test/KeySelectorTest.java
+++ b/src/test/java/javax/xml/crypto/test/KeySelectorTest.java
@@ -23,6 +23,7 @@
import java.util.*;
+import static org.junit.Assert.assertTrue;
import java.security.Key;
import java.security.cert.X509Certificate;
@@ -30,8 +31,6 @@
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.dsig.*;
-import static org.junit.Assert.assertTrue;
-
/**
* Unit test for javax.xml.crypto.KeySelector
*
@@ -98,4 +97,4 @@
}
return result;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/KeySelectors.java b/src/test/java/javax/xml/crypto/test/KeySelectors.java
index 2f3d774..e4b75cd 100644
--- a/src/test/java/javax/xml/crypto/test/KeySelectors.java
+++ b/src/test/java/javax/xml/crypto/test/KeySelectors.java
@@ -234,7 +234,7 @@
case MATCH_SUBJECT_KEY_ID:
byte[] extension = c.getExtensionValue("2.5.29.14");
if (extension != null) {
- byte[] extVal = new byte[extension.length - 4];
+ byte extVal[] = new byte[extension.length - 4];
System.arraycopy(extension, 4, extVal, 0, extVal.length);
if (Arrays.equals(extVal, (byte[]) value)) {
@@ -281,13 +281,13 @@
// assume KeyName contains subject DN and search
// collection of certs for match
List<X509Certificate> result = match(MATCH_SUBJECT, name, certs);
- int numOfMatches = result == null ? 0 : result.size();
+ int numOfMatches = (result == null? 0 : result.size());
if (numOfMatches != 1) {
throw new KeySelectorException
((numOfMatches == 0 ? "No":"More than one") +
" match found");
}
- pk = result.get(0).getPublicKey();
+ pk = ((X509Certificate)result.get(0)).getPublicKey();
}
return new SimpleKSResult(pk);
} else if (xmlStructure instanceof RetrievalMethod) {
@@ -331,14 +331,14 @@
throw new KeySelectorException("Unsupported X509Data: " + obj);
}
}
- int numOfMatches = result == null ? 0 : result.size();
+ int numOfMatches = (result == null ? 0 : result.size());
if (numOfMatches != 1) {
throw new KeySelectorException
- ((numOfMatches == 0 ? "No" : "More than one") +
+ ((numOfMatches==0?"No":"More than one") +
" match found");
-
}
- return new SimpleKSResult(result.get(0).getPublicKey());
+ return new SimpleKSResult(((X509Certificate)
+ result.get(0)).getPublicKey());
}
} catch (Exception ex) {
throw new KeySelectorException(ex);
@@ -365,7 +365,7 @@
public static String dumpArray(byte[] in) {
int numDumped = 0;
StringBuilder buf = new StringBuilder(512);
- buf.append('{');
+ buf.append("{");
for (int i = 0;i < (in.length / numBytesPerRow); i++) {
for (int j=0; j < (numBytesPerRow); j++) {
buf.append("(byte)0x");
@@ -377,10 +377,10 @@
while (numDumped < in.length) {
buf.append("(byte)0x");
buf.append(getHex(in[numDumped]));
- buf.append(' ');
+ buf.append(" ");
numDumped += 1;
}
- buf.append('}');
+ buf.append("}");
return buf.toString();
}
}
diff --git a/src/test/java/javax/xml/crypto/test/OctetStreamDataTest.java b/src/test/java/javax/xml/crypto/test/OctetStreamDataTest.java
index 03e8e53..6a37bf4 100644
--- a/src/test/java/javax/xml/crypto/test/OctetStreamDataTest.java
+++ b/src/test/java/javax/xml/crypto/test/OctetStreamDataTest.java
@@ -21,17 +21,12 @@
*/
package javax.xml.crypto.test;
+import static org.junit.Assert.*;
import java.io.*;
import java.util.*;
import javax.xml.crypto.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.OctetStreamData
*
@@ -78,4 +73,4 @@
assertEquals(osdata.getMimeType(), mimeType);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/Baltimore18Test.java b/src/test/java/javax/xml/crypto/test/dsig/Baltimore18Test.java
index e2a3e3d..9d019d0 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/Baltimore18Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/Baltimore18Test.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.security.Security;
@@ -30,8 +31,6 @@
import javax.xml.crypto.URIDereferencer;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all "merlin-xmldsig-eighteen"
* testcases from Baltimore
@@ -122,4 +121,4 @@
assertTrue("Signature failed core validation", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/Baltimore23Test.java b/src/test/java/javax/xml/crypto/test/dsig/Baltimore23Test.java
index 7ef7673..db0b664 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/Baltimore23Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/Baltimore23Test.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.FileInputStream;
@@ -33,10 +34,6 @@
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a testcase to validate all "merlin-xmldsig-twenty-three"
* testcases from Baltimore
@@ -244,4 +241,4 @@
assertTrue("Signature failed core validation", cv);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/BaltimoreExcC14n1Test.java b/src/test/java/javax/xml/crypto/test/dsig/BaltimoreExcC14n1Test.java
index 757e3e3..072bbfa 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/BaltimoreExcC14n1Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/BaltimoreExcC14n1Test.java
@@ -21,14 +21,13 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.security.Security;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all "merlin-exc-c14n-one"
* testcases from Baltimore
@@ -62,4 +61,4 @@
assertTrue("Signature failed core validation", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/BaltimoreIaik2Test.java b/src/test/java/javax/xml/crypto/test/dsig/BaltimoreIaik2Test.java
index 72f760c..a8be98a 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/BaltimoreIaik2Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/BaltimoreIaik2Test.java
@@ -21,14 +21,13 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.security.Security;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all "ec-merlin-iaikTests-two"
* testcases from Baltimore
@@ -62,4 +61,4 @@
assertTrue("Signature failed core validation", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/BaltimoreXPathFilter2ThreeTest.java b/src/test/java/javax/xml/crypto/test/dsig/BaltimoreXPathFilter2ThreeTest.java
index 96f0816..ae7136d 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/BaltimoreXPathFilter2ThreeTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/BaltimoreXPathFilter2ThreeTest.java
@@ -21,14 +21,13 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.security.Security;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate the "merlin-xpath-filter2-three" testcases
* under data/vectors/ie/baltimore/merlin-examples directory
@@ -78,4 +77,4 @@
assertTrue("Signature failed core validation#2", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/C14N11Test.java b/src/test/java/javax/xml/crypto/test/dsig/C14N11Test.java
index 46eeb56..39b4bae 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/C14N11Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/C14N11Test.java
@@ -27,7 +27,6 @@
import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all the W3C xmldsig C14N11 testcases.
*
@@ -174,4 +173,4 @@
assertTrue(file + " failed core validation", coreValidity);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CanonicalizationMethodTest.java b/src/test/java/javax/xml/crypto/test/dsig/CanonicalizationMethodTest.java
index 882f4b6..5712b9e 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CanonicalizationMethodTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CanonicalizationMethodTest.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.security.*;
import java.security.spec.AlgorithmParameterSpec;
@@ -28,14 +29,6 @@
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.CanonicalizationMethod
*
@@ -49,7 +42,7 @@
(new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI(), 1);
}
- private static final String[] C14N_ALGOS = {
+ private static final String C14N_ALGOS[] = {
CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
CanonicalizationMethod.INCLUSIVE,
CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS,
@@ -76,7 +69,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(cm.isFeatureSupported("not supported"));
+ assertTrue(!cm.isFeatureSupported("not supported"));
}
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/ComRSASecurityTest.java b/src/test/java/javax/xml/crypto/test/dsig/ComRSASecurityTest.java
index d7cd97e..7c3c4fe 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/ComRSASecurityTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/ComRSASecurityTest.java
@@ -21,14 +21,13 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.security.Security;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all "bdournaee"
* testcases from RSA
@@ -70,4 +69,4 @@
assertTrue("Signature failed core validation", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreateBaltimore23Test.java b/src/test/java/javax/xml/crypto/test/dsig/CreateBaltimore23Test.java
index 4e691e6..23a84a0 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreateBaltimore23Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreateBaltimore23Test.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.*;
import java.math.BigInteger;
@@ -46,6 +47,7 @@
import javax.xml.crypto.dsig.dom.DOMValidateContext;
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.dsig.spec.*;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
@@ -55,11 +57,6 @@
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* Test that recreates merlin-xmldsig-twenty-three test vectors but with
* different keys and X.509 data.
@@ -69,6 +66,7 @@
private XMLSignatureFactory fac;
private KeyInfoFactory kifac;
+ private DocumentBuilder db;
private CanonicalizationMethod withoutComments;
private Transform withComments;
private SignatureMethod dsaSha1, rsaSha1;
@@ -91,16 +89,16 @@
fac = XMLSignatureFactory.getInstance
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
kifac = fac.getKeyInfoFactory();
+ db = XMLUtils.createDocumentBuilder(false);
// get key & self-signed certificate from keystore
String fs = System.getProperty("file.separator");
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
- try (FileInputStream fis = new FileInputStream
- (base + fs + "src/test/resources" + fs + "test.jks")) {
- ks = KeyStore.getInstance("JKS");
- ks.load(fis, "changeit".toCharArray());
- }
+ FileInputStream fis = new FileInputStream
+ (base + fs + "src/test/resources" + fs + "test.jks");
+ ks = KeyStore.getInstance("JKS");
+ ks.load(fis, "changeit".toCharArray());
signingKey = ks.getKey("mullan", "changeit".toCharArray());
signingCert = ks.getCertificate("mullan");
validatingKey = signingCert.getPublicKey();
@@ -137,7 +135,7 @@
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, dsa);
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
Element envelope = doc.createElementNS
("http://example.org/envelope", "Envelope");
envelope.setAttributeNS
@@ -152,7 +150,7 @@
(kvks, envelope.getFirstChild());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
@@ -435,7 +433,7 @@
(Transform.XPATH, xpf)));
KeyInfo ki = kifac.newKeyInfo(Collections.singletonList(rm), null);
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
// create objects
List<XMLObject> objs = new ArrayList<>();
@@ -498,7 +496,7 @@
+ "</xsl:stylesheet>\n";
Document docxslt = null;
try (InputStream is = new ByteArrayInputStream(xslt.getBytes())) {
- docxslt = XMLUtils.read(is, false);
+ docxslt = db.parse(is);
}
Node xslElem = docxslt.getDocumentElement();
@@ -599,7 +597,8 @@
// read document back into DOM tree
try {
- doc = XMLUtils.read(new InputSource(new StringReader(sw.toString())), false);
+ doc = XMLUtils.createDocumentBuilder(false).parse
+ (new InputSource(new StringReader(sw.toString())));
} catch (SAXParseException spe) {
System.err.println("line:" + spe.getLineNumber());
System.err.println("xml:" + sw.toString());
@@ -627,7 +626,7 @@
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
@@ -659,7 +658,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, ki);
@@ -689,7 +688,7 @@
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
@@ -711,7 +710,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
// create Objects
XMLObject obj = fac.newXMLObject(Collections.singletonList
(new DOMStructure(doc.createTextNode("some text"))),
@@ -729,8 +728,8 @@
(ks, doc.getDocumentElement());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropExcC14NTest.java b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropExcC14NTest.java
index 2ee7b5c..3ffeeae 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropExcC14NTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropExcC14NTest.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.*;
import java.security.*;
@@ -37,9 +38,7 @@
import org.w3c.dom.*;
import javax.xml.crypto.test.KeySelectors;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import javax.xml.parsers.DocumentBuilder;
/**
* Test that recreates interop exc C14N test vectors
@@ -50,6 +49,7 @@
private XMLSignatureFactory fac;
private KeyInfoFactory kifac;
+ private DocumentBuilder db;
private KeyStore ks;
private Key signingKey;
private PublicKey validatingKey;
@@ -63,16 +63,16 @@
fac = XMLSignatureFactory.getInstance
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
kifac = fac.getKeyInfoFactory();
+ db = XMLUtils.createDocumentBuilder(false);
// get key & self-signed certificate from keystore
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
String fs = System.getProperty("file.separator");
- try (FileInputStream fis = new FileInputStream
- (base + fs + "src/test/resources" + fs + "test.jks")) {
- ks = KeyStore.getInstance("JKS");
- ks.load(fis, "changeit".toCharArray());
- }
+ FileInputStream fis = new FileInputStream
+ (base + fs + "src/test/resources" + fs + "test.jks");
+ ks = KeyStore.getInstance("JKS");
+ ks.load(fis, "changeit".toCharArray());
Certificate signingCert = ks.getCertificate("mullan");
signingKey = ks.getKey("mullan", "changeit".toCharArray());
validatingKey = signingCert.getPublicKey();
@@ -138,7 +138,7 @@
KeyInfo ki = kifac.newKeyInfo(kits);
// create Objects
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
Element baz = doc.createElementNS("urn:bar", "bar:Baz");
Comment com = doc.createComment(" comment ");
baz.appendChild(com);
@@ -165,7 +165,7 @@
(new KeySelectors.KeyValueKeySelector(), foo.getLastChild());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXFilter2Test.java b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXFilter2Test.java
index 7ec85cc..ee83d67 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXFilter2Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXFilter2Test.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.*;
import java.security.*;
@@ -37,9 +38,7 @@
import org.w3c.dom.*;
import javax.xml.crypto.test.KeySelectors;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import javax.xml.parsers.DocumentBuilder;
/**
* Test that recreates merlin-xpath-filter2-three test vectors
@@ -50,6 +49,7 @@
private XMLSignatureFactory fac;
private KeyInfoFactory kifac;
+ private DocumentBuilder db;
private KeyStore ks;
private Key signingKey;
private PublicKey validatingKey;
@@ -64,16 +64,16 @@
fac = XMLSignatureFactory.getInstance
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
kifac = fac.getKeyInfoFactory();
+ db = XMLUtils.createDocumentBuilder(false);
// get key & self-signed certificate from keystore
String fs = System.getProperty("file.separator");
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
- try (FileInputStream fis = new FileInputStream
- (base + fs + "src/test/resources" + fs + "test.jks")) {
- ks = KeyStore.getInstance("JKS");
- ks.load(fis, "changeit".toCharArray());
- }
+ FileInputStream fis = new FileInputStream
+ (base + fs + "src/test/resources" + fs + "test.jks");
+ ks = KeyStore.getInstance("JKS");
+ ks.load(fis, "changeit".toCharArray());
signingKey = ks.getKey("mullan", "changeit".toCharArray());
signingCert = ks.getCertificate("mullan");
validatingKey = signingCert.getPublicKey();
@@ -128,7 +128,7 @@
XMLSignature sig = fac.newXMLSignature
(si, ki, null, null, "signature-value");
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
Element tbs1 = doc.createElementNS(null, "ToBeSigned");
Comment tbs1Com = doc.createComment(" comment ");
Element tbs1Data = doc.createElementNS(null, "Data");
@@ -164,9 +164,9 @@
(new KeySelectors.KeyValueKeySelector(), document.getLastChild());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java
index 145c5d6..0d7fda7 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java
@@ -29,16 +29,15 @@
import javax.xml.crypto.dsig.dom.*;
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.dsig.spec.*;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.*;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to generate all the W3C xmldsig XMLDSig11 testcases.
*
@@ -53,6 +52,7 @@
hmacSha384, hmacSha512;
private KeyInfo p256ki, p384ki, p521ki, rsaki, rsa2048ki;
private XMLSignatureFactory fac;
+ private DocumentBuilder db;
private KeyPair p256, p384, p521, rsa2048;
private boolean ecSupport = true;
@@ -82,6 +82,7 @@
rsakpg.initialize(2048);
rsa2048 = rsakpg.generateKeyPair();
+ db = XMLUtils.createDocumentBuilder(false);
// create common objects
fac = XMLSignatureFactory.getInstance("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
KeyInfoFactory kifac = fac.getKeyInfoFactory();
@@ -294,7 +295,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
@@ -315,8 +316,8 @@
(ks, doc.getDocumentElement());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/CreatePhaosXMLDSig3Test.java b/src/test/java/javax/xml/crypto/test/dsig/CreatePhaosXMLDSig3Test.java
index 5524503..36ad7ac 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/CreatePhaosXMLDSig3Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/CreatePhaosXMLDSig3Test.java
@@ -21,35 +21,22 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
+
import java.nio.charset.StandardCharsets;
-import java.security.Security;
-import java.util.Collections;
+import java.security.*;
+import java.util.*;
import javax.xml.crypto.URIDereferencer;
-import javax.xml.crypto.dsig.CanonicalizationMethod;
-import javax.xml.crypto.dsig.DigestMethod;
-import javax.xml.crypto.dsig.Reference;
-import javax.xml.crypto.dsig.SignatureMethod;
-import javax.xml.crypto.dsig.SignedInfo;
-import javax.xml.crypto.dsig.Transform;
-import javax.xml.crypto.dsig.XMLSignature;
-import javax.xml.crypto.dsig.XMLSignatureException;
-import javax.xml.crypto.dsig.XMLSignatureFactory;
-import javax.xml.crypto.dsig.dom.DOMSignContext;
-import javax.xml.crypto.dsig.dom.DOMValidateContext;
-import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
-import javax.xml.crypto.dsig.spec.HMACParameterSpec;
-import javax.xml.crypto.dsig.spec.TransformParameterSpec;
-import javax.xml.crypto.test.KeySelectors;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import javax.xml.crypto.dsig.*;
+import javax.xml.crypto.dsig.dom.*;
+import javax.xml.crypto.dsig.spec.*;
import org.apache.xml.security.utils.XMLUtils;
+import org.w3c.dom.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import javax.xml.crypto.test.KeySelectors;
+import javax.xml.parsers.DocumentBuilder;
/**
* Test that recreates Phaos XMLDSig-3 test vectors
@@ -60,6 +47,7 @@
public class CreatePhaosXMLDSig3Test {
private XMLSignatureFactory fac;
+ private DocumentBuilder db;
static {
Security.insertProviderAt
@@ -69,6 +57,7 @@
public CreatePhaosXMLDSig3Test() throws Exception {
fac = XMLSignatureFactory.getInstance
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
+ db = XMLUtils.createDocumentBuilder(false);
}
@org.junit.Test
@@ -112,7 +101,7 @@
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, null);
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
DOMSignContext dsc = new DOMSignContext
(new KeySelectors.SecretKeySelector
("test".getBytes(StandardCharsets.US_ASCII)), doc);
@@ -129,7 +118,7 @@
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
@@ -154,7 +143,7 @@
// create XMLSignature
XMLSignature sig = fac.newXMLSignature(si, null);
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
Element player = doc.createElementNS(null, "player");
player.setAttributeNS(null, "bats", "left");
player.setAttributeNS(null, "id", "10012");
@@ -184,9 +173,9 @@
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/DetachedTest.java b/src/test/java/javax/xml/crypto/test/dsig/DetachedTest.java
index 5da466e..7819309 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/DetachedTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/DetachedTest.java
@@ -28,6 +28,7 @@
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
+import static org.junit.Assert.*;
import java.security.*;
import java.util.*;
@@ -35,10 +36,6 @@
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a simple example of generating and validating a Detached XML
* Signature using the JSR 105 API. The resulting signature will look
@@ -137,7 +134,7 @@
// Create an XMLSignContext and set the
// DSA PrivateKey for signing
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
DOMSignContext signContext = new DOMSignContext(kp.getPrivate(), doc);
signContext.putNamespacePrefix(XMLSignature.XMLNS, "ds");
@@ -160,7 +157,7 @@
boolean coreValidity = signature.validate(vc);
// Check core validation status
- if (!coreValidity) {
+ if (coreValidity == false) {
// check the validation status of each Reference
@SuppressWarnings("unchecked")
Iterator<Reference> i = signature.getSignedInfo().getReferences().iterator();
diff --git a/src/test/java/javax/xml/crypto/test/dsig/DigestMethodTest.java b/src/test/java/javax/xml/crypto/test/dsig/DigestMethodTest.java
index e6e11a9..1c7b205 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/DigestMethodTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/DigestMethodTest.java
@@ -23,15 +23,10 @@
import javax.xml.crypto.dsig.*;
+import static org.junit.Assert.*;
import java.security.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.DigestMethod
*
@@ -40,7 +35,7 @@
private XMLSignatureFactory factory;
- private static final String[] MD_ALGOS = {
+ private static final String MD_ALGOS[] = {
DigestMethod.SHA1
};
@@ -59,7 +54,7 @@
dm.isFeatureSupported(null);
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(dm.isFeatureSupported("not supported"));
+ assertTrue(!dm.isFeatureSupported("not supported"));
}
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/HMACSignatureAlgorithmTest.java b/src/test/java/javax/xml/crypto/test/dsig/HMACSignatureAlgorithmTest.java
index 439863c..8f463d4 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/HMACSignatureAlgorithmTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/HMACSignatureAlgorithmTest.java
@@ -40,16 +40,15 @@
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.test.KeySelectors;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
/**
* Test signing using all available HMAC signing algorithms
*/
@@ -61,6 +60,7 @@
private DigestMethod sha1;
private SignatureMethod hmacSha1, hmacSha224, hmacSha256, hmacSha384, hmacSha512, ripemd160;
private XMLSignatureFactory fac;
+ private DocumentBuilder db;
static {
Security.insertProviderAt
@@ -91,6 +91,7 @@
public HMACSignatureAlgorithmTest() throws Exception {
+ db = XMLUtils.createDocumentBuilder(false);
// create common objects
fac = XMLSignatureFactory.getInstance("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
withoutComments = fac.newCanonicalizationMethod
@@ -163,7 +164,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
@@ -187,8 +188,8 @@
(ks, doc.getDocumentElement());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/IaikCoreFeaturesTest.java b/src/test/java/javax/xml/crypto/test/dsig/IaikCoreFeaturesTest.java
index b67aa48..68d84ca 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/IaikCoreFeaturesTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/IaikCoreFeaturesTest.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
@@ -30,8 +31,6 @@
import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all "coreFeatures"
* testcases from IAIK
@@ -136,4 +135,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/IaikSignatureAlgosTest.java b/src/test/java/javax/xml/crypto/test/dsig/IaikSignatureAlgosTest.java
index a1861de..1c51671 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/IaikSignatureAlgosTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/IaikSignatureAlgosTest.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.File;
import java.nio.charset.StandardCharsets;
@@ -29,10 +30,6 @@
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a testcase to validate all "signatureAlgorithms"
* testcases from IAIK
@@ -97,4 +94,4 @@
assertTrue("Signature failed core validation", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/IaikTransformsTest.java b/src/test/java/javax/xml/crypto/test/dsig/IaikTransformsTest.java
index 11a031a..bb85279 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/IaikTransformsTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/IaikTransformsTest.java
@@ -21,14 +21,13 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.security.Security;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all "transforms"
* testcases from IAIK
@@ -89,4 +88,4 @@
assertTrue("Signature failed core validation", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/InteropC14nTest.java b/src/test/java/javax/xml/crypto/test/dsig/InteropC14nTest.java
index f9105e4..46b04aa 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/InteropC14nTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/InteropC14nTest.java
@@ -21,14 +21,13 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.security.Security;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all "c14n" testcases
* under data/vectors/interop directory
@@ -130,4 +129,4 @@
assertTrue("Signature failed core validation#2", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java b/src/test/java/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java
index da81f3b..afb29ba 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java
@@ -29,7 +29,6 @@
import static org.junit.Assert.assertTrue;
-
/**
* This is a testcase to validate all the W3C xmldsig XMLDSig11 testcases.
*
@@ -210,4 +209,4 @@
boolean coreValidity = validator.validate(file, ks);
assertTrue(file + " failed core validation", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenRefCountTest.java b/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenRefCountTest.java
index cde731e..e5ff3ee 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenRefCountTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenRefCountTest.java
@@ -18,9 +18,9 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.io.FileInputStream;
import java.security.Security;
import javax.xml.crypto.MarshalException;
@@ -31,8 +31,6 @@
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertTrue;
-
/**
* This is a test for a forbidden number of references when secure validation is enabled.
*/
@@ -74,10 +72,11 @@
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.read(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ org.w3c.dom.Document doc = db.parse(f);
return (Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
Constants._TAG_SIGNEDINFO).item(0);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenReferenceTest.java b/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenReferenceTest.java
index 8b18890..c445330 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenReferenceTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenReferenceTest.java
@@ -18,6 +18,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.File;
import java.nio.charset.StandardCharsets;
@@ -27,10 +28,6 @@
import javax.xml.crypto.dsig.dom.DOMValidateContext;
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a test for a forbidden Reference algorithm when secure validation is enabled.
*/
@@ -76,4 +73,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/JSRWrappingAttackTest.java b/src/test/java/javax/xml/crypto/test/dsig/JSRWrappingAttackTest.java
index 716901c..e12aec3 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/JSRWrappingAttackTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/JSRWrappingAttackTest.java
@@ -18,9 +18,9 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.File;
-import java.io.FileInputStream;
import java.security.Security;
import javax.xml.crypto.dsig.XMLSignatureException;
@@ -31,10 +31,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a test for a wrapping attack.
*/
@@ -61,7 +57,7 @@
public void testWrappingAttack() throws Exception {
String file = "manifestSignatureWrapping.xml";
- Document doc = XMLUtils.read(new FileInputStream(new File(dir, file)), false);
+ Document doc = XMLUtils.createDocumentBuilder(false, false).parse(new File(dir, file));
Element sigElement = SignatureValidator.getSignatureElement(doc);
if (sigElement == null) {
throw new Exception("Couldn't find signature Element");
@@ -89,4 +85,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/ManifestTest.java b/src/test/java/javax/xml/crypto/test/dsig/ManifestTest.java
index 5c181b5..2a5fa39 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/ManifestTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/ManifestTest.java
@@ -21,17 +21,11 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.util.*;
import javax.xml.crypto.dsig.*;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.Manifest
*
@@ -76,7 +70,7 @@
break;
}
assertNotNull(man);
- assertArrayEquals(man.getReferences().toArray(), refs.toArray());
+ assertTrue(Arrays.equals(man.getReferences().toArray(), refs.toArray()));
assertEquals(man.getId(), expectedId);
}
@@ -154,7 +148,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(man.isFeatureSupported("not supported"));
+ assertTrue(!man.isFeatureSupported("not supported"));
}
@org.junit.Test
diff --git a/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java b/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java
index 3a12c96..8329023 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java
@@ -44,6 +44,7 @@
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.test.KeySelectors;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.utils.XMLUtils;
import org.junit.BeforeClass;
@@ -51,10 +52,8 @@
import org.w3c.dom.Element;
import org.w3c.dom.Text;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
/**
* Test signing using all available PublicKey signing algorithms
*/
@@ -67,6 +66,7 @@
private SignatureMethod rsaSha1Mgf1, rsaSha224Mgf1, rsaSha256Mgf1, rsaSha384Mgf1, rsaSha512Mgf1;
private SignatureMethod ecdsaSha1, ecdsaSha224, ecdsaSha256, ecdsaSha384, ecdsaSha512, ecdsaRipemd160;
private XMLSignatureFactory fac;
+ private DocumentBuilder db;
private KeyPair rsaKeyPair, ecKeyPair;
private KeyInfo rsaki, ecki;
private boolean ecAlgParamsSupport = true;
@@ -109,6 +109,7 @@
ecAlgParamsSupport = false;
}
+ db = XMLUtils.createDocumentBuilder(false);
// create common objects
fac = XMLSignatureFactory.getInstance("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
withoutComments = fac.newCanonicalizationMethod
@@ -290,7 +291,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
@@ -314,8 +315,8 @@
(ks, doc.getDocumentElement());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java b/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java
index 73051bc..0ab7177 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.File;
import java.nio.charset.StandardCharsets;
@@ -32,11 +33,6 @@
import javax.xml.crypto.test.KeySelectors;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a testcase to validate all "phaos-xmldsig-three"
* testcases from Phaos
@@ -315,4 +311,4 @@
validator.validate(file, new KeySelectors.RawX509KeySelector());
assertTrue("Signature failed core validation", coreValidity);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java b/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java
index 2b8aa9f..866eafb 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.*;
import java.security.MessageDigest;
@@ -35,15 +36,6 @@
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.Reference
*
@@ -138,8 +130,8 @@
// try empty transforms list
ref = fac.newReference(uri, dmSHA1, transforms,
type, id);
- assertArrayEquals(transforms.toArray(),
- ref.getTransforms().toArray());
+ assertTrue(Arrays.equals(transforms.toArray(),
+ ref.getTransforms().toArray()));
} catch(Exception ex) {
fail("Unexpected Exception: " + ex);
}
@@ -178,8 +170,8 @@
try {
// try a transforms list with a Transform object
ref = fac.newReference(uri, dmSHA1, transforms, type, id);
- assertArrayEquals(transforms.toArray(),
- ref.getTransforms().toArray());
+ assertTrue(Arrays.equals(transforms.toArray(),
+ ref.getTransforms().toArray()));
} catch (Exception ex) {
fail("Unexpected Exception: " + ex);
}
@@ -193,7 +185,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(ref.isFeatureSupported("not supported"));
+ assertTrue(!ref.isFeatureSupported("not supported"));
}
@org.junit.Test
@@ -272,7 +264,7 @@
}
byte[] dv = validated_ref.getDigestValue();
byte[] cdv = validated_ref.getCalculatedDigestValue();
- assertArrayEquals(dv, cdv);
+ assertTrue(Arrays.equals(dv, cdv));
boolean valid = validated_ref.validate(validateContext);
assertTrue(valid);
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java b/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java
index e00813e..5e4228e 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java
@@ -30,8 +30,6 @@
import javax.xml.crypto.test.KeySelectors;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
public class SecureXSLTTest {
@@ -82,7 +80,7 @@
File f = new File("doc.xml");
Document doc =
- XMLUtils.read(new FileInputStream(signatureFile), false);
+ XMLUtils.createDocumentBuilder(false).parse(new FileInputStream(signatureFile));
NodeList nl =
doc.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
@@ -102,8 +100,8 @@
} finally {
if (f.exists()) {
f.delete(); // cleanup file. comment out when debugging
- fail("Test FAILED: doc.xml was successfully created");
+ throw new Exception("Test FAILED: doc.xml was successfully created");
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java b/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
index 7afe5cc..90499ce 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
@@ -38,16 +38,15 @@
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.test.KeySelectors;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
/**
* Test signing using all available digest methods
*/
@@ -60,6 +59,7 @@
private SignatureMethod rsaSha1;
private KeyInfo rsaki;
private XMLSignatureFactory fac;
+ private DocumentBuilder db;
private boolean bcInstalled;
static {
@@ -69,6 +69,7 @@
public SignatureDigestMethodTest() throws Exception {
+ db = XMLUtils.createDocumentBuilder(false);
// create common objects
fac = XMLSignatureFactory.getInstance("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
KeyInfoFactory kifac = fac.getKeyInfoFactory();
@@ -182,7 +183,7 @@
SignedInfo si = fac.newSignedInfo(withoutComments, sm,
Collections.singletonList(ref));
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
// create Objects
Element webElem = doc.createElementNS(null, "Web");
Text text = doc.createTextNode("up up and away");
@@ -206,8 +207,8 @@
(ks, doc.getDocumentElement());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- assertEquals(sig, sig2);
+ assertTrue(sig.equals(sig2));
assertTrue(sig2.validate(dvc));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java b/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java
index ede7b5c..480668a 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java
@@ -23,15 +23,10 @@
import javax.xml.crypto.dsig.*;
+import static org.junit.Assert.*;
import java.security.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.SignatureMethod
*
@@ -40,7 +35,7 @@
XMLSignatureFactory factory;
- private static final String[] SIG_ALGOS = {
+ private static final String SIG_ALGOS[] = {
SignatureMethod.DSA_SHA1,
SignatureMethod.RSA_SHA1,
SignatureMethod.HMAC_SHA1
@@ -62,7 +57,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(sm.isFeatureSupported("not supported"));
+ assertTrue(!sm.isFeatureSupported("not supported"));
}
}
@@ -104,3 +99,4 @@
}
}
+
diff --git a/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java b/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java
index b775632..eb8933b 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java
@@ -21,17 +21,11 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.util.*;
import javax.xml.crypto.dsig.*;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.SignatureProperties
*
@@ -98,7 +92,7 @@
unmodifiable.add(prop);
fail("Should return an unmodifiable List object");
} catch (UnsupportedOperationException uoe) {}
- assertArrayEquals(unmodifiable.toArray(), list.toArray());
+ assertTrue(Arrays.equals(unmodifiable.toArray(), list.toArray()));
assertNotNull(props);
assertEquals(props.getId(), id);
}
@@ -113,7 +107,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(props.isFeatureSupported("not supported"));
+ assertTrue(!props.isFeatureSupported("not supported"));
}
@SuppressWarnings({
diff --git a/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java b/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java
index 9318d1a..471c664 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java
@@ -21,18 +21,12 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.util.*;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.*;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.SignatureProperty
*
@@ -100,7 +94,7 @@
unmodifiable.add(new TestUtils.MyOwnXMLStructure());
fail("Should return an unmodifiable List object");
} catch (UnsupportedOperationException uoe) {}
- assertArrayEquals(unmodifiable.toArray(), list.toArray());
+ assertTrue(Arrays.equals(unmodifiable.toArray(), list.toArray()));
assertEquals(prop.getTarget(), target);
assertEquals(prop.getId(), id);
assertNotNull(prop);
@@ -117,7 +111,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(prop.isFeatureSupported("not supported"));
+ assertTrue(!prop.isFeatureSupported("not supported"));
}
@SuppressWarnings({
diff --git a/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java b/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java
index 205ed11..b401e13 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java
@@ -52,7 +52,7 @@
public DOMValidateContext getValidateContext(String fn, KeySelector ks)
throws Exception {
- Document doc = XMLUtils.read(new FileInputStream(new File(dir, fn)), false);
+ Document doc = XMLUtils.createDocumentBuilder(false, false).parse(new File(dir, fn));
Element sigElement = getSignatureElement(doc);
if (sigElement == null) {
throw new Exception("Couldn't find signature Element");
@@ -81,7 +81,7 @@
boolean coreValidity = signature.validate(vc);
// Check core validation status
- if (!coreValidity) {
+ if (coreValidity == false) {
// check the validation status of each Reference
@SuppressWarnings("unchecked")
Iterator<Reference> i = signature.getSignedInfo().getReferences().iterator();
diff --git a/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java b/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java
index 80ef9fa..bb127ce 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java
@@ -21,19 +21,13 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.security.Security;
import java.util.*;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.SignedInfo
*
@@ -123,8 +117,8 @@
sm.getAlgorithm());
assertEquals(si.getSignatureMethod().getParameterSpec(),
sm.getParameterSpec());
- assertArrayEquals(si.getReferences().toArray(),
- references.toArray());
+ assertTrue(Arrays.equals(si.getReferences().toArray(),
+ references.toArray()));
assertNull(si.getId());
// test XMLSignatureFactory.newSignedInfo(
diff --git a/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java b/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
index a1252a0..c4b5d3a 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
@@ -23,7 +23,6 @@
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -63,6 +62,7 @@
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
@@ -114,9 +114,9 @@
public static PublicKey getPublicKey(String algo)
throws InvalidKeySpecException, NoSuchAlgorithmException {
- if ("DSA".equalsIgnoreCase(algo)) {
+ if (algo.equalsIgnoreCase("DSA")) {
return getPublicKey("DSA", 1024);
- } else if ("RSA".equalsIgnoreCase(algo)) {
+ } else if (algo.equalsIgnoreCase("RSA")) {
return getPublicKey("RSA", 512);
} else {
throw new RuntimeException("Unsupported key algorithm " + algo);
@@ -127,7 +127,7 @@
throws InvalidKeySpecException, NoSuchAlgorithmException {
KeyFactory kf = KeyFactory.getInstance(algo);
KeySpec kspec;
- if ("DSA".equalsIgnoreCase(algo)) {
+ if (algo.equalsIgnoreCase("DSA")) {
if (keysize == 1024) {
kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y),
new BigInteger(DSA_P),
@@ -141,7 +141,7 @@
} else {
throw new RuntimeException("Unsupported keysize:" + keysize);
}
- } else if ("RSA".equalsIgnoreCase(algo)) {
+ } else if (algo.equalsIgnoreCase("RSA")) {
if (keysize == 512) {
kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD),
new BigInteger(RSA_PUB));
@@ -164,9 +164,9 @@
public static PrivateKey getPrivateKey(String algo)
throws InvalidKeySpecException, NoSuchAlgorithmException {
- if ("DSA".equalsIgnoreCase(algo)) {
+ if (algo.equalsIgnoreCase("DSA")) {
return getPrivateKey("DSA", 1024);
- } else if ("RSA".equalsIgnoreCase(algo)) {
+ } else if (algo.equalsIgnoreCase("RSA")) {
return getPrivateKey("RSA", 512);
} else {
throw new RuntimeException("Unsupported key algorithm " + algo);
@@ -177,7 +177,7 @@
throws InvalidKeySpecException, NoSuchAlgorithmException {
KeyFactory kf = KeyFactory.getInstance(algo);
KeySpec kspec;
- if ("DSA".equalsIgnoreCase(algo)) {
+ if (algo.equalsIgnoreCase("DSA")) {
if (keysize == 1024) {
kspec = new DSAPrivateKeySpec
(new BigInteger(DSA_X), new BigInteger(DSA_P),
@@ -189,7 +189,7 @@
} else {
throw new RuntimeException("Unsupported keysize:" + keysize);
}
- } else if ("RSA".equalsIgnoreCase(algo)) {
+ } else if (algo.equalsIgnoreCase("RSA")) {
if (keysize == 512) {
kspec = new RSAPrivateKeySpec
(new BigInteger(RSA_MOD), new BigInteger(RSA_PRIV));
@@ -214,7 +214,8 @@
public static Document newDocument() {
try {
- return XMLUtils.newDocument();
+ DocumentBuilder docBuilder = XMLUtils.createDocumentBuilder(false);
+ return docBuilder.newDocument();
} catch (Exception ex) {
return null;
}
@@ -232,8 +233,9 @@
File input,
String tag)
throws Exception {
- if ("dom".equalsIgnoreCase(type)) {
- Document doc = XMLUtils.read(new FileInputStream(input), false);
+ if (type.equalsIgnoreCase("dom")) {
+ DocumentBuilder docBuilder = XMLUtils.createDocumentBuilder(false, false);
+ Document doc = docBuilder.parse(input);
if (tag == null) {
return new DOMValidateContext
(TestUtils.getPublicKey("RSA", 512),
@@ -288,7 +290,7 @@
}
public byte[] getCalculatedDigestValue() {
- return new byte[0];
+ return null;
}
public DigestMethod getDigestMethod() { return DIG_METHOD; }
@@ -341,7 +343,7 @@
private byte[] data;
public OctetStreamURIDereferencer(byte[] in) {
- data = in.clone();
+ data = (byte[]) in.clone();
}
public Data dereference(URIReference ref, XMLCryptoContext ctxt) {
diff --git a/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java b/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java
index 1ffe0b6..f1aaabf 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java
@@ -30,15 +30,10 @@
import javax.xml.crypto.dsig.spec.XPathFilter2ParameterSpec;
import javax.xml.crypto.dsig.spec.XSLTTransformParameterSpec;
+import static org.junit.Assert.*;
import java.security.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.Transform
*
@@ -47,7 +42,7 @@
XMLSignatureFactory factory;
- private static final String[] TRANSFORM_ALGOS = {
+ private static final String TRANSFORM_ALGOS[] = {
Transform.BASE64,
Transform.ENVELOPED,
Transform.XPATH,
@@ -87,7 +82,7 @@
": Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(tm.isFeatureSupported("not supported"));
+ assertTrue(!tm.isFeatureSupported("not supported"));
}
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/ValidateSignatureTest.java b/src/test/java/javax/xml/crypto/test/dsig/ValidateSignatureTest.java
index a93b0eb..af2d463 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/ValidateSignatureTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/ValidateSignatureTest.java
@@ -18,6 +18,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.File;
import java.nio.charset.StandardCharsets;
@@ -36,11 +37,6 @@
import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.dsig.dom.DOMValidateContext;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a testcase that validates various signatures
*
@@ -168,4 +164,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/X509KeySelector.java b/src/test/java/javax/xml/crypto/test/dsig/X509KeySelector.java
index 2af9347..40a9c14 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/X509KeySelector.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/X509KeySelector.java
@@ -230,7 +230,7 @@
SignatureMethod sm) throws KeyStoreException {
// skip non-signer certs
boolean[] keyUsage = xcert.getKeyUsage();
- if (keyUsage != null && !keyUsage[0]) {
+ if (keyUsage != null && keyUsage[0] == false) {
return null;
}
String alias = ks.getCertificateAlias(xcert);
@@ -273,8 +273,15 @@
*/
//@@@FIXME: this should also work for key types other than DSA/RSA
private boolean algEquals(String algURI, String algName) {
- return ("DSA".equalsIgnoreCase(algName) && algURI.equalsIgnoreCase(SignatureMethod.DSA_SHA1)
- || "RSA".equalsIgnoreCase(algName) && algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1));
+ if (algName.equalsIgnoreCase("DSA") &&
+ algURI.equalsIgnoreCase(SignatureMethod.DSA_SHA1)) {
+ return true;
+ } else if (algName.equalsIgnoreCase("RSA") &&
+ algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1)) {
+ return true;
+ } else {
+ return false;
+ }
}
/**
diff --git a/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java b/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java
index 1378dff..e1cbac2 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/XMLObjectTest.java
@@ -21,18 +21,12 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.util.*;
import javax.xml.crypto.XMLStructure;
import javax.xml.crypto.dsig.*;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.XMLObject
*
@@ -79,7 +73,7 @@
obj = factory.newXMLObject(list, id, mimeType, encoding);
assertNotNull(obj);
assertNotNull(obj.getContent());
- assertArrayEquals(obj.getContent().toArray(), list.toArray());
+ assertTrue(Arrays.equals(obj.getContent().toArray(), list.toArray()));
assertEquals(obj.getId(), id);
assertEquals(obj.getMimeType(), mimeType);
assertEquals(obj.getEncoding(), encoding);
@@ -90,7 +84,7 @@
unmodifiable.add(new TestUtils.MyOwnXMLStructure());
fail("Should return an unmodifiable List object");
} catch (UnsupportedOperationException uoe) {}
- assertArrayEquals(unmodifiable.toArray(), list.toArray());
+ assertTrue(Arrays.equals(unmodifiable.toArray(), list.toArray()));
}
@org.junit.Test
@@ -103,7 +97,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(obj.isFeatureSupported("not supported"));
+ assertTrue(!obj.isFeatureSupported("not supported"));
}
@SuppressWarnings({
diff --git a/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java b/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java
index c48ce42..102c54f 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/XMLSignContextTest.java
@@ -26,17 +26,13 @@
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.URIDereferencer;
+import static org.junit.Assert.*;
import java.security.*;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.XMLSignContext
*
@@ -112,4 +108,4 @@
defContext.setKeySelector(ks);
assertEquals(defContext.getKeySelector(), ks);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java b/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java
index a62b9a9..9c1cdc9 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureFactoryTest.java
@@ -21,9 +21,9 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.File;
-import java.io.FileInputStream;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
@@ -32,17 +32,12 @@
import javax.xml.crypto.*;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.dom.DOMValidateContext;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.XMLSignatureFactory
*
@@ -107,7 +102,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(factory.isFeatureSupported("not supported"));
+ assertTrue(!factory.isFeatureSupported("not supported"));
}
@org.junit.Test
@@ -158,12 +153,13 @@
" for wrong inputs");
}
+ DocumentBuilder docBuilder = XMLUtils.createDocumentBuilder(false, false);
String fs = System.getProperty("file.separator");
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
File dir = new File(base + fs +
"src/test/resources" + fs + "ie" + fs + "baltimore" + fs + "merlin-examples",
"merlin-xmldsig-twenty-three");
- Document doc = XMLUtils.read(new FileInputStream(new File(dir, "signature.xml")), false);
+ Document doc = docBuilder.parse(new File(dir, "signature.xml"));
NodeList nl = doc.getElementsByTagName("KeyInfo");
try {
stuff = factory.unmarshalXMLSignature
@@ -178,6 +174,7 @@
assertNotNull(stuff);
} catch (MarshalException ex) {
fail("Unmarshal failed: " + ex.getMessage());
+ ex.printStackTrace();
}
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java b/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
index e21b1e4..5359b12 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig;
+import static org.junit.Assert.*;
import java.io.*;
import java.util.*;
@@ -38,14 +39,6 @@
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.*;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.XMLSignature
*
@@ -109,10 +102,13 @@
// for generating XMLSignature objects
for (int i = 0; i < 2; i++) {
try {
- if (i == 0) {
+ switch (i) {
+ case 0:
sig = fac.newXMLSignature(null, defKi);
- } else if (i == 1) {
+ break;
+ case 1:
sig = fac.newXMLSignature(null, defKi, objs, id, sigValueId);
+ break;
}
fail("Should throw a NPE for null references");
} catch (NullPointerException npe) {
@@ -135,7 +131,7 @@
sig = fac.newXMLSignature(defSi, defKi, objs, id, sigValueId);
assertEquals(sig.getId(), id);
assertEquals(sig.getKeyInfo(), defKi);
- assertArrayEquals(sig.getObjects().toArray(), objs.toArray());
+ assertTrue(Arrays.equals(sig.getObjects().toArray(), objs.toArray()));
assertNull(sig.getSignatureValue().getValue());
assertEquals(sig.getSignatureValue().getId(), sigValueId);
assertEquals(sig.getSignedInfo(), defSi);
@@ -159,7 +155,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(sig.isFeatureSupported("not supported"));
+ assertTrue(!sig.isFeatureSupported("not supported"));
}
@org.junit.Test
@@ -187,7 +183,7 @@
validateContext = new DOMValidateContext
(VALIDATE_KEYS[i], doc.getDocumentElement());
validateContext.setURIDereferencer(ud);
- if (!sig.validate(validateContext)) {
+ if (sig.validate(validateContext) == false) {
status = false;
TestUtils.dumpDocument(doc, "signatureTest_out"+i+".xml");
}
@@ -293,11 +289,11 @@
(VALIDATE_KEYS[1], doc.getDocumentElement());
XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
- if (!sig.equals(sig2)) {
+ if (sig.equals(sig2) == false) {
throw new Exception
("Unmarshalled signature is not equal to generated signature");
}
- if (!sig2.validate(dvc)) {
+ if (sig2.validate(dvc) == false) {
throw new Exception("Validation of generated signature failed");
}
}
@@ -310,7 +306,7 @@
File f = new File(base + "/src/test/resources/javax/xml/crypto/dsig/" +
"signature-enveloping-rsa-template.xml");
- Document doc = XMLUtils.read(new FileInputStream(f), false);
+ Document doc = XMLUtils.createDocumentBuilder(false).parse(new FileInputStream(f));
// Find Signature element
NodeList nl =
@@ -337,7 +333,7 @@
// check that Object element retained namespace definitions
Element objElem = (Element)parent.getFirstChild().getLastChild();
Attr a = objElem.getAttributeNode("xmlns:test");
- if (!"http://www.example.org/ns".equals(a.getValue())) {
+ if (!a.getValue().equals("http://www.example.org/ns")) {
throw new Exception("Object namespace definition not retained");
}
}
@@ -385,7 +381,7 @@
SignatureMethod sm = fac.newSignatureMethod(DSA_SHA256, null);
SignedInfo si = createSignedInfo(sm);
KeyInfo ki = kifac.newKeyInfo(Collections.singletonList
- (kifac.newKeyValue(TestUtils.getPublicKey("DSA", 2048))));
+ (kifac.newKeyValue((PublicKey)TestUtils.getPublicKey("DSA", 2048))));
XMLSignature sig = fac.newXMLSignature(si, ki, objs, id, sigValueId);
Document doc = TestUtils.newDocument();
XMLSignContext signContext =
diff --git a/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java b/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java
index 95631c6..873f60d 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/XMLValidateContextTest.java
@@ -25,15 +25,11 @@
import javax.xml.crypto.dsig.dom.DOMValidateContext;
import javax.xml.crypto.dsig.*;
+import static org.junit.Assert.*;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.XMLValidateContext
*
@@ -107,4 +103,4 @@
defContext.setURIDereferencer(null);
assertNull(defContext.getURIDereferencer());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/dom/DOMValidateContextTest.java b/src/test/java/javax/xml/crypto/test/dsig/dom/DOMValidateContextTest.java
index 263b5b9..bf6d56a 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/dom/DOMValidateContextTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/dom/DOMValidateContextTest.java
@@ -21,18 +21,13 @@
*/
package javax.xml.crypto.test.dsig.dom;
+import static org.junit.Assert.*;
import java.io.*;
import javax.xml.crypto.dsig.dom.DOMValidateContext;
import javax.xml.crypto.test.dsig.TestUtils;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.dom.DOMValidateContext
*
@@ -97,4 +92,4 @@
assertNotNull(domVC.getNode());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoFactoryTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoFactoryTest.java
index c6a524b..0eed51b 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoFactoryTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoFactoryTest.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig.keyinfo;
+import static org.junit.Assert.*;
import java.math.BigInteger;
import java.util.*;
@@ -29,13 +30,6 @@
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.*;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.keyinfo.KeyInfoFactory
*
@@ -75,7 +69,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(factory.isFeatureSupported("not supported"));
+ assertTrue(!factory.isFeatureSupported("not supported"));
}
@org.junit.Test
@@ -148,7 +142,7 @@
// test newPGPData(byte[])
PGPData pd = factory.newPGPData(valid_id);
- assertArrayEquals(valid_id, pd.getKeyId());
+ assertTrue(Arrays.equals(valid_id, pd.getKeyId()));
try {
pd = factory.newPGPData(invalid_id);
fail("Should throw IAE for invalid key id values");
@@ -156,8 +150,8 @@
// test newPGPData(byte[], byte[], List)
pd = factory.newPGPData(valid_id, valid_packet, null);
- assertArrayEquals(valid_id, pd.getKeyId());
- assertArrayEquals(valid_packet, pd.getKeyPacket());
+ assertTrue(Arrays.equals(valid_id, pd.getKeyId()));
+ assertTrue(Arrays.equals(valid_packet, pd.getKeyPacket()));
try {
pd = factory.newPGPData(invalid_id, valid_packet, null);
fail("Should throw IAE for invalid key id values");
@@ -173,7 +167,7 @@
// test newPGPData(byte[], List)
pd = factory.newPGPData(valid_packet, null);
- assertArrayEquals(valid_packet, pd.getKeyPacket());
+ assertTrue(Arrays.equals(valid_packet, pd.getKeyPacket()));
try {
pd = factory.newPGPData(invalid_packet, null);
fail("Should throw IAE for invalid key packet values");
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
index 587afc1..f1b0a2a 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyInfoTest.java
@@ -21,6 +21,7 @@
*/
package javax.xml.crypto.test.dsig.keyinfo;
+import static org.junit.Assert.*;
import java.security.Key;
import java.util.Collections;
@@ -37,12 +38,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.keyinfo.KeyInfo
*
@@ -108,7 +103,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(ki.isFeatureSupported("not supported"));
+ assertTrue(!ki.isFeatureSupported("not supported"));
}
@org.junit.Test
@@ -120,7 +115,7 @@
fail("Should raise a NullPointerException");
} catch (NullPointerException npe) {}
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Element elem = doc.createElementNS("http://acme.org", "parent");
doc.appendChild(elem);
DOMStructure parent = new DOMStructure(elem);
@@ -131,16 +126,16 @@
}
Element kiElem = DOMUtils.getFirstChildElement(elem);
- if (!"KeyInfo".equals(kiElem.getLocalName())) {
+ if (!kiElem.getLocalName().equals("KeyInfo")) {
fail("Should be KeyInfo element: " + kiElem.getLocalName());
}
Element knElem = DOMUtils.getFirstChildElement(kiElem);
- if (!"KeyName".equals(knElem.getLocalName())) {
+ if (!knElem.getLocalName().equals("KeyName")) {
fail("Should be KeyName element: " + knElem.getLocalName());
}
// check if key info is inserted before nextSibling
- doc = XMLUtils.newDocument();
+ doc = XMLUtils.createDocumentBuilder(false).newDocument();
elem = doc.createElementNS("http://acme.org", "parent");
doc.appendChild(elem);
Element nextSib = doc.createElementNS("http://acme.org", "nextSib");
@@ -156,7 +151,7 @@
@Override
public byte[] getEncoded() {
- return new byte[0];
+ return null;
}
@Override
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyNameTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyNameTest.java
index e9dcd83..64d5e57 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyNameTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyNameTest.java
@@ -21,15 +21,10 @@
*/
package javax.xml.crypto.test.dsig.keyinfo;
+import static org.junit.Assert.*;
import javax.xml.crypto.dsig.keyinfo.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.keyinfo.KeyName
*
@@ -68,6 +63,6 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(kn.isFeatureSupported("not supported"));
+ assertTrue(!kn.isFeatureSupported("not supported"));
}
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java
index 502d0ca..ffa5553 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java
@@ -21,16 +21,11 @@
*/
package javax.xml.crypto.test.dsig.keyinfo;
+import static org.junit.Assert.*;
import java.security.*;
import javax.xml.crypto.dsig.keyinfo.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.keyinfo.KeyValue
*
@@ -86,7 +81,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(kv.isFeatureSupported("not supported"));
+ assertTrue(!kv.isFeatureSupported("not supported"));
}
private PublicKey genPublicKey(String algo, int keysize) throws Exception {
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java
index 91d4fbc..51e97c9 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/PGPDataTest.java
@@ -21,18 +21,14 @@
*/
package javax.xml.crypto.test.dsig.keyinfo;
+import static org.junit.Assert.*;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import javax.xml.crypto.*;
import javax.xml.crypto.dsig.keyinfo.*;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.keyinfo.PGPData
*
@@ -109,27 +105,30 @@
public void testConstructor() {
// test newPGPKeyData(byte[])
PGPData pd = fac.newPGPData(values[0]);
- assertArrayEquals(values[0], pd.getKeyId());
+ assertTrue(Arrays.equals(values[0], pd.getKeyId()));
// test newPGPData(byte[], byte[], List)
pd = fac.newPGPData(values[0], values[1], null);
- assertArrayEquals(values[0], pd.getKeyId());
- assertArrayEquals(values[1], pd.getKeyPacket());
+ assertTrue(Arrays.equals(values[0], pd.getKeyId()));
+ assertTrue(Arrays.equals(values[1], pd.getKeyPacket()));
// test newPGPData(byte[], List)
pd = fac.newPGPData(values[1], null);
- assertArrayEquals(values[1], pd.getKeyPacket());
+ assertTrue(Arrays.equals(values[1], pd.getKeyPacket()));
}
@org.junit.Test
public void testisFeatureSupported() {
PGPData pd = null;
for (int i = 0; i < 3; i++) {
- if (i == 0) {
+ switch (i) {
+ case 0:
pd = fac.newPGPData(values[0]);
- } else if (i == 1) {
+ break;
+ case 1:
pd = fac.newPGPData(values[0], values[1], null);
- } else {
+ break;
+ case 2:
pd = fac.newPGPData(values[1], null);
}
try {
@@ -137,7 +136,7 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(pd.isFeatureSupported("not supported"));
+ assertTrue(!pd.isFeatureSupported("not supported"));
}
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/RetrievalMethodTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/RetrievalMethodTest.java
index 201d8e2..98d325a 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/RetrievalMethodTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/RetrievalMethodTest.java
@@ -21,16 +21,10 @@
*/
package javax.xml.crypto.test.dsig.keyinfo;
+import static org.junit.Assert.*;
import javax.xml.crypto.dsig.keyinfo.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.keyinfo.RetrievalMethod
*
@@ -92,17 +86,20 @@
String type = "http://www.w3.org/2000/09/xmldsig#X509Data";
RetrievalMethod rm = null;
for (int i = 0; i < 2; i++) {
- if (i == 0) {
+ switch (i) {
+ case 0:
rm = fac.newRetrievalMethod(uri);
- } else if (i == 1) {
+ break;
+ case 1:
rm = fac.newRetrievalMethod(uri, type, null);
+ break;
}
try {
rm.isFeatureSupported(null);
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(rm.isFeatureSupported("not supported"));
+ assertTrue(!rm.isFeatureSupported("not supported"));
}
}
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/X509DataTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/X509DataTest.java
index 38d64aa..5875e21 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/X509DataTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/X509DataTest.java
@@ -24,16 +24,12 @@
import java.util.*;
import java.security.cert.X509Certificate;
+import static org.junit.Assert.*;
import java.security.cert.X509CRL;
import javax.xml.crypto.*;
import javax.xml.crypto.dsig.keyinfo.*;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.keyinfo.X509Data
*
@@ -82,6 +78,6 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(x509.isFeatureSupported("not supported"));
+ assertTrue(!x509.isFeatureSupported("not supported"));
}
}
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/X509IssuerSerialTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/X509IssuerSerialTest.java
index de42ad4..68b10a6 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/X509IssuerSerialTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/X509IssuerSerialTest.java
@@ -21,16 +21,11 @@
*/
package javax.xml.crypto.test.dsig.keyinfo;
+import static org.junit.Assert.*;
import java.math.BigInteger;
import javax.xml.crypto.dsig.keyinfo.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
/**
* Unit test for javax.xml.crypto.dsig.keyinfo.X509IssuerSerial
*
@@ -92,6 +87,6 @@
fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
- assertFalse(x509is.isFeatureSupported("not supported"));
+ assertTrue(!x509is.isFeatureSupported("not supported"));
}
}
diff --git a/src/test/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImplTest.java b/src/test/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImplTest.java
index 01a1662..885bdff 100644
--- a/src/test/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImplTest.java
+++ b/src/test/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImplTest.java
@@ -41,8 +41,7 @@
import static org.apache.xml.security.stax.securityToken.SecurityTokenConstants.KeyIdentifier_KeyName;
import static org.apache.xml.security.test.stax.utils.KeyLoader.loadPublicKey;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
public class SecurityTokenFactoryImplTest {
private KeyInfoType keyInfoType;
@@ -139,4 +138,4 @@
factory.getSecurityToken(keyInfoType, keyUsage, xmlSecurityProperties, inboundSecurityContext);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/CreateExclC14nInteropValues.java b/src/test/java/org/apache/xml/security/test/dom/CreateExclC14nInteropValues.java
index ca46809..9909c35 100644
--- a/src/test/java/org/apache/xml/security/test/dom/CreateExclC14nInteropValues.java
+++ b/src/test/java/org/apache/xml/security/test/dom/CreateExclC14nInteropValues.java
@@ -25,6 +25,8 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.signature.ObjectContainer;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.transforms.Transforms;
@@ -46,11 +48,12 @@
* @param unused
* @throws Exception
*/
- public static void main(String[] unused) throws Exception {
+ public static void main(String unused[]) throws Exception {
org.apache.xml.security.Init.init();
- Document doc = XMLUtils.newDocument();
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
String directory = "data/org/apache/xml/security/c14n/outExcl/";
File signatureFile = new File(directory + "apacheSignature.xml");
XMLSignature xmlSignature = new XMLSignature(doc,
@@ -197,7 +200,7 @@
+ "\n" + "</included>";
Document importDoc = null;
try (InputStream is = new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8))) {
- importDoc = XMLUtils.read(is, false);
+ importDoc = db.parse(is);
}
obj.getElement().appendChild(doc.createTextNode("\n"));
@@ -232,7 +235,7 @@
+ "\n" + "</included>";
Document importDoc = null;
try (InputStream is = new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8))) {
- importDoc = XMLUtils.read(is, false);
+ importDoc = db.parse(is);
}
obj.getElement().appendChild(doc.createTextNode("\n"));
@@ -267,7 +270,7 @@
+ "\n" + "</included>";
Document importDoc = null;
try (InputStream is = new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8))) {
- importDoc = XMLUtils.read(is, false);
+ importDoc = db.parse(is);
}
obj.getElement().appendChild(doc.createTextNode("\n"));
@@ -303,7 +306,7 @@
+ "\n" + "</included>";
Document importDoc = null;
try (InputStream is = new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8))) {
- importDoc = XMLUtils.read(is, false);
+ importDoc = db.parse(is);
}
obj.getElement().appendChild(doc.createTextNode("\n"));
@@ -340,7 +343,7 @@
+ "</included>" + "\n" + "</included>";
Document importDoc = null;
try (InputStream is = new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8))) {
- importDoc = XMLUtils.read(is, false);
+ importDoc = db.parse(is);
}
obj.getElement().appendChild(doc.createTextNode("\n"));
@@ -377,7 +380,7 @@
+ "</included>";
Document importDoc = null;
try (InputStream is = new ByteArrayInputStream(xmlStr.getBytes(StandardCharsets.UTF_8))) {
- importDoc = XMLUtils.read(is, false);
+ importDoc = db.parse(is);
}
obj.getElement().appendChild(doc.createTextNode("\n"));
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/DigestAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/DigestAlgorithmTest.java
index ac61b00..eeeb4e1 100644
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/DigestAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/algorithms/DigestAlgorithmTest.java
@@ -18,22 +18,18 @@
*/
package org.apache.xml.security.test.dom.algorithms;
+import static org.junit.Assert.*;
import java.lang.reflect.Constructor;
import java.security.MessageDigest;
import java.security.Provider;
import java.security.Security;
+import java.util.Arrays;
import org.apache.xml.security.algorithms.MessageDigestAlgorithm;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-
/**
* A test to make sure that the various digest algorithms are working
*/
@@ -73,7 +69,7 @@
@org.junit.Test
public void testSHA1() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);
@@ -86,12 +82,12 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testSHA224() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA224);
@@ -104,12 +100,12 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA-224");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testSHA256() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA256);
@@ -122,12 +118,12 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testSHA384() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA384);
@@ -140,12 +136,12 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA-384");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testSHA512() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA512);
@@ -158,12 +154,12 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA-512");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testMD5() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5);
@@ -176,13 +172,13 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testRIPEMD160() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_RIPEMD160);
@@ -195,13 +191,13 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("RIPEMD160");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testWhirlpool() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_WHIRLPOOL);
@@ -214,13 +210,13 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("WHIRLPOOL");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testSHA3_224() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_224);
@@ -233,13 +229,13 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA3-224");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testSHA3_256() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_256);
@@ -252,13 +248,13 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA3-256");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testSHA3_384() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_384);
@@ -271,13 +267,13 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA3-384");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
@org.junit.Test
public void testSHA3_512() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm =
MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA3_512);
@@ -290,7 +286,7 @@
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA3-512");
byte[] digest2 = md.digest("test-string".getBytes());
- assertArrayEquals(digest, digest2);
+ assertTrue(Arrays.equals(digest, digest2));
}
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/HMACSignatureAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/HMACSignatureAlgorithmTest.java
index c69e5af..59c3c9d 100644
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/HMACSignatureAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/algorithms/HMACSignatureAlgorithmTest.java
@@ -30,6 +30,7 @@
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -38,18 +39,16 @@
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* A test to make sure that the various Signature HMAC algorithms are working
*/
-public class HMACSignatureAlgorithmTest {
+public class HMACSignatureAlgorithmTest extends Assert {
static {
org.apache.xml.security.Init.init();
@@ -90,7 +89,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -110,7 +110,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -130,7 +131,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -150,7 +152,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -170,7 +173,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -190,7 +194,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -212,7 +217,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -248,7 +254,7 @@
(NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
for (int i = 0; i < elementsToSign.getLength(); i++) {
Element elementToSign = (Element)elementsToSign.item(i);
- assertNotNull(elementToSign);
+ Assert.assertNotNull(elementToSign);
String id = UUID.randomUUID().toString();
elementToSign.setAttributeNS(null, "Id", id);
elementToSign.setIdAttributeNS(null, "Id", true);
@@ -265,7 +271,7 @@
String expression = "//ds:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
+ Assert.assertNotNull(sigElement);
return sig;
}
@@ -291,19 +297,19 @@
String expression = "//dsig:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
+ Assert.assertNotNull(sigElement);
for (String name : localNames) {
expression = "//*[local-name()='" + name + "']";
Element signedElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(signedElement);
+ Assert.assertNotNull(signedElement);
signedElement.setIdAttributeNS(null, "Id", true);
}
XMLSignature signature = new XMLSignature(sigElement, "", secureValidation);
- assertTrue(signature.checkSignatureValue(key));
+ Assert.assertTrue(signature.checkSignatureValue(key));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/JCEMapperTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/JCEMapperTest.java
deleted file mode 100644
index 21c62f2..0000000
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/JCEMapperTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.xml.security.test.dom.algorithms;
-
-import org.apache.xml.security.algorithms.JCEMapper;
-import org.apache.xml.security.algorithms.MessageDigestAlgorithm;
-
-import static org.junit.Assert.assertEquals;
-
-public class JCEMapperTest {
-
- static {
- org.apache.xml.security.Init.init();
- }
-
- @org.junit.Test
- public void testSHA1() throws Exception {
- assertEquals("MessageDigest", JCEMapper.getAlgorithmClassFromURI(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1));
- assertEquals("SHA-1", JCEMapper.translateURItoJCEID(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1));
- }
-
-
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/KeyWrapEncryptionAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/KeyWrapEncryptionAlgorithmTest.java
index 2c53002..ebd4096 100644
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/KeyWrapEncryptionAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/algorithms/KeyWrapEncryptionAlgorithmTest.java
@@ -30,6 +30,7 @@
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -41,19 +42,16 @@
import org.apache.xml.security.stax.ext.XMLSecurityConstants;
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* A test to make sure that the various KeyWrap Encryption algorithms are working
*/
-public class KeyWrapEncryptionAlgorithmTest {
+public class KeyWrapEncryptionAlgorithmTest extends Assert {
private static KeyPair rsaKeyPair;
private static boolean bcInstalled;
@@ -97,7 +95,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -121,14 +120,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -137,7 +136,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -161,14 +161,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -177,7 +177,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -201,14 +202,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -217,7 +218,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -239,14 +241,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -255,7 +257,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -275,14 +278,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, rsaKeyPair.getPrivate());
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -291,7 +294,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -311,14 +315,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, rsaKeyPair.getPrivate());
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -327,7 +331,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -347,14 +352,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, rsaKeyPair.getPrivate());
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -365,7 +370,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -389,14 +395,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -407,7 +413,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -431,14 +438,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -449,7 +456,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -473,14 +481,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -491,7 +499,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("SEED");
@@ -515,14 +524,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
private void encrypt(
@@ -551,7 +560,7 @@
String expression = "//*[local-name()='" + localName + "']";
Element elementToEncrypt =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(elementToEncrypt);
+ Assert.assertNotNull(elementToEncrypt);
document = cipher.doFinal(document, elementToEncrypt, false);
}
@@ -560,7 +569,7 @@
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertTrue(nodeList.getLength() > 0);
+ Assert.assertTrue(nodeList.getLength() > 0);
}
private Document decrypt(
@@ -592,4 +601,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/PKSignatureAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/PKSignatureAlgorithmTest.java
index 98db30e..cf92e8e 100644
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/PKSignatureAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/algorithms/PKSignatureAlgorithmTest.java
@@ -29,6 +29,7 @@
import java.util.List;
import java.util.UUID;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -37,18 +38,16 @@
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* A test to make sure that the various Public Key Signature algorithms are working
*/
-public class PKSignatureAlgorithmTest {
+public class PKSignatureAlgorithmTest extends Assert {
private static KeyPair rsaKeyPair, ecKeyPair;
private static boolean bcInstalled;
@@ -96,7 +95,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -112,7 +112,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -128,7 +129,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -144,7 +146,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -160,7 +163,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -176,7 +180,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -194,7 +199,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -212,7 +218,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -230,7 +237,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -248,7 +256,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -266,7 +275,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -284,7 +294,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -302,7 +313,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -320,7 +332,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -338,7 +351,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -356,7 +370,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -372,7 +387,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -388,7 +404,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -404,7 +421,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -420,7 +438,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -436,7 +455,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -454,7 +474,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
List<String> localNames = new ArrayList<>();
localNames.add("PaymentInfo");
@@ -486,7 +507,7 @@
(NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
for (int i = 0; i < elementsToSign.getLength(); i++) {
Element elementToSign = (Element)elementsToSign.item(i);
- assertNotNull(elementToSign);
+ Assert.assertNotNull(elementToSign);
String id = UUID.randomUUID().toString();
elementToSign.setAttributeNS(null, "Id", id);
elementToSign.setIdAttributeNS(null, "Id", true);
@@ -503,7 +524,7 @@
String expression = "//ds:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
+ Assert.assertNotNull(sigElement);
return sig;
}
@@ -529,19 +550,19 @@
String expression = "//dsig:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
+ Assert.assertNotNull(sigElement);
for (String name : localNames) {
expression = "//*[local-name()='" + name + "']";
Element signedElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(signedElement);
+ Assert.assertNotNull(signedElement);
signedElement.setIdAttributeNS(null, "Id", true);
}
XMLSignature signature = new XMLSignature(sigElement, "", secureValidation);
- assertTrue(signature.checkSignatureValue(key));
+ Assert.assertTrue(signature.checkSignatureValue(key));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java
index 7dd143b..c91219a 100644
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java
@@ -38,7 +38,7 @@
@org.junit.Test
public void testSameKeySeveralAlgorithmSigning() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
SignatureAlgorithm signatureAlgorithm =
new SignatureAlgorithm(doc, XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1);
PrivateKey pk = KeyPairGenerator.getInstance("RSA").genKeyPair().getPrivate();
diff --git a/src/test/java/org/apache/xml/security/test/dom/algorithms/SymmetricEncryptionAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/algorithms/SymmetricEncryptionAlgorithmTest.java
index b9f4661..bc05e05 100644
--- a/src/test/java/org/apache/xml/security/test/dom/algorithms/SymmetricEncryptionAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/algorithms/SymmetricEncryptionAlgorithmTest.java
@@ -28,6 +28,7 @@
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -36,19 +37,16 @@
import org.apache.xml.security.stax.ext.XMLSecurityConstants;
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* A test to make sure that the various Symmetric Encryption algorithms are working
*/
-public class SymmetricEncryptionAlgorithmTest {
+public class SymmetricEncryptionAlgorithmTest extends Assert {
private static boolean bcInstalled;
@@ -89,7 +87,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -105,14 +104,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -121,7 +120,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -137,14 +137,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -153,7 +153,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -169,14 +170,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -185,7 +186,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -201,14 +203,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -217,7 +219,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -233,14 +236,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -249,7 +252,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -265,14 +269,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -281,7 +285,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -296,14 +301,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -314,7 +319,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("SEED");
@@ -330,14 +336,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -348,7 +354,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -364,14 +371,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -382,7 +389,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -398,14 +406,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@org.junit.Test
@@ -416,7 +424,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -432,14 +441,14 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
document = decrypt(encryptionAlgorithm, document, key);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
private void encrypt(
@@ -459,7 +468,7 @@
String expression = "//*[local-name()='" + localName + "']";
Element elementToEncrypt =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(elementToEncrypt);
+ Assert.assertNotNull(elementToEncrypt);
document = cipher.doFinal(document, elementToEncrypt, false);
}
@@ -468,7 +477,7 @@
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertTrue(nodeList.getLength() > 0);
+ Assert.assertTrue(nodeList.getLength() > 0);
}
private Document decrypt(
@@ -487,4 +496,4 @@
return cipher.doFinal(document, ee);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/helper/AttrCompareTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/helper/AttrCompareTest.java
index 3a5022d..d5b2f7c 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/helper/AttrCompareTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/helper/AttrCompareTest.java
@@ -18,7 +18,9 @@
*/
package org.apache.xml.security.test.dom.c14n.helper;
+import static org.junit.Assert.*;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xml.security.c14n.helper.AttrCompare;
@@ -29,11 +31,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-
/**
* Unit test for {@link org.apache.xml.security.c14n.AttrCompare#compare}
@@ -221,7 +218,9 @@
private static Document createDoc(
String documentElement
) throws ParserConfigurationException {
- Document doc = XMLUtils.newDocument();
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(false);
+
+ Document doc = documentBuilder.newDocument();
Element root = doc.createElementNS(null, documentElement);
doc.appendChild(root);
@@ -230,3 +229,5 @@
}
}
+
+
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/helper/C14nHelperTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/helper/C14nHelperTest.java
index 7b08aef..44d11be 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/helper/C14nHelperTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/helper/C14nHelperTest.java
@@ -18,11 +18,10 @@
*/
package org.apache.xml.security.test.dom.c14n.helper;
+import static org.junit.Assert.assertTrue;
import org.apache.xml.security.c14n.helper.C14nHelper;
-import static org.junit.Assert.assertTrue;
-
/**
*/
@@ -109,4 +108,4 @@
C14nHelper.namespaceIsRelative(namespaceURI));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Bug45961Test.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Bug45961Test.java
index b955f08..a68b567 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Bug45961Test.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Bug45961Test.java
@@ -18,12 +18,15 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.c14n.Canonicalizer;
import org.apache.xml.security.keys.KeyInfo;
@@ -37,10 +40,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-
public class Bug45961Test {
private static final String OBJECT_ID = "Object";
@@ -48,12 +47,14 @@
MockCanonicalizationMethod.MOCK_CANONICALIZATION_METHOD;
private static final char[] PASSWORD = "changeit".toCharArray();
private static final String ALIAS = "mullan";
+ private DocumentBuilder _builder;
private ObjectContainer object;
public Bug45961Test() throws Exception {
Init.init();
Canonicalizer.register(MOCK_CANONICALIZATION_METHOD,
MockCanonicalizationMethod.class.getName());
+ _builder = XMLUtils.createDocumentBuilder(false);
}
@org.junit.Test
@@ -83,7 +84,7 @@
X509Certificate signingCert = (X509Certificate) ks
.getCertificate(ALIAS);
- Document document = XMLUtils.newDocument();
+ Document document = _builder.newDocument();
XMLSignature signature = new XMLSignature(document, null,
XMLSignature.ALGO_ID_SIGNATURE_DSA,
@@ -125,4 +126,4 @@
return path;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java
index 326bd33..366cd81 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer11Test.java
@@ -18,25 +18,33 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.*;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+import org.apache.xml.security.c14n.CanonicalizationException;
import org.apache.xml.security.c14n.Canonicalizer;
+import org.apache.xml.security.c14n.InvalidCanonicalizerException;
import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.utils.IgnoreAllErrorHandler;
import org.apache.xml.security.utils.JavaUtils;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.xml.sax.SAXException;
/**
* Unit test for
@@ -64,9 +72,21 @@
/**
* 3.1 PIs, Comments, and Outside of Document Element
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test31withCommentsSubtree() throws Exception {
+ public void test31withCommentsSubtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (commented)";
@@ -74,116 +94,189 @@
String fileRef = prefix + "in/31_c14n-comments.xml";
String fileOut = prefix + "out/xpath_31_output-comments.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.2 Whitespace in Document Content
-
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-WhitespaceInContent">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test32subtree() throws Exception {
+ public void test32subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.2 Whitespace in Document Content. (uncommented)";
String fileIn = prefix + "in/32_input.xml";
String fileRef = prefix + "in/32_c14n.xml";
String fileOut = prefix + "out/xpath_32_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.3 Start and End Tags
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-SETags">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test33subtree() throws Exception {
+ public void test33subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.3 Start and End Tags. (uncommented)";
String fileIn = prefix + "in/33_input.xml";
String fileRef = prefix + "in/33_c14n.xml";
String fileOut = prefix + "out/xpath_33_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null; // Canonicalizer.XPATH_C14N_OMIT_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.4 Character Modifications and Character References
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see #test34validatingParser
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-Chars">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test34() throws Exception {
+ public void test34()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.4 Character Modifications and Character References. (uncommented)";
String fileIn = prefix + "in/34_input.xml";
String fileRef = prefix + "in/34_c14n.xml";
String fileOut = prefix + "out/xpath_34_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
+ boolean validating = false;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.5 Entity References
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-Entities">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test35subtree() throws Exception {
+ public void test35subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.5 Entity References. (uncommented)";
String fileIn = prefix + "in/35_input.xml";
String fileRef = prefix + "in/35_c14n.xml";
String fileOut = prefix + "out/xpath_35_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.6 UTF-8 Encoding
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-UTF8">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test36subtree() throws Exception {
+ public void test36subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.6 UTF-8 Encoding. (uncommented)";
String fileIn = prefix + "in/36_input.xml";
String fileRef = prefix + "in/36_c14n.xml";
String fileOut = prefix + "out/xpath_36_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.7 Document Subsets
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-DocSubsets">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test37() throws Exception {
+ public void test37()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.7 Document Subsets. (uncommented)";
String fileIn = prefix + "in/37_input.xml";
String fileRef = prefix + "in/37_c14n.xml";
String fileOut = prefix + "out/xpath_37_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
+ boolean validating = true;
Map<String, String> namespace = new HashMap<>();
namespace.put("ietf", "http://www.ietf.org");
@@ -196,19 +289,32 @@
+ "]";
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath, namespace));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath, namespace));
}
/**
* 3.8 Document Subsets and XML Attributes
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test38() throws Exception {
+ public void test38()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.8 Document Subsets and XML Attributes (uncommented)";
String fileIn = prefix + "in/38_input.xml";
String fileRef = prefix + "in/38_c14n.xml";
String fileOut = prefix + "out/xpath_38_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
+ boolean validating = true;
Map<String, String> namespace = new HashMap<>();
namespace.put("ietf", "http://www.ietf.org");
@@ -221,7 +327,7 @@
+ "]";
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath, namespace));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath, namespace));
}
private boolean c14nAndCompare(
@@ -229,11 +335,14 @@
String fileRef,
String fileOut,
String c14nURI,
+ boolean validating,
String xpath
- ) throws Exception {
+ ) throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
Map<String, String> namespace = new HashMap<>();
return c14nAndCompare(fileIn, fileRef, fileOut,
- c14nURI, xpath, namespace);
+ c14nURI, validating, xpath, namespace);
}
private boolean c14nAndCompare(
@@ -241,14 +350,27 @@
String fileRef,
String fileOut,
String c14nURI,
+ boolean validating,
String xpath,
Map<String, String> namespaces
- ) throws Exception {
+ ) throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
- Document doc = XMLUtils.read(fileIn, false);
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(validating, false);
+
+ // throw away all warnings and errors
+ documentBuilder.setErrorHandler(new IgnoreAllErrorHandler());
+
+ // org.xml.sax.EntityResolver resolver = new TestVectorResolver();
+ // documentBuilder.setEntityResolver(resolver);
+ // Document doc = documentBuilder.parse(resolver.resolveEntity(null, fileIn));
+
+ Document doc = documentBuilder.parse(fileIn);
+
Canonicalizer c14n = Canonicalizer.getInstance(c14nURI);
- byte[] c14nBytes = null;
+ byte c14nBytes[] = null;
if (xpath == null) {
c14nBytes = c14n.canonicalizeSubtree(doc);
@@ -267,8 +389,8 @@
}
// org.xml.sax.InputSource refIs = resolver.resolveEntity(null, fileRef);
- // byte[] refBytes = JavaUtils.getBytesFromStream(refIs.getByteStream());
- byte[] refBytes = JavaUtils.getBytesFromFile(fileRef);
+ // byte refBytes[] = JavaUtils.getBytesFromStream(refIs.getByteStream());
+ byte refBytes[] = JavaUtils.getBytesFromFile(fileRef);
// if everything is OK, result is true; we do a binary compare, byte by byte
boolean result = java.security.MessageDigest.isEqual(refBytes, c14nBytes);
@@ -291,4 +413,4 @@
return result;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
index 361f6ab..83b1100 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315ExclusiveTest.java
@@ -18,23 +18,33 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.*;
import java.io.File;
-import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.StringReader;
import java.util.HashSet;
import java.util.Set;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+import org.apache.xml.security.c14n.CanonicalizationException;
+import org.apache.xml.security.c14n.InvalidCanonicalizerException;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315Excl;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315ExclOmitComments;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315ExclWithComments;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315WithComments;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.signature.XMLSignature;
+import org.apache.xml.security.signature.XMLSignatureException;
import org.apache.xml.security.signature.XMLSignatureInput;
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.utils.Constants;
@@ -45,9 +55,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.xml.sax.SAXException;
/**
@@ -63,11 +71,34 @@
Canonicalizer20010315ExclusiveTest.class
);
+ /** Field db */
+ DocumentBuilder db;
+
+ public Canonicalizer20010315ExclusiveTest() throws ParserConfigurationException {
+ this.db = XMLUtils.createDocumentBuilder(false);
+ }
+
/**
* Method testA
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XMLSecurityException
+ * @throws XMLSignatureException
+ * @throws org.apache.xml.security.keys.keyresolver.KeyResolverException
*/
@org.junit.Test
- public void testA() throws Exception {
+ public void testA()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException,
+ XMLSignatureException, XMLSecurityException,
+ org.apache.xml.security.keys.keyresolver.KeyResolverException {
File fileIn = new File(getAbsolutePath(
"src/test/resources/ie/baltimore/merlin-examples/ec-merlin-iaikTests-two/signature.xml"));
@@ -75,7 +106,7 @@
// File fileIn = new File("signature.xml");
assertTrue("file exists", fileIn.exists());
- Document doc = XMLUtils.read(new FileInputStream(fileIn), false);
+ Document doc = this.db.parse(fileIn);
Element signatureElement =
(Element) doc.getElementsByTagNameNS(
Constants.SignatureSpecNS, Constants._TAG_SIGNATURE).item(0);
@@ -101,14 +132,27 @@
/**
* Method test221
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XMLSecurityException
+ * @throws XMLSignatureException
*/
@org.junit.Test
- public void test221() throws Exception {
+ public void test221()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException,
+ XMLSignatureException, XMLSecurityException {
Document doc =
- XMLUtils.read(
- new FileInputStream(getAbsolutePath("src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_1.xml")),
- false
+ this.db.parse(
+ getAbsolutePath("src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_1.xml")
);
Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315 c = new Canonicalizer20010315WithComments();
@@ -122,13 +166,27 @@
/**
* Method test222
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XMLSecurityException
+ * @throws XMLSignatureException
*/
@org.junit.Test
- public void test222() throws Exception {
+ public void test222()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException,
+ XMLSignatureException, XMLSecurityException {
Document doc =
- XMLUtils.read(new FileInputStream(getAbsolutePath(
+ this.db.parse(getAbsolutePath(
"src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_2.xml")
- ), false);
+ );
Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315 c = new Canonicalizer20010315WithComments();
byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
@@ -141,13 +199,26 @@
/**
* Method test221excl
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XMLSecurityException
+ * @throws XMLSignatureException
*/
@org.junit.Test
- public void test221excl() throws Exception {
+ public void test221excl()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException,
+ XMLSignatureException, XMLSecurityException {
Document doc =
- XMLUtils.read(new FileInputStream(getAbsolutePath(
- "src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_1.xml")),
- false);
+ this.db.parse(getAbsolutePath(
+ "src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_1.xml"));
Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
@@ -160,13 +231,26 @@
/**
* Method test222excl
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XMLSecurityException
+ * @throws XMLSignatureException
*/
@org.junit.Test
- public void test222excl() throws Exception {
+ public void test222excl()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException,
+ XMLSignatureException, XMLSecurityException {
Document doc =
- XMLUtils.read(new FileInputStream(getAbsolutePath(
- "src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_2.xml")),
- false);
+ this.db.parse(getAbsolutePath(
+ "src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_2.xml"));
Node root = doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
byte[] reference = JavaUtils.getBytesFromFile(getAbsolutePath(
@@ -181,13 +265,27 @@
* Method test223excl
*
* Provided by Gabriel McGoldrick - see e-mail of 21/11/03
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XMLSecurityException
+ * @throws XMLSignatureException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test223excl() throws Exception {
+ public void test223excl()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException,
+ XMLSignatureException, XMLSecurityException, XPathExpressionException {
Document doc =
- XMLUtils.read(new FileInputStream(getAbsolutePath(
- "src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_3.xml")),
- false);
+ this.db.parse(getAbsolutePath(
+ "src/test/resources/org/apache/xml/security/c14n/inExcl/example2_2_3.xml"));
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
@@ -238,7 +336,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
Set<Node> nodeSet = new HashSet<>();
@@ -256,10 +354,9 @@
@org.junit.Test
public void test24excl() throws Exception {
Document doc =
- XMLUtils.read(
- new FileInputStream(getAbsolutePath(
- "src/test/resources/org/apache/xml/security/c14n/inExcl/example2_4.xml")),
- false);
+ this.db.parse(
+ getAbsolutePath(
+ "src/test/resources/org/apache/xml/security/c14n/inExcl/example2_4.xml"));
Node root =
doc.getElementsByTagNameNS("http://example.net", "elem2").item(0);
Canonicalizer20010315Excl c = new Canonicalizer20010315ExclWithComments();
@@ -279,7 +376,7 @@
*/
@org.junit.Test
public void test24Aexcl() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Element local = doc.createElementNS("foo:bar", "dsig:local");
Element test = doc.createElementNS("http://example.net", "etsi:test");
Element elem2 = doc.createElementNS("http://example.net", "etsi:elem2");
@@ -332,7 +429,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
{
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
@@ -395,7 +492,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
{
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
@@ -445,7 +542,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
{
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
@@ -495,7 +592,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
{
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
@@ -545,7 +642,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
byte[] bytes = c14n.engineCanonicalizeSubTree(doc.getDocumentElement().getFirstChild(), "#default", true);
@@ -580,7 +677,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
byte[] bytes = c14n.engineCanonicalizeSubTree(doc.getDocumentElement().getFirstChild(), "#default", true);
@@ -615,7 +712,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
byte[] bytes = c14n.engineCanonicalizeSubTree(doc.getDocumentElement().getFirstChild(), "#default", true);
@@ -650,7 +747,7 @@
+ "</ns0:Ping>"
+ "</env:Body>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
byte[] bytes = c14n.engineCanonicalizeSubTree(doc.getDocumentElement().getFirstChild(), "#default", true);
@@ -680,7 +777,7 @@
+ "<ns0:text xsi:type=\"xsd:string\">hello</ns0:text>"
+ "</ns0:Ping>";
- Document doc = XMLUtils.read(new InputSource(new StringReader(XML)), false);
+ Document doc = this.db.parse(new InputSource(new StringReader(XML)));
Canonicalizer20010315ExclOmitComments c14n =
new Canonicalizer20010315ExclOmitComments();
byte[] bytes = c14n.engineCanonicalizeSubTree(doc.getDocumentElement().getFirstChild().getFirstChild(), "#default", true);
@@ -695,4 +792,4 @@
return path;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java
index fb83ff7..98c00b6 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Canonicalizer20010315Test.java
@@ -18,35 +18,43 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.apache.xml.security.c14n.CanonicalizationException;
import org.apache.xml.security.c14n.Canonicalizer;
+import org.apache.xml.security.c14n.InvalidCanonicalizerException;
import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.test.dom.resource.TestVectorResolver;
+import org.apache.xml.security.utils.IgnoreAllErrorHandler;
import org.apache.xml.security.utils.JavaUtils;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.xml.sax.SAXException;
/**
@@ -76,9 +84,21 @@
/**
* 3.1 PIs, Comments, and Outside of Document Element
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test31withCommentsSubtree() throws Exception {
+ public void test31withCommentsSubtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (commented)";
@@ -86,17 +106,30 @@
String fileRef = prefix + "in/31_c14n-comments.xml";
String fileOut = prefix + "out/xpath_31_output-comments.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.1 PIs, Comments, and Outside of Document Element
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test31withCommentsSubset() throws Exception {
+ public void test31withCommentsSubset()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (commented)";
@@ -104,38 +137,62 @@
String fileRef = prefix + "in/31_c14n-comments.xml";
String fileOut = prefix + "out/xpath_31_output-comments.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
+ boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.1 PIs, Comments, and Outside of Document Element
-
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-OutsideDoc">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test31subtree() throws Exception {
+ public void test31subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (uncommented)";
String fileIn = prefix + "in/31_input.xml";
String fileRef = prefix + "in/31_c14n.xml";
String fileOut = prefix + "out/xpath_31_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.1 PIs, Comments, and Outside of Document Element
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-OutsideDoc">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test31subset() throws Exception {
+ public void test31subset()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.1: PIs, Comments, and Outside of Document Element. (uncommented)";
@@ -143,97 +200,150 @@
String fileRef = prefix + "in/31_c14n.xml";
String fileOut = prefix + "out/xpath_31_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.2 Whitespace in Document Content
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-WhitespaceInContent">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test32subtree() throws Exception {
+ public void test32subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.2 Whitespace in Document Content. (uncommented)";
String fileIn = prefix + "in/32_input.xml";
String fileRef = prefix + "in/32_c14n.xml";
String fileOut = prefix + "out/xpath_32_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.2 Whitespace in Document Content
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-WhitespaceInContent">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test32subset() throws Exception {
+ public void test32subset()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.2 Whitespace in Document Content. (uncommented)";
String fileIn = prefix + "in/32_input.xml";
String fileRef = prefix + "in/32_c14n.xml";
String fileOut = prefix + "out/xpath_32_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.3 Start and End Tags
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-SETags">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test33subtree() throws Exception {
+ public void test33subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.3 Start and End Tags. (uncommented)";
String fileIn = prefix + "in/33_input.xml";
String fileRef = prefix + "in/33_c14n.xml";
String fileOut = prefix + "out/xpath_33_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null; // Canonicalizer.XPATH_C14N_OMIT_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
@org.junit.Test
- public void test33subset() throws Exception {
+ public void test33subset()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.3 Start and End Tags. (uncommented)";
String fileIn = prefix + "in/33_input.xml";
String fileRef = prefix + "in/33_c14n.xml";
String fileOut = prefix + "out/xpath_33_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.4 Character Modifications and Character References
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see #test34validatingParser
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-Chars">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test34() throws Exception {
+ public void test34()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.4 Character Modifications and Character References. (uncommented)";
String fileIn = prefix + "in/34_input.xml";
String fileRef = prefix + "in/34_c14n.xml";
String fileOut = prefix + "out/xpath_34_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = false;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
@@ -247,20 +357,32 @@
* containing this element from the input and canonical form. In general,
* XML consumers should be discouraged from using this feature of XML.
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-Chars">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test34subtree() throws Exception {
+ public void test34subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.4 Character Modifications and Character References. (uncommented, patched to run on validating Parsers)";
String fileIn = prefix + "in/34_input_validatingParser.xml";
String fileRef = prefix + "in/34_c14n_validatingParser.xml";
String fileOut = prefix + "out/xpath_34_output_validatingParser.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
@@ -274,10 +396,21 @@
* containing this element from the input and canonical form. In general,
* XML consumers should be discouraged from using this feature of XML.
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-Chars">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test34subset() throws Exception {
+ public void test34subset()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri =
"3.4 Character Modifications and Character References. (uncommented, patched to run on validating Parsers)";
@@ -285,96 +418,157 @@
String fileRef = prefix + "in/34_c14n_validatingParser.xml";
String fileOut = prefix + "out/xpath_34_output_validatingParser.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.5 Entity References
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-Entities">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test35subtree() throws Exception{
+ public void test35subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.5 Entity References. (uncommented)";
String fileIn = prefix + "in/35_input.xml";
String fileRef = prefix + "in/35_c14n.xml";
String fileOut = prefix + "out/xpath_35_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.5 Entity References
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-Entities">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test35subset() throws Exception {
+ public void test35subset()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.5 Entity References. (uncommented)";
String fileIn = prefix + "in/35_input.xml";
String fileRef = prefix + "in/35_c14n.xml";
String fileOut = prefix + "out/xpath_35_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.6 UTF-8 Encoding
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-UTF8">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test36subtree() throws Exception {
+ public void test36subtree()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.6 UTF-8 Encoding. (uncommented)";
String fileIn = prefix + "in/36_input.xml";
String fileRef = prefix + "in/36_c14n.xml";
String fileOut = prefix + "out/xpath_36_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = null;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.6 UTF-8 Encoding
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-UTF8">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test36subset() throws Exception {
+ public void test36subset()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.6 UTF-8 Encoding. (uncommented)";
String fileIn = prefix + "in/36_input.xml";
String fileRef = prefix + "in/36_c14n.xml";
String fileOut = prefix + "out/xpath_36_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
String xpath = Canonicalizer.XPATH_C14N_WITH_COMMENTS_SINGLE_NODE;
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath));
}
/**
* 3.7 Document Subsets
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-DocSubsets">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test37() throws Exception {
+ public void test37()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
String descri = "3.7 Document Subsets. (uncommented)";
String fileIn = prefix + "in/37_input.xml";
String fileRef = prefix + "in/37_c14n.xml";
String fileOut = prefix + "out/xpath_37_output.xml";
String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ boolean validating = true;
Map<String, String> namespace = new HashMap<>();
namespace.put("ietf", "http://www.ietf.org");
@@ -387,23 +581,40 @@
+ "]";
assertTrue(descri,
- c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, xpath, namespace));
+ c14nAndCompare(fileIn, fileRef, fileOut, c14nURI, validating, xpath, namespace));
}
/**
* 3.7 Document Subsets
*
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
* @see <A HREF="http://www.w3.org/TR/2001/PR-xml-c14n-20010119#Example-DocSubsets">the example from the spec</A>
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void test37byNodeList() throws Exception {
+ public void test37byNodeList()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
//String descri = "3.7 Document Subsets. (uncommented), c14n by NodeList";
String fileIn = prefix + "in/37_input.xml";
String fileRef = prefix + "in/37_c14n.xml";
//String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+ //boolean validating = true;
- Document doc = XMLUtils.read(new FileInputStream(fileIn), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.xml.sax.EntityResolver resolver = new TestVectorResolver();
+
+ db.setEntityResolver(resolver);
+
+ Document doc = db.parse(resolver.resolveEntity(null, fileIn));
String xpath = "(//. | //@* | //namespace::*)"
+ "[ "
@@ -424,9 +635,10 @@
NodeList nodes = (NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
Canonicalizer c14n =
Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
- byte[] c14nBytes = c14n.canonicalizeXPathNodeSet(nodes);
- InputStream refStream = new FileInputStream(fileRef);
- byte[] refBytes = JavaUtils.getBytesFromStream(refStream);
+ byte c14nBytes[] = c14n.canonicalizeXPathNodeSet(nodes);
+ InputStream refStream = resolver.resolveEntity(null,
+ fileRef).getByteStream();
+ byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
assertEquals(new String(refBytes),new String(c14nBytes));
}
@@ -439,9 +651,20 @@
*
* Implementations MUST report an operation failure on documents containing
* relative namespace URIs.
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
*/
@org.junit.Test
- public void testRelativeNSbehaviour() throws Exception {
+ public void testRelativeNSbehaviour()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException {
//J-
String inputStr = ""
@@ -453,9 +676,10 @@
+ "";
//J+
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
Document doc = null;
try (InputStream is = new ByteArrayInputStream(inputStr.getBytes())) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
boolean weCatchedTheRelativeNS = false;
@@ -482,17 +706,31 @@
* within the UTF-16 data are not removed) [UTF-16, Section 3.2]. Support
* for ISO-8859-1 encoding is RECOMMENDED, and all other character encodings
* are OPTIONAL.
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
*/
@org.junit.Test
- public void testTranslationFromUTF16toUTF8() throws Exception {
+ public void testTranslationFromUTF16toUTF8()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException {
String val =
"<UTF16>The german &auml (which is Unicode &#xE4;): "ä"</UTF16>";
- byte[] utf16 = convertToUTF16(val.getBytes());
+ byte utf16[] = convertToUTF16(val.getBytes());
Canonicalizer c14n =
Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
- byte[] c14nBytes = c14n.canonicalize(utf16);
- InputStream refStream = new FileInputStream(prefix + "/in/testTranslationFromUTF16toUTF8.xml");
- byte[] refBytes = JavaUtils.getBytesFromStream(refStream);
+ byte c14nBytes[] = c14n.canonicalize(utf16);
+ org.xml.sax.EntityResolver resolver = new TestVectorResolver();
+ InputStream refStream =
+ resolver.resolveEntity(
+ null, prefix + "/in/testTranslationFromUTF16toUTF8.xml").getByteStream();
+ byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
boolean equal = java.security.MessageDigest.isEqual(refBytes, c14nBytes);
assertTrue("Parser does not translate to UCS character domain", equal);
@@ -500,9 +738,21 @@
/**
* Method testXMLAttributes1
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void testXMLAttributes1() throws Exception {
+ public void testXMLAttributes1()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
//J-
String input = ""
+ "<included xml:lang='de'>"
@@ -525,9 +775,21 @@
/**
* Method testXMLAttributes2
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void testXMLAttributes2() throws Exception {
+ public void testXMLAttributes2()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
//J-
String input = ""
+ "<included xml:lang='uk'>"
@@ -550,9 +812,21 @@
/**
* Method testXMLAttributes3
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
- public void testXMLAttributes3() throws Exception {
+ public void testXMLAttributes3()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
//J-
String input = ""
+ "<included xml:lang='de'>"
@@ -575,10 +849,22 @@
/**
* Method testXMLAttributes4
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
@org.junit.Ignore
- public void _testXMLAttributes4() throws Exception {
+ public void _testXMLAttributes4()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
//J-
String input = ""
+ "<included xml:lang='de'>"
@@ -603,10 +889,22 @@
/**
* Method testXMLAttributes5
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
@org.junit.Ignore
- public void _testXMLAttributes5() throws Exception {
+ public void _testXMLAttributes5()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
//J-
String input = ""
+ "<included xml:lang='de'>"
@@ -631,10 +929,22 @@
/**
* Method testXMLAttributes6
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
@org.junit.Test
@org.junit.Ignore
- public void _testXMLAttributes6() throws Exception {
+ public void _testXMLAttributes6()
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
//J-
String input = ""
+ "<included xml:space='preserve' xml:lang='de'>"
@@ -663,12 +973,28 @@
* @param input
* @param definedOutput
* @param writeResultsToFile
+ *
+ * @throws CanonicalizationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws InvalidCanonicalizerException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerException
+ * @throws XPathExpressionException
*/
- private boolean doTestXMLAttributes(String input, String definedOutput) throws Exception {
+ private boolean doTestXMLAttributes(String input, String definedOutput)
+ throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
+
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(true);
+
+ db.setErrorHandler(new IgnoreAllErrorHandler());
Document doc = null;
try (InputStream is = new ByteArrayInputStream(input.getBytes())) {
- doc = XMLUtils.read(is, true);
+ doc = db.parse(is);
}
Canonicalizer c14nizer =
Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
@@ -684,8 +1010,8 @@
NodeList nodes =
(NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
- byte[] result = c14nizer.canonicalizeXPathNodeSet(nodes);
- byte[] defined = definedOutput.getBytes();
+ byte result[] = c14nizer.canonicalizeXPathNodeSet(nodes);
+ byte defined[] = definedOutput.getBytes();
assertEquals(definedOutput, new String(result));
return java.security.MessageDigest.isEqual(defined, result);
}
@@ -695,11 +1021,14 @@
String fileRef,
String fileOut,
String c14nURI,
+ boolean validating,
String xpath
- ) throws Exception {
+ ) throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
Map<String, String> namespace = new HashMap<>();
return c14nAndCompare(fileIn, fileRef, fileOut,
- c14nURI, xpath, namespace);
+ c14nURI, validating, xpath, namespace);
}
private boolean c14nAndCompare(
@@ -707,15 +1036,27 @@
String fileRef,
String fileOut,
String c14nURI,
+ boolean validating,
String xpath,
Map<String, String> namespaces
- ) throws Exception {
+ ) throws IOException, FileNotFoundException, SAXException,
+ ParserConfigurationException, CanonicalizationException,
+ InvalidCanonicalizerException, TransformerException, XPathExpressionException {
- Document doc = XMLUtils.read(fileIn, false);
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(validating, false);
+
+ // throw away all warnings and errors
+ documentBuilder.setErrorHandler(new IgnoreAllErrorHandler());
+
+ // org.xml.sax.EntityResolver resolver = new TestVectorResolver();
+ // documentBuilder.setEntityResolver(resolver);
+ // Document doc = documentBuilder.parse(resolver.resolveEntity(null, fileIn));
+
+ Document doc = documentBuilder.parse(fileIn);
Canonicalizer c14n = Canonicalizer.getInstance(c14nURI);
- byte[] c14nBytes = null;
+ byte c14nBytes[] = null;
if (xpath == null) {
c14nBytes = c14n.canonicalizeSubtree(doc);
@@ -734,8 +1075,8 @@
}
// org.xml.sax.InputSource refIs = resolver.resolveEntity(null, fileRef);
- // byte[] refBytes = JavaUtils.getBytesFromStream(refIs.getByteStream());
- byte[] refBytes = JavaUtils.getBytesFromFile(fileRef);
+ // byte refBytes[] = JavaUtils.getBytesFromStream(refIs.getByteStream());
+ byte refBytes[] = JavaUtils.getBytesFromFile(fileRef);
// if everything is OK, result is true; we do a binary compare, byte by byte
boolean result = java.security.MessageDigest.isEqual(refBytes, c14nBytes);
@@ -763,14 +1104,23 @@
* UTF-16 encoded XML document which is serialized to byte[] and returned.
*
* @param input
+ *
+ * @throws IOException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws TransformerConfigurationException
+ * @throws TransformerException
*/
- public static byte[] convertToUTF16(byte[] input) throws Exception {
+ public static byte[] convertToUTF16(byte input[])
+ throws ParserConfigurationException, IOException, SAXException,
+ TransformerConfigurationException, TransformerException {
//String ENCODING_ISO8859_1 = "ISO-8859-1";
//String ENCODING_UTF8 = java.nio.charset.StandardCharsets.UTF_8;
String ENCODING_UTF16 = "UTF-16";
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
Document doc = null;
try (InputStream is = new ByteArrayInputStream(input)) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
@@ -787,4 +1137,4 @@
return os.toByteArray();
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/ExclusiveC14NInteropTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/ExclusiveC14NInteropTest.java
index 4d158e9..1559fce 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/ExclusiveC14NInteropTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/ExclusiveC14NInteropTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.xml.security.signature.Reference;
import org.apache.xml.security.signature.XMLSignature;
@@ -29,8 +29,6 @@
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertNull;
-
/**
* Interop test for exclusive canonical XML.
@@ -62,7 +60,7 @@
String success = t("src/test/resources/interop/c14n/Y1", "exc-signature.xml", true);
- assertNull(success);
+ assertTrue(success, success == null);
}
/**
@@ -75,7 +73,7 @@
String success = t("src/test/resources/interop/c14n/Y2", "signature-joseph-exc.xml", false);
- assertNull(success);
+ assertTrue(success, success == null);
}
/**
@@ -88,7 +86,7 @@
String success = t("src/test/resources/interop/c14n/Y3", "signature.xml", false);
- assertNull(success);
+ assertTrue(success, success == null);
}
/**
@@ -101,7 +99,7 @@
String success = t("src/test/resources/interop/c14n/Y4", "signature.xml", true);
- assertNull(success);
+ assertTrue(success, success == null);
}
@org.junit.Test
@@ -109,7 +107,7 @@
String success = t("src/test/resources/interop/xfilter2/merlin-xpath-filter2-three", "sign-spec.xml", true);
- assertNull(success);
+ assertTrue(success, success == null);
}
private String t(String directory, String file, boolean secureValidation) throws Exception {
@@ -120,7 +118,8 @@
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.read(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(f);
Element sigElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
@@ -143,7 +142,7 @@
LOG.debug("Reference " + i + " was OK");
} else {
sb.append(i);
- sb.append(' ');
+ sb.append(" ");
//JavaUtils.writeBytesToFilename(directory + "/c14n-" + i + ".apache.txt", signature.getSignedInfo().item(i).getContentsAfterTransformation().getBytes());
//JavaUtils.writeBytesToFilename(directory + "/c14n-" + i + ".apache.html", signature.getSignedInfo().item(i).getHTMLRepresentation().getBytes());
@@ -165,4 +164,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/NameSpaceSymbTableTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/NameSpaceSymbTableTest.java
index d87728f..046cacf 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/NameSpaceSymbTableTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/NameSpaceSymbTableTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
@@ -27,22 +28,15 @@
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
public class NameSpaceSymbTableTest {
static Attr node1, node2;
static {
try {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
node1 = doc.createAttributeNS("a","b");
node2 = doc.createAttributeNS("b","c");
} catch (Exception e) {
- // e.printStackTrace();
+ e.printStackTrace();
}
}
@@ -208,4 +202,4 @@
ns.addMappingAndRender("ctrl", "http://foo.com/controls", node1);
ns.addMappingAndRender("wiki", "http://foo.com/samples/wiki", node1);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Santuario191Test.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Santuario191Test.java
index c19d9c1..8be923f 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Santuario191Test.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Santuario191Test.java
@@ -18,19 +18,20 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import javax.xml.parsers.DocumentBuilder;
+
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.apache.xml.security.c14n.implementations.Canonicalizer11_OmitComments;
import org.apache.xml.security.utils.XMLUtils;
-import static org.junit.Assert.assertEquals;
-
/**
* This is a test for Santuario-191:
*
@@ -54,6 +55,8 @@
+ " <user2>Bob</user2>"
+ "</data>";
+ private DocumentBuilder db;
+
static {
org.apache.xml.security.Init.init();
}
@@ -63,9 +66,10 @@
//
// Parse the Data
//
+ db = XMLUtils.createDocumentBuilder(false);
Document doc = null;
try (InputStream is = new ByteArrayInputStream(INPUT_DATA.getBytes(StandardCharsets.UTF_8))) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
//
@@ -80,7 +84,7 @@
//
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(result);
- assertEquals(EXPECTED_RESULT, out.toString(StandardCharsets.UTF_8.name()));
+ assertTrue(EXPECTED_RESULT.equals(out.toString(StandardCharsets.UTF_8.name())));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Santuario273Test.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Santuario273Test.java
index 8c73484..8195f43 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Santuario273Test.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/Santuario273Test.java
@@ -18,10 +18,12 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -33,8 +35,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import static org.junit.Assert.assertEquals;
-
/**
* This is a test for Santuario-273:
*
@@ -79,9 +79,12 @@
@org.junit.Test
public void testC14n11Base() throws Exception {
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(true);
+
+ documentBuilder.setErrorHandler(new org.apache.xml.security.utils.IgnoreAllErrorHandler());
Document doc = null;
try (InputStream is = new ByteArrayInputStream(input.getBytes())) {
- doc = XMLUtils.read(is, false);
+ doc = documentBuilder.parse(is);
}
Canonicalizer c14n =
@@ -98,4 +101,4 @@
assertEquals( new String(output, java.nio.charset.StandardCharsets.UTF_8), expectedResult);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/UtfHelperTest.java b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/UtfHelperTest.java
index 1b379e6..f0f6a6f 100644
--- a/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/UtfHelperTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/c14n/implementations/UtfHelperTest.java
@@ -18,22 +18,24 @@
*/
package org.apache.xml.security.test.dom.c14n.implementations;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import org.apache.xml.security.c14n.implementations.UtfHelpper;
-import static org.junit.Assert.assertArrayEquals;
-
public class UtfHelperTest {
@org.junit.Test
public void testBug40156() {
String s = "\u00e4\u00f6\u00fc";
- byte[] a = UtfHelpper.getStringInUtf8(s);
- byte[] correct = s.getBytes(StandardCharsets.UTF_8);
- assertArrayEquals(correct, a);
+ byte a[] = UtfHelpper.getStringInUtf8(s);
+ byte correct[] = s.getBytes(StandardCharsets.UTF_8);
+ boolean equals = Arrays.equals(correct, a);
+ assertTrue(equals);
}
@org.junit.Test
@@ -54,7 +56,7 @@
ByteArrayOutputStream charByCharOs = new ByteArrayOutputStream();
ByteArrayOutputStream strOs = new ByteArrayOutputStream();
- char[] chs = new char[chunk * 2];
+ char chs[] = new char[chunk * 2];
int pos = 0;
for (int i = 0; i < chunk; i++) {
int ch = chunk * j + i;
@@ -66,7 +68,7 @@
pos += offset;
}
}
- char[] newResult = new char[pos];
+ char newResult[] = new char[pos];
System.arraycopy(chs, 0, newResult, 0, pos);
for (int i = 0; i < pos; ) {
int ch = Character.codePointAt(newResult, i);
@@ -75,20 +77,23 @@
}
String str = new String(newResult);
- byte[] a = UtfHelpper.getStringInUtf8(str);
-
- // System.out.println("chunk:"+j);
- byte[] correct = str.getBytes(StandardCharsets.UTF_8);
- assertArrayEquals("UtfHelper.getStringInUtf8 false", correct, a);
- assertArrayEquals(
- "UtfHelper.getStringInUtf8 false",
- correct, charByCharOs.toByteArray()
- );
- UtfHelpper.writeStringToUtf8(str, strOs);
- assertArrayEquals(
- "UtfHelper.writeStringToUtf8 false",
- correct, strOs.toByteArray()
- );
+ byte a[] = UtfHelpper.getStringInUtf8(str);
+ try {
+ // System.out.println("chunk:"+j);
+ byte correct[] = str.getBytes(StandardCharsets.UTF_8);
+ assertTrue("UtfHelper.getStringInUtf8 false", Arrays.equals(correct, a));
+ assertTrue(
+ "UtfHelper.getStringInUtf8 false",
+ Arrays.equals(correct, charByCharOs.toByteArray())
+ );
+ UtfHelpper.writeStringToUtf8(str, strOs);
+ assertTrue(
+ "UtfHelper.writeStringToUtf8 false",
+ Arrays.equals(correct, strOs.toByteArray())
+ );
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/BaltimoreEncTest.java b/src/test/java/org/apache/xml/security/test/dom/encryption/BaltimoreEncTest.java
index b848726..0bff4f6 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/BaltimoreEncTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/BaltimoreEncTest.java
@@ -33,6 +33,7 @@
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
@@ -55,9 +56,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
+import static org.junit.Assert.*;
/**
* Interop test for XML Encryption
@@ -92,7 +91,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
cardNumber = retrieveCCNumber(doc);
@@ -392,7 +392,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
// Now we have the document, lets build the XMLCipher element
Element ee = null;
@@ -431,7 +432,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
// Now we have the document, lets build the XMLCipher element
Element ee = null;
@@ -599,7 +601,7 @@
String cc = retrieveCCNumber(d);
LOG.debug("Retrieved Credit Card : " + cc);
- assertEquals(cardNumber, cc);
+ assertTrue(cc, cc!= null && cc.equals(cardNumber));
// Test cc numbers
if (doNodeCheck) {
@@ -618,4 +620,4 @@
String input = new String(data, StandardCharsets.US_ASCII);
assertEquals(testDecryptString, input);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/BobKeyResolver.java b/src/test/java/org/apache/xml/security/test/dom/encryption/BobKeyResolver.java
index 74b8a17..d867a95 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/BobKeyResolver.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/BobKeyResolver.java
@@ -62,7 +62,7 @@
try {
if (isKeyName) {
_kn = new KeyName(element, "");
- if ("bob".equals(_kn.getKeyName())) {
+ if (_kn.getKeyName().equals("bob")) {
return true;
}
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/EncryptContentTest.java b/src/test/java/org/apache/xml/security/test/dom/encryption/EncryptContentTest.java
index 311bfb8..170ea49 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/EncryptContentTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/EncryptContentTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.encryption;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -29,6 +30,7 @@
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.TransformerFactory;
import org.apache.xml.security.algorithms.JCEMapper;
@@ -42,8 +44,6 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-
public class EncryptContentTest {
static org.slf4j.Logger LOG =
@@ -71,11 +71,13 @@
" </user>\n" +
"</users>\n";
+ private DocumentBuilder db;
private SecretKey secretKey;
private boolean haveISOPadding;
public EncryptContentTest() throws Exception {
org.apache.xml.security.Init.init();
+ db = XMLUtils.createDocumentBuilder(false);
byte[] bits192 = "abcdefghijklmnopqrstuvwx".getBytes();
DESedeKeySpec keySpec = new DESedeKeySpec(bits192);
@@ -116,7 +118,7 @@
Document doc = null;
try (InputStream is = new ByteArrayInputStream(DATA.getBytes(StandardCharsets.UTF_8))) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
NodeList dataToEncrypt = doc.getElementsByTagName("user");
@@ -136,7 +138,7 @@
// child should be EncryptedData, if not throw exception
Element childElem = (Element) child;
- if (!"EncryptedData".equals(childElem.getLocalName())) {
+ if (!childElem.getLocalName().equals("EncryptedData")) {
// t.transform(new DOMSource(doc), new StreamResult(System.out));
throw new Exception("Element content not replaced");
}
@@ -168,7 +170,7 @@
Document doc = null;
try (InputStream is = new ByteArrayInputStream(MULTIPLE_USER_DATA.getBytes(StandardCharsets.UTF_8))) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
NodeList dataToEncrypt = doc.getElementsByTagName("user");
@@ -189,4 +191,4 @@
assertEquals(keyInfoList.getLength(), 2);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/ReferenceListTest.java b/src/test/java/org/apache/xml/security/test/dom/encryption/ReferenceListTest.java
index b2b88eb..9ceca17 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/ReferenceListTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/ReferenceListTest.java
@@ -18,9 +18,12 @@
*/
package org.apache.xml.security.test.dom.encryption;
+import static org.junit.Assert.*;
import java.util.Iterator;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.encryption.Reference;
import org.apache.xml.security.encryption.ReferenceList;
import org.apache.xml.security.encryption.XMLCipher;
@@ -29,24 +32,21 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-
-
public class ReferenceListTest {
static org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(ReferenceListTest.class);
+ private DocumentBuilder db;
public ReferenceListTest() throws Exception {
org.apache.xml.security.Init.init();
+ db = XMLUtils.createDocumentBuilder(false);
}
@org.junit.Test
public void testReferenceList() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
XMLCipher dataCipher = XMLCipher.getInstance();
dataCipher.init(XMLCipher.DECRYPT_MODE, null);
@@ -104,7 +104,7 @@
ref = iter.next();
assertEquals(EncryptionConstants._TAG_DATAREFERENCE, ref.getType());
assertEquals("#id2", ref.getURI());
- assertFalse(iter.hasNext());
+ assertTrue(!iter.hasNext());
iter = keyRefList.getReferences();
ref = iter.next();
@@ -113,6 +113,6 @@
ref = iter.next();
assertEquals(EncryptionConstants._TAG_KEYREFERENCE, ref.getType());
assertEquals("#id20", ref.getURI());
- assertFalse(iter.hasNext());
+ assertTrue(!iter.hasNext());
}
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/SignedEncryptedTest.java b/src/test/java/org/apache/xml/security/test/dom/encryption/SignedEncryptedTest.java
index a018830..079402f 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/SignedEncryptedTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/SignedEncryptedTest.java
@@ -26,6 +26,7 @@
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -33,6 +34,7 @@
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.transform.TransformerFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
@@ -47,11 +49,9 @@
import java.security.PublicKey;
import java.util.UUID;
-import static org.junit.Assert.assertTrue;
-
/**
*/
-public class SignedEncryptedTest {
+public class SignedEncryptedTest extends Assert {
private static final String SAMPLE_MSG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<SOAP-ENV:Envelope "
@@ -100,9 +100,10 @@
}
public void secureAndVerify(TransformerFactory transformerFactory, boolean useDocumentSerializer) throws Exception {
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
Document document = null;
try (InputStream is = new ByteArrayInputStream(SAMPLE_MSG.getBytes(StandardCharsets.UTF_8))) {
- document = XMLUtils.read(is, false);
+ document = builder.parse(is);
}
// Set up the Key
@@ -156,6 +157,6 @@
deCipher.doFinal(document, element, true);
XMLSignature xmlSignatureVerifier = new XMLSignature(sigElement, "");
- assertTrue(xmlSignatureVerifier.checkSignatureValue(pub));
+ Assert.assertTrue(xmlSignatureVerifier.checkSignatureValue(pub));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java b/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java
index 3f11545..8eb1537 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/XMLCipherTest.java
@@ -18,13 +18,11 @@
*/
package org.apache.xml.security.test.dom.encryption;
+import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.Key;
@@ -41,7 +39,7 @@
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.SecretKeySpec;
-import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.algorithms.JCEMapper;
import org.apache.xml.security.c14n.Canonicalizer;
@@ -61,12 +59,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
/**
*
@@ -633,7 +625,9 @@
public void testSameDocumentCipherReference() throws Exception {
if (haveISOPadding) {
- Document d = XMLUtils.newDocument();
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+
+ Document d = db.newDocument();
Element docElement = d.createElement("EncryptedDoc");
d.appendChild(docElement);
@@ -704,6 +698,8 @@
public void testPhysicalRepresentation() throws Exception {
if (haveISOPadding) {
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+
byte[] bits192 = "abcdefghijklmnopqrstuvwx".getBytes();
DESedeKeySpec keySpec = new DESedeKeySpec(bits192);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede");
@@ -714,7 +710,7 @@
final String DATA1 = "<ns:root xmlns:ns=\"ns.com\"><ns:elem xmlns:ns2=\"ns2.com\">11</ns:elem></ns:root>";
Document doc = null;
try (InputStream is = new ByteArrayInputStream(DATA1.getBytes(StandardCharsets.UTF_8))) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
Element elem = (Element)doc.getDocumentElement().getFirstChild();
@@ -740,7 +736,7 @@
// Test default namespace undeclaration is preserved
final String DATA2 = "<ns:root xmlns=\"defns.com\" xmlns:ns=\"ns.com\"><elem xmlns=\"\">11</elem></ns:root>";
try (InputStream is = new ByteArrayInputStream(DATA2.getBytes(StandardCharsets.UTF_8))) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
elem = (Element)doc.getDocumentElement().getFirstChild();
@@ -767,9 +763,9 @@
// Other c14n algorithms add a newline after comments and PIs, when they are before or after the document element.
final String DATA3 = "<root><!--comment1--><?pi1 target1?><elem/><!--comment2--><?pi2 target2?></root>";
try (InputStream is = new ByteArrayInputStream(DATA3.getBytes(StandardCharsets.UTF_8))) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
- elem = doc.getDocumentElement();
+ elem = (Element)doc.getDocumentElement();
dataCipher = XMLCipher.getInstance(XMLCipher.TRIPLEDES);
dataCipher.init(XMLCipher.ENCRYPT_MODE, secretKey);
@@ -864,7 +860,8 @@
}
File f = new File(filename);
- Document document = XMLUtils.read(new FileInputStream(f), false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(f);
XMLCipher keyCipher = XMLCipher.getInstance();
keyCipher.init(XMLCipher.UNWRAP_MODE, null);
@@ -984,9 +981,18 @@
return baos.toString(StandardCharsets.UTF_8.name());
}
- private Document document() throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
- File f = new File(documentName);
- return XMLUtils.read(new FileInputStream(f), false);
+ private Document document() {
+ Document d = null;
+ try {
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ File f = new File(documentName);
+ d = db.parse(f);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ return d;
}
private String element() {
@@ -994,7 +1000,16 @@
}
private int index() {
- return Integer.parseInt(elementIndex);
+ int result = -1;
+
+ try {
+ result = Integer.parseInt(elementIndex);
+ } catch (NumberFormatException nfe) {
+ nfe.printStackTrace();
+ System.exit(-1);
+ }
+
+ return result;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java b/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java
index c8d5629..ad16b04 100644
--- a/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java
+++ b/src/test/java/org/apache/xml/security/test/dom/encryption/XMLEncryption11Test.java
@@ -32,6 +32,7 @@
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
@@ -52,10 +53,8 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
/**
* This is a set of tests that use the test vectors associated with the W3C XML Encryption 1.1 specification:
*
@@ -88,7 +87,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
cardNumber = retrieveCCNumber(doc);
@@ -183,7 +183,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
Key sessionKey = getSessionKey("http://www.w3.org/2009/xmlenc11#aes128-gcm");
EncryptedKey encryptedKey =
@@ -247,7 +248,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
Key sessionKey = getSessionKey("http://www.w3.org/2009/xmlenc11#aes128-gcm");
EncryptedKey encryptedKey =
@@ -349,7 +351,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
Key sessionKey = getSessionKey("http://www.w3.org/2009/xmlenc11#aes192-gcm");
EncryptedKey encryptedKey =
@@ -450,7 +453,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
Key sessionKey = getSessionKey("http://www.w3.org/2009/xmlenc11#aes256-gcm");
EncryptedKey encryptedKey =
@@ -551,7 +555,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
Key sessionKey = getSessionKey("http://www.w3.org/2009/xmlenc11#aes256-gcm");
EncryptedKey encryptedKey =
@@ -603,7 +608,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
return decryptElement(doc, rsaKey, rsaCert);
}
@@ -635,7 +641,7 @@
X509Data certData = kiek.itemX509Data(0);
XMLX509Certificate xcert = certData.itemCertificate(0);
X509Certificate cert = xcert.getX509Certificate();
- assertEquals(rsaCert, cert);
+ assertTrue(rsaCert.equals(cert));
XMLCipher cipher2 = XMLCipher.getInstance();
cipher2.init(XMLCipher.UNWRAP_MODE, rsaKey);
@@ -801,7 +807,7 @@
String cc = retrieveCCNumber(d);
LOG.debug("Retrieved Credit Card : " + cc);
- assertEquals(cardNumber, cc);
+ assertTrue(cc, cc!= null && cc.equals(cardNumber));
// Test cc numbers
if (doNodeCheck) {
@@ -813,4 +819,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/interop/BaltimoreTest.java b/src/test/java/org/apache/xml/security/test/dom/interop/BaltimoreTest.java
index 3c99c9f..7db5e3d 100644
--- a/src/test/java/org/apache/xml/security/test/dom/interop/BaltimoreTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/interop/BaltimoreTest.java
@@ -21,16 +21,12 @@
import org.apache.xml.security.test.dom.utils.resolver.OfflineResolver;
import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
+import static org.junit.Assert.*;
import java.nio.charset.StandardCharsets;
import org.apache.xml.security.signature.XMLSignatureException;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This test is to ensure interoperability with the examples provided by Merlin Huges
* from Baltimore using KeyTools XML. These test vectors are located in the directory
@@ -107,7 +103,7 @@
LOG.error("Verification crashed for " + filename);
throw ex;
} catch (XMLSignatureException ex) {
- if (!"algorithms.HMACOutputLengthMin".equals(ex.getMsgID())) {
+ if (!ex.getMsgID().equals("algorithms.HMACOutputLengthMin")) {
fail(ex.getMessage());
}
}
@@ -373,7 +369,7 @@
LOG.error("Verification crashed for " + filename);
throw ex;
} catch (XMLSignatureException ex) {
- if (!"algorithms.HMACOutputLengthMin".equals(ex.getMsgID())) {
+ if (!ex.getMsgID().equals("algorithms.HMACOutputLengthMin")) {
fail(ex.getMessage());
}
}
@@ -569,4 +565,4 @@
assertTrue(filename, verify);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/interop/IAIKTest.java b/src/test/java/org/apache/xml/security/test/dom/interop/IAIKTest.java
index 3844cb9..4b31bf5 100644
--- a/src/test/java/org/apache/xml/security/test/dom/interop/IAIKTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/interop/IAIKTest.java
@@ -20,6 +20,7 @@
import org.apache.xml.security.test.dom.utils.resolver.OfflineResolver;
+import static org.junit.Assert.*;
import java.nio.charset.StandardCharsets;
@@ -27,10 +28,6 @@
import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
import org.apache.xml.security.utils.resolver.implementations.ResolverAnonymous;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This test is to ensure interoperability with the examples provided by the IAIK
* XML Signature implementation. Thanks to Gregor Karlinger who provided these
@@ -83,7 +80,7 @@
LOG.error("Verification crashed for " + filename);
throw ex;
} catch (XMLSignatureException ex) {
- if (!"algorithms.HMACOutputLengthMin".equals(ex.getMsgID())) {
+ if (!ex.getMsgID().equals("algorithms.HMACOutputLengthMin")) {
fail(ex.getMessage());
}
}
@@ -411,4 +408,4 @@
assertTrue(filename, verify);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/interop/IBMTest.java b/src/test/java/org/apache/xml/security/test/dom/interop/IBMTest.java
index 5ac8e07..2f57aaf 100644
--- a/src/test/java/org/apache/xml/security/test/dom/interop/IBMTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/interop/IBMTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.interop;
+import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -25,9 +26,6 @@
import org.apache.xml.security.utils.JavaUtils;
import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
/**
* This test is to ensure interoperability with the examples provided by the IBM
@@ -310,7 +308,7 @@
LOG.error("Verification failed for " + filename + ", had to be broken but was successful");
}
- assertFalse(filename, verify);
+ assertTrue(filename, !verify);
}
/**
diff --git a/src/test/java/org/apache/xml/security/test/dom/interop/InteropTestBase.java b/src/test/java/org/apache/xml/security/test/dom/interop/InteropTestBase.java
index e483347..a2e6541 100644
--- a/src/test/java/org/apache/xml/security/test/dom/interop/InteropTestBase.java
+++ b/src/test/java/org/apache/xml/security/test/dom/interop/InteropTestBase.java
@@ -19,7 +19,6 @@
package org.apache.xml.security.test.dom.interop;
import java.io.File;
-import java.io.FileInputStream;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.Iterator;
@@ -41,9 +40,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
+import static org.junit.Assert.*;
public class InteropTestBase {
@@ -63,7 +60,8 @@
String filename, ResourceResolverSpi resolver, boolean followManifests, byte[] hmacKey
) throws Exception {
File f = new File(filename);
- org.w3c.dom.Document doc = XMLUtils.read(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(new java.io.FileInputStream(f));
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
@@ -79,7 +77,7 @@
}
signature.setFollowNestedManifests(followManifests);
- byte[] keybytes = hmacKey;
+ byte keybytes[] = hmacKey;
javax.crypto.SecretKey sk = signature.createSecretKey(keybytes);
return signature.checkSignatureValue(sk);
@@ -94,7 +92,8 @@
boolean followManifests, boolean secureValidation)
throws Exception {
File f = new File(filename);
- org.w3c.dom.Document doc = XMLUtils.read(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(f);
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
@@ -178,4 +177,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/interop/RSASecurityTest.java b/src/test/java/org/apache/xml/security/test/dom/interop/RSASecurityTest.java
index baf175a..e96cd17 100644
--- a/src/test/java/org/apache/xml/security/test/dom/interop/RSASecurityTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/interop/RSASecurityTest.java
@@ -19,11 +19,10 @@
package org.apache.xml.security.test.dom.interop;
+import static org.junit.Assert.assertTrue;
import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
-import static org.junit.Assert.assertTrue;
-
/**
* This test is to ensure interoperability with the examples provided by Blake Dournaee
@@ -86,4 +85,4 @@
assertTrue(filename, verify);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java
index caa0c52..460e33b 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/DEREncodedKeyValueTest.java
@@ -23,32 +23,33 @@
import java.security.PublicKey;
import java.security.spec.X509EncodedKeySpec;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.keys.content.DEREncodedKeyValue;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.JavaUtils;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
-public class DEREncodedKeyValueTest {
+public class DEREncodedKeyValueTest extends Assert {
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
- private static final String ID_CONTROL = "abc123";
+ private DocumentBuilder documentBuilder;
private PublicKey rsaKeyControl;
private PublicKey dsaKeyControl;
private PublicKey ecKeyControl;
+ private final String idControl = "abc123";
+
public DEREncodedKeyValueTest() throws Exception {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+
rsaKeyControl = loadPublicKey("rsa.key", "RSA");
dsaKeyControl = loadPublicKey("dsa.key", "DSA");
ecKeyControl = loadPublicKey("ec.key", "EC");
@@ -56,7 +57,7 @@
@org.junit.Test
public void testSchema() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), rsaKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), rsaKeyControl);
Element element = derEncodedKeyValue.getElement();
assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
@@ -72,7 +73,7 @@
DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(element, "");
assertEquals(rsaKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(rsaKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
- assertEquals(ID_CONTROL, derEncodedKeyValue.getId());
+ assertEquals(idControl, derEncodedKeyValue.getId());
}
@org.junit.Test
@@ -84,7 +85,7 @@
DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(element, "");
assertEquals(dsaKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(dsaKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
- assertEquals(ID_CONTROL, derEncodedKeyValue.getId());
+ assertEquals(idControl, derEncodedKeyValue.getId());
}
@org.junit.Test
@@ -96,38 +97,38 @@
DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(element, "");
assertEquals(ecKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(ecKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
- assertEquals(ID_CONTROL, derEncodedKeyValue.getId());
+ assertEquals(idControl, derEncodedKeyValue.getId());
}
@org.junit.Test
public void testRSAPublicKeyFromKey() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), rsaKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), rsaKeyControl);
assertEquals(rsaKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(rsaKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
}
@org.junit.Test
public void testDSAPublicKeyFromKey() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), dsaKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), dsaKeyControl);
assertEquals(dsaKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(dsaKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
}
@org.junit.Test
public void testECPublicKeyFromKey() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), ecKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), ecKeyControl);
assertEquals(ecKeyControl, derEncodedKeyValue.getPublicKey());
assertArrayEquals(ecKeyControl.getEncoded(), derEncodedKeyValue.getBytesFromTextChild());
}
@org.junit.Test
public void testId() throws Exception {
- DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(XMLUtils.newDocument(), rsaKeyControl);
+ DEREncodedKeyValue derEncodedKeyValue = new DEREncodedKeyValue(documentBuilder.newDocument(), rsaKeyControl);
assertEquals("", derEncodedKeyValue.getId());
assertNull(derEncodedKeyValue.getElement().getAttributeNodeNS(null, Constants._ATT_ID));
- derEncodedKeyValue.setId(ID_CONTROL);
- assertEquals(ID_CONTROL, derEncodedKeyValue.getId());
+ derEncodedKeyValue.setId(idControl);
+ assertEquals(idControl, derEncodedKeyValue.getId());
assertTrue(derEncodedKeyValue.getElement().getAttributeNodeNS(null, Constants._ATT_ID).isId());
derEncodedKeyValue.setId(null);
@@ -145,7 +146,7 @@
}
private Document loadXML(String fileName) throws Exception {
- return XMLUtils.read(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
private PublicKey loadPublicKey(String filePath, String algorithm) throws Exception {
@@ -156,4 +157,4 @@
return kf.generatePublic(keySpec);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/KeyInfoReferenceTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/KeyInfoReferenceTest.java
index e4282b5..7c6f489 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/KeyInfoReferenceTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/KeyInfoReferenceTest.java
@@ -20,29 +20,33 @@
import java.io.FileInputStream;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.keys.content.KeyInfoReference;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
-public class KeyInfoReferenceTest {
+public class KeyInfoReferenceTest extends Assert {
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
- private static final String ID_CONTROL = "abc123";
- private static final String URI_CONTROL = "http://www.example.org/keyinfo.xml";
+ private DocumentBuilder documentBuilder;
+
+ private final String idControl = "abc123";
+ private final String uriControl = "http://www.example.org/keyinfo.xml";
+
+ public KeyInfoReferenceTest() throws Exception {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+ }
@org.junit.Test
public void testSchema() throws Exception {
- KeyInfoReference keyInfoReference = new KeyInfoReference(XMLUtils.newDocument(), URI_CONTROL);
+ KeyInfoReference keyInfoReference = new KeyInfoReference(documentBuilder.newDocument(), uriControl);
Element element = keyInfoReference.getElement();
assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
@@ -56,24 +60,24 @@
Element element = (Element) nl.item(0);
KeyInfoReference keyInfoReference = new KeyInfoReference(element, "");
- assertEquals(URI_CONTROL, keyInfoReference.getURI());
- assertEquals(ID_CONTROL, keyInfoReference.getId());
+ assertEquals(uriControl, keyInfoReference.getURI());
+ assertEquals(idControl, keyInfoReference.getId());
}
@org.junit.Test
public void testURIOnConstruction() throws Exception {
- KeyInfoReference keyInfoReference = new KeyInfoReference(XMLUtils.newDocument(), URI_CONTROL);
- assertEquals(URI_CONTROL, keyInfoReference.getURI());
+ KeyInfoReference keyInfoReference = new KeyInfoReference(documentBuilder.newDocument(), uriControl);
+ assertEquals(uriControl, keyInfoReference.getURI());
}
@org.junit.Test
public void testId() throws Exception {
- KeyInfoReference keyInfoReference = new KeyInfoReference(XMLUtils.newDocument(), URI_CONTROL);
+ KeyInfoReference keyInfoReference = new KeyInfoReference(documentBuilder.newDocument(), uriControl);
assertEquals("", keyInfoReference.getId());
assertNull(keyInfoReference.getElement().getAttributeNodeNS(null, Constants._ATT_ID));
- keyInfoReference.setId(ID_CONTROL);
- assertEquals(ID_CONTROL, keyInfoReference.getId());
+ keyInfoReference.setId(idControl);
+ assertEquals(idControl, keyInfoReference.getId());
assertTrue(keyInfoReference.getElement().getAttributeNodeNS(null, Constants._ATT_ID).isId());
keyInfoReference.setId(null);
@@ -91,7 +95,7 @@
}
private Document loadXML(String fileName) throws Exception {
- return XMLUtils.read(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509CertificateTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509CertificateTest.java
index cc321e5..e990354 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509CertificateTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509CertificateTest.java
@@ -45,7 +45,7 @@
SEP + "signature-x509-crt.xml");
FileInputStream fis = new FileInputStream(f);
- Document doc = XMLUtils.read(fis, false);
+ Document doc = XMLUtils.createDocumentBuilder(false).parse(fis);
NodeList nl = doc.getElementsByTagNameNS
(Constants.SignatureSpecNS, "X509Certificate");
XMLX509Certificate xmlCert =
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java
index 7b14e4e..abf859a 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509DigestTest.java
@@ -22,33 +22,37 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.keys.content.x509.XMLX509Digest;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-
-public class XMLX509DigestTest {
+public class XMLX509DigestTest extends Assert {
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
- private static final String ALG_URI_CONTROL = "http://www.w3.org/2001/04/xmlenc#sha256";
- private static final String DIGEST_B64_CONTROL = "jToLQ/K7aaLHy/aXLFnjEfCwSQd9z0MrBOH6Ru/aJyY=";
+ private DocumentBuilder documentBuilder;
private X509Certificate certControl;
+
+ private final String algorithmURIControl = "http://www.w3.org/2001/04/xmlenc#sha256";
+
+ private final String digestBase64Control = "jToLQ/K7aaLHy/aXLFnjEfCwSQd9z0MrBOH6Ru/aJyY=";
private final byte[] digestControl;
public XMLX509DigestTest() throws Exception {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+
certControl = loadCertificate("cert-X509Digest.crt");
- digestControl = XMLUtils.decode(DIGEST_B64_CONTROL);
+ digestControl = XMLUtils.decode(digestBase64Control);
if (!Init.isInitialized()) {
Init.init();
@@ -57,7 +61,7 @@
@org.junit.Test
public void testSchema() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(), digestControl, ALG_URI_CONTROL);
+ XMLX509Digest x509Digest = new XMLX509Digest(documentBuilder.newDocument(), digestControl, algorithmURIControl);
Element element = x509Digest.getElement();
assertEquals("http://www.w3.org/2009/xmldsig11#", element.getNamespaceURI());
@@ -71,27 +75,27 @@
Element element = (Element) nl.item(0);
XMLX509Digest x509Digest = new XMLX509Digest(element, "");
- assertEquals(ALG_URI_CONTROL, x509Digest.getAlgorithm());
+ assertEquals(algorithmURIControl, x509Digest.getAlgorithm());
assertArrayEquals(digestControl, x509Digest.getDigestBytes());
}
@org.junit.Test
public void testDigestOnConstructionWithCert() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(), certControl, ALG_URI_CONTROL);
- assertEquals(ALG_URI_CONTROL, x509Digest.getAlgorithm());
+ XMLX509Digest x509Digest = new XMLX509Digest(documentBuilder.newDocument(), certControl, algorithmURIControl);
+ assertEquals(algorithmURIControl, x509Digest.getAlgorithm());
assertArrayEquals(digestControl, x509Digest.getDigestBytes());
}
@org.junit.Test
public void testDigestOnConstructionWithBytes() throws Exception {
- XMLX509Digest x509Digest = new XMLX509Digest(XMLUtils.newDocument(), digestControl, ALG_URI_CONTROL);
- assertEquals(ALG_URI_CONTROL, x509Digest.getAlgorithm());
+ XMLX509Digest x509Digest = new XMLX509Digest(documentBuilder.newDocument(), digestControl, algorithmURIControl);
+ assertEquals(algorithmURIControl, x509Digest.getAlgorithm());
assertArrayEquals(digestControl, x509Digest.getDigestBytes());
}
@org.junit.Test
public void testGetDigestBytesFromCert() throws Exception {
- assertArrayEquals(digestControl, XMLX509Digest.getDigestBytesFromCert(certControl, ALG_URI_CONTROL));
+ assertArrayEquals(digestControl, XMLX509Digest.getDigestBytesFromCert(certControl, algorithmURIControl));
}
@@ -105,7 +109,7 @@
}
private Document loadXML(String fileName) throws Exception {
- return XMLUtils.read(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
private X509Certificate loadCertificate(String fileName) throws Exception {
@@ -114,4 +118,4 @@
return (X509Certificate) certFactory.generateCertificate(fis);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java
index 1dde17a..619e641 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509IssuerSerialTest.java
@@ -18,13 +18,12 @@
*/
package org.apache.xml.security.test.dom.keys.content.x509;
+import static org.junit.Assert.assertEquals;
import org.apache.xml.security.keys.content.x509.XMLX509IssuerSerial;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertEquals;
-
/**
* XMLX509IssuerSerial tests.
*
@@ -34,7 +33,7 @@
private Document doc;
public XMLX509IssuerSerialTest() throws Exception {
- doc = XMLUtils.newDocument();
+ doc = XMLUtils.createDocumentBuilder(false).newDocument();
}
@org.junit.Test
@@ -50,4 +49,4 @@
assertEquals("CN=\\#abc123", is.getIssuerName());
// System.out.println(is.getIssuerName());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509SKITest.java b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509SKITest.java
index 4a753e1..f534c71 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509SKITest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/content/x509/XMLX509SKITest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.keys.content.x509;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
@@ -31,8 +32,6 @@
import org.apache.xml.security.keys.content.x509.XMLX509SKI;
-import static org.junit.Assert.assertFalse;
-
/**
* Test bugfix 41892: XML Security 1.4.0 does not build with IBM's JDK
*/
@@ -78,6 +77,6 @@
new CollectionCertStoreParameters(Collections.singleton(cert)));
Collection<?> certs = cs.getCertificates(xcs);
- assertFalse(certs.isEmpty());
+ assertTrue(!certs.isEmpty());
}
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java
index 19b1458..060163b 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/DEREncodedKeyValueResolverTest.java
@@ -25,12 +25,12 @@
import org.apache.xml.security.Init;
import org.apache.xml.security.keys.KeyInfo;
+import org.junit.Assert;
import static org.apache.xml.security.test.stax.utils.KeyLoader.loadPublicKey;
import static org.apache.xml.security.test.stax.utils.KeyLoader.loadXML;
-import static org.junit.Assert.assertEquals;
-public class DEREncodedKeyValueResolverTest {
+public class DEREncodedKeyValueResolverTest extends Assert {
private PublicKey rsaKeyControl;
private PublicKey dsaKeyControl;
@@ -73,4 +73,4 @@
KeyInfo keyInfo = new KeyInfo(element, "");
assertEquals(ecKeyControl, keyInfo.getPublicKey());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyInfoReferenceResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyInfoReferenceResolverTest.java
index fad83c7..c58c794 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyInfoReferenceResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyInfoReferenceResolverTest.java
@@ -25,26 +25,28 @@
import java.security.cert.X509Certificate;
import java.security.spec.X509EncodedKeySpec;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.JavaUtils;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-
-public class KeyInfoReferenceResolverTest {
+public class KeyInfoReferenceResolverTest extends Assert {
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
+ private DocumentBuilder documentBuilder;
+
public KeyInfoReferenceResolverTest() throws Exception {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+
if (!Init.isInitialized()) {
Init.init();
}
@@ -135,7 +137,7 @@
}
private Document loadXML(String fileName) throws Exception {
- return XMLUtils.read(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
private PublicKey loadPublicKey(String filePath, String algorithm) throws Exception {
@@ -160,4 +162,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java
index f1cf884..4fb6c5f 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/KeyResolverTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.keys.keyresolver;
+import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.math.BigInteger;
@@ -36,6 +37,7 @@
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import org.apache.xml.security.algorithms.JCEMapper;
import org.apache.xml.security.encryption.EncryptedData;
@@ -61,10 +63,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Text;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-
/**
* KeyResolver test.
*/
@@ -109,7 +107,8 @@
KeyResolverSpi privateKeyResolver = new PrivateKeyResolver(ks, pwd);
KeyResolverSpi secretKeyResolver = new SecretKeyResolver(ks, pwd);
- Document doc = XMLUtils.newDocument();
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
KeyInfo ki;
X509Data x509data;
@@ -219,7 +218,7 @@
}
// Create a sample XML document
- Document document = XMLUtils.newDocument();
+ Document document = XMLUtils.createDocumentBuilder(false).newDocument();
Element rootElement = document.createElement("root");
document.appendChild(rootElement);
@@ -339,4 +338,4 @@
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/RetrievalMethodResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/RetrievalMethodResolverTest.java
index 26949d2..e9b99c5 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/RetrievalMethodResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/RetrievalMethodResolverTest.java
@@ -21,6 +21,8 @@
import java.io.FileInputStream;
import java.security.Security;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.utils.XMLUtils;
@@ -50,7 +52,8 @@
fis = new FileInputStream(filename);
}
- Document doc = XMLUtils.read(fis, false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(fis);
KeyInfo keyInfo = new KeyInfo(doc.getDocumentElement(), null);
@@ -69,7 +72,8 @@
fis = new FileInputStream(filename);
}
- Document doc = XMLUtils.read(fis, false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(fis);
KeyInfo keyInfo = new KeyInfo(doc.getDocumentElement(), null);
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/X509DigestResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/X509DigestResolverTest.java
index 1c70fea..42fe4d5 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/X509DigestResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/keyresolver/X509DigestResolverTest.java
@@ -22,28 +22,31 @@
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.keys.storage.StorageResolver;
import org.apache.xml.security.keys.storage.implementations.SingleCertificateResolver;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-
-public class X509DigestResolverTest {
+public class X509DigestResolverTest extends Assert {
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
+ private DocumentBuilder documentBuilder;
+
private X509Certificate certControl;
private StorageResolver storageResolver;
public X509DigestResolverTest() throws Exception {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+
certControl = loadCertificate("cert-X509Digest.crt");
storageResolver = new StorageResolver(new SingleCertificateResolver(certControl));
@@ -80,7 +83,7 @@
}
private Document loadXML(String fileName) throws Exception {
- return XMLUtils.read(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
private X509Certificate loadCertificate(String fileName) throws Exception {
@@ -89,4 +92,4 @@
return (X509Certificate) certFactory.generateCertificate(fis);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/storage/KeyStoreResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/storage/KeyStoreResolverTest.java
index 2e0a28d..234462d 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/storage/KeyStoreResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/storage/KeyStoreResolverTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.keys.storage;
+import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.security.KeyStore;
@@ -27,11 +28,6 @@
import org.apache.xml.security.keys.storage.implementations.KeyStoreResolver;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
-
/**
* KeyStore StorageResolver test.
*/
@@ -104,4 +100,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/keys/storage/StorageResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/keys/storage/StorageResolverTest.java
index 57b1fd2..795df00 100644
--- a/src/test/java/org/apache/xml/security/test/dom/keys/storage/StorageResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/keys/storage/StorageResolverTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.keys.storage;
+import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.security.KeyStore;
@@ -27,11 +28,6 @@
import org.apache.xml.security.keys.storage.StorageResolver;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
-
/**
* KeyStore StorageResolver test.
*/
@@ -109,4 +105,5 @@
//
}
}
-}
\ No newline at end of file
+}
+
diff --git a/src/test/java/org/apache/xml/security/test/dom/resource/TestVectorResolver.java b/src/test/java/org/apache/xml/security/test/dom/resource/TestVectorResolver.java
new file mode 100644
index 0000000..69a60c6
--- /dev/null
+++ b/src/test/java/org/apache/xml/security/test/dom/resource/TestVectorResolver.java
@@ -0,0 +1,201 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.xml.security.test.dom.resource;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+/**
+ * This package is responsible for retrieving test vectors for our unit tests.
+ *
+ * $todo$ Currently, the test vectors are in the file system under the data/ directory.
+ * It is planned to put them all into a single jar/zip which is deployed with the library.
+ */
+public class TestVectorResolver implements EntityResolver {
+
+ static org.slf4j.Logger LOG =
+ org.slf4j.LoggerFactory.getLogger(TestVectorResolver.class);
+
+ /** Field alreadyInitialized */
+ static boolean alreadyInitialized = false;
+
+ /** Field zis */
+ static java.util.zip.ZipInputStream zis = null;
+
+ /** Field vectors */
+ static java.util.Map<String, byte[]> vectors = null;
+
+ static {
+ org.apache.xml.security.Init.init();
+ TestVectorResolver.init();
+ }
+
+ /** Field _firstEntityResolved */
+ boolean _firstEntityResolved = false;
+
+ /** Field _firstEntitySystemId */
+ String _firstEntitySystemIdDirectory = null;
+
+ /**
+ * Method init
+ *
+ */
+ public static void init() {
+ String thisClass =
+ "org.apache.xml.security.test.resource.TestVectorResolver";
+ String testVectorFile = "testvectors.zip";
+
+ if (!TestVectorResolver.alreadyInitialized) {
+ TestVectorResolver.alreadyInitialized = true;
+ TestVectorResolver.vectors = new java.util.HashMap<String, byte[]>(30);
+
+ try {
+ zis =
+ new java.util.zip.ZipInputStream(
+ Class.forName(thisClass).getResourceAsStream(testVectorFile)
+ );
+
+ java.util.zip.ZipEntry ze = null;
+ while ((ze = zis.getNextEntry()) != null) {
+ if (!ze.isDirectory()) {
+ byte data[] =
+ org.apache.xml.security.utils.JavaUtils.getBytesFromStream(zis);
+
+ TestVectorResolver.vectors.put(ze.getName(), data);
+ LOG.debug("Contents of " + thisClass + "/" + testVectorFile
+ + "#" + ze.getName() + " " + data.length + " bytes");
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ //
+ }
+ catch (IOException e) {
+ //
+ }
+ }
+ }
+
+ /**
+ * Method getCurrentDir
+ *
+ *
+ * @throws IOException
+ */
+ private String getCurrentDir() throws IOException {
+
+ String currentDir = new File(".").getCanonicalPath();
+
+ currentDir = currentDir.replace(File.separatorChar, '/');
+ currentDir = "file:///" + currentDir + "/";
+
+ return currentDir;
+ }
+
+ /**
+ * Method getFileName
+ *
+ * @param systemId
+ *
+ * @throws IOException
+ */
+ private String getFileName(String systemId) throws IOException {
+
+ // clean up file name
+ String currentDir = getCurrentDir();
+
+ if (systemId.startsWith(currentDir)) {
+ return systemId.substring(currentDir.length());
+ } else {
+ return systemId;
+ }
+ }
+
+ /**
+ * Method getFilePath
+ *
+ * @param systemId
+ *
+ * @throws IOException
+ */
+ private String getFilePath(String systemId) throws IOException {
+
+ String t = new File(systemId).getCanonicalPath();
+
+ t = t.replace(File.separatorChar, '/');
+ t = "file:///" + t;
+
+ String currentDir = getCurrentDir();
+
+ if (t.startsWith(currentDir)) {
+ t = t.substring(currentDir.length());
+ }
+
+ t = t.substring(0, t.lastIndexOf("/"));
+
+ return t;
+ }
+
+ /**
+ * Method set1stSystemId
+ *
+ * @param systemId
+ * @throws IOException
+ */
+ private void set1stSystemId(String systemId) throws IOException {
+
+ this._firstEntitySystemIdDirectory = getFilePath(systemId);
+
+ LOG.debug("this._firstEntitySystemIdDirectory = "
+ + this._firstEntitySystemIdDirectory);
+ }
+
+ /**
+ * Method resolveEntity
+ *
+ * @param publicId
+ * @param systemId
+ *
+ */
+ public InputSource resolveEntity(String publicId, String systemId) {
+ try {
+ if (!this._firstEntityResolved) {
+ this.set1stSystemId(systemId);
+ }
+
+ systemId = this.getFileName(systemId);
+
+ LOG.debug("publicId=\"" + publicId + "\" systemId=\"" + systemId
+ + "\"");
+
+ // InputStream result = this.getInputStream(systemId);
+ // return new InputSource(result);
+ return new InputSource(new FileInputStream(systemId));
+ } catch (FileNotFoundException ex) {
+ return null;
+ } catch (IOException ex) {
+ return null;
+ }
+ }
+
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenAlgorithmTest.java b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenAlgorithmTest.java
index 06daae6..9000360 100644
--- a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenAlgorithmTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenAlgorithmTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.xml.security.test.dom.secure_val;
+import static org.junit.Assert.*;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
@@ -29,11 +29,6 @@
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a test for a forbidden algorithm (MD5) when secure validation is enabled.
@@ -64,7 +59,7 @@
} catch (XMLSignatureException ex) {
String error = "It is forbidden to use algorithm http://www.w3.org/2001/04/xmldsig-more#md5 "
+ "when secure validation is enabled";
- assertEquals(ex.getMessage(), error);
+ assertTrue(ex.getMessage().equals(error));
}
}
@@ -78,7 +73,8 @@
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.read(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(f);
Element sigElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
@@ -87,4 +83,4 @@
return signature.checkSignatureValue(signature.getKeyInfo().getPublicKey());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java
index ed8d40f..731fc74 100644
--- a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRefCountTest.java
@@ -18,41 +18,23 @@
*/
package org.apache.xml.security.test.dom.secure_val;
+import static org.junit.Assert.*;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.security.KeyStore;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.util.Enumeration;
-
-import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.signature.XMLSignature;
-import org.apache.xml.security.signature.XMLSignatureException;
+import org.apache.xml.security.signature.Manifest;
import org.apache.xml.security.test.dom.interop.InteropTestBase;
-import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
/**
* This is a test for a forbidden number of references when secure validation is enabled.
*/
public class ForbiddenRefCountTest extends InteropTestBase {
- private static final String BASEDIR =
- System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
- public static final String KEYSTORE_DIRECTORY = BASEDIR + "/src/test/resources/";
- public static final String KEYSTORE_PASSWORD_STRING = "changeit";
- public static final char[] KEYSTORE_PASSWORD = KEYSTORE_PASSWORD_STRING.toCharArray();
-
static org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(ForbiddenRefCountTest.class);
@@ -66,82 +48,37 @@
@org.junit.Test
public void testReferenceCount() throws Exception {
- Document doc = getOriginalDocument();
- signDocument(doc, 31);
- assertTrue(verifySignature(doc, false));
+ boolean success =
+ readAndVerifyManifest("src/test/resources/interop/c14n/Y4", "signature-manifest.xml", false);
+
+ assertTrue(success);
try {
- verifySignature(doc, true);
+ readAndVerifyManifest("src/test/resources/interop/c14n/Y4", "signature-manifest.xml", true);
fail("Failure expected when secure validation is enabled");
} catch (XMLSecurityException ex) {
assertTrue(ex.getMessage().contains("references are contained in the Manifest"));
}
}
- private Document getOriginalDocument() throws ParserConfigurationException {
- Document doc = XMLUtils.newDocument();
-
- Element rootElement = doc.createElementNS("http://ns.example.org/", "root");
- rootElement.appendChild(doc.createTextNode("Hello World!"));
- doc.appendChild(rootElement);
-
- return doc;
- }
-
- private void signDocument(Document doc, int refCount) throws Exception {
- XMLSignature sig = new XMLSignature(doc, "", XMLSignature.ALGO_ID_SIGNATURE_DSA);
- Element root = doc.getDocumentElement();
- root.appendChild(sig.getElement());
-
- for (int i = 0; i < refCount; i++) {
- Transforms transforms = new Transforms(doc);
- transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
- transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
- sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1);
+ private boolean readAndVerifyManifest(
+ String directory, String file, boolean secValidation
+ ) throws Exception {
+ String basedir = System.getProperty("basedir");
+ if (basedir != null && !"".equals(basedir)) {
+ directory = basedir + "/" + directory;
}
- sig.addKeyInfo(getPublicKey());
- sig.sign(getPrivateKey());
- }
+ File f = new File(directory + "/" + file);
- private boolean verifySignature(Document doc, boolean secValidation) throws XMLSignatureException, XMLSecurityException {
- Element sigElement =
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ org.w3c.dom.Document doc = db.parse(f);
+
+ Element manifestElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
- Constants._TAG_SIGNATURE).item(0);
- XMLSignature signature = new XMLSignature(sigElement, null, secValidation);
- return signature.checkSignatureValue(signature.getKeyInfo().getPublicKey());
+ Constants._TAG_SIGNEDINFO).item(0);
+ Manifest manifest = new Manifest(manifestElement, f.toURI().toURL().toString(), secValidation);
+ return manifest.verifyReferences();
}
- private KeyStore getKeyStore() throws Exception {
- KeyStore ks = KeyStore.getInstance("JKS");
- InputStream ksis = new FileInputStream(KEYSTORE_DIRECTORY + "test.jks");
- ks.load(ksis, KEYSTORE_PASSWORD);
- ksis.close();
- return ks;
- }
-
- private PublicKey getPublicKey() throws Exception {
- KeyStore keyStore = getKeyStore();
- Enumeration<String> aliases = keyStore.aliases();
- while (aliases.hasMoreElements()) {
- String alias = aliases.nextElement();
- if (keyStore.isKeyEntry(alias)) {
- return keyStore.getCertificate(alias).getPublicKey();
- }
- }
- return null;
- }
-
- private PrivateKey getPrivateKey() throws Exception {
- KeyStore keyStore = getKeyStore();
- Enumeration<String> aliases = keyStore.aliases();
- while (aliases.hasMoreElements()) {
- String alias = aliases.nextElement();
- if (keyStore.isKeyEntry(alias)) {
- return (PrivateKey) keyStore.getKey(alias, KEYSTORE_PASSWORD);
- }
- }
- return null;
- }
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenReferenceTest.java b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenReferenceTest.java
index 3bd027d..013a550 100644
--- a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenReferenceTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenReferenceTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.xml.security.test.dom.secure_val;
+import static org.junit.Assert.*;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.xml.security.signature.Manifest;
import org.apache.xml.security.signature.MissingResourceFailureException;
@@ -29,10 +29,6 @@
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a test for a forbidden Reference algorithm when secure validation is enabled.
@@ -75,7 +71,9 @@
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.read(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ org.w3c.dom.Document doc = db.parse(f);
+ XMLUtils.repoolDocumentBuilder(db);
Element manifestElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
@@ -84,4 +82,4 @@
return manifest.verifyReferences();
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRetrievalMethodTest.java b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRetrievalMethodTest.java
index ae1844e..4065d30 100644
--- a/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRetrievalMethodTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/secure_val/ForbiddenRetrievalMethodTest.java
@@ -18,15 +18,16 @@
*/
package org.apache.xml.security.test.dom.secure_val;
+import static org.junit.Assert.assertNull;
import java.io.FileInputStream;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertNull;
-
/**
* This is a test for a Retrieval Method pointing to another Retrieval Method (forbidden under
@@ -51,7 +52,8 @@
fis = new FileInputStream(filename);
}
- Document doc = XMLUtils.read(fis, false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(fis);
KeyInfo keyInfo = new KeyInfo(doc.getDocumentElement(), null);
keyInfo.setSecureValidation(true);
@@ -61,4 +63,4 @@
assertNull(keyInfo.getX509Certificate());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/secure_val/WrappingAttackTest.java b/src/test/java/org/apache/xml/security/test/dom/secure_val/WrappingAttackTest.java
index 5d0b183..b2826ac 100644
--- a/src/test/java/org/apache/xml/security/test/dom/secure_val/WrappingAttackTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/secure_val/WrappingAttackTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.xml.security.test.dom.secure_val;
+import static org.junit.Assert.*;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
@@ -29,10 +29,6 @@
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a test for a wrapping attack.
@@ -80,7 +76,8 @@
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.read(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(f);
Element sigElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
@@ -99,7 +96,8 @@
File f = new File(directory + "/" + file);
- org.w3c.dom.Document doc = XMLUtils.read(new FileInputStream(f), false);
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
+ org.w3c.dom.Document doc = db.parse(f);
Element sigElement =
(Element) doc.getElementsByTagNameNS(Constants.SignatureSpecNS,
@@ -113,4 +111,4 @@
return signature.checkSignatureValue(signature.getKeyInfo().getPublicKey());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java
index 7b1f2e5..646ef3b 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/CreateSignatureTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.signature;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -51,8 +52,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertTrue;
-
/**
* Tests that create signatures.
*
@@ -66,8 +65,10 @@
private static final String SEP = System.getProperty("file.separator");
private KeyPair kp;
+ private javax.xml.parsers.DocumentBuilder db;
public CreateSignatureTest() throws Exception {
+ db = XMLUtils.createDocumentBuilder(false);
org.apache.xml.security.Init.init();
kp = KeyPairGenerator.getInstance("RSA").genKeyPair();
}
@@ -78,7 +79,7 @@
*/
@org.junit.Test
public void testEmptyNodeSet() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
Element envelope = doc.createElementNS("http://www.usps.gov/", "Envelope");
envelope.appendChild(doc.createTextNode("\n"));
doc.appendChild(envelope);
@@ -153,7 +154,7 @@
@org.junit.Test
public void testXFilter2Signature() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -196,7 +197,7 @@
// Now Verify
try (InputStream is = new ByteArrayInputStream(signedDoc.getBytes())) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
XPathFactory xpf = XPathFactory.newInstance();
@@ -217,7 +218,7 @@
Document doc = null;
try (InputStream is = new ByteArrayInputStream(signedXML.getBytes())) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
XPathFactory xpf = XPathFactory.newInstance();
@@ -256,7 +257,7 @@
@org.junit.Test
public void testSHA256Digest() throws Exception {
PrivateKey privateKey = kp.getPrivate();
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -294,7 +295,7 @@
private String doSign() throws Exception {
PrivateKey privateKey = kp.getPrivate();
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -339,7 +340,7 @@
}
ks.load(fis, "changeit".toCharArray());
PrivateKey privateKey = (PrivateKey) ks.getKey("mullan", "changeit".toCharArray());
- Document doc = XMLUtils.newDocument();
+ Document doc = db.newDocument();
X509Certificate signingCert = (X509Certificate) ks.getCertificate("mullan");
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -378,7 +379,7 @@
private void doVerify(String signedXML) throws Exception {
Document doc = null;
try (InputStream is = new ByteArrayInputStream(signedXML.getBytes())) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
XPathFactory xpf = XPathFactory.newInstance();
@@ -403,4 +404,4 @@
assertTrue(signature.checkSignatureValue(pk));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
index 2533be5..2100520 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/ECDSASignatureTest.java
@@ -46,7 +46,6 @@
import static org.junit.Assert.assertTrue;
-
/**
* Tests that creates and verifies ECDSA signatures.
*
@@ -59,11 +58,14 @@
"src/test/resources/org/apache/xml/security/samples/input/ecdsa.jks";
private static final String ECDSA_JKS_PASSWORD = "security";
+ private javax.xml.parsers.DocumentBuilder db;
+
public ECDSASignatureTest() throws Exception {
//String id = "http://apache.org/xml/properties/dom/document-class-name";
//dbf.setAttribute(id, IndexedDocument.class.getName());
+ db = XMLUtils.createDocumentBuilder(false);
org.apache.xml.security.Init.init();
}
@@ -123,7 +125,7 @@
}
private byte[] doSign(PrivateKey privateKey, X509Certificate x509, PublicKey publicKey) throws Exception {
- org.w3c.dom.Document doc = XMLUtils.newDocument();
+ org.w3c.dom.Document doc = db.newDocument();
doc.appendChild(doc.createComment(" Comment before "));
Element root = doc.createElementNS("", "RootElement");
@@ -168,7 +170,7 @@
}
private void doVerify(InputStream is) throws Exception {
- org.w3c.dom.Document doc = XMLUtils.read(is, false);
+ org.w3c.dom.Document doc = this.db.parse(is);
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
@@ -276,4 +278,4 @@
}
*/
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java
index 3bdd180..4887ccb 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/HMACOutputLengthTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.xml.security.test.dom.signature;
+import static org.junit.Assert.fail;
import java.io.File;
-import java.io.FileInputStream;
import java.nio.charset.StandardCharsets;
import javax.crypto.SecretKey;
@@ -35,8 +35,6 @@
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
-import static org.junit.Assert.fail;
-
public class HMACOutputLengthTest {
static org.slf4j.Logger LOG =
@@ -58,7 +56,7 @@
fail("Expected HMACOutputLength exception");
} catch (XMLSignatureException xse) {
// System.out.println(xse.getMessage());
- if (!"algorithms.HMACOutputLengthMin".equals(xse.getMsgID())) {
+ if (!xse.getMsgID().equals("algorithms.HMACOutputLengthMin")) {
fail(xse.getMessage());
}
}
@@ -70,7 +68,7 @@
validate("signature-enveloping-hmac-sha1-trunclen-8-attack.xml");
} catch (XMLSignatureException xse) {
// System.out.println(xse.getMessage());
- if (!"algorithms.HMACOutputLengthMin".equals(xse.getMsgID())) {
+ if (!xse.getMsgID().equals("algorithms.HMACOutputLengthMin")) {
fail(xse.getMessage());
}
}
@@ -78,7 +76,7 @@
@org.junit.Test
public void test_generate_hmac_sha1_40() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
XMLSignature sig =
new XMLSignature(
doc, null, XMLSignature.ALGO_ID_MAC_HMAC_SHA1,
@@ -89,7 +87,7 @@
fail("Expected HMACOutputLength Exception");
} catch (XMLSignatureException xse) {
// System.out.println(xse.getMessage());
- if (!"algorithms.HMACOutputLengthMin".equals(xse.getMsgID())) {
+ if (!xse.getMsgID().equals("algorithms.HMACOutputLengthMin")) {
fail(xse.getMessage());
}
}
@@ -100,7 +98,7 @@
new File(BASEDIR + SEP + "src/test/resources" + SEP + "javax" + SEP + "xml"
+ SEP + "crypto" + SEP + "dsig" + SEP, data);
- Document doc = XMLUtils.read(new FileInputStream(file), false);
+ Document doc = XMLUtils.createDocumentBuilder(false).parse(file);
NodeList nl =
doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature");
if (nl.getLength() == 0) {
@@ -121,4 +119,4 @@
};
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/InvalidKeyTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/InvalidKeyTest.java
index 1f0ec15..1eea9c4 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/InvalidKeyTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/InvalidKeyTest.java
@@ -65,7 +65,7 @@
FileInputStream is = new FileInputStream(BASEDIR + SEP +
"src/test/resources/org/apache/xml/security/samples/input/test-assertion.xml");
- Document e = XMLUtils.read(is, false);
+ Document e = XMLUtils.createDocumentBuilder(false).parse(is);
Node assertion = e.getFirstChild();
while (!(assertion instanceof Element)) {
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/KeyValueTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/KeyValueTest.java
index 4670b99..754ca62 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/KeyValueTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/KeyValueTest.java
@@ -18,11 +18,14 @@
*/
package org.apache.xml.security.test.dom.signature;
+import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.io.FileInputStream;
import java.security.PublicKey;
+import javax.xml.parsers.DocumentBuilder;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -33,17 +36,21 @@
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
-import static org.junit.Assert.assertNotNull;
-
public class KeyValueTest {
private static final String BASEDIR = System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
+ private DocumentBuilder db;
+
static {
Init.init();
}
+ public KeyValueTest() throws Exception {
+ db = XMLUtils.createDocumentBuilder(false);
+ }
+
@org.junit.Test
public void testDSAPublicKey() throws Exception {
File f = null;
@@ -54,7 +61,7 @@
} else {
f = new File(filename);
}
- Document doc = XMLUtils.read(new FileInputStream(f), false);
+ Document doc = db.parse(new FileInputStream(f));
NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature");
XMLSignature sig = new XMLSignature
((Element) nl.item(0), f.toURI().toURL().toString());
@@ -64,4 +71,4 @@
assertNotNull(pk);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/NoKeyInfoTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/NoKeyInfoTest.java
index adadfde..6f81aa7 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/NoKeyInfoTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/NoKeyInfoTest.java
@@ -18,10 +18,13 @@
*/
package org.apache.xml.security.test.dom.signature;
+import static org.junit.Assert.assertNull;
import java.io.File;
import java.io.FileInputStream;
+import javax.xml.parsers.DocumentBuilder;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -31,8 +34,6 @@
import org.apache.xml.security.utils.Constants;
import org.apache.xml.security.utils.XMLUtils;
-import static org.junit.Assert.assertNull;
-
public class NoKeyInfoTest {
private static final String BASEDIR = System.getProperty("basedir");
@@ -42,6 +43,12 @@
Init.init();
}
+ private DocumentBuilder db;
+
+ public NoKeyInfoTest() throws Exception {
+ db = XMLUtils.createDocumentBuilder(false);
+ }
+
@org.junit.Test
public void testNullKeyInfo() throws Exception {
File f = null;
@@ -52,7 +59,7 @@
} else {
f = new File(filename);
}
- Document doc = XMLUtils.read(new FileInputStream(f), false);
+ Document doc = db.parse(new FileInputStream(f));
NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature");
XMLSignature sig = new XMLSignature
((Element) nl.item(0), f.toURI().toURL().toString());
@@ -60,4 +67,4 @@
assertNull(ki);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java
index c48e1fc..7108ad1 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/PreCalculatedDigestSignatureTest.java
@@ -37,7 +37,10 @@
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.FileInputStream;
@@ -50,7 +53,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
public class PreCalculatedDigestSignatureTest {
private static final Logger LOG = LoggerFactory.getLogger(PreCalculatedDigestSignatureTest.class);
@@ -119,8 +121,9 @@
assertTrue(signature.checkSignatureValue(signingCert));
}
- private XMLSignature openSignature(String signatureFile) throws Exception {
- Document document = XMLUtils.read(new FileInputStream(new File(signatureFile)), false);
+ private XMLSignature openSignature(String signatureFile) throws ParserConfigurationException, SAXException, IOException, XMLSecurityException {
+ DocumentBuilder builder = createDocumentBuilder();
+ Document document = builder.parse(new File(signatureFile));
Element root = document.getDocumentElement();
Element signatureDocument = (Element) root.getFirstChild();
String baseURI = "";
@@ -136,7 +139,8 @@
}
private XMLSignature createXmlSignature() throws ParserConfigurationException, XMLSecurityException {
- Document signatureDocument = XMLUtils.newDocument();
+ DocumentBuilder documentBuilder = createDocumentBuilder();
+ Document signatureDocument = documentBuilder.newDocument();
Element root = createSignatureRoot(signatureDocument);
String baseURI = "";
@@ -148,6 +152,12 @@
return signature;
}
+ private DocumentBuilder createDocumentBuilder() throws ParserConfigurationException {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ return documentBuilderFactory.newDocumentBuilder();
+ }
+
private Transforms createTransformsForSignature(Document signatureDocument) throws TransformationException {
Transforms transforms = new Transforms(signatureDocument);
transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
@@ -233,4 +243,4 @@
return uriAttr.getNodeValue();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/ProcessingInstructionTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/ProcessingInstructionTest.java
index f54cca3..89fc2fa 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/ProcessingInstructionTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/ProcessingInstructionTest.java
@@ -24,6 +24,7 @@
import java.net.URISyntaxException;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -62,8 +63,9 @@
@org.junit.Test
public void testProcessingInstruction() throws Exception {
String signatureFileName = dir + "upp_sign.xml";
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
File f = new File(signatureFileName);
- Document doc = XMLUtils.read(new FileInputStream(f), false);
+ Document doc = db.parse(new FileInputStream(f));
Node obj =
doc.getElementsByTagNameNS("http://uri.etsi.org/01903/v1.3.2#", "QualifyingProperties").item(0);
@@ -133,7 +135,10 @@
@Override
public boolean engineCanResolveURI(ResourceResolverContext context) {
- return !(context.uriToResolve == null || !"out.xml".equals(context.uriToResolve));
+ if (context.uriToResolve == null || !"out.xml".equals(context.uriToResolve)) {
+ return false;
+ }
+ return true;
}
private static URI getNewURI(String uri, String baseURI) throws URISyntaxException {
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/Santuario499Test.java b/src/test/java/org/apache/xml/security/test/dom/signature/Santuario499Test.java
index 44ef370..542ea93 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/Santuario499Test.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/Santuario499Test.java
@@ -53,7 +53,7 @@
URL signatureFile = this.getClass().getResource("Arbeidstijd_anonymous.xml");
assertNotNull(signatureFile);
- Document doc = XMLUtils.read(signatureFile.openStream(), false);
+ Document doc = XMLUtils.createDocumentBuilder(false).parse(signatureFile.openStream());
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java
index 81b7277..6f38504 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/SignatureReferenceTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.signature;
+import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -28,6 +29,7 @@
import java.util.List;
import javax.xml.crypto.dsig.DigestMethod;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
@@ -56,13 +58,6 @@
import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
import org.apache.xml.security.utils.resolver.implementations.ResolverXPointer;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* Test a Signature and Validation, and check that we have access to the Element(s) that was
* validated.
@@ -101,7 +96,7 @@
Element referenceElement =
(Element)((ReferenceNodeSetData)referenceData).iterator().next();
assertNotNull(referenceElement);
- assertEquals("root", referenceElement.getLocalName());
+ assertTrue("root".equals(referenceElement.getLocalName()));
Element originalElement =
(Element) doc.getElementsByTagNameNS("http://ns.example.org/", "root").item(0);
@@ -112,7 +107,8 @@
// See SANTUARIO-465
@org.junit.Test
public void testNoReferenceChildren() throws ParserConfigurationException, XMLSecurityException {
- Document doc = XMLUtils.newDocument();
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(true);
+ Document doc = db.newDocument();
Element referenceElement = doc.createElementNS(Constants.SignatureSpecNS, "Reference");
referenceElement.setAttributeNS(null, "URI", "#_12345");
@@ -142,6 +138,8 @@
referenceElement.appendChild(digestValue);
new WrappedReference(referenceElement, "_54321", null);
+
+ XMLUtils.repoolDocumentBuilder(db);
}
@org.junit.Test
@@ -154,7 +152,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"at/iaik/ixsil/coreFeatures/signatures/manifestSignature.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false, false);
+ Document document = builder.parse(sourceDocument);
String expression = "//dsig:Signature[1]";
Element sigElement =
@@ -189,6 +188,8 @@
assertEquals(1, verifiedReferences.get(0).getManifestReferences().size());
assertEquals("../samples/sampleXMLData.xml", verifiedReferences.get(0).getManifestReferences().get(0).getUri());
assertFalse(verifiedReferences.get(0).getManifestReferences().get(0).isValid());
+
+ XMLUtils.repoolDocumentBuilder(builder);
}
/**
@@ -230,7 +231,8 @@
}
private Document getOriginalDocument() throws Throwable {
- Document doc = XMLUtils.newDocument();
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
Element rootElement = doc.createElementNS("http://ns.example.org/", "root");
rootElement.appendChild(doc.createTextNode("Hello World!"));
@@ -281,4 +283,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java
index 1efefe0..b29838c 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/SignatureTest.java
@@ -20,6 +20,7 @@
import java.io.InputStream;
+import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import java.security.KeyStore;
@@ -27,6 +28,8 @@
import java.security.PublicKey;
import java.util.Enumeration;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.security.Init;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
@@ -38,8 +41,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertTrue;
-
public class SignatureTest {
public static final String DS_NS = "http://www.w3.org/2000/09/xmldsig#";
@@ -172,7 +173,8 @@
}
private Document getOriginalDocument() throws Throwable {
- Document doc = XMLUtils.newDocument();
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
Element rootElement = doc.createElementNS("http://ns.example.org/", "root");
rootElement.appendChild(doc.createTextNode("Hello World!"));
@@ -198,4 +200,4 @@
return sig;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/UnknownAlgoSignatureTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/UnknownAlgoSignatureTest.java
index b2d5693..90f63b2 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/UnknownAlgoSignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/UnknownAlgoSignatureTest.java
@@ -18,28 +18,36 @@
*/
package org.apache.xml.security.test.dom.signature;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
+import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.apache.xml.security.Init;
import org.apache.xml.security.c14n.InvalidCanonicalizerException;
+import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.signature.XMLSignatureException;
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.xml.sax.SAXException;
/**
* Tests cases where signature algorithms are unknown.
@@ -69,7 +77,8 @@
Init.init();
}
- public UnknownAlgoSignatureTest() throws Exception {
+ public UnknownAlgoSignatureTest() throws KeyStoreException, NoSuchAlgorithmException,
+ CertificateException, IOException {
FileInputStream fis = null;
if (BASEDIR != null && !"".equals(BASEDIR)) {
fis = new FileInputStream(BASEDIR + SEP + KEYSTORE_FILE);
@@ -83,12 +92,14 @@
}
@org.junit.Test
- public void testGood() throws Exception {
+ public void testGood() throws ParserConfigurationException, SAXException,
+ IOException, TransformerException, XMLSignatureException, XMLSecurityException, XPathExpressionException {
assertTrue(checkSignature("signature-good.xml"));
}
@org.junit.Test
- public void testBadC14NAlgo() throws Exception {
+ public void testBadC14NAlgo() throws ParserConfigurationException,
+ SAXException, IOException, TransformerException, XMLSecurityException, XPathExpressionException {
try {
assertTrue(checkSignature("signature-bad-c14n-algo.xml"));
fail("Exception not caught");
@@ -98,7 +109,8 @@
}
@org.junit.Test
- public void testBadSigAlgo() throws Exception {
+ public void testBadSigAlgo() throws ParserConfigurationException,
+ SAXException, IOException, TransformerException, XMLSecurityException, XPathExpressionException {
try {
assertTrue(checkSignature("signature-bad-sig-algo.xml"));
fail("Exception not caught");
@@ -108,7 +120,8 @@
}
@org.junit.Test
- public void testBadTransformAlgo() throws Exception {
+ public void testBadTransformAlgo() throws ParserConfigurationException,
+ SAXException, IOException, TransformerException, XMLSecurityException, XPathExpressionException {
try {
assertTrue(checkReferences("signature-bad-transform-algo.xml"));
fail("Exception not caught");
@@ -117,17 +130,23 @@
}
}
- protected boolean checkSignature(String fileName) throws Exception {
+ protected boolean checkSignature(String fileName)
+ throws ParserConfigurationException, SAXException, IOException,
+ TransformerException, XMLSecurityException, XPathExpressionException {
XMLSignature signature = unmarshalXMLSignature(fileName);
return signature.checkSignatureValue(publicKey);
}
- protected boolean checkReferences(String fileName) throws Exception {
+ protected boolean checkReferences(String fileName)
+ throws ParserConfigurationException, SAXException, IOException,
+ TransformerException, XMLSecurityException, XPathExpressionException {
XMLSignature signature = unmarshalXMLSignature(fileName);
return signature.getSignedInfo().verify(false);
}
- private XMLSignature unmarshalXMLSignature(String fileName) throws Exception {
+ private XMLSignature unmarshalXMLSignature(String fileName)
+ throws ParserConfigurationException, SAXException, IOException,
+ TransformerException, XMLSecurityException, XPathExpressionException {
File file = null;
if (BASEDIR != null && !"".equals(BASEDIR)) {
file = new File(BASEDIR + SEP + SIGNATURE_SOURCE_PATH, fileName);
@@ -146,8 +165,11 @@
return new XMLSignature(sigElement, file.toURI().toURL().toString());
}
- public static Document getDocument(File file) throws Exception {
- return XMLUtils.read(new FileInputStream(file), false);
+ public static Document getDocument(File file)
+ throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new FileInputStream(file));
+ return doc;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java
index 814e1ff..34b79d7 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/X509DataTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.signature;
+import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -33,10 +34,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-
public class X509DataTest {
private static final String BASEDIR = System.getProperty("basedir");
@@ -47,7 +44,8 @@
public void testAddX509SubjectName() throws Exception {
Init.init();
- Document doc = XMLUtils.newDocument();
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
XMLSignature sig = new XMLSignature(doc, "", XMLSignature.ALGO_ID_SIGNATURE_DSA);
doc.appendChild(sig.getElement());
@@ -77,9 +75,10 @@
private XMLSignature getSignature(byte[] s) throws Exception {
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
Document doc = null;
try (InputStream is = new ByteArrayInputStream(s)) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
Element el = (Element)doc.getFirstChild();
return new XMLSignature(el, "");
@@ -119,4 +118,4 @@
return privateKey;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/XMLSignatureInputTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/XMLSignatureInputTest.java
index 0b3e830..d5872e9 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/XMLSignatureInputTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/XMLSignatureInputTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.signature;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -28,10 +29,6 @@
import org.apache.xml.security.c14n.InvalidCanonicalizerException;
import org.apache.xml.security.signature.XMLSignatureInput;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
/**
* Unit test for {@link org.apache.xml.security.signature.XMLSignatureInput}
*
@@ -98,17 +95,17 @@
int off = 0;
while (res.available() > 0) {
- byte[] array = new byte[1024];
+ byte array[] = new byte[1024];
int len = res.read(array);
baos.write(array, off, len);
off += len;
}
- byte[] resBytes = baos.toByteArray();
+ byte resBytes[] = baos.toByteArray();
String resString = new String(resBytes, java.nio.charset.StandardCharsets.UTF_8);
- assertEquals(resString, _octetStreamTextInput);
+ assertTrue(resString.equals(_octetStreamTextInput));
}
@org.junit.Test
@@ -137,7 +134,7 @@
new ByteArrayInputStream(_octetStreamTextInput.getBytes())) {
XMLSignatureInput input = new XMLSignatureInput(inputStream);
- assertFalse("Input is not node set", input.isNodeSet());
+ assertTrue("Input is not node set", !input.isNodeSet());
}
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/XPointerResourceResolver.java b/src/test/java/org/apache/xml/security/test/dom/signature/XPointerResourceResolver.java
index 8fd9279..97b127e 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/XPointerResourceResolver.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/XPointerResourceResolver.java
@@ -75,7 +75,7 @@
return false;
}
- String[] parts = xpURI.substring(1).split("\\s");
+ String parts[] = xpURI.substring(1).split("\\s");
// plain ID reference.
if (parts.length == 1 && !parts[0].startsWith(XNS_OPEN)) {
@@ -116,7 +116,7 @@
return null;
}
- String[] parts = xpURI.substring(1).split("\\s");
+ String parts[] = xpURI.substring(1).split("\\s");
int i = 0;
Map<String, String> namespaces = new HashMap<>();
diff --git a/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java b/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java
index 75fe551..973b008 100644
--- a/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/signature/XmlSecTest.java
@@ -26,6 +26,7 @@
import java.security.PublicKey;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
@@ -44,7 +45,6 @@
import static org.junit.Assert.assertTrue;
-
/**
* Tests creating and validating an XML Signature with an XPath Transform.
* Tests bug #44617.
@@ -71,7 +71,8 @@
private void checkXmlSignatureSoftwareStack(boolean cert) throws Exception {
Init.init();
- Document testDocument = XMLUtils.newDocument();
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(false);
+ Document testDocument = documentBuilder.newDocument();
Element rootElement =
testDocument.createElementNS("urn:namespace", "tns:document");
@@ -151,4 +152,4 @@
assertTrue(signResult);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/transforms/EmptyNamespaceTest.java b/src/test/java/org/apache/xml/security/test/dom/transforms/EmptyNamespaceTest.java
index 22a89fc..096e8cc 100644
--- a/src/test/java/org/apache/xml/security/test/dom/transforms/EmptyNamespaceTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/transforms/EmptyNamespaceTest.java
@@ -22,9 +22,11 @@
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315ExclOmitComments;
import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl;
import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_ExclOmitCommentsTransformer;
-import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.w3c.dom.Document;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -33,8 +35,6 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-
public class EmptyNamespaceTest {
private static final String message = "<SOAP-ENV:Body xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"XWSSGID-1465203363337-2063525437\">\n" +
@@ -85,7 +85,7 @@
transformer.doFinal();
String result = outputStream.toString();
- assertEquals(message, result);
+ Assert.assertEquals(message, result);
}
}
@@ -96,9 +96,13 @@
Canonicalizer20010315Excl transformer = new Canonicalizer20010315ExclOmitComments();
+ final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ documentBuilderFactory.setValidating(false);
+ final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = null;
try (InputStream is = new ByteArrayInputStream(message.getBytes(java.nio.charset.StandardCharsets.UTF_8))) {
- document = XMLUtils.read(is, false);
+ document = documentBuilder.parse(is);
}
String inclusiveNamespaces = "SOAP-ENV ec ec1 ns0 ns1 ns11 ns2 ns4 ns9";
@@ -106,6 +110,6 @@
transformer.engineCanonicalizeSubTree(document, inclusiveNamespaces);
String result = new String(output, java.nio.charset.StandardCharsets.UTF_8);
- assertEquals(message, result);
+ Assert.assertEquals(message, result);
}
}
\ No newline at end of file
diff --git a/src/test/java/org/apache/xml/security/test/dom/transforms/SampleTransform.java b/src/test/java/org/apache/xml/security/test/dom/transforms/SampleTransform.java
index 535da93..3b6975f 100644
--- a/src/test/java/org/apache/xml/security/test/dom/transforms/SampleTransform.java
+++ b/src/test/java/org/apache/xml/security/test/dom/transforms/SampleTransform.java
@@ -19,17 +19,12 @@
package org.apache.xml.security.test.dom.transforms;
import java.io.IOException;
-
import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.xml.security.c14n.CanonicalizationException;
-import org.apache.xml.security.c14n.InvalidCanonicalizerException;
-import org.apache.xml.security.exceptions.AlgorithmAlreadyRegisteredException;
-import org.apache.xml.security.signature.XMLSignatureInput;
-import org.apache.xml.security.transforms.Transform;
-import org.apache.xml.security.transforms.TransformSpi;
-import org.apache.xml.security.transforms.TransformationException;
import org.xml.sax.SAXException;
+import org.apache.xml.security.c14n.*;
+import org.apache.xml.security.exceptions.*;
+import org.apache.xml.security.signature.XMLSignatureInput;
+import org.apache.xml.security.transforms.*;
public class SampleTransform extends TransformSpi {
diff --git a/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java b/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java
index 9fb55f1..a3e6bbe 100644
--- a/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformBase64DecodeTest.java
@@ -18,10 +18,12 @@
*/
package org.apache.xml.security.test.dom.transforms.implementations;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
@@ -35,8 +37,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import static org.junit.Assert.assertEquals;
-
/**
* Unit test for {@link org.apache.xml.security.transforms.implementations.TransformBase64Decode}
*
@@ -69,7 +69,9 @@
XMLSignatureInput out = t.performTransforms(in);
String result = new String(out.getBytes());
- assertEquals(result, "The URI of the transform is http://www.w3.org/2000/09/xmldsig#base64");
+ assertTrue(
+ result.equals("The URI of the transform is http://www.w3.org/2000/09/xmldsig#base64")
+ );
}
@org.junit.Test
@@ -91,7 +93,9 @@
XMLSignatureInput out = t.performTransforms(t.performTransforms(in));
String result = new String(out.getBytes());
- assertEquals(result, "The URI of the transform is http://www.w3.org/2000/09/xmldsig#base64");
+ assertTrue(
+ result.equals("The URI of the transform is http://www.w3.org/2000/09/xmldsig#base64")
+ );
}
@org.junit.Test
@@ -106,10 +110,13 @@
+ "</Object>\n"
;
//J+
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+
+ db.setErrorHandler(new org.apache.xml.security.utils.IgnoreAllErrorHandler());
Document doc = null;
try (InputStream is = new ByteArrayInputStream(input.getBytes())) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
//XMLUtils.circumventBug2650(doc);
@@ -131,14 +138,15 @@
XMLSignatureInput out = t.performTransforms(xmlinput);
String result = new String(out.getBytes());
- assertEquals(
+ assertTrue(
"\"" + result + "\"",
- result, "The URI of the transform is http://www.w3.org/2000/09/xmldsig#base64"
+ result.equals("The URI of the transform is http://www.w3.org/2000/09/xmldsig#base64")
);
}
private static Document createDocument() throws ParserConfigurationException {
- Document doc = XMLUtils.newDocument();
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.newDocument();
if (doc == null) {
throw new RuntimeException("Could not create a Document");
@@ -148,4 +156,4 @@
return doc;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformXSLTTest.java b/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformXSLTTest.java
index 2515c79..f45b777 100644
--- a/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformXSLTTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/TransformXSLTTest.java
@@ -20,18 +20,21 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
import org.apache.xml.security.signature.XMLSignatureInput;
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.transforms.Transform;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.XMLUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
public class TransformXSLTTest {
@@ -83,8 +86,9 @@
transform.performTransform(new XMLSignatureInput(doc2));
}
- private static Document getDocument(File file) throws Exception {
- return XMLUtils.read(new FileInputStream(file), false);
+ private static Document getDocument(File file)
+ throws ParserConfigurationException, SAXException, IOException {
+ return XMLUtils.createDocumentBuilder(false).parse(new FileInputStream(file));
}
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/Xpath2TransformationTest.java b/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/Xpath2TransformationTest.java
index 2a85722..5b97960 100644
--- a/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/Xpath2TransformationTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/transforms/implementations/Xpath2TransformationTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.transforms.implementations;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
@@ -27,8 +28,6 @@
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-
public class Xpath2TransformationTest {
static {
@@ -130,9 +129,10 @@
" </edoc:ObjectContent>\n" +
" </edoc:Object>";
+ javax.xml.parsers.DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
org.w3c.dom.Document doc = null;
try (ByteArrayInputStream is = new ByteArrayInputStream(sig.getBytes())) {
- doc = XMLUtils.read(is, false);
+ doc = db.parse(is);
}
Element sigElement =
(Element) doc.getElementsByTagNameNS(
@@ -156,4 +156,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/utils/DocumentBuilderPoolingTest.java b/src/test/java/org/apache/xml/security/test/dom/utils/DocumentBuilderPoolingTest.java
new file mode 100644
index 0000000..05add92
--- /dev/null
+++ b/src/test/java/org/apache/xml/security/test/dom/utils/DocumentBuilderPoolingTest.java
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.xml.security.test.dom.utils;
+
+import org.apache.xml.security.utils.WeakObjectPool;
+import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Test;
+
+import javax.xml.parsers.DocumentBuilder;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+import java.util.Iterator;
+import java.util.concurrent.*;
+
+import static org.junit.Assert.*;
+
+public class DocumentBuilderPoolingTest {
+
+ private static final String DOCUMENTBUILDERPROXY_CLASSNAME =
+ "org.apache.xml.security.utils.XMLUtils$DocumentBuilderProxy";
+
+ @Test
+ public void testEquals() throws Exception {
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(true);
+ assertEquals(documentBuilder, documentBuilder);
+ }
+
+ @Test
+ public void testGetValidatingDocumentBuilder() throws Exception {
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(true);
+ assertTrue(documentBuilder.isValidating());
+ }
+
+ @Test
+ public void testGetNonValidatingDocumentBuilder() throws Exception {
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(false);
+ assertFalse(documentBuilder.isValidating());
+ }
+
+ @Test
+ public void testGetValidatingAndAllowDocTypeDeclarationsDocumentBuilder() throws Exception {
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(true, false);
+ assertTrue(documentBuilder.isValidating());
+ assertEquals(documentBuilder.getClass().getName(), DOCUMENTBUILDERPROXY_CLASSNAME);
+ assertAllowDocTypeDeclarations(documentBuilder, false);
+ }
+
+ @Test
+ public void testGetValidatingAndDisAllowDocTypeDeclarationsDocumentBuilder() throws Exception {
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(true, true);
+ assertTrue(documentBuilder.isValidating());
+ assertEquals(documentBuilder.getClass().getName(), DOCUMENTBUILDERPROXY_CLASSNAME);
+ assertAllowDocTypeDeclarations(documentBuilder, true);
+ }
+
+ private void assertAllowDocTypeDeclarations(DocumentBuilder documentBuilder, boolean allow) throws Exception {
+ Field field = documentBuilder.getClass().getDeclaredField("disAllowDocTypeDeclarations");
+ field.setAccessible(true);
+ assertEquals(allow, field.get(documentBuilder));
+ }
+
+ @Test
+ public void testNewDocumentBuilderInstances() throws Exception {
+ int count = 4;
+
+ // get all possible combinations of DocumentBuilders:
+ DocumentBuilder[] documentBuilders = new DocumentBuilder[count];
+ for (int i = 0; i < count; i++) {
+ documentBuilders[i] = XMLUtils.createDocumentBuilder(i / 2 > 0, i % 2 == 1);
+ }
+
+ //test that we got always a new instance:
+ for (int i = 0; i < count; i++) {
+ for (int j = i + 1; j < count; j++) {
+ assertNotEquals(documentBuilders[i], documentBuilders[j]);
+ assertNotSame(documentBuilders[i], documentBuilders[j]);
+ }
+ }
+ }
+
+ @Test
+ public void testRepoolingTwice() throws Exception {
+ DocumentBuilder documentBuilder = XMLUtils.createDocumentBuilder(true);
+ assertTrue(XMLUtils.repoolDocumentBuilder(documentBuilder));
+ assertFalse("can't repool the same object twice!", XMLUtils.repoolDocumentBuilder(documentBuilder));
+ }
+
+ @Test(timeout = 30000)
+ public void testPooling() throws Exception {
+ int nThreads = 8;
+ ExecutorService exec = Executors.newFixedThreadPool(nThreads);
+ Future<?>[] results = new Future[nThreads];
+ for (int i = 0; i < nThreads - 1; i++) {
+ results[i] = exec.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ while (true) {
+ // retrieve some DocumentBuilders...
+ DocumentBuilder documentBuilders[] = new DocumentBuilder[10];
+ for (int j = 0; j < documentBuilders.length; j++) {
+ documentBuilders[j] = XMLUtils.createDocumentBuilder(false);
+ assertNotNull(documentBuilders[j]);
+ }
+ // ...then repool them so that another thread may pickup them again
+ for (int j = 0; j < documentBuilders.length; j++) {
+ assertTrue(XMLUtils.repoolDocumentBuilder(documentBuilders[j]));
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ }
+ // more or less mimic gc
+ results[nThreads - 1] = exec.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ final Field poolField = XMLUtils.class.getDeclaredField("pools");
+ poolField.setAccessible(true);
+ final WeakObjectPool[] weakObjectPools = (WeakObjectPool[]) poolField.get(null);
+
+ final Field availableField = WeakObjectPool.class.getDeclaredField("available");
+ availableField.setAccessible(true);
+
+ while (true) {
+ final BlockingDeque blockingDeque = (BlockingDeque) availableField.get(weakObjectPools[1]);
+ Iterator iterator = blockingDeque.iterator();
+ while (iterator.hasNext()) {
+ ((WeakReference) iterator.next()).clear();
+ }
+ Thread.sleep(200);
+ }
+ } catch (InterruptedException e) {
+ return;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+
+ exec.shutdown();
+ exec.awaitTermination(5, TimeUnit.SECONDS);
+ for (Future<?> f : results) {
+ if (!f.isDone()) {
+ f.cancel(false);
+ }
+ try {
+ assertNull(f.get(1000, TimeUnit.MILLISECONDS));
+ } catch (CancellationException ce) {
+ //expected since we did cancel it
+ } catch (TimeoutException e) {
+ fail(f + "didn't cancel after timeout?");
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/utils/RFC2253ParserTest.java b/src/test/java/org/apache/xml/security/test/dom/utils/RFC2253ParserTest.java
index 896133c..d031984 100644
--- a/src/test/java/org/apache/xml/security/test/dom/utils/RFC2253ParserTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/utils/RFC2253ParserTest.java
@@ -19,93 +19,102 @@
package org.apache.xml.security.test.dom.utils;
import org.apache.xml.security.utils.RFC2253Parser;
+import org.junit.Assert;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
/**
*/
-public class RFC2253ParserTest {
+public class RFC2253ParserTest extends Assert {
@Test
public void testToXML1() throws Exception {
- assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=\"Steve, Kille\", O=Isode Limited, C=GB"), "CN=Steve\\, Kille,O=Isode Limited,C=GB");
+ Assert.assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=\"Steve, Kille\", O=Isode Limited, C=GB"), "CN=Steve\\, Kille,O=Isode Limited,C=GB");
}
@Test
public void testToXML2() throws Exception {
- assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=Steve Kille , O=Isode Limited,C=GB"), "CN=Steve Kille,O=Isode Limited,C=GB");
+ Assert.assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=Steve Kille , O=Isode Limited,C=GB"), "CN=Steve Kille,O=Isode Limited,C=GB");
}
@Test
public void testToXML3() throws Exception {
- assertEquals(RFC2253Parser.rfc2253toXMLdsig("\\ OU=Sales+CN=J. Smith,O=Widget Inc.,C=US\\ \\ "), "\\20OU=Sales+CN=J. Smith,O=Widget Inc.,C=US\\20\\20");
+ Assert.assertEquals(RFC2253Parser.rfc2253toXMLdsig("\\ OU=Sales+CN=J. Smith,O=Widget Inc.,C=US\\ \\ "), "\\20OU=Sales+CN=J. Smith,O=Widget Inc.,C=US\\20\\20");
}
@Test
public void testToXML4() throws Exception {
- assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB"), "CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB");
+ Assert.assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB"), "CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB");
}
@Test
public void testToXML5() throws Exception {
- assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=Before\\0DAfter,O=Test,C=GB"), "CN=Before\\0DAfter,O=Test,C=GB");
+ Assert.assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=Before\\0DAfter,O=Test,C=GB"), "CN=Before\\0DAfter,O=Test,C=GB");
}
@Test
public void testToXML6() throws Exception {
- assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=\"L. Eagle,O=Sue, = + < > # ;Grabbit and Runn\",C=GB"), "CN=L. Eagle\\,O\\=Sue\\, \\= \\+ \\< \\> \\# \\;Grabbit and Runn,C=GB");
+ Assert.assertEquals(RFC2253Parser.rfc2253toXMLdsig("CN=\"L. Eagle,O=Sue, = + < > # ;Grabbit and Runn\",C=GB"), "CN=L. Eagle\\,O\\=Sue\\, \\= \\+ \\< \\> \\# \\;Grabbit and Runn,C=GB");
}
@Test
public void testToXML7() throws Exception {
- assertEquals(RFC2253Parser.rfc2253toXMLdsig("1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB"), "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB");
+ Assert.assertEquals(RFC2253Parser.rfc2253toXMLdsig("1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB"), "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB");
}
@Test
public void testToXML8() throws Exception {
- StringBuilder sb = new StringBuilder("Lu\uc48di\uc487");
- assertEquals(RFC2253Parser.rfc2253toXMLdsig("SN=" + sb.toString()), "SN=Lu\uc48di\uc487");
+ StringBuilder sb = new StringBuilder();
+ sb.append('L');
+ sb.append('u');
+ sb.append('\uc48d');
+ sb.append('i');
+ sb.append('\uc487');
+ Assert.assertEquals(RFC2253Parser.rfc2253toXMLdsig("SN=" + sb.toString()), "SN=Lu\uc48di\uc487");
}
@Test
public void testToRFC1() throws Exception {
- assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=\"Steve, Kille\", O=Isode Limited, C=GB"), "CN=Steve\\, Kille,O=Isode Limited,C=GB");
+ Assert.assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=\"Steve, Kille\", O=Isode Limited, C=GB"), "CN=Steve\\, Kille,O=Isode Limited,C=GB");
}
@Test
public void testToRFC2() throws Exception {
- assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=Steve Kille , O=Isode Limited,C=GB"), "CN=Steve Kille,O=Isode Limited,C=GB");
+ Assert.assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=Steve Kille , O=Isode Limited,C=GB"), "CN=Steve Kille,O=Isode Limited,C=GB");
}
@Test
public void testToRFC3() throws Exception {
- assertEquals(RFC2253Parser.xmldsigtoRFC2253("\\20OU=Sales+CN=J. Smith,O=Widget Inc.,C=US\\20\\20 "), "\\ OU=Sales+CN=J. Smith,O=Widget Inc.,C=US\\ \\ ");
+ Assert.assertEquals(RFC2253Parser.xmldsigtoRFC2253("\\20OU=Sales+CN=J. Smith,O=Widget Inc.,C=US\\20\\20 "), "\\ OU=Sales+CN=J. Smith,O=Widget Inc.,C=US\\ \\ ");
}
@Test
public void testToRFC4() throws Exception {
- assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB"), "CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB");
+ Assert.assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB"), "CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB");
}
@Test
public void testToRFC5() throws Exception {
- assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=Before\\12After,O=Test,C=GB"), "CN=Before\\\u0012After,O=Test,C=GB");
+ Assert.assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=Before\\12After,O=Test,C=GB"), "CN=Before\\\u0012After,O=Test,C=GB");
}
@Test
public void testToRFC6() throws Exception {
- assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=\"L. Eagle,O=Sue, = + < > # ;Grabbit and Runn\",C=GB"), "CN=L. Eagle\\,O\\=Sue\\, \\= \\+ \\< \\> \\# \\;Grabbit and Runn,C=GB");
+ Assert.assertEquals(RFC2253Parser.xmldsigtoRFC2253("CN=\"L. Eagle,O=Sue, = + < > # ;Grabbit and Runn\",C=GB"), "CN=L. Eagle\\,O\\=Sue\\, \\= \\+ \\< \\> \\# \\;Grabbit and Runn,C=GB");
}
@Test
public void testToRFC7() throws Exception {
- assertEquals(RFC2253Parser.xmldsigtoRFC2253("1.3.6.1.4.1.1466.0=\\#04024869,O=Test,C=GB"), "1.3.6.1.4.1.1466.0=\\#04024869,O=Test,C=GB");
+ Assert.assertEquals(RFC2253Parser.xmldsigtoRFC2253("1.3.6.1.4.1.1466.0=\\#04024869,O=Test,C=GB"), "1.3.6.1.4.1.1466.0=\\#04024869,O=Test,C=GB");
}
@Test
public void testToRFC8() throws Exception {
- StringBuilder sb = new StringBuilder("Lu\uc48di\uc487");
- assertEquals(RFC2253Parser.xmldsigtoRFC2253("SN=" + sb.toString()), "SN=Lu\uc48di\uc487");
+ StringBuilder sb = new StringBuilder();
+ sb.append('L');
+ sb.append('u');
+ sb.append('\uc48d');
+ sb.append('i');
+ sb.append('\uc487');
+ Assert.assertEquals(RFC2253Parser.xmldsigtoRFC2253("SN=" + sb.toString()), "SN=Lu\uc48di\uc487");
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/utils/XMLUtilsPerformanceTest.java b/src/test/java/org/apache/xml/security/test/dom/utils/XMLUtilsPerformanceTest.java
index 021d09e..62ccdcc 100644
--- a/src/test/java/org/apache/xml/security/test/dom/utils/XMLUtilsPerformanceTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/utils/XMLUtilsPerformanceTest.java
@@ -20,9 +20,7 @@
import java.io.StringReader;
-import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.xml.security.utils.XMLUtils;
import org.junit.Test;
@@ -38,22 +36,11 @@
@BenchmarkOptions(callgc = false, benchmarkRounds = 100000, warmupRounds = 100)
@Test
- public void testXMLUtils() throws Exception {
- InputSource inputSource = new InputSource(new StringReader("<xml>123</xml>"));
- XMLUtils.read(inputSource, false);
- }
-
- @BenchmarkOptions(callgc = false, benchmarkRounds = 100000, warmupRounds = 100)
- @Test
public void testCreateDocumentBuilder() throws Exception {
- DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
- dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
- dfactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
- dfactory.setNamespaceAware(true);
- DocumentBuilder documentBuilder = dfactory.newDocumentBuilder();
-
InputSource inputSource = new InputSource(new StringReader("<xml>123</xml>"));
- documentBuilder.parse(inputSource);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ db.parse(inputSource);
+ XMLUtils.repoolDocumentBuilder(db);
}
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/OfflineResolver.java b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/OfflineResolver.java
index d31fb24..29afcd5 100644
--- a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/OfflineResolver.java
+++ b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/OfflineResolver.java
@@ -118,7 +118,7 @@
return result;
} else {
- Object[] exArgs = {"The URI " + URI + " is not configured for offline work" };
+ Object exArgs[] = {"The URI " + URI + " is not configured for offline work" };
throw new ResourceResolverException(
"generic.EmptyMessage", exArgs, context.uriToResolve, context.baseUri
@@ -139,14 +139,14 @@
@Override
public boolean engineCanResolveURI(ResourceResolverContext context) {
String uriNodeValue = context.uriToResolve;
- if (uriNodeValue.isEmpty() || uriNodeValue.charAt(0) == '#') {
+ if (uriNodeValue.equals("") || uriNodeValue.startsWith("#")) {
return false;
}
URI uriNew = null;
try {
uriNew = getNewURI(context.uriToResolve, context.baseUri);
- if ("http".equals(uriNew.getScheme())) {
+ if (uriNew.getScheme().equals("http")) {
LOG.debug("I state that I can resolve " + uriNew.toString());
return true;
}
diff --git a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java
index 53bc03a..8ad6dd3 100644
--- a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResolverDirectHTTPTest.java
@@ -24,17 +24,14 @@
import org.apache.xml.security.utils.resolver.ResourceResolverContext;
import org.apache.xml.security.utils.resolver.ResourceResolverException;
import org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-
-public class ResolverDirectHTTPTest {
+public class ResolverDirectHTTPTest extends Assert {
//change these properties to match your environment
private static final String url = "http://www.apache.org";
@@ -52,7 +49,7 @@
@Test
public void testBug40783() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("id");
uri.setNodeValue("urn:ddd:uuu");
doc.createElement("test").setAttributeNode(uri);
@@ -67,7 +64,7 @@
@Test
@Ignore
public void testProxyAuth() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -84,7 +81,7 @@
@Test
@Ignore
public void testProxyAuthWithWrongPassword() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -97,16 +94,16 @@
new ResourceResolverContext(uri, url, true);
try {
resolverDirectHTTP.engineResolveURI(context);
- fail("Expected ResourceResolverException");
+ Assert.fail("Expected ResourceResolverException");
} catch (ResourceResolverException e) {
- assertEquals("Server returned HTTP response code: 407 for URL: " + url, e.getMessage());
+ Assert.assertEquals("Server returned HTTP response code: 407 for URL: " + url, e.getMessage());
}
}
@Test
@Ignore
public void testServerAuth() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -121,7 +118,7 @@
@Test
@Ignore
public void testServerAuthWithWrongPassword() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
@@ -132,16 +129,16 @@
new ResourceResolverContext(uri, url, true);
try {
resolverDirectHTTP.engineResolveURI(context);
- fail("Expected ResourceResolverException");
+ Assert.fail("Expected ResourceResolverException");
} catch (ResourceResolverException e) {
- assertEquals("Server returned HTTP response code: 401 for URL: " + url, e.getMessage());
+ Assert.assertEquals("Server returned HTTP response code: 401 for URL: " + url, e.getMessage());
}
}
@Test
@Ignore
public void testProxyAndServerAuth() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uri = doc.createAttribute("URI");
uri.setNodeValue(url);
diff --git a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java
index 355de19..0315ada 100644
--- a/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/utils/resolver/ResourceResolverTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.dom.utils.resolver;
+import static org.junit.Assert.fail;
import java.io.File;
@@ -26,8 +27,6 @@
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
-import static org.junit.Assert.fail;
-
/**
* Unit test for {@link org.apache.xml.security.utils.resolver.ResourceResolver}
*
@@ -50,7 +49,7 @@
String className =
"org.apache.xml.security.test.dom.utils.resolver.OfflineResolver";
ResourceResolver.registerAtStart(className);
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uriAttr = doc.createAttribute("URI");
uriAttr.setValue("http://www.apache.org");
ResourceResolver res =
@@ -59,6 +58,7 @@
uriAttr.setValue("http://xmldsig.pothole.com/xml-stylesheet.txt");
res.resolve(uriAttr, null, true);
} catch (Exception e) {
+ e.printStackTrace();
fail(uriAttr.getValue()
+ " should be resolvable by the OfflineResolver");
}
@@ -73,7 +73,7 @@
@org.junit.Test
public void testLocalFileWithEmptyBaseURI() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Attr uriAttr = doc.createAttribute("URI");
String basedir = System.getProperty("basedir");
String file = new File(basedir, "pom.xml").toURI().toString();
@@ -86,4 +86,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/dom/version/VersionTest.java b/src/test/java/org/apache/xml/security/test/dom/version/VersionTest.java
index 3e45c70..a98f192 100644
--- a/src/test/java/org/apache/xml/security/test/dom/version/VersionTest.java
+++ b/src/test/java/org/apache/xml/security/test/dom/version/VersionTest.java
@@ -18,14 +18,11 @@
*/
package org.apache.xml.security.test.dom.version;
+import static org.junit.Assert.assertTrue;
import java.security.Provider;
import java.security.Security;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* Version test.
*/
@@ -38,13 +35,13 @@
@org.junit.Test
public void testConvertVersion() throws Exception {
String version = convertVersion("1.4.4");
- assertEquals("1.44", version);
+ assertTrue("1.44".equals(version));
version = convertVersion("1.4.4-SNAPSHOT");
- assertEquals("1.44", version);
+ assertTrue("1.44".equals(version));
version = convertVersion("1.4");
- assertEquals("1.4", version);
+ assertTrue("1.4".equals(version));
}
@org.junit.Test
@@ -52,10 +49,10 @@
Security.addProvider(new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
Provider provider = Security.getProvider("ApacheXMLDSig");
- assertNotNull(provider);
+ assertTrue(provider != null);
String version = System.getProperty("product.version");
- assertNotNull(version);
+ assertTrue(version != null);
version = convertVersion(version);
@@ -89,4 +86,4 @@
return version;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/IVSplittingOutputStreamTest.java b/src/test/java/org/apache/xml/security/test/stax/IVSplittingOutputStreamTest.java
index 7aa4795..2c69ee7 100644
--- a/src/test/java/org/apache/xml/security/test/stax/IVSplittingOutputStreamTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/IVSplittingOutputStreamTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.stax;
+import org.junit.Assert;
import org.junit.Test;
import org.apache.xml.security.stax.impl.util.IVSplittingOutputStream;
@@ -28,15 +29,11 @@
import javax.crypto.SecretKey;
import java.io.ByteArrayOutputStream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
/**
*/
-public class IVSplittingOutputStreamTest {
+public class IVSplittingOutputStreamTest extends Assert {
- private static final String TEST_STR
- = "Within this class we test if the IVSplittingOutputStream works correctly under different conditions";
+ private final String testString = "Within this class we test if the IVSplittingOutputStream works correctly under different conditions";
@Test
public void testWriteBytes() throws Exception {
@@ -52,16 +49,16 @@
IVSplittingOutputStream ivSplittingOutputStream = new IVSplittingOutputStream(byteArrayOutputStream, cipher, secretKey, ivSize);
ReplaceableOuputStream replaceableOuputStream = new ReplaceableOuputStream(ivSplittingOutputStream);
ivSplittingOutputStream.setParentOutputStream(replaceableOuputStream);
- byte[] testBytes = TEST_STR.getBytes();
+ byte[] testBytes = testString.getBytes();
for (int i = 0; i < testBytes.length; i++) {
replaceableOuputStream.write(testBytes[i]);
}
replaceableOuputStream.close();
- assertEquals(new String(ivSplittingOutputStream.getIv()), TEST_STR.substring(0, ivSize));
- assertEquals(new String(byteArrayOutputStream.toByteArray()), TEST_STR.substring(ivSize));
- assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), TEST_STR);
- assertTrue(ivSplittingOutputStream.isIVComplete());
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()), testString.substring(0, ivSize));
+ Assert.assertEquals(new String(byteArrayOutputStream.toByteArray()), testString.substring(ivSize));
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), testString);
+ Assert.assertTrue(ivSplittingOutputStream.isIVComplete());
}
@Test
@@ -78,13 +75,13 @@
IVSplittingOutputStream ivSplittingOutputStream = new IVSplittingOutputStream(byteArrayOutputStream, cipher, secretKey, ivSize);
ReplaceableOuputStream replaceableOuputStream = new ReplaceableOuputStream(ivSplittingOutputStream);
ivSplittingOutputStream.setParentOutputStream(replaceableOuputStream);
- replaceableOuputStream.write(TEST_STR.getBytes());
+ replaceableOuputStream.write(testString.getBytes());
replaceableOuputStream.close();
- assertEquals(new String(ivSplittingOutputStream.getIv()), TEST_STR.substring(0, ivSize));
- assertEquals(new String(byteArrayOutputStream.toByteArray()), TEST_STR.substring(ivSize));
- assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), TEST_STR);
- assertTrue(ivSplittingOutputStream.isIVComplete());
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()), testString.substring(0, ivSize));
+ Assert.assertEquals(new String(byteArrayOutputStream.toByteArray()), testString.substring(ivSize));
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), testString);
+ Assert.assertTrue(ivSplittingOutputStream.isIVComplete());
}
@Test
@@ -102,7 +99,7 @@
ReplaceableOuputStream replaceableOuputStream = new ReplaceableOuputStream(ivSplittingOutputStream);
ivSplittingOutputStream.setParentOutputStream(replaceableOuputStream);
- byte[] testBytes = TEST_STR.getBytes();
+ byte[] testBytes = testString.getBytes();
for (int i = 0; i < testBytes.length - ivSize; i += ivSize) {
replaceableOuputStream.write(testBytes, i, ivSize);
}
@@ -110,10 +107,10 @@
replaceableOuputStream.write(testBytes, testBytes.length - testBytes.length % ivSize, testBytes.length % ivSize);
replaceableOuputStream.close();
- assertEquals(new String(ivSplittingOutputStream.getIv()), TEST_STR.substring(0, ivSize));
- assertEquals(new String(byteArrayOutputStream.toByteArray()), TEST_STR.substring(ivSize));
- assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), TEST_STR);
- assertTrue(ivSplittingOutputStream.isIVComplete());
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()), testString.substring(0, ivSize));
+ Assert.assertEquals(new String(byteArrayOutputStream.toByteArray()), testString.substring(ivSize));
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), testString);
+ Assert.assertTrue(ivSplittingOutputStream.isIVComplete());
}
@Test
@@ -131,16 +128,16 @@
ReplaceableOuputStream replaceableOuputStream = new ReplaceableOuputStream(ivSplittingOutputStream);
ivSplittingOutputStream.setParentOutputStream(replaceableOuputStream);
- byte[] testBytes = TEST_STR.getBytes();
+ byte[] testBytes = testString.getBytes();
replaceableOuputStream.write(testBytes, 0, testBytes.length - ivSize);
//write last part
replaceableOuputStream.write(testBytes, testBytes.length - ivSize, ivSize);
replaceableOuputStream.close();
- assertEquals(new String(ivSplittingOutputStream.getIv()), TEST_STR.substring(0, ivSize));
- assertEquals(new String(byteArrayOutputStream.toByteArray()), TEST_STR.substring(ivSize));
- assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), TEST_STR);
- assertTrue(ivSplittingOutputStream.isIVComplete());
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()), testString.substring(0, ivSize));
+ Assert.assertEquals(new String(byteArrayOutputStream.toByteArray()), testString.substring(ivSize));
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), testString);
+ Assert.assertTrue(ivSplittingOutputStream.isIVComplete());
}
@Test
@@ -158,7 +155,7 @@
ReplaceableOuputStream replaceableOuputStream = new ReplaceableOuputStream(ivSplittingOutputStream);
ivSplittingOutputStream.setParentOutputStream(replaceableOuputStream);
- byte[] testBytes = TEST_STR.getBytes();
+ byte[] testBytes = testString.getBytes();
for (int i = 0; i < testBytes.length - 4; i += 4) {
replaceableOuputStream.write(testBytes, i, 4);
}
@@ -166,9 +163,9 @@
replaceableOuputStream.write(testBytes, testBytes.length - testBytes.length % 4, testBytes.length % 4);
replaceableOuputStream.close();
- assertEquals(new String(ivSplittingOutputStream.getIv()), TEST_STR.substring(0, ivSize));
- assertEquals(new String(byteArrayOutputStream.toByteArray()), TEST_STR.substring(ivSize));
- assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), TEST_STR);
- assertTrue(ivSplittingOutputStream.isIVComplete());
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()), testString.substring(0, ivSize));
+ Assert.assertEquals(new String(byteArrayOutputStream.toByteArray()), testString.substring(ivSize));
+ Assert.assertEquals(new String(ivSplittingOutputStream.getIv()) + new String(byteArrayOutputStream.toByteArray()), testString);
+ Assert.assertTrue(ivSplittingOutputStream.isIVComplete());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/InputProcessorChainTest.java b/src/test/java/org/apache/xml/security/test/stax/InputProcessorChainTest.java
index c9fd61e..dbf663f 100644
--- a/src/test/java/org/apache/xml/security/test/stax/InputProcessorChainTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/InputProcessorChainTest.java
@@ -21,6 +21,7 @@
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.config.Init;
import org.apache.xml.security.stax.impl.InboundSecurityContextImpl;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -34,11 +35,9 @@
import java.util.HashSet;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-
/**
*/
-public class InputProcessorChainTest {
+public class InputProcessorChainTest extends Assert {
@Before
public void setUp() throws Exception {
@@ -112,9 +111,9 @@
};
inputProcessorChain.addProcessor(inputProcessor3);
- assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor3);
- assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor2);
- assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor1);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor3);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor2);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor1);
}
@Test
@@ -149,12 +148,12 @@
};
inputProcessorChain.addProcessor(inputProcessor6);
- assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor4);
- assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor3);
- assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor6);
- assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor1);
- assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor5);
- assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor2);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor4);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor3);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor6);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor1);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor5);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor2);
}
@Test
@@ -192,12 +191,12 @@
inputProcessor6.addBeforeProcessor(inputProcessor1.getClass().getName());
inputProcessorChain.addProcessor(inputProcessor6);
- assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor3);
- assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor4);
- assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor1);
- assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor6);
- assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor2);
- assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor5);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor3);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor4);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor1);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor6);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor2);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor5);
}
@Test
@@ -235,12 +234,12 @@
inputProcessor6.addAfterProcessor(inputProcessor1.getClass().getName());
inputProcessorChain.addProcessor(inputProcessor6);
- assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor4);
- assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor3);
- assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor6);
- assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor1);
- assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor5);
- assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor2);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor4);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor3);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor6);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor1);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor5);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor2);
}
@Test
@@ -275,11 +274,11 @@
inputProcessor6.addAfterProcessor("");
inputProcessorChain.addProcessor(inputProcessor6);
- assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor4);
- assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor5);
- assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor6);
- assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor3);
- assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor2);
- assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor1);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(0), inputProcessor4);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(1), inputProcessor5);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(2), inputProcessor6);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(3), inputProcessor3);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(4), inputProcessor2);
+ Assert.assertEquals(inputProcessorChain.getProcessors().get(5), inputProcessor1);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/OutputProcessorChainTest.java b/src/test/java/org/apache/xml/security/test/stax/OutputProcessorChainTest.java
index 6a87db8..f5469d6 100644
--- a/src/test/java/org/apache/xml/security/test/stax/OutputProcessorChainTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/OutputProcessorChainTest.java
@@ -18,29 +18,24 @@
*/
package org.apache.xml.security.test.stax;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.xml.stream.XMLStreamException;
-
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.stax.config.Init;
-import org.apache.xml.security.stax.ext.OutputProcessor;
-import org.apache.xml.security.stax.ext.OutputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.impl.OutboundSecurityContextImpl;
-import org.apache.xml.security.stax.impl.OutputProcessorChainImpl;
-
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.impl.OutputProcessorChainImpl;
+
+import javax.xml.stream.XMLStreamException;
+import java.util.HashSet;
+import java.util.Set;
/**
*/
-public class OutputProcessorChainTest {
+public class OutputProcessorChainTest extends Assert {
@Before
public void setUp() throws Exception {
@@ -120,9 +115,9 @@
};
outputProcessorChain.addProcessor(outputProcessor3);
- assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor1);
- assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor2);
- assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor3);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor1);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor2);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor3);
}
@Test
@@ -157,12 +152,12 @@
};
outputProcessorChain.addProcessor(outputProcessor6);
- assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor2);
- assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor5);
- assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor1);
- assertEquals(outputProcessorChain.getProcessors().get(3), outputProcessor6);
- assertEquals(outputProcessorChain.getProcessors().get(4), outputProcessor3);
- assertEquals(outputProcessorChain.getProcessors().get(5), outputProcessor4);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor2);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor5);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor1);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(3), outputProcessor6);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(4), outputProcessor3);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(5), outputProcessor4);
}
@Test
@@ -200,12 +195,12 @@
outputProcessor6.addBeforeProcessor(outputProcessor1.getClass().getName());
outputProcessorChain.addProcessor(outputProcessor6);
- assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor5);
- assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor2);
- assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor6);
- assertEquals(outputProcessorChain.getProcessors().get(3), outputProcessor1);
- assertEquals(outputProcessorChain.getProcessors().get(4), outputProcessor4);
- assertEquals(outputProcessorChain.getProcessors().get(5), outputProcessor3);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor5);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor2);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor6);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(3), outputProcessor1);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(4), outputProcessor4);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(5), outputProcessor3);
}
@Test
@@ -243,12 +238,12 @@
outputProcessor6.addAfterProcessor(outputProcessor1.getClass().getName());
outputProcessorChain.addProcessor(outputProcessor6);
- assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor2);
- assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor5);
- assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor1);
- assertEquals(outputProcessorChain.getProcessors().get(3), outputProcessor6);
- assertEquals(outputProcessorChain.getProcessors().get(4), outputProcessor3);
- assertEquals(outputProcessorChain.getProcessors().get(5), outputProcessor4);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor2);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor5);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor1);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(3), outputProcessor6);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(4), outputProcessor3);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(5), outputProcessor4);
}
@Test
@@ -283,11 +278,11 @@
outputProcessor6.addAfterProcessor("");
outputProcessorChain.addProcessor(outputProcessor6);
- assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor1);
- assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor2);
- assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor3);
- assertEquals(outputProcessorChain.getProcessors().get(3), outputProcessor6);
- assertEquals(outputProcessorChain.getProcessors().get(4), outputProcessor5);
- assertEquals(outputProcessorChain.getProcessors().get(5), outputProcessor4);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(0), outputProcessor1);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(1), outputProcessor2);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(2), outputProcessor3);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(3), outputProcessor6);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(4), outputProcessor5);
+ Assert.assertEquals(outputProcessorChain.getProcessors().get(5), outputProcessor4);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/TrimmerOutputStreamTest.java b/src/test/java/org/apache/xml/security/test/stax/TrimmerOutputStreamTest.java
index be6da51..445439e 100644
--- a/src/test/java/org/apache/xml/security/test/stax/TrimmerOutputStreamTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/TrimmerOutputStreamTest.java
@@ -18,34 +18,32 @@
*/
package org.apache.xml.security.test.stax;
+import org.junit.Assert;
import org.junit.Test;
import org.apache.xml.security.stax.impl.util.TrimmerOutputStream;
import java.io.ByteArrayOutputStream;
-import static org.junit.Assert.assertEquals;
-
/**
*/
-public class TrimmerOutputStreamTest {
+public class TrimmerOutputStreamTest extends Assert {
- private static final String TEST_STR
- = "Within this class we test if the TrimmerOutputStream works correctly under different conditions";
+ private final String testString = "Within this class we test if the TrimmerOutputStream works correctly under different conditions";
@Test
public void testWriteSingleBytes() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
TrimmerOutputStream trimmerOutputStream = new TrimmerOutputStream(baos, 32, 3, 4);
- byte[] TEST_STRBytes = ("<a>" + TEST_STR + "</a>").getBytes();
- for (int i = 0; i < TEST_STRBytes.length; i++) {
- trimmerOutputStream.write(TEST_STRBytes[i]);
+ byte[] testStringBytes = ("<a>" + testString + "</a>").getBytes();
+ for (int i = 0; i < testStringBytes.length; i++) {
+ trimmerOutputStream.write(testStringBytes[i]);
}
trimmerOutputStream.close();
- assertEquals(baos.size(), TEST_STRBytes.length - 7);
- assertEquals(baos.toString(), TEST_STR);
+ Assert.assertEquals(baos.size(), testStringBytes.length - 7);
+ Assert.assertEquals(baos.toString(), testString);
}
@Test
@@ -55,25 +53,25 @@
StringBuilder stringBuffer = new StringBuilder("<a>");
for (int i = 0; i < 100; i++) {
- stringBuffer.append(TEST_STR);
+ stringBuffer.append(testString);
}
stringBuffer.append("</a>");
- byte[] TEST_STRBytes = stringBuffer.toString().getBytes();
+ byte[] testStringBytes = stringBuffer.toString().getBytes();
int written = 0;
int count = 0;
do {
count++;
- trimmerOutputStream.write(TEST_STRBytes, written, count);
+ trimmerOutputStream.write(testStringBytes, written, count);
written += count;
}
- while ((written + count + 1) < TEST_STRBytes.length);
+ while ((written + count + 1) < testStringBytes.length);
- trimmerOutputStream.write(TEST_STRBytes, written, TEST_STRBytes.length - written);
+ trimmerOutputStream.write(testStringBytes, written, testStringBytes.length - written);
trimmerOutputStream.close();
- assertEquals(baos.size(), TEST_STRBytes.length - 7);
- assertEquals(baos.toString(), stringBuffer.toString().substring(3, stringBuffer.length() - 4));
+ Assert.assertEquals(baos.size(), testStringBytes.length - 7);
+ Assert.assertEquals(baos.toString(), stringBuffer.toString().substring(3, stringBuffer.length() - 4));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/UncategorizedTest.java b/src/test/java/org/apache/xml/security/test/stax/UncategorizedTest.java
index 1243239..e5c9cd2 100644
--- a/src/test/java/org/apache/xml/security/test/stax/UncategorizedTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/UncategorizedTest.java
@@ -19,6 +19,7 @@
package org.apache.xml.security.test.stax;
import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.junit.Assert;
import org.junit.Test;
import org.apache.xml.security.stax.config.Init;
import org.apache.xml.security.stax.ext.XMLSec;
@@ -30,30 +31,27 @@
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
/**
*/
-public class UncategorizedTest {
+public class UncategorizedTest extends Assert {
@Test
public void testConfigurationLoadFromUrl() throws Exception {
URL url =
this.getClass().getClassLoader().getResource(
- "org/apache/xml/security/c14n/in/32_input.xml");
+ "org/apache/xml/security/c14n/in/31_input.xml");
try {
Init.init(url.toURI(), this.getClass());
- fail();
+ Assert.fail();
} catch (XMLSecurityException e) {
- assertTrue(e.getMessage().contains("Cannot find the declaration of element 'doc'."));
+ Assert.assertTrue(e.getMessage().contains("Cannot find the declaration of element 'doc'."));
}
}
@Test
public void testDuplicateActions() throws Exception {
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -66,9 +64,9 @@
try {
XMLSec.getOutboundXMLSec(properties);
- fail();
+ Assert.fail();
} catch (XMLSecurityConfigurationException ex) {
- assertTrue(ex.getMessage().contains("Duplicate Actions are not allowed"));
+ Assert.assertTrue(ex.getMessage().contains("Duplicate Actions are not allowed"));
}
}
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/XMLSecEventTest.java b/src/test/java/org/apache/xml/security/test/stax/XMLSecEventTest.java
index c8737a3..622aadb 100644
--- a/src/test/java/org/apache/xml/security/test/stax/XMLSecEventTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/XMLSecEventTest.java
@@ -18,73 +18,56 @@
*/
package org.apache.xml.security.test.stax;
-import java.io.StringWriter;
-import java.util.ArrayDeque;
-import java.util.Deque;
+import org.apache.xml.security.stax.ext.stax.*;
+import org.apache.xml.security.stax.impl.XMLSecurityEventReader;
+import org.apache.xml.security.stax.impl.stax.*;
+import org.junit.Assert;
+import org.junit.Test;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.XMLEvent;
-
-import org.apache.xml.security.stax.ext.stax.XMLSecAttribute;
-import org.apache.xml.security.stax.ext.stax.XMLSecCharacters;
-import org.apache.xml.security.stax.ext.stax.XMLSecComment;
-import org.apache.xml.security.stax.ext.stax.XMLSecEntityDeclaration;
-import org.apache.xml.security.stax.ext.stax.XMLSecEntityReference;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
-import org.apache.xml.security.stax.ext.stax.XMLSecNamespace;
-import org.apache.xml.security.stax.ext.stax.XMLSecProcessingInstruction;
-import org.apache.xml.security.stax.impl.XMLSecurityEventReader;
-import org.apache.xml.security.stax.impl.stax.XMLSecAttributeImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecCharactersImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecCommentImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecEntityDeclarationImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecEntityReferenceImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecNamespaceImpl;
-import org.apache.xml.security.stax.impl.stax.XMLSecProcessingInstructionImpl;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import java.io.StringWriter;
+import java.util.ArrayDeque;
+import java.util.Deque;
/**
*/
-public class XMLSecEventTest {
+public class XMLSecEventTest extends Assert {
@Test
public void testWriteCharactersEncoded() throws Exception {
StringWriter stringWriter = new StringWriter();
XMLSecCharacters xmlSecCharacters = new XMLSecCharactersImpl("test", false, false, false, null);
xmlSecCharacters.writeAsEncodedUnicode(stringWriter);
- assertEquals("test", stringWriter.toString());
+ Assert.assertEquals("test", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecCharacters = new XMLSecCharactersImpl("<", false, false, false, null);
xmlSecCharacters.writeAsEncodedUnicode(stringWriter);
- assertEquals("<", stringWriter.toString());
+ Assert.assertEquals("<", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecCharacters = new XMLSecCharactersImpl(">", false, false, false, null);
xmlSecCharacters.writeAsEncodedUnicode(stringWriter);
- assertEquals(">", stringWriter.toString());
+ Assert.assertEquals(">", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecCharacters = new XMLSecCharactersImpl("&", false, false, false, null);
xmlSecCharacters.writeAsEncodedUnicode(stringWriter);
- assertEquals("&", stringWriter.toString());
+ Assert.assertEquals("&", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecCharacters = new XMLSecCharactersImpl("<&>", false, false, false, null);
xmlSecCharacters.writeAsEncodedUnicode(stringWriter);
- assertEquals("<&>", stringWriter.toString());
+ Assert.assertEquals("<&>", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecCharacters = new XMLSecCharactersImpl(" < & > ", false, false, false, null);
xmlSecCharacters.writeAsEncodedUnicode(stringWriter);
- assertEquals(" < & > ", stringWriter.toString());
+ Assert.assertEquals(" < & > ", stringWriter.toString());
}
@Test
@@ -92,22 +75,22 @@
StringWriter stringWriter = new StringWriter();
XMLSecAttribute xmlSecAttribute = new XMLSecAttributeImpl(new QName("test", "test", "test"), "test");
xmlSecAttribute.writeAsEncodedUnicode(stringWriter);
- assertEquals("test:test=\"test\"", stringWriter.toString());
+ Assert.assertEquals("test:test=\"test\"", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecAttribute = new XMLSecAttributeImpl(new QName("test"), "\"");
xmlSecAttribute.writeAsEncodedUnicode(stringWriter);
- assertEquals("test=\""\"", stringWriter.toString());
+ Assert.assertEquals("test=\""\"", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecAttribute = new XMLSecAttributeImpl(new QName("test"), "&");
xmlSecAttribute.writeAsEncodedUnicode(stringWriter);
- assertEquals("test=\"&\"", stringWriter.toString());
+ Assert.assertEquals("test=\"&\"", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecAttribute = new XMLSecAttributeImpl(new QName("test"), " & \" > < ");
xmlSecAttribute.writeAsEncodedUnicode(stringWriter);
- assertEquals("test=\" & " > < \"", stringWriter.toString());
+ Assert.assertEquals("test=\" & " > < \"", stringWriter.toString());
}
@Test
@@ -115,7 +98,7 @@
StringWriter stringWriter = new StringWriter();
XMLSecComment xmlSecAttribute = new XMLSecCommentImpl(" < > & \" '", null);
xmlSecAttribute.writeAsEncodedUnicode(stringWriter);
- assertEquals("<!-- < > & \" '-->", stringWriter.toString());
+ Assert.assertEquals("<!-- < > & \" '-->", stringWriter.toString());
}
@Test
@@ -123,7 +106,7 @@
StringWriter stringWriter = new StringWriter();
XMLSecEntityDeclaration xmlSecEntityDeclaration = new XMLSecEntityDeclarationImpl("test");
xmlSecEntityDeclaration.writeAsEncodedUnicode(stringWriter);
- assertEquals("<!ENTITY test \"\">", stringWriter.toString());
+ Assert.assertEquals("<!ENTITY test \"\">", stringWriter.toString());
}
@Test
@@ -131,7 +114,7 @@
StringWriter stringWriter = new StringWriter();
XMLSecEntityReference xmlSecEntityReference = new XMLSecEntityReferenceImpl("test", null, null);
xmlSecEntityReference.writeAsEncodedUnicode(stringWriter);
- assertEquals("&test;", stringWriter.toString());
+ Assert.assertEquals("&test;", stringWriter.toString());
}
@Test
@@ -139,22 +122,22 @@
StringWriter stringWriter = new StringWriter();
XMLSecNamespace xmlSecNamespace = XMLSecNamespaceImpl.getInstance("test", "test");
xmlSecNamespace.writeAsEncodedUnicode(stringWriter);
- assertEquals("xmlns:test=\"test\"", stringWriter.toString());
+ Assert.assertEquals("xmlns:test=\"test\"", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecNamespace = XMLSecNamespaceImpl.getInstance("", "\"");
xmlSecNamespace.writeAsEncodedUnicode(stringWriter);
- assertEquals("xmlns=\""\"", stringWriter.toString());
+ Assert.assertEquals("xmlns=\""\"", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecNamespace = XMLSecNamespaceImpl.getInstance("test", "&");
xmlSecNamespace.writeAsEncodedUnicode(stringWriter);
- assertEquals("xmlns:test=\"&\"", stringWriter.toString());
+ Assert.assertEquals("xmlns:test=\"&\"", stringWriter.toString());
stringWriter = new StringWriter();
xmlSecNamespace = XMLSecNamespaceImpl.getInstance("test", " & \" > < ");
xmlSecNamespace.writeAsEncodedUnicode(stringWriter);
- assertEquals("xmlns:test=\" & " > < \"", stringWriter.toString());
+ Assert.assertEquals("xmlns:test=\" & " > < \"", stringWriter.toString());
}
@Test
@@ -163,7 +146,7 @@
XMLSecProcessingInstruction xmlSecProcessingInstruction =
new XMLSecProcessingInstructionImpl("test", "test", null);
xmlSecProcessingInstruction.writeAsEncodedUnicode(stringWriter);
- assertEquals("<?test test?>", stringWriter.toString());
+ Assert.assertEquals("<?test test?>", stringWriter.toString());
}
@Test
@@ -173,7 +156,7 @@
xmlInputFactory.createXMLStreamReader(this.getClass().getClassLoader().getResourceAsStream(
"org/apache/xml/security/c14n/inExcl/plain-soap-1.1.xml"));
- Deque<XMLSecEvent> xmlSecEventDeque = new ArrayDeque<>();
+ Deque<XMLSecEvent> xmlSecEventDeque = new ArrayDeque<XMLSecEvent>();
do {
xmlSecEventDeque.push(XMLSecEventFactory.allocate(xmlStreamReader, null));
xmlStreamReader.next();
@@ -197,6 +180,6 @@
secXmlEvent.writeAsEncodedUnicode(secWriter);
}
- assertEquals(secWriter.toString(), stdWriter.toString());
+ Assert.assertEquals(secWriter.toString(), stdWriter.toString());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/XMLSecurityEventReaderTest.java b/src/test/java/org/apache/xml/security/test/stax/XMLSecurityEventReaderTest.java
index a43d105..0945919 100644
--- a/src/test/java/org/apache/xml/security/test/stax/XMLSecurityEventReaderTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/XMLSecurityEventReaderTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.xml.security.test.stax;
+import org.junit.Assert;
import org.junit.Test;
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
@@ -31,13 +32,9 @@
import java.util.ArrayDeque;
import java.util.Deque;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-
/**
*/
-public class XMLSecurityEventReaderTest {
+public class XMLSecurityEventReaderTest extends Assert {
@Test
public void testConformness() throws Exception {
@@ -46,7 +43,7 @@
xmlInputFactory.createXMLStreamReader(this.getClass().getClassLoader().getResourceAsStream(
"org/apache/xml/security/c14n/inExcl/plain-soap-1.1.xml"));
- Deque<XMLSecEvent> xmlSecEventDeque = new ArrayDeque<>();
+ Deque<XMLSecEvent> xmlSecEventDeque = new ArrayDeque<XMLSecEvent>();
do {
xmlSecEventDeque.push(XMLSecEventFactory.allocate(xmlStreamReader, null));
xmlStreamReader.next();
@@ -60,22 +57,22 @@
xmlInputFactory.createXMLEventReader(this.getClass().getClassLoader().getResourceAsStream(
"org/apache/xml/security/c14n/inExcl/plain-soap-1.1.xml"));
while (xmlEventReader.hasNext()) {
- assertEquals(xmlEventReader.hasNext(), xmlSecurityEventReader.hasNext());
+ Assert.assertEquals(xmlEventReader.hasNext(), xmlSecurityEventReader.hasNext());
XMLEvent stdXmlEvent = xmlEventReader.nextEvent();
XMLEvent secXmlEvent = xmlSecurityEventReader.nextEvent();
- assertEquals(stdXmlEvent.getEventType(), secXmlEvent.getEventType());
+ Assert.assertEquals(stdXmlEvent.getEventType(), secXmlEvent.getEventType());
XMLEvent stdPeekedXMLEvent = xmlEventReader.peek();
XMLEvent secPeekedXMLEvent = xmlSecurityEventReader.peek();
if (stdPeekedXMLEvent == null) {
- assertNull(secPeekedXMLEvent);
+ Assert.assertNull(secPeekedXMLEvent);
} else {
- assertEquals(stdPeekedXMLEvent.getEventType(), secPeekedXMLEvent.getEventType());
+ Assert.assertEquals(stdPeekedXMLEvent.getEventType(), secPeekedXMLEvent.getEventType());
}
}
- assertFalse(xmlEventReader.hasNext());
- assertFalse(xmlSecurityEventReader.hasNext());
+ Assert.assertFalse(xmlEventReader.hasNext());
+ Assert.assertFalse(xmlSecurityEventReader.hasNext());
}
@Test
@@ -85,7 +82,7 @@
xmlInputFactory.createXMLStreamReader(this.getClass().getClassLoader().getResourceAsStream(
"org/apache/xml/security/c14n/inExcl/plain-soap-1.1.xml"));
- Deque<XMLSecEvent> xmlSecEventDeque = new ArrayDeque<>();
+ Deque<XMLSecEvent> xmlSecEventDeque = new ArrayDeque<XMLSecEvent>();
do {
xmlSecEventDeque.push(XMLSecEventFactory.allocate(xmlStreamReader, null));
xmlStreamReader.next();
@@ -109,18 +106,18 @@
}
XMLEvent secXmlEvent = xmlSecurityEventReader.nextEvent();
- assertEquals(stdXmlEvent.getEventType(), secXmlEvent.getEventType());
+ Assert.assertEquals(stdXmlEvent.getEventType(), secXmlEvent.getEventType());
XMLEvent stdPeekedXMLEvent = xmlEventReader.peek();
XMLEvent secPeekedXMLEvent = xmlSecurityEventReader.peek();
if (stdPeekedXMLEvent == null) {
- assertNull(secPeekedXMLEvent);
+ Assert.assertNull(secPeekedXMLEvent);
} else {
- assertEquals(stdPeekedXMLEvent.getEventType(), secPeekedXMLEvent.getEventType());
+ Assert.assertEquals(stdPeekedXMLEvent.getEventType(), secPeekedXMLEvent.getEventType());
}
}
- assertFalse(xmlEventReader.hasNext());
- assertFalse(xmlSecurityEventReader.hasNext());
+ Assert.assertFalse(xmlEventReader.hasNext());
+ Assert.assertFalse(xmlSecurityEventReader.hasNext());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/XMLSecurityEventWriterTest.java b/src/test/java/org/apache/xml/security/test/stax/XMLSecurityEventWriterTest.java
index 5025d50..497ab3c 100644
--- a/src/test/java/org/apache/xml/security/test/stax/XMLSecurityEventWriterTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/XMLSecurityEventWriterTest.java
@@ -23,6 +23,7 @@
import org.apache.xml.security.stax.impl.stax.XMLSecEndElementImpl;
import org.apache.xml.security.stax.impl.stax.XMLSecNamespaceImpl;
import org.apache.xml.security.stax.impl.stax.XMLSecStartElementImpl;
+import org.junit.Assert;
import org.junit.Test;
import org.custommonkey.xmlunit.XMLAssert;
@@ -33,11 +34,9 @@
import javax.xml.stream.events.XMLEvent;
import java.io.StringWriter;
-import static org.junit.Assert.assertEquals;
-
/**
*/
-public class XMLSecurityEventWriterTest {
+public class XMLSecurityEventWriterTest extends Assert {
@Test
public void testConformness() throws Exception {
@@ -80,7 +79,7 @@
xmlEventWriter.add(new XMLSecStartElementImpl(new QName("http://ns3", "c", ""), null, null));
xmlEventWriter.close();
- assertEquals(
+ Assert.assertEquals(
"<ns1:a xmlns:ns1=\"http://ns1\">" +
"<b xmlns=\"http://ns2\"/>" +
"<c xmlns=\"http://ns3\">" +
@@ -88,4 +87,4 @@
"</ns1:a>",
stringWriter.toString());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamReaderTest.java b/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamReaderTest.java
index 3f2c9b7..2c27061 100644
--- a/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamReaderTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamReaderTest.java
@@ -18,13 +18,20 @@
*/
package org.apache.xml.security.test.stax;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.HashSet;
-import java.util.Set;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.config.Init;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.custommonkey.xmlunit.XMLAssert;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
+import org.apache.xml.security.stax.impl.DocumentContextImpl;
+import org.apache.xml.security.stax.impl.InputProcessorChainImpl;
+import org.apache.xml.security.stax.impl.InboundSecurityContextImpl;
+import org.apache.xml.security.stax.impl.XMLSecurityStreamReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
@@ -33,32 +40,17 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamResult;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.config.Init;
-import org.apache.xml.security.stax.ext.InputProcessor;
-import org.apache.xml.security.stax.ext.InputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.ext.stax.XMLSecEventFactory;
-import org.apache.xml.security.stax.impl.DocumentContextImpl;
-import org.apache.xml.security.stax.impl.InboundSecurityContextImpl;
-import org.apache.xml.security.stax.impl.InputProcessorChainImpl;
-import org.apache.xml.security.stax.impl.XMLSecurityStreamReader;
-
-import org.custommonkey.xmlunit.XMLAssert;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.HashSet;
+import java.util.Set;
/**
*/
-public class XMLSecurityStreamReaderTest {
+public class XMLSecurityStreamReaderTest extends Assert {
@Before
public void setUp() throws Exception {
@@ -75,7 +67,7 @@
inputProcessorChain.addProcessor(new EventReaderProcessor());
XMLSecurityStreamReader xmlSecurityStreamReader = new XMLSecurityStreamReader(inputProcessorChain, securityProperties);
int event = xmlSecurityStreamReader.next();
- assertEquals(XMLStreamConstants.START_DOCUMENT, event);
+ Assert.assertEquals(XMLStreamConstants.START_DOCUMENT, event);
}
@Test
@@ -87,7 +79,7 @@
inputProcessorChain.addProcessor(new EventReaderProcessor());
XMLSecurityStreamReader xmlSecurityStreamReader = new XMLSecurityStreamReader(inputProcessorChain, securityProperties);
int event = xmlSecurityStreamReader.next();
- assertEquals(XMLStreamConstants.START_ELEMENT, event);
+ Assert.assertEquals(XMLStreamConstants.START_ELEMENT, event);
}
@Test
@@ -128,128 +120,128 @@
do {
switch (stdXMLEventType) {
case XMLStreamConstants.START_ELEMENT:
- assertTrue(xmlSecurityStreamReader.isStartElement());
- assertFalse(xmlSecurityStreamReader.isEndElement());
- assertEquals(stdXmlStreamReader.getLocalName(), xmlSecurityStreamReader.getLocalName());
- assertEquals(stdXmlStreamReader.getName(), xmlSecurityStreamReader.getName());
- assertEquals(stdXmlStreamReader.getNamespaceURI(), xmlSecurityStreamReader.getNamespaceURI());
+ Assert.assertTrue(xmlSecurityStreamReader.isStartElement());
+ Assert.assertFalse(xmlSecurityStreamReader.isEndElement());
+ Assert.assertEquals(stdXmlStreamReader.getLocalName(), xmlSecurityStreamReader.getLocalName());
+ Assert.assertEquals(stdXmlStreamReader.getName(), xmlSecurityStreamReader.getName());
+ Assert.assertEquals(stdXmlStreamReader.getNamespaceURI(), xmlSecurityStreamReader.getNamespaceURI());
if (stdXmlStreamReader.getPrefix() == null) {
- assertEquals("", xmlSecurityStreamReader.getPrefix());
+ Assert.assertEquals("", xmlSecurityStreamReader.getPrefix());
} else {
- assertEquals(stdXmlStreamReader.getPrefix(), xmlSecurityStreamReader.getPrefix());
+ Assert.assertEquals(stdXmlStreamReader.getPrefix(), xmlSecurityStreamReader.getPrefix());
}
- assertEquals(stdXmlStreamReader.hasName(), xmlSecurityStreamReader.hasName());
- assertEquals(stdXmlStreamReader.hasText(), xmlSecurityStreamReader.hasText());
- assertEquals(stdXmlStreamReader.getAttributeCount(), xmlSecurityStreamReader.getAttributeCount());
- assertEquals(stdXmlStreamReader.getNamespaceCount(), xmlSecurityStreamReader.getNamespaceCount());
+ Assert.assertEquals(stdXmlStreamReader.hasName(), xmlSecurityStreamReader.hasName());
+ Assert.assertEquals(stdXmlStreamReader.hasText(), xmlSecurityStreamReader.hasText());
+ Assert.assertEquals(stdXmlStreamReader.getAttributeCount(), xmlSecurityStreamReader.getAttributeCount());
+ Assert.assertEquals(stdXmlStreamReader.getNamespaceCount(), xmlSecurityStreamReader.getNamespaceCount());
for (int i = 0; i < stdXmlStreamReader.getAttributeCount(); i++) {
- assertEquals(stdXmlStreamReader.getAttributeLocalName(i), xmlSecurityStreamReader.getAttributeLocalName(i));
- assertEquals(stdXmlStreamReader.getAttributeName(i), xmlSecurityStreamReader.getAttributeName(i));
+ Assert.assertEquals(stdXmlStreamReader.getAttributeLocalName(i), xmlSecurityStreamReader.getAttributeLocalName(i));
+ Assert.assertEquals(stdXmlStreamReader.getAttributeName(i), xmlSecurityStreamReader.getAttributeName(i));
if (stdXmlStreamReader.getAttributeNamespace(i) == null) {
- assertEquals("", xmlSecurityStreamReader.getAttributeNamespace(i));
+ Assert.assertEquals("", xmlSecurityStreamReader.getAttributeNamespace(i));
} else {
- assertEquals(stdXmlStreamReader.getAttributeNamespace(i), xmlSecurityStreamReader.getAttributeNamespace(i));
+ Assert.assertEquals(stdXmlStreamReader.getAttributeNamespace(i), xmlSecurityStreamReader.getAttributeNamespace(i));
}
if (stdXmlStreamReader.getAttributePrefix(i) == null) {
- assertEquals("", xmlSecurityStreamReader.getAttributePrefix(i));
+ Assert.assertEquals("", xmlSecurityStreamReader.getAttributePrefix(i));
} else {
- assertEquals(stdXmlStreamReader.getAttributePrefix(i), xmlSecurityStreamReader.getAttributePrefix(i));
+ Assert.assertEquals(stdXmlStreamReader.getAttributePrefix(i), xmlSecurityStreamReader.getAttributePrefix(i));
}
- assertEquals(stdXmlStreamReader.getAttributeType(i), xmlSecurityStreamReader.getAttributeType(i));
- assertEquals(stdXmlStreamReader.getAttributeValue(i), xmlSecurityStreamReader.getAttributeValue(i));
+ Assert.assertEquals(stdXmlStreamReader.getAttributeType(i), xmlSecurityStreamReader.getAttributeType(i));
+ Assert.assertEquals(stdXmlStreamReader.getAttributeValue(i), xmlSecurityStreamReader.getAttributeValue(i));
}
for (int i = 0; i < stdXmlStreamReader.getNamespaceCount(); i++) {
if (stdXmlStreamReader.getNamespacePrefix(i) == null) {
- assertEquals("", xmlSecurityStreamReader.getNamespacePrefix(i));
+ Assert.assertEquals("", xmlSecurityStreamReader.getNamespacePrefix(i));
} else {
- assertEquals(stdXmlStreamReader.getNamespacePrefix(i), xmlSecurityStreamReader.getNamespacePrefix(i));
+ Assert.assertEquals(stdXmlStreamReader.getNamespacePrefix(i), xmlSecurityStreamReader.getNamespacePrefix(i));
}
- assertEquals(stdXmlStreamReader.getNamespaceURI(i), xmlSecurityStreamReader.getNamespaceURI(i));
+ Assert.assertEquals(stdXmlStreamReader.getNamespaceURI(i), xmlSecurityStreamReader.getNamespaceURI(i));
}
break;
case XMLStreamConstants.END_ELEMENT:
- assertFalse(xmlSecurityStreamReader.isStartElement());
- assertTrue(xmlSecurityStreamReader.isEndElement());
- assertEquals(stdXmlStreamReader.getLocalName(), xmlSecurityStreamReader.getLocalName());
- assertEquals(stdXmlStreamReader.getName(), xmlSecurityStreamReader.getName());
- assertEquals(stdXmlStreamReader.getNamespaceURI(), xmlSecurityStreamReader.getNamespaceURI());
+ Assert.assertFalse(xmlSecurityStreamReader.isStartElement());
+ Assert.assertTrue(xmlSecurityStreamReader.isEndElement());
+ Assert.assertEquals(stdXmlStreamReader.getLocalName(), xmlSecurityStreamReader.getLocalName());
+ Assert.assertEquals(stdXmlStreamReader.getName(), xmlSecurityStreamReader.getName());
+ Assert.assertEquals(stdXmlStreamReader.getNamespaceURI(), xmlSecurityStreamReader.getNamespaceURI());
if (stdXmlStreamReader.getPrefix() == null) {
- assertEquals("", xmlSecurityStreamReader.getPrefix());
+ Assert.assertEquals("", xmlSecurityStreamReader.getPrefix());
} else {
- assertEquals(stdXmlStreamReader.getPrefix(), xmlSecurityStreamReader.getPrefix());
+ Assert.assertEquals(stdXmlStreamReader.getPrefix(), xmlSecurityStreamReader.getPrefix());
}
- assertEquals(stdXmlStreamReader.hasName(), xmlSecurityStreamReader.hasName());
- assertEquals(stdXmlStreamReader.hasText(), xmlSecurityStreamReader.hasText());
+ Assert.assertEquals(stdXmlStreamReader.hasName(), xmlSecurityStreamReader.hasName());
+ Assert.assertEquals(stdXmlStreamReader.hasText(), xmlSecurityStreamReader.hasText());
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
- assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
- assertEquals(stdXmlStreamReader.getPITarget(), xmlSecurityStreamReader.getPITarget());
- assertEquals(stdXmlStreamReader.getPIData(), xmlSecurityStreamReader.getPIData());
+ Assert.assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
+ Assert.assertEquals(stdXmlStreamReader.getPITarget(), xmlSecurityStreamReader.getPITarget());
+ Assert.assertEquals(stdXmlStreamReader.getPIData(), xmlSecurityStreamReader.getPIData());
break;
case XMLStreamConstants.CHARACTERS:
- assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
- assertEquals(stdXmlStreamReader.isWhiteSpace(), xmlSecurityStreamReader.isWhiteSpace());
- assertEquals(stdXmlStreamReader.getText(), xmlSecurityStreamReader.getText());
- assertEquals(
+ Assert.assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
+ Assert.assertEquals(stdXmlStreamReader.isWhiteSpace(), xmlSecurityStreamReader.isWhiteSpace());
+ Assert.assertEquals(stdXmlStreamReader.getText(), xmlSecurityStreamReader.getText());
+ Assert.assertEquals(
new String(stdXmlStreamReader.getTextCharacters(), stdXmlStreamReader.getTextStart(), stdXmlStreamReader.getTextLength()),
new String(xmlSecurityStreamReader.getTextCharacters(), xmlSecurityStreamReader.getTextStart(), xmlSecurityStreamReader.getTextLength()));
- assertEquals(stdXmlStreamReader.getTextLength(), xmlSecurityStreamReader.getTextLength());
+ Assert.assertEquals(stdXmlStreamReader.getTextLength(), xmlSecurityStreamReader.getTextLength());
break;
case XMLStreamConstants.COMMENT:
- assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
- assertEquals(stdXmlStreamReader.isWhiteSpace(), xmlSecurityStreamReader.isWhiteSpace());
- assertEquals(stdXmlStreamReader.getText(), xmlSecurityStreamReader.getText());
- assertEquals(
+ Assert.assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
+ Assert.assertEquals(stdXmlStreamReader.isWhiteSpace(), xmlSecurityStreamReader.isWhiteSpace());
+ Assert.assertEquals(stdXmlStreamReader.getText(), xmlSecurityStreamReader.getText());
+ Assert.assertEquals(
new String(stdXmlStreamReader.getTextCharacters(), stdXmlStreamReader.getTextStart(), stdXmlStreamReader.getTextLength()),
new String(xmlSecurityStreamReader.getTextCharacters(), xmlSecurityStreamReader.getTextStart(), xmlSecurityStreamReader.getTextLength()));
- assertEquals(stdXmlStreamReader.getTextLength(), xmlSecurityStreamReader.getTextLength());
+ Assert.assertEquals(stdXmlStreamReader.getTextLength(), xmlSecurityStreamReader.getTextLength());
break;
case XMLStreamConstants.SPACE:
- assertEquals(stdXmlStreamReader.isWhiteSpace(), xmlSecurityStreamReader.isWhiteSpace());
- assertEquals(stdXmlStreamReader.getText(), xmlSecurityStreamReader.getText());
- assertEquals(
+ Assert.assertEquals(stdXmlStreamReader.isWhiteSpace(), xmlSecurityStreamReader.isWhiteSpace());
+ Assert.assertEquals(stdXmlStreamReader.getText(), xmlSecurityStreamReader.getText());
+ Assert.assertEquals(
new String(stdXmlStreamReader.getTextCharacters(), stdXmlStreamReader.getTextStart(), stdXmlStreamReader.getTextLength()),
new String(xmlSecurityStreamReader.getTextCharacters(), xmlSecurityStreamReader.getTextStart(), xmlSecurityStreamReader.getTextLength()));
- assertEquals(stdXmlStreamReader.getTextLength(), xmlSecurityStreamReader.getTextLength());
+ Assert.assertEquals(stdXmlStreamReader.getTextLength(), xmlSecurityStreamReader.getTextLength());
break;
case XMLStreamConstants.START_DOCUMENT:
- assertEquals(stdXmlStreamReader.getCharacterEncodingScheme(), xmlSecurityStreamReader.getCharacterEncodingScheme());
- assertEquals(stdXmlStreamReader.getEncoding(), xmlSecurityStreamReader.getEncoding());
- //assertEquals(stdXmlStreamReader.getVersion(), xmlSecurityStreamReader.getVersion());
+ Assert.assertEquals(stdXmlStreamReader.getCharacterEncodingScheme(), xmlSecurityStreamReader.getCharacterEncodingScheme());
+ Assert.assertEquals(stdXmlStreamReader.getEncoding(), xmlSecurityStreamReader.getEncoding());
+ //Assert.assertEquals(stdXmlStreamReader.getVersion(), xmlSecurityStreamReader.getVersion());
break;
case XMLStreamConstants.END_DOCUMENT:
break;
case XMLStreamConstants.ENTITY_REFERENCE:
- assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
- assertEquals(stdXmlStreamReader.getText(), xmlSecurityStreamReader.getText());
+ Assert.assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
+ Assert.assertEquals(stdXmlStreamReader.getText(), xmlSecurityStreamReader.getText());
break;
case XMLStreamConstants.ATTRIBUTE:
break;
case XMLStreamConstants.DTD:
- assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
+ Assert.assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
break;
case XMLStreamConstants.CDATA:
- assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
+ Assert.assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
break;
case XMLStreamConstants.NAMESPACE:
break;
case XMLStreamConstants.NOTATION_DECLARATION:
break;
case XMLStreamConstants.ENTITY_DECLARATION:
- assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
+ Assert.assertEquals(stdXmlStreamReader.isCharacters(), xmlSecurityStreamReader.isCharacters());
break;
}
//hmm2 an eventreader returns a CHARACTER EVENT for an ignorable whitespace whereby a streamReader returns it as SPACE
if (stdXMLEventType == XMLStreamConstants.SPACE && secXMLEventType == XMLStreamConstants.CHARACTERS) {
secXMLEventType = XMLStreamConstants.SPACE;
}
- assertEquals(stdXMLEventType, secXMLEventType);
+ Assert.assertEquals(stdXMLEventType, secXMLEventType);
if (stdXmlStreamReader.hasNext()) {
- assertTrue(xmlSecurityStreamReader.hasNext());
+ Assert.assertTrue(xmlSecurityStreamReader.hasNext());
stdXMLEventType = stdXmlStreamReader.next();
secXMLEventType = xmlSecurityStreamReader.next();
} else {
- assertFalse(xmlSecurityStreamReader.hasNext());
+ Assert.assertFalse(xmlSecurityStreamReader.hasNext());
break;
}
} while (true);
diff --git a/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamWriterTest.java b/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamWriterTest.java
index e064d8e..c427366 100644
--- a/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamWriterTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/XMLSecurityStreamWriterTest.java
@@ -18,41 +18,32 @@
*/
package org.apache.xml.security.test.stax;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.config.Init;
+import org.apache.xml.security.stax.impl.OutboundSecurityContextImpl;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.custommonkey.xmlunit.XMLAssert;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
+import org.apache.xml.security.stax.impl.OutputProcessorChainImpl;
+import org.apache.xml.security.stax.impl.XMLSecurityStreamWriter;
import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.stax.config.Init;
-import org.apache.xml.security.stax.ext.OutputProcessor;
-import org.apache.xml.security.stax.ext.OutputProcessorChain;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
-import org.apache.xml.security.stax.impl.OutboundSecurityContextImpl;
-import org.apache.xml.security.stax.impl.OutputProcessorChainImpl;
-import org.apache.xml.security.stax.impl.XMLSecurityStreamWriter;
-
-import org.custommonkey.xmlunit.XMLAssert;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
/**
*/
-public class XMLSecurityStreamWriterTest {
+public class XMLSecurityStreamWriterTest extends Assert {
@Before
public void setUp() throws Exception {
@@ -184,7 +175,7 @@
xmlSecurityStreamWriter.writeProcessingInstruction("PI", "there");
stdXmlStreamWriter.writeProcessingInstruction("PI", "there");
- assertEquals(xmlSecurityStreamWriter.getPrefix("test4ns"), stdXmlStreamWriter.getPrefix("test4ns"));
+ Assert.assertEquals(xmlSecurityStreamWriter.getPrefix("test4ns"), stdXmlStreamWriter.getPrefix("test4ns"));
stdXmlStreamWriter.close();
xmlSecurityStreamWriter.close();
diff --git a/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer11Test.java b/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer11Test.java
index 0714995..28f5522 100644
--- a/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer11Test.java
+++ b/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer11Test.java
@@ -32,6 +32,7 @@
import javax.xml.stream.XMLResolver;
import javax.xml.stream.XMLStreamException;
+import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -39,12 +40,6 @@
import java.net.URL;
import java.nio.charset.StandardCharsets;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
*/
public class Canonicalizer11Test {
@@ -332,10 +327,47 @@
c14nAndCompare(fileIn, fileIn, true);
fail();
} catch (XMLStreamException cex) {
- assertNotNull(cex);
+ assertTrue(cex != null);
}
}
+// /**
+// * The XPath data model represents data using UCS characters.
+// * Implementations MUST use XML processors that support UTF-8 and UTF-16
+// * and translate to the UCS character domain. For UTF-16, the leading byte
+// * order mark is treated as an artifact of encoding and stripped from the
+// * UCS character data (subsequent zero width non-breaking spaces appearing
+// * within the UTF-16 data are not removed) [UTF-16, Section 3.2]. Support
+// * for ISO-8859-1 encoding is RECOMMENDED, and all other character encodings
+// * are OPTIONAL.
+// *
+// * $todo$ implement the test
+// * @throws CanonicalizationException
+// * @throws java.io.FileNotFoundException
+// * @throws java.io.IOException
+// * @throws InvalidCanonicalizerException
+// * @throws javax.xml.parsers.ParserConfigurationException
+// * @throws org.xml.sax.SAXException
+// * @throws javax.xml.transform.TransformerException
+// */
+// public static void testTranslationFromUTF16toUTF8() throws Exception {
+//
+// String val =
+// "<UTF16>The german &auml (which is Unicode &#xE4;): "ä"</UTF16>";
+// byte utf16[] = convertToUTF16(val.getBytes());
+// Canonicalizer c14n =
+// Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
+// byte c14nBytes[] = c14n.canonicalize(utf16);
+// org.xml.sax.EntityResolver resolver = new TestVectorResolver();
+// InputStream refStream = resolver.resolveEntity(
+// null,
+// prefix + "/in/testTranslationFromUTF16toUTF8.xml")
+// .getByteStream();
+// byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
+// boolean equal = java.security.MessageDigest.isEqual(refBytes, c14nBytes);
+//
+// assertTrue("Parser does not translate to UCS character domain", equal);
+// }
//
// /**
// * Method testXMLAttributes1
@@ -563,7 +595,7 @@
// db.setErrorHandler(new org.apache.xml.security.utils
// .IgnoreAllErrorHandler());
//
-// Document doc = XMLUtils.read(new ByteArrayInputStream(input.getBytes()));
+// Document doc = db.parse(new ByteArrayInputStream(input.getBytes()));
// Canonicalizer c14nizer =
// Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
// CachedXPathAPI xpathAPI = new CachedXPathAPI();
@@ -572,8 +604,8 @@
//
// NodeList nodes =
// xpathAPI.selectNodeList(doc, "(//*[local-name()='included'] | //@*[parent::node()[local-name()='included']])");
-// byte[] result = c14nizer.canonicalizeXPathNodeSet(nodes);
-// byte[] defined = definedOutput.getBytes();
+// byte result[] = c14nizer.canonicalizeXPathNodeSet(nodes);
+// byte defined[] = definedOutput.getBytes();
// assertEquals(definedOutput, new String(result));
// return java.security.MessageDigest.isEqual(defined, result);
// }
@@ -602,8 +634,8 @@
}
// org.xml.sax.InputSource refIs = resolver.resolveEntity(null, fileRef);
- // byte[] refBytes = JavaUtils.getBytesFromStream(refIs.getByteStream());
- byte[] refBytes = getBytesFromResource(fileRef);
+ // byte refBytes[] = JavaUtils.getBytesFromStream(refIs.getByteStream());
+ byte refBytes[] = getBytesFromResource(fileRef);
// if everything is OK, result is true; we do a binary compare, byte by byte
boolean result = java.security.MessageDigest.isEqual(refBytes, baos.toByteArray());
@@ -619,7 +651,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream inputStream = resource.openStream();
try {
- byte[] buf = new byte[1024];
+ byte buf[] = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
baos.write(buf, 0, len);
@@ -643,14 +675,14 @@
// * @throws javax.xml.transform.TransformerConfigurationException
// * @throws javax.xml.transform.TransformerException
// */
-// public static byte[] convertToUTF16(byte[] input) throws Exception {
+// public static byte[] convertToUTF16(byte input[]) throws Exception {
//
// //String ENCODING_ISO8859_1 = "ISO-8859-1";
// //String ENCODING_UTF8 = java.nio.charset.StandardCharsets.UTF_8;
// String ENCODING_UTF16 = "UTF-16";
// DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// DocumentBuilder db = dbf.newDocumentBuilder();
-// Document doc = XMLUtils.read(new ByteArrayInputStream(input));
+// Document doc = db.parse(new ByteArrayInputStream(input));
// TransformerFactory tFactory = TransformerFactory.newInstance();
// Transformer transformer = tFactory.newTransformer();
//
@@ -665,4 +697,4 @@
//
// return os.toByteArray();
// }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java b/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java
index 25d901f..95686de 100644
--- a/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315ExclusiveTest.java
@@ -37,6 +37,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import static org.junit.Assert.*;
import java.io.*;
import java.net.URL;
@@ -45,10 +46,6 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-
/**
*/
public class Canonicalizer20010315ExclusiveTest {
@@ -236,7 +233,7 @@
*/
@org.junit.Test
public void test24Aexcl() throws Exception {
- Document doc = XMLUtils.newDocument();
+ Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
Element local = doc.createElementNS("foo:bar", "dsig:local");
Element test = doc.createElementNS("http://example.net", "etsi:test");
Element elem2 = doc.createElementNS("http://example.net", "etsi:elem2");
@@ -781,7 +778,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream inputStream = resource.openStream();
try {
- byte[] buf = new byte[1024];
+ byte buf[] = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
baos.write(buf, 0, len);
diff --git a/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java b/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java
index cd811b6..f54d27a 100644
--- a/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java
+++ b/src/test/java/org/apache/xml/security/test/stax/c14n/Canonicalizer20010315Test.java
@@ -33,6 +33,7 @@
import javax.xml.stream.XMLResolver;
import javax.xml.stream.XMLStreamException;
+import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -40,12 +41,6 @@
import java.net.URL;
import java.nio.charset.StandardCharsets;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
*/
public class Canonicalizer20010315Test {
@@ -367,7 +362,7 @@
c14nAndCompare(fileIn, fileIn, true);
fail();
} catch (XMLStreamException cex) {
- assertNotNull(cex);
+ assertTrue(cex != null);
}
}
@@ -436,12 +431,16 @@
//
// String val =
// "<UTF16>The german &auml (which is Unicode &#xE4;): "ä"</UTF16>";
-// byte[] utf16 = convertToUTF16(val.getBytes());
+// byte utf16[] = convertToUTF16(val.getBytes());
// Canonicalizer c14n =
// Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
-// byte[] c14nBytes = c14n.canonicalize(utf16);
-// InputStream refStream = new FileInputStream(prefix + "/in/testTranslationFromUTF16toUTF8.xml");
-// byte[] refBytes = JavaUtils.getBytesFromStream(refStream);
+// byte c14nBytes[] = c14n.canonicalize(utf16);
+// org.xml.sax.EntityResolver resolver = new TestVectorResolver();
+// InputStream refStream = resolver.resolveEntity(
+// null,
+// prefix + "/in/testTranslationFromUTF16toUTF8.xml")
+// .getByteStream();
+// byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
// boolean equal = java.security.MessageDigest.isEqual(refBytes, c14nBytes);
//
// assertTrue("Parser does not translate to UCS character domain", equal);
@@ -673,7 +672,7 @@
// db.setErrorHandler(new org.apache.xml.security.utils
// .IgnoreAllErrorHandler());
//
-// Document doc = XMLUtils.read(new ByteArrayInputStream(input.getBytes()));
+// Document doc = db.parse(new ByteArrayInputStream(input.getBytes()));
// Canonicalizer c14nizer =
// Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
// CachedXPathAPI xpathAPI = new CachedXPathAPI();
@@ -682,8 +681,8 @@
//
// NodeList nodes =
// xpathAPI.selectNodeList(doc, "(//*[local-name()='included'] | //@*[parent::node()[local-name()='included']])");
-// byte[] result = c14nizer.canonicalizeXPathNodeSet(nodes);
-// byte[] defined = definedOutput.getBytes();
+// byte result[] = c14nizer.canonicalizeXPathNodeSet(nodes);
+// byte defined[] = definedOutput.getBytes();
// assertEquals(definedOutput, new String(result));
// return java.security.MessageDigest.isEqual(defined, result);
// }
@@ -711,8 +710,8 @@
}
// org.xml.sax.InputSource refIs = resolver.resolveEntity(null, fileRef);
- // byte[] refBytes = JavaUtils.getBytesFromStream(refIs.getByteStream());
- byte[] refBytes = getBytesFromResource(fileRef);
+ // byte refBytes[] = JavaUtils.getBytesFromStream(refIs.getByteStream());
+ byte refBytes[] = getBytesFromResource(fileRef);
// if everything is OK, result is true; we do a binary compare, byte by byte
boolean result = java.security.MessageDigest.isEqual(refBytes, baos.toByteArray());
@@ -734,7 +733,7 @@
inputStream = new UnixInputStream(inputStream);
}
try {
- byte[] buf = new byte[1024];
+ byte buf[] = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
baos.write(buf, 0, len);
@@ -758,14 +757,14 @@
// * @throws javax.xml.transform.TransformerConfigurationException
// * @throws javax.xml.transform.TransformerException
// */
-// public static byte[] convertToUTF16(byte[] input) throws Exception {
+// public static byte[] convertToUTF16(byte input[]) throws Exception {
//
// //String ENCODING_ISO8859_1 = "ISO-8859-1";
// //String ENCODING_UTF8 = StandardCharsets.UTF_8;
// String ENCODING_UTF16 = "UTF-16";
// DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// DocumentBuilder db = dbf.newDocumentBuilder();
-// Document doc = XMLUtils.read(new ByteArrayInputStream(input));
+// Document doc = db.parse(new ByteArrayInputStream(input));
// TransformerFactory tFactory = TransformerFactory.newInstance();
// Transformer transformer = tFactory.newTransformer();
//
@@ -780,4 +779,4 @@
//
// return os.toByteArray();
// }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/c14n/ExclusiveC14NInteropTest.java b/src/test/java/org/apache/xml/security/test/stax/c14n/ExclusiveC14NInteropTest.java
index 04417d5..21f0ab0 100644
--- a/src/test/java/org/apache/xml/security/test/stax/c14n/ExclusiveC14NInteropTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/c14n/ExclusiveC14NInteropTest.java
@@ -30,6 +30,7 @@
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -81,7 +82,8 @@
// Read in plaintext document
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream("interop/c14n/Y1/exc-signature.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey();
@@ -105,7 +107,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
private static PublicKey getPublicKey()
diff --git a/src/test/java/org/apache/xml/security/test/stax/c14n/Santuario191Test.java b/src/test/java/org/apache/xml/security/test/stax/c14n/Santuario191Test.java
index 05e7719..2ce686d 100644
--- a/src/test/java/org/apache/xml/security/test/stax/c14n/Santuario191Test.java
+++ b/src/test/java/org/apache/xml/security/test/stax/c14n/Santuario191Test.java
@@ -29,12 +29,11 @@
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
+import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
import java.io.StringReader;
-import static org.junit.Assert.assertEquals;
-
/**
* This is a test for Santuario-191:
* <p></p>
@@ -98,4 +97,4 @@
assertEquals(new String(baos.toByteArray(), java.nio.charset.StandardCharsets.UTF_8), EXPECTED_RESULT);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java b/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java
index d206a3c..89376e6 100644
--- a/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/encryption/BaltimoreEncTest.java
@@ -31,6 +31,7 @@
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -55,10 +56,8 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
/**
* Interop test for XML Encryption
*
@@ -87,7 +86,8 @@
}
File f = new File(filename);
- Document doc = XMLUtils.read(new java.io.FileInputStream(f), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(new java.io.FileInputStream(f));
cardNumber = retrieveCCNumber(doc);
@@ -114,7 +114,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-content-tripledes-cbc.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] keyBytes = "abcdefghijklmnopqrstuvwx".getBytes(StandardCharsets.US_ASCII);
@@ -140,7 +141,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
checkDecryptedDoc(document, true);
}
@@ -151,7 +152,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-content-aes256-cbc-prop.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] keyBytes = "abcdefghijklmnopqrstuvwxyz012345".getBytes(StandardCharsets.US_ASCII);
@@ -177,7 +179,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
checkDecryptedDoc(document, true);
}
@@ -188,7 +190,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-content-aes128-cbc-kw-aes192.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] keyBytes = "abcdefghijklmnopqrstuvwx".getBytes(StandardCharsets.US_ASCII);
@@ -214,7 +217,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
checkDecryptedDoc(document, true);
}
@@ -225,7 +228,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-element-tripledes-cbc-kw-aes128.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] keyBytes = "abcdefghijklmnop".getBytes(StandardCharsets.US_ASCII);
@@ -251,7 +255,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
checkDecryptedDoc(document, true);
}
@@ -262,7 +266,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-element-aes128-cbc-rsa-1_5.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -284,7 +289,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
checkDecryptedDoc(document, true);
}
@@ -295,7 +300,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-data-aes128-cbc.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] keyBytes = "abcdefghijklmnop".getBytes(StandardCharsets.US_ASCII);
@@ -321,7 +327,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -330,7 +336,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-data-aes256-cbc-kw-tripledes.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] keyBytes = "abcdefghijklmnopqrstuvwx".getBytes(StandardCharsets.US_ASCII);
@@ -356,7 +363,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -365,7 +372,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-data-aes192-cbc-kw-aes256.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] keyBytes = "abcdefghijklmnopqrstuvwxyz012345".getBytes(StandardCharsets.US_ASCII);
@@ -391,7 +399,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -400,7 +408,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/encrypt-data-tripledes-cbc-rsa-oaep-mgf1p.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -422,7 +431,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
/*
@@ -432,7 +441,7 @@
private void checkDecryptedDoc(Document d, boolean doNodeCheck) throws Exception {
String cc = retrieveCCNumber(d);
- assertEquals(cardNumber, cc);
+ assertTrue(cc, cc != null && cc.equals(cardNumber));
// Test cc numbers
if (doNodeCheck) {
@@ -499,4 +508,4 @@
return count;
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java b/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java
index 7a58232..073688a 100644
--- a/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/encryption/DecryptionTest.java
@@ -37,6 +37,7 @@
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -70,23 +71,16 @@
import org.apache.xml.security.test.stax.utils.StAX2DOM;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* A set of test-cases for Decryption.
*
*/
-public class DecryptionTest {
+public class DecryptionTest extends Assert {
private XMLInputFactory xmlInputFactory;
private TransformerFactory transformerFactory = TransformerFactory.newInstance();
@@ -105,7 +99,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
SecretKey secretKey = generateSecretKey();
@@ -120,7 +115,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -139,11 +134,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedElementSecurityEvents(securityEventListener);
@@ -160,7 +155,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
SecretKey secretKey = generateSecretKey();
@@ -175,7 +171,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -197,11 +193,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedContentSecurityEvents(securityEventListener);
@@ -217,7 +213,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -234,7 +231,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -256,11 +253,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedElementSecurityEvents(securityEventListener);
@@ -276,7 +273,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
SecretKey secretKey = generateSecretKey();
@@ -292,7 +290,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -314,15 +312,15 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the ShippingAddress decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "ShippingAddress");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkMultipleEncryptedElementSecurityEvents(securityEventListener);
@@ -342,7 +340,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] bits192 = "abcdefghijklmnopqrstuvwx".getBytes();
@@ -363,7 +362,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -385,11 +384,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedContentSecurityEvents(securityEventListener);
@@ -411,7 +410,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
@@ -434,7 +434,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -456,11 +456,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
// Check the SecurityEvents
checkEncryptedContentSecurityEvents(securityEventListener);
@@ -478,7 +478,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
@@ -501,7 +502,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -523,11 +524,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
// Check the SecurityEvents
checkEncryptedContentSecurityEvents(securityEventListener);
@@ -549,7 +550,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] bits192 = "abcdefghijklmnopqrstuvwx".getBytes();
@@ -572,7 +574,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -594,11 +596,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedContentSecurityEvents(securityEventListener);
@@ -616,7 +618,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] passPhrase = "24 Bytes per DESede key!".getBytes();
@@ -634,7 +637,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -656,11 +659,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedElementSecurityEvents(securityEventListener);
@@ -676,7 +679,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] bits128 = {
@@ -696,7 +700,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -718,11 +722,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedElementSecurityEvents(securityEventListener);
@@ -738,7 +742,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] bits192 = {
@@ -760,7 +765,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -782,11 +787,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedElementSecurityEvents(securityEventListener);
@@ -802,7 +807,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] bits256 = {
@@ -826,7 +832,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -848,11 +854,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedElementSecurityEvents(securityEventListener);
@@ -870,7 +876,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] passPhrase = "24 Bytes per DESede key!".getBytes();
@@ -888,7 +895,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -910,11 +917,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptionToken(securityEventListener, null, secretKey,
@@ -927,9 +934,10 @@
public void testPhysicalRepresentation() throws Exception {
final String DATA1 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:root xmlns:ns=\"ns.com\"><ns:elem xmlns:ns2=\"ns2.com\">11</ns:elem></ns:root>";
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
Document document = null;
try (InputStream is = new ByteArrayInputStream(DATA1.getBytes(StandardCharsets.UTF_8))) {
- document = XMLUtils.read(is, false);
+ document = db.parse(is);
}
// Set up the Key
@@ -948,7 +956,7 @@
// Check the element encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("ns.com", "elem");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -969,11 +977,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the element decrypted ok
nodeList = document.getElementsByTagNameNS("ns.com", "elem");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
Element decrElem = (Element)document.getDocumentElement().getFirstChild();
assertEquals("ns:elem", decrElem.getNodeName());
@@ -994,9 +1002,10 @@
public void testPhysicalRepresentation2() throws Exception {
final String DATA1 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:root xmlns=\"defns.com\" xmlns:ns=\"ns.com\"><elem xmlns=\"\">11</elem></ns:root>";
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
Document document = null;
try (InputStream is = new ByteArrayInputStream(DATA1.getBytes(StandardCharsets.UTF_8))) {
- document = XMLUtils.read(is, false);
+ document = db.parse(is);
}
// Set up the Key
@@ -1015,7 +1024,7 @@
// Check the element encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("", "elem");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1036,11 +1045,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the element decrypted ok
nodeList = document.getElementsByTagNameNS("", "elem");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
Element decrElem = (Element)document.getDocumentElement().getFirstChild();
assertEquals("elem", decrElem.getNodeName());
@@ -1153,7 +1162,7 @@
String expression = "//*[local-name()='" + localName + "']";
Element elementToEncrypt =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(elementToEncrypt);
+ Assert.assertNotNull(elementToEncrypt);
document = cipher.doFinal(document, elementToEncrypt, content);
}
@@ -1162,7 +1171,7 @@
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertTrue(nodeList.getLength() > 0);
+ Assert.assertTrue(nodeList.getLength() > 0);
}
protected void checkEncryptedElementSecurityEvents(TestSecurityEventListener securityEventListener) {
@@ -1263,7 +1272,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
for (int i = 0; i < 7; i++) {
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
@@ -1300,7 +1310,7 @@
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Exception expected");
} catch (XMLStreamException e) {
assertTrue(e.getCause() instanceof XMLSecurityException);
@@ -1315,7 +1325,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyPairGenerator rsaKeygen = KeyPairGenerator.getInstance("RSA");
@@ -1338,13 +1349,13 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
NodeList cipherValues = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_CipherValue.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_CipherValue.getLocalPart());
Element cipherValueElement = (Element)cipherValues.item(0);
- assertEquals(
+ Assert.assertEquals(
cipherValueElement.getParentNode().getParentNode().getLocalName(),
XMLSecurityConstants.TAG_xenc_EncryptedKey.getLocalPart());
@@ -1381,9 +1392,9 @@
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} catch (XMLStreamException e) {
- assertFalse(e.getMessage().contains("Unwrapping failed"));
+ Assert.assertFalse(e.getMessage().contains("Unwrapping failed"));
}
}
@@ -1393,7 +1404,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -1420,7 +1432,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1441,11 +1453,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -1454,7 +1466,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -1491,7 +1504,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1512,11 +1525,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -1525,7 +1538,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -1561,7 +1575,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1583,11 +1597,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -1596,7 +1610,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -1632,7 +1647,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1654,11 +1669,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -1675,7 +1690,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -1711,7 +1727,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1733,11 +1749,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -1746,7 +1762,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -1773,7 +1790,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1795,11 +1812,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -1808,7 +1825,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
SecretKey secretKey = generateSecretKey();
@@ -1823,7 +1841,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1846,13 +1864,13 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// XMLUtils.outputDOM(document, System.out);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedElementSecurityEvents(securityEventListener);
@@ -1869,7 +1887,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
SecretKey secretKey = generateSecretKey();
@@ -1884,7 +1903,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1907,11 +1926,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
checkEncryptedContentSecurityEvents(securityEventListener);
@@ -1927,7 +1946,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
SecretKey secretKey = generateSecretKey();
@@ -1942,7 +1962,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PurchaseOrder");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -1965,11 +1985,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "PurchaseOrder");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the SecurityEvents
EncryptedElementSecurityEvent encryptedElementEvent =
@@ -1983,4 +2003,4 @@
checkEncryptionMethod(
securityEventListener, "http://www.w3.org/2001/04/xmlenc#tripledes-cbc", null);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/encryption/EncryptionCreationTest.java b/src/test/java/org/apache/xml/security/test/stax/encryption/EncryptionCreationTest.java
index bc70543..9b9217c 100644
--- a/src/test/java/org/apache/xml/security/test/stax/encryption/EncryptionCreationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/encryption/EncryptionCreationTest.java
@@ -54,6 +54,7 @@
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Attr;
@@ -61,17 +62,11 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* A set of test-cases for Encryption.
*
*/
-public class EncryptionCreationTest {
+public class EncryptionCreationTest extends Assert {
private XMLInputFactory xmlInputFactory;
@@ -87,7 +82,7 @@
public void testEncryptionContentCreation() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -116,21 +111,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -138,14 +133,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testEncryptRootElementInRequest() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -175,18 +170,18 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -194,14 +189,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testExceptionOnElementToEncryptNotFound() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -226,10 +221,10 @@
try {
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- fail("Exception expected");
+ Assert.fail("Exception expected");
} catch (XMLStreamException e) {
- assertTrue(e.getCause() instanceof XMLSecurityException);
- assertEquals("Part to encrypt not found: {urn:example:po}NotExistingElement", e.getCause().getMessage());
+ Assert.assertTrue(e.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("Part to encrypt not found: {urn:example:po}NotExistingElement", e.getCause().getMessage());
}
}
@@ -237,7 +232,7 @@
public void testEncryptionElementCreation() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -266,21 +261,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -288,14 +283,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testStrongEncryption() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -325,21 +320,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -347,14 +342,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testEncryptionMultipleElements() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -386,21 +381,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 2);
+ Assert.assertEquals(nodeList.getLength(), 2);
}
// Test encryption using a generated AES 128 bit key that is encrypted using a AES 192 bit key.
@@ -408,7 +403,7 @@
public void testAES128ElementAES192KWCipherUsingKEKOutbound() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -444,21 +439,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -466,7 +461,7 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
// Test encryption using a generated AES 256 bit key that is encrypted using an RSA key.
@@ -474,7 +469,7 @@
public void testAES256ElementRSAKWCipherUsingKEKOutbound() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -513,21 +508,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -535,14 +530,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testEncryptedKeyKeyValueReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -582,21 +577,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -604,14 +599,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testEncryptedKeyKeyNameReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -652,21 +647,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -674,14 +669,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testEncryptedKeyMultipleElements() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -724,18 +719,18 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 2);
+ Assert.assertEquals(nodeList.getLength(), 2);
// Decrypt using DOM API
decryptUsingDOM("http://www.w3.org/2001/04/xmlenc#tripledes-cbc", null, priv, document);
@@ -745,7 +740,7 @@
public void testEncryptedKeyIssuerSerialReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -787,21 +782,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -809,14 +804,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testEncryptedKeyX509CertificateReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -858,21 +853,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -880,7 +875,7 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -895,7 +890,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -937,21 +932,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -959,14 +954,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testEncryptedKeyX509SubjectName() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1008,21 +1003,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1030,14 +1025,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testEncryptedKeyNoKeyInfo() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1079,21 +1074,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1101,7 +1096,7 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
// Test encryption using a generated AES 192 bit key that is encrypted using a 3DES key.
@@ -1109,7 +1104,7 @@
public void testAES192Element3DESKWCipher() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1144,21 +1139,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1166,14 +1161,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testTripleDesElementCipher() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1205,21 +1200,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1227,14 +1222,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAes128ElementCipher() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1268,21 +1263,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1290,14 +1285,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAes192ElementCipher() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1333,21 +1328,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1355,14 +1350,14 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAes256ElementCipher() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1399,20 +1394,20 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document =
- XMLUtils.read(new ByteArrayInputStream(baos.toByteArray()), false);
+ XMLUtils.createDocumentBuilder(false).parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1420,7 +1415,7 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
// Test case for when the entire document is encrypted and decrypted
@@ -1429,7 +1424,7 @@
public void testTripleDesDocumentCipher() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1461,21 +1456,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1483,7 +1478,7 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
// Test physical representation of decrypted element, see SANTUARIO-309
@@ -1491,7 +1486,7 @@
public void testPhysicalRepresentation1() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1524,17 +1519,17 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("ns.com", "elem");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1554,7 +1549,7 @@
public void testPhysicalRepresentation2() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1587,17 +1582,17 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("", "elem");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1616,7 +1611,7 @@
public void testTransportKey() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -1647,21 +1642,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc =
@@ -1669,7 +1664,7 @@
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
/**
diff --git a/src/test/java/org/apache/xml/security/test/stax/encryption/KeyWrapEncryptionCreationTest.java b/src/test/java/org/apache/xml/security/test/stax/encryption/KeyWrapEncryptionCreationTest.java
index 350708f..6c1e59d 100644
--- a/src/test/java/org/apache/xml/security/test/stax/encryption/KeyWrapEncryptionCreationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/encryption/KeyWrapEncryptionCreationTest.java
@@ -50,18 +50,17 @@
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-
/**
* A test to make sure that the various KeyWrap Encryption algorithms are working
*/
-public class KeyWrapEncryptionCreationTest {
+public class KeyWrapEncryptionCreationTest extends Assert {
private static KeyPair rsaKeyPair;
private static boolean bcInstalled;
@@ -107,7 +106,7 @@
public void testAES128KW() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -147,35 +146,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAES192KW() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -215,35 +214,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAES256KW() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -283,35 +282,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testTripleDESKW() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -349,35 +348,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testRSAv15KW() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -414,35 +413,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, rsaKeyPair.getPrivate());
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testRSAOAEPKW() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -479,35 +478,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, rsaKeyPair.getPrivate());
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testRSAOAEP11KW() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -544,28 +543,28 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, rsaKeyPair.getPrivate());
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -574,7 +573,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -614,28 +613,28 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -644,7 +643,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -684,28 +683,28 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -714,7 +713,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -754,28 +753,28 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -784,7 +783,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -824,28 +823,28 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(document, keyWrappingKey);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
private Document decryptUsingDOM(
@@ -877,4 +876,4 @@
return cipher.doFinal(document, ee);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/encryption/KeyWrapEncryptionVerificationTest.java b/src/test/java/org/apache/xml/security/test/stax/encryption/KeyWrapEncryptionVerificationTest.java
index ce38e8a..44561f4 100644
--- a/src/test/java/org/apache/xml/security/test/stax/encryption/KeyWrapEncryptionVerificationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/encryption/KeyWrapEncryptionVerificationTest.java
@@ -32,6 +32,7 @@
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -54,20 +55,17 @@
import org.apache.xml.security.test.stax.utils.StAX2DOM;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* A test to make sure that the various KeyWrap Decryption algorithms are working
*/
-public class KeyWrapEncryptionVerificationTest {
+public class KeyWrapEncryptionVerificationTest extends Assert {
private static boolean bcInstalled;
private static KeyPair rsaKeyPair;
@@ -116,7 +114,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -140,7 +139,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -159,11 +158,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -172,7 +171,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -196,7 +196,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -215,11 +215,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -228,7 +228,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -252,7 +253,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -271,11 +272,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -284,7 +285,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -306,7 +308,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -328,11 +330,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -341,7 +343,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -362,7 +365,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -384,11 +387,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -397,7 +400,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -418,7 +422,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -440,11 +444,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -453,7 +457,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -474,7 +479,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -496,11 +501,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -511,7 +516,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -535,7 +541,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -557,11 +563,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -572,7 +578,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -596,7 +603,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -618,11 +625,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -633,7 +640,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -657,7 +665,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -679,11 +687,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -694,7 +702,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("SEED");
@@ -718,7 +727,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -740,11 +749,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
private void encrypt(
@@ -773,7 +782,7 @@
String expression = "//*[local-name()='" + localName + "']";
Element elementToEncrypt =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(elementToEncrypt);
+ Assert.assertNotNull(elementToEncrypt);
document = cipher.doFinal(document, elementToEncrypt, false);
}
@@ -782,7 +791,7 @@
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertTrue(nodeList.getLength() > 0);
+ Assert.assertTrue(nodeList.getLength() > 0);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/encryption/SymmetricEncryptionCreationTest.java b/src/test/java/org/apache/xml/security/test/stax/encryption/SymmetricEncryptionCreationTest.java
index be62d40..2757d5a 100644
--- a/src/test/java/org/apache/xml/security/test/stax/encryption/SymmetricEncryptionCreationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/encryption/SymmetricEncryptionCreationTest.java
@@ -45,18 +45,17 @@
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-
/**
* A test to make sure that the various Symmetric Encryption algorithms are working
*/
-public class SymmetricEncryptionCreationTest {
+public class SymmetricEncryptionCreationTest extends Assert {
private static boolean bcInstalled;
private XMLInputFactory xmlInputFactory;
@@ -99,7 +98,7 @@
public void testAES128() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -132,35 +131,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAES128_GCM() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -193,35 +192,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAES192() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -254,35 +253,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAES192_GCM() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -315,35 +314,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAES256() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -376,35 +375,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testAES256_GCM() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -437,35 +436,35 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
public void testTRIPLE_DES() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -497,28 +496,28 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
// Check the CreditCard decrypted ok
nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -527,7 +526,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -560,21 +559,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
@@ -589,7 +588,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -622,21 +621,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
@@ -651,7 +650,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -684,21 +683,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
@@ -713,7 +712,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -746,21 +745,21 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// Check the CreditCard encrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Decrypt using DOM API
Document doc = decryptUsingDOM(algorithm, key, null, document);
@@ -792,4 +791,4 @@
return cipher.doFinal(document, ee);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/encryption/SymmetricEncryptionVerificationTest.java b/src/test/java/org/apache/xml/security/test/stax/encryption/SymmetricEncryptionVerificationTest.java
index 7cccbf1..b66eaa6 100644
--- a/src/test/java/org/apache/xml/security/test/stax/encryption/SymmetricEncryptionVerificationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/encryption/SymmetricEncryptionVerificationTest.java
@@ -31,6 +31,7 @@
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -53,20 +54,17 @@
import org.apache.xml.security.test.stax.utils.StAX2DOM;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* A test to make sure that the various Symmetric Encryption algorithms are working
*/
-public class SymmetricEncryptionVerificationTest {
+public class SymmetricEncryptionVerificationTest extends Assert {
private static boolean bcInstalled;
private XMLInputFactory xmlInputFactory;
@@ -112,7 +110,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -129,7 +128,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -151,11 +150,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -164,7 +163,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -181,7 +181,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -203,11 +203,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -216,7 +216,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -233,7 +234,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -255,11 +256,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -268,7 +269,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -285,7 +287,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -307,11 +309,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -320,7 +322,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -337,7 +340,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -359,11 +362,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -372,7 +375,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("AES");
@@ -389,7 +393,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -411,11 +415,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -424,7 +428,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("DESede");
@@ -440,7 +445,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -462,11 +467,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -477,7 +482,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("SEED");
@@ -494,7 +500,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -516,11 +522,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -531,7 +537,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -548,7 +555,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -570,11 +577,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -585,7 +592,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -602,7 +610,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -624,11 +632,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
@Test
@@ -639,7 +647,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyGenerator keygen = KeyGenerator.getInstance("Camellia");
@@ -656,7 +665,7 @@
// Check the CreditCard encrypted ok
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
// XMLUtils.outputDOM(document, System.out);
@@ -678,11 +687,11 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the CreditCard decrypted ok
nodeList = document.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
}
private void encryptUsingDOM(
@@ -753,7 +762,7 @@
String expression = "//*[local-name()='" + localName + "']";
Element elementToEncrypt =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(elementToEncrypt);
+ Assert.assertNotNull(elementToEncrypt);
document = cipher.doFinal(document, elementToEncrypt, content);
}
@@ -762,7 +771,7 @@
XMLSecurityConstants.TAG_xenc_EncryptedData.getNamespaceURI(),
XMLSecurityConstants.TAG_xenc_EncryptedData.getLocalPart()
);
- assertTrue(nodeList.getLength() > 0);
+ Assert.assertTrue(nodeList.getLength() > 0);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java b/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java
index a23cc54..385a2b9 100644
--- a/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java
+++ b/src/test/java/org/apache/xml/security/test/stax/encryption/XMLEncryption11Test.java
@@ -36,13 +36,12 @@
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
@@ -64,27 +63,21 @@
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.Before;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
*/
-public class XMLEncryption11Test {
+public class XMLEncryption11Test extends Assert {
private String cardNumber;
private int nodeCount;
private XMLInputFactory xmlInputFactory;
- private TransformerFactory transformerFactory = TransformerFactory.newInstance();
@Before
public void setUp() throws Exception {
@@ -95,7 +88,8 @@
xmlInputFactory.setEventAllocator(new XMLSecEventAllocator());
String filename = "org/w3c/www/interop/xmlenc-core-11/plaintext.xml";
- Document doc = XMLUtils.read(this.getClass().getClassLoader().getResourceAsStream(filename), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(this.getClass().getClassLoader().getResourceAsStream(filename));
cardNumber = retrieveCCNumber(doc);
nodeCount = countNodes(doc);
@@ -413,12 +407,12 @@
// Perform decryption
try {
decryptElementStAX(ed, rsaKey);
- fail("Exception expected");
+ Assert.fail("Exception expected");
} catch (XMLStreamException e) {
- assertTrue(e.getCause() instanceof IOException);
- assertTrue(e.getCause().getCause() instanceof BadPaddingException);
+ Assert.assertTrue(e.getCause() instanceof IOException);
+ Assert.assertTrue(e.getCause().getCause() instanceof BadPaddingException);
String cause = e.getCause().getCause().getMessage();
- assertTrue("mac check in GCM failed".equals(cause) || "Tag mismatch!".equals(cause));
+ Assert.assertTrue("mac check in GCM failed".equals(cause) || "Tag mismatch!".equals(cause));
}
}
@@ -429,7 +423,8 @@
* decrypt it and return the resulting document
*/
private Document decryptElement(String filename, Key rsaKey) throws Exception {
- Document doc = XMLUtils.read(this.getClass().getClassLoader().getResourceAsStream(filename), false);
+ DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
+ Document doc = db.parse(this.getClass().getClassLoader().getResourceAsStream(filename));
return decryptElement(doc, rsaKey);
}
@@ -455,17 +450,13 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
TestSecurityEventListener securityEventListener = new TestSecurityEventListener();
- javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- transformer.transform(new DOMSource(doc), new StreamResult(baos));
-
final XMLStreamReader xmlStreamReader =
- xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray()));
+ xmlInputFactory.createXMLStreamReader(new DOMSource(doc));
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- return StAX2DOM.readDoc(securityStreamReader);
+ return StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
/**
@@ -510,7 +501,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -538,32 +529,32 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("urn:example:po", "PaymentInfo");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
NodeList encryptionMethodElements = document.getElementsByTagNameNS(XMLSecurityConstants.NS_XMLENC, "EncryptionMethod");
- assertEquals(2, encryptionMethodElements.getLength());
- assertEquals(encryptionMethodAlgo, ((Element) encryptionMethodElements.item(0)).getAttribute("Algorithm"));
- assertEquals(encryptedKeyAlgo, ((Element) encryptionMethodElements.item(1)).getAttribute("Algorithm"));
+ Assert.assertEquals(2, encryptionMethodElements.getLength());
+ Assert.assertEquals(encryptionMethodAlgo, ((Element) encryptionMethodElements.item(0)).getAttribute("Algorithm"));
+ Assert.assertEquals(encryptedKeyAlgo, ((Element) encryptionMethodElements.item(1)).getAttribute("Algorithm"));
if (digestMethodAlgo != null) {
NodeList digestMethodElements = document.getElementsByTagNameNS(XMLSecurityConstants.NS_DSIG, "DigestMethod");
- assertEquals(1, digestMethodElements.getLength());
- assertEquals(digestMethodAlgo, ((Element) digestMethodElements.item(0)).getAttribute("Algorithm"));
+ Assert.assertEquals(1, digestMethodElements.getLength());
+ Assert.assertEquals(digestMethodAlgo, ((Element) digestMethodElements.item(0)).getAttribute("Algorithm"));
}
if (mgfAlgo != null) {
NodeList mfgElements = document.getElementsByTagNameNS(XMLSecurityConstants.NS_XMLENC11, "MGF");
- assertEquals(1, mfgElements.getLength());
- assertEquals(mgfAlgo, ((Element) mfgElements.item(0)).getAttribute("Algorithm"));
+ Assert.assertEquals(1, mfgElements.getLength());
+ Assert.assertEquals(mgfAlgo, ((Element) mfgElements.item(0)).getAttribute("Algorithm"));
}
if (oaepParams != null) {
NodeList oaepParamsElements = document.getElementsByTagNameNS(XMLSecurityConstants.NS_XMLENC, "OAEPparams");
- assertEquals(1, oaepParamsElements.getLength());
+ Assert.assertEquals(1, oaepParamsElements.getLength());
String content = XMLUtils.getFullTextChildrenFromNode(oaepParamsElements.item(0));
- assertArrayEquals(oaepParams, XMLUtils.decode(content));
+ Assert.assertArrayEquals(oaepParams, XMLUtils.decode(content));
}
return document;
}
@@ -632,7 +623,7 @@
private void checkDecryptedDoc(Document d, boolean doNodeCheck) throws Exception {
String cc = retrieveCCNumber(d);
- assertEquals(cardNumber, cc);
+ assertTrue(cc, cc != null && cc.equals(cardNumber));
// Test cc numbers
if (doNodeCheck) {
diff --git a/src/test/java/org/apache/xml/security/test/stax/performance/AbstractPerformanceTest.java b/src/test/java/org/apache/xml/security/test/stax/performance/AbstractPerformanceTest.java
index e11568d..80c2224 100644
--- a/src/test/java/org/apache/xml/security/test/stax/performance/AbstractPerformanceTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/performance/AbstractPerformanceTest.java
@@ -18,13 +18,28 @@
*/
package org.apache.xml.security.test.stax.performance;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.OutputStream;
+import org.apache.xml.security.encryption.XMLCipher;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.signature.XMLSignature;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
+import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
+import org.apache.xml.security.transforms.Transforms;
+import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.crypto.KeyGenerator;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import java.io.*;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.KeyStore;
@@ -32,33 +47,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.crypto.KeyGenerator;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.xml.security.encryption.XMLCipher;
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.signature.XMLSignature;
-import org.apache.xml.security.stax.ext.InboundXMLSec;
-import org.apache.xml.security.stax.ext.OutboundXMLSec;
-import org.apache.xml.security.stax.ext.SecurePart;
-import org.apache.xml.security.stax.ext.XMLSec;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
-import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
-import org.apache.xml.security.transforms.Transforms;
-import org.apache.xml.security.utils.XMLUtils;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-
/**
*/
public abstract class AbstractPerformanceTest {
@@ -136,8 +124,10 @@
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(fileInputStream);
while (xmlStreamReader.hasNext()) {
xmlStreamReader.next();
- if (XMLStreamConstants.START_ELEMENT == xmlStreamReader.getEventType()) {
- i++;
+ switch (xmlStreamReader.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ i++;
+ break;
}
}
xmlStreamReader.close();
@@ -149,7 +139,7 @@
protected void setUpOutboundSignatureXMLSec() throws XMLSecurityException {
XMLSecurityProperties xmlSecurityProperties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
xmlSecurityProperties.setActions(actions);
xmlSecurityProperties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_X509KeyIdentifier);
@@ -180,7 +170,7 @@
protected void setUpOutboundEncryptionXMLSec() throws XMLSecurityException {
XMLSecurityProperties xmlSecurityProperties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
xmlSecurityProperties.setActions(actions);
xmlSecurityProperties.setEncryptionKey(encryptionSymKey);
@@ -234,7 +224,8 @@
protected void doDOMSignatureOutbound(File file, int tagCount) throws Exception {
- Document document = XMLUtils.read(new FileInputStream(file), false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(file);
XMLSignature sig = new XMLSignature(document, "", "http://www.w3.org/2000/09/xmldsig#rsa-sha1");
Element root = document.getDocumentElement();
@@ -253,7 +244,8 @@
protected void doDOMSignatureInbound(File file, int tagCount) throws Exception {
- Document document = XMLUtils.read(new FileInputStream(file), false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(file);
Element signatureElement = (Element) document.getElementsByTagNameNS("http://www.w3.org/2000/09/xmldsig#", "Signature").item(0);
((Element) signatureElement.getParentNode()).setIdAttributeNS(null, "Id", true);
@@ -294,7 +286,8 @@
protected void doDOMEncryptionOutbound(File file, int tagCount) throws Exception {
- Document document = XMLUtils.read(new FileInputStream(file), false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(file);
XMLCipher cipher = XMLCipher.getInstance("http://www.w3.org/2001/04/xmlenc#aes256-cbc");
cipher.init(XMLCipher.ENCRYPT_MODE, encryptionSymKey);
@@ -305,7 +298,8 @@
protected void doDOMDecryptionInbound(File file, int tagCount) throws Exception {
- Document document = XMLUtils.read(new FileInputStream(file), false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(file);
XMLCipher cipher = XMLCipher.getInstance("http://www.w3.org/2001/04/xmlenc#aes256-cbc");
cipher.init(XMLCipher.DECRYPT_MODE, encryptionSymKey);
diff --git a/src/test/java/org/apache/xml/security/test/stax/performance/PerformanceMemoryTest.java b/src/test/java/org/apache/xml/security/test/stax/performance/PerformanceMemoryTest.java
index 872f22f..93913e7 100644
--- a/src/test/java/org/apache/xml/security/test/stax/performance/PerformanceMemoryTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/performance/PerformanceMemoryTest.java
@@ -35,8 +35,8 @@
private static final int xmlResizeFactor = 1000;
//junit creates for every test method a new class instance so we need a static list
- private static Map<Integer, File> signedFiles = new TreeMap<>();
- private static Map<Integer, File> encryptedFiles = new TreeMap<>();
+ private static Map<Integer, File> signedFiles = new TreeMap<Integer, File>();
+ private static Map<Integer, File> encryptedFiles = new TreeMap<Integer, File>();
@Override
@@ -219,7 +219,7 @@
private long memoryDiff;
private volatile boolean stop = false;
- private List<Integer> memory = new LinkedList<>();
+ private List<Integer> memory = new LinkedList<Integer>();
MemorySamplerThread(long memoryDiff) {
this.memoryDiff = memoryDiff;
diff --git a/src/test/java/org/apache/xml/security/test/stax/performance/PerformanceTimingTest.java b/src/test/java/org/apache/xml/security/test/stax/performance/PerformanceTimingTest.java
index 85aa540..568ffe8 100644
--- a/src/test/java/org/apache/xml/security/test/stax/performance/PerformanceTimingTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/performance/PerformanceTimingTest.java
@@ -36,8 +36,8 @@
private static final int runs = 40;
private static final int xmlResizeFactor = 1000;
- private static Map<Integer, File> signedFiles = new TreeMap<>();
- private static Map<Integer, File> encryptedFiles = new TreeMap<>();
+ private static Map<Integer, File> signedFiles = new TreeMap<Integer, File>();
+ private static Map<Integer, File> encryptedFiles = new TreeMap<Integer, File>();
@Override
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureCreationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureCreationTest.java
index 9127926..73cb6bf 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureCreationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureCreationTest.java
@@ -37,18 +37,14 @@
import org.apache.xml.security.utils.resolver.ResourceResolverContext;
import org.apache.xml.security.utils.resolver.ResourceResolverException;
import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
+import org.junit.Assert;
import org.junit.Before;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-
/**
*/
-public class AbstractSignatureCreationTest {
+public class AbstractSignatureCreationTest extends Assert {
protected static String BASEDIR;
@@ -107,7 +103,7 @@
String expression = "//dsig:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
+ Assert.assertNotNull(sigElement);
for (SecurePart securePart : secureParts) {
if (securePart.getName() == null) {
@@ -116,7 +112,7 @@
expression = "//*[local-name()='" + securePart.getName().getLocalPart() + "']";
Element signedElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(signedElement);
+ Assert.assertNotNull(signedElement);
signedElement.setIdAttributeNS(null, idAttributeNS, true);
}
@@ -126,10 +122,10 @@
}
if (keyInfoRequired) {
KeyInfo ki = signature.getKeyInfo();
- assertNotNull(ki);
+ Assert.assertNotNull(ki);
}
- assertTrue(signature.checkSignatureValue(cert));
+ Assert.assertTrue(signature.checkSignatureValue(cert));
}
/**
@@ -145,18 +141,18 @@
String expression = "//dsig:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
+ Assert.assertNotNull(sigElement);
for (SecurePart securePart : secureParts) {
expression = "//*[local-name()='" + securePart.getName().getLocalPart() + "']";
Element signedElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(signedElement);
+ Assert.assertNotNull(signedElement);
signedElement.setIdAttributeNS(null, "Id", true);
}
XMLSignature signature = new XMLSignature(sigElement, "");
- assertTrue(signature.checkSignatureValue(key));
+ Assert.assertTrue(signature.checkSignatureValue(key));
}
protected void verifyUsingDOMWihtoutId(
@@ -169,22 +165,22 @@
String expression = "//dsig:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
- assertEquals("", sigElement.getAttribute("Id"));
+ Assert.assertNotNull(sigElement);
+ Assert.assertEquals("", sigElement.getAttribute("Id"));
assertEquals("Without Id there can only be one secure part", 1, secureParts.size());
expression = "//*[local-name()='" + secureParts.get(0).getName().getLocalPart() + "']";
Element signedElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(signedElement);
- assertEquals("", signedElement.getAttribute("Id"));
+ Assert.assertNotNull(signedElement);
+ Assert.assertEquals("", signedElement.getAttribute("Id"));
XMLSignature signature = new XMLSignature(sigElement, "");
// We need a special resolver for the empty URI
signature.addResourceResolver(new EmptyURIResourceResolverSpi(signedElement));
- assertTrue(signature.checkSignatureValue(key));
+ Assert.assertTrue(signature.checkSignatureValue(key));
}
protected void verifyUsingDOMWihtoutIdAndDefaultTransform (
@@ -197,8 +193,8 @@
String expression = "//dsig:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
- assertEquals("", sigElement.getAttribute("Id"));
+ Assert.assertNotNull(sigElement);
+ Assert.assertEquals("", sigElement.getAttribute("Id"));
assertEquals("Without Id there can only be one secure part", 1, secureParts.size());
//assertNull(secureParts.get(0).getName());
@@ -210,7 +206,7 @@
// We need a special resolver for the empty URI
signature.addResourceResolver(new EmptyURIResourceResolverSpi(signedElement));
- assertTrue(signature.checkSignatureValue(key));
+ Assert.assertTrue(signature.checkSignatureValue(key));
}
private XPath getxPath() {
@@ -240,4 +236,4 @@
return context.uriToResolve.isEmpty();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureVerificationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureVerificationTest.java
index d18129f..4cbdbea 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureVerificationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/AbstractSignatureVerificationTest.java
@@ -18,22 +18,6 @@
*/
package org.apache.xml.security.test.stax.signature;
-import java.io.File;
-import java.security.Key;
-import java.security.cert.X509Certificate;
-import java.util.List;
-import java.util.UUID;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.stax.config.Init;
@@ -42,31 +26,32 @@
import org.apache.xml.security.stax.impl.securityToken.X509IssuerSerialSecurityToken;
import org.apache.xml.security.stax.impl.securityToken.X509SecurityToken;
import org.apache.xml.security.stax.impl.securityToken.X509SubjectNameSecurityToken;
-import org.apache.xml.security.stax.securityEvent.AlgorithmSuiteSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.DefaultTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.KeyNameTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.KeyValueTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.SecurityEvent;
-import org.apache.xml.security.stax.securityEvent.SecurityEventConstants;
-import org.apache.xml.security.stax.securityEvent.SignatureValueSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.SignedElementSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.X509TokenSecurityEvent;
+import org.apache.xml.security.stax.securityEvent.*;
import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
import org.apache.xml.security.test.dom.DSNamespaceContext;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.transforms.Transforms;
import org.apache.xml.security.utils.resolver.ResourceResolverSpi;
-
+import org.junit.Assert;
import org.junit.Before;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+import java.io.File;
+import java.security.Key;
+import java.security.cert.X509Certificate;
+import java.util.List;
+import java.util.UUID;
/**
*/
-public class AbstractSignatureVerificationTest {
+public class AbstractSignatureVerificationTest extends Assert {
protected static String BASEDIR;
@@ -239,7 +224,7 @@
(NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
for (int i = 0; i < elementsToSign.getLength(); i++) {
Element elementToSign = (Element)elementsToSign.item(i);
- assertNotNull(elementToSign);
+ Assert.assertNotNull(elementToSign);
String id = UUID.randomUUID().toString();
elementToSign.setAttributeNS(null, "Id", id);
elementToSign.setIdAttributeNS(null, "Id", true);
@@ -271,7 +256,7 @@
String expression = "//ds:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(sigElement);
+ Assert.assertNotNull(sigElement);
return sig;
}
@@ -449,4 +434,4 @@
this.binary = binary;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/BaltimoreTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/BaltimoreTest.java
index 3fa526b..ee69bcc 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/BaltimoreTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/BaltimoreTest.java
@@ -38,6 +38,7 @@
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -66,22 +67,17 @@
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.utils.XMLUtils;
import org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This test is to ensure interoperability with the examples provided by Merlin Huges
* from Baltimore using KeyTools XML. These test vectors are located in the directory
* <CODE>data/ie/baltimore/merlin-examples/</CODE>.
*/
-public class BaltimoreTest {
+public class BaltimoreTest extends Assert {
// Define the Keys
private static final String DSA_Y_15 =
@@ -129,7 +125,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/signature-enveloping-hmac-sha1.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -155,7 +152,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, key,
@@ -168,7 +165,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/signature-enveloping-hmac-sha1-40.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -193,11 +191,11 @@
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a short HMAC length");
} catch (XMLStreamException ex) {
- assertTrue(ex.getCause() instanceof XMLSecurityException);
- assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
+ Assert.assertTrue(ex.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
}
}
@@ -208,7 +206,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/signature-enveloped-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -229,7 +228,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA", 15),
@@ -242,7 +241,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/signature-enveloping-b64-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -263,7 +263,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA", 15),
@@ -276,7 +276,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/signature-enveloping-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -297,7 +298,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA", 15),
@@ -310,7 +311,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/signature-enveloping-rsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -331,7 +333,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("RSA", 15),
@@ -356,7 +358,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/signature-external-b64-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey("DSA", 15);
@@ -381,7 +384,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA", 15),
@@ -411,7 +414,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-fifteen/signature-external-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey("DSA", 15);
@@ -436,7 +440,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA", 15),
@@ -453,7 +457,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-enveloping-hmac-sha1.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -479,7 +484,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, key,
@@ -492,7 +497,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-enveloping-hmac-sha1-40.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -517,11 +523,11 @@
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a short HMAC length");
} catch (XMLStreamException ex) {
- assertTrue(ex.getCause() instanceof XMLSecurityException);
- assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
+ Assert.assertTrue(ex.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
}
}
@@ -532,7 +538,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-enveloped-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey("DSA", 23);
@@ -557,7 +564,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA", 23),
@@ -570,7 +577,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-enveloping-b64-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey("DSA", 23);
@@ -595,7 +603,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA", 23),
@@ -608,7 +616,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-enveloping-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -629,7 +638,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA", 23),
@@ -642,7 +651,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-enveloping-rsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -663,7 +673,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("RSA", 23),
@@ -689,7 +699,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-external-b64-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey("DSA", 23);
@@ -714,7 +725,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("RSA", 23),
@@ -744,7 +755,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-external-dsa.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey("DSA", 23);
@@ -769,7 +781,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("RSA", 23),
@@ -799,7 +811,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-keyname.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
CertificateFactory cf = CertificateFactory.getInstance("X509");
@@ -829,7 +842,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, cert.getPublicKey(),
@@ -859,7 +872,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-retrievalmethod-rawx509crt.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
CertificateFactory cf = CertificateFactory.getInstance("X509");
@@ -887,7 +901,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -913,7 +927,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-x509-crt-crl.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -932,7 +947,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -958,7 +973,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-x509-crt.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -977,7 +993,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -1003,7 +1019,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-x509-is.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1033,7 +1050,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, cert.getPublicKey(),
@@ -1063,7 +1080,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-x509-ski.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1091,7 +1109,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -1117,7 +1135,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/signature-x509-sn.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1147,7 +1166,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, cert.getPublicKey(),
@@ -1164,7 +1183,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-exc-c14n-one/exc-signature.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1183,7 +1203,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -1204,7 +1224,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/signature-keyname.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
CertificateFactory cf = CertificateFactory.getInstance("X509");
@@ -1234,7 +1255,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, cert.getPublicKey(),
@@ -1264,7 +1285,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/signature-retrievalmethod-rawx509crt.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
CertificateFactory cf = CertificateFactory.getInstance("X509");
@@ -1292,7 +1314,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -1318,7 +1340,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/signature-x509-crt-crl.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1337,7 +1360,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -1363,7 +1386,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/signature-x509-crt.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1382,7 +1406,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -1408,7 +1432,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/signature-x509-is.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1438,7 +1463,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, cert.getPublicKey(),
@@ -1468,7 +1493,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/signature-x509-ski.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1496,7 +1522,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -1522,7 +1548,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/signature-x509-sn.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -1552,7 +1579,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, cert.getPublicKey(),
@@ -1568,7 +1595,7 @@
throws InvalidKeySpecException, NoSuchAlgorithmException {
KeyFactory kf = KeyFactory.getInstance(algo);
KeySpec kspec = null;
- if ("DSA".equalsIgnoreCase(algo)) {
+ if (algo.equalsIgnoreCase("DSA")) {
if (number == 15) {
kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y_15),
new BigInteger(DSA_P_15),
@@ -1580,7 +1607,7 @@
new BigInteger(DSA_Q_23),
new BigInteger(DSA_G_23));
}
- } else if ("RSA".equalsIgnoreCase(algo)) {
+ } else if (algo.equalsIgnoreCase("RSA")) {
if (number == 15) {
kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD_15),
new BigInteger(RSA_PUB));
@@ -1638,4 +1665,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/IAIKTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/IAIKTest.java
index 927abfc..fd5238a 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/IAIKTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/IAIKTest.java
@@ -34,6 +34,7 @@
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -60,22 +61,17 @@
import org.apache.xml.security.test.stax.utils.TestUtils;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This test is to ensure interoperability with the examples provided by the IAIK
* XML Signature implementation. Thanks to Gregor Karlinger who provided these
* test vectors. They are located in the directory <CODE>data/at/iaik/ixsil/</CODE>.
*/
-public class IAIKTest {
+public class IAIKTest extends Assert {
// Define the Keys
private static final String DSA_Y =
@@ -112,7 +108,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"at/iaik/ixsil/signatureAlgorithms/signatures/hMACSignature.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -138,7 +135,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, key, SecurityTokenConstants.KeyIdentifier_NoKeyInfo);
@@ -150,7 +147,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"at/iaik/ixsil/signatureAlgorithms/signatures/hMACShortSignature.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -172,11 +170,11 @@
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a short HMAC length");
} catch (XMLStreamException ex) {
- assertTrue(ex.getCause() instanceof XMLSecurityException);
- assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
+ Assert.assertTrue(ex.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
}
}
@@ -186,7 +184,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"at/iaik/ixsil/signatureAlgorithms/signatures/dSASignature.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -207,7 +206,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("DSA"),
@@ -220,7 +219,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"at/iaik/ixsil/signatureAlgorithms/signatures/rSASignature.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -241,7 +241,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("RSA"),
@@ -272,7 +272,7 @@
try {
TestUtils.switchAllowNotSameDocumentReferences(true);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
}
@@ -306,7 +306,7 @@
try {
TestUtils.switchAllowNotSameDocumentReferences(true);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
}
@@ -322,7 +322,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"at/iaik/ixsil/transforms/signatures/envelopedSignatureSignature.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
Key publicKey = getPublicKey("RSA");
@@ -347,7 +348,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, getPublicKey("RSA"),
@@ -358,12 +359,12 @@
throws InvalidKeySpecException, NoSuchAlgorithmException {
KeyFactory kf = KeyFactory.getInstance(algo);
KeySpec kspec = null;
- if ("DSA".equalsIgnoreCase(algo)) {
+ if (algo.equalsIgnoreCase("DSA")) {
kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y),
new BigInteger(DSA_P),
new BigInteger(DSA_Q),
new BigInteger(DSA_G));
- } else if ("RSA".equalsIgnoreCase(algo)) {
+ } else if (algo.equalsIgnoreCase("RSA")) {
kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD),
new BigInteger(RSA_PUB));
} else {
@@ -412,4 +413,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/PKSignatureCreationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/PKSignatureCreationTest.java
index 0e982a6..b6c2366 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/PKSignatureCreationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/PKSignatureCreationTest.java
@@ -91,7 +91,7 @@
public void testRSA_SHA1() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -123,7 +123,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -134,7 +134,7 @@
public void testRSA_SHA256() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -166,7 +166,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -177,7 +177,7 @@
public void testRSA_SHA384() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -209,7 +209,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -220,7 +220,7 @@
public void testRSA_SHA512() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -252,7 +252,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -265,7 +265,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -297,7 +297,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -310,7 +310,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -342,7 +342,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -355,7 +355,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -387,7 +387,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -400,7 +400,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -432,7 +432,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -445,7 +445,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -477,7 +477,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -490,7 +490,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -522,7 +522,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -533,7 +533,7 @@
public void testECDSA_SHA1() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -565,7 +565,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -576,7 +576,7 @@
public void testECDSA_SHA224() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -608,7 +608,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -619,7 +619,7 @@
public void testECDSA_SHA256() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -651,7 +651,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -662,7 +662,7 @@
public void testECDSA_SHA384() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -694,7 +694,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -705,7 +705,7 @@
public void testECDSA_SHA512() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -737,7 +737,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -750,7 +750,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -782,7 +782,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/PKSignatureVerificationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/PKSignatureVerificationTest.java
index a90febe..82cbbe0 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/PKSignatureVerificationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/PKSignatureVerificationTest.java
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.List;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -103,7 +104,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
List<String> localNames = new ArrayList<>();
@@ -134,7 +136,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -143,7 +145,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
List<String> localNames = new ArrayList<>();
@@ -174,7 +177,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -183,7 +186,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";
List<String> localNames = new ArrayList<>();
@@ -214,7 +218,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -223,7 +227,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";
List<String> localNames = new ArrayList<>();
@@ -254,7 +259,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -265,7 +270,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#rsa-ripemd160";
List<String> localNames = new ArrayList<>();
@@ -296,7 +302,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -307,7 +313,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1";
List<String> localNames = new ArrayList<>();
@@ -338,7 +345,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -349,7 +356,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2007/05/xmldsig-more#sha224-rsa-MGF1";
List<String> localNames = new ArrayList<>();
@@ -380,7 +388,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -391,7 +399,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1";
List<String> localNames = new ArrayList<>();
@@ -422,7 +431,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -433,7 +442,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1";
List<String> localNames = new ArrayList<>();
@@ -464,7 +474,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -475,7 +485,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1";
List<String> localNames = new ArrayList<>();
@@ -506,7 +517,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -515,7 +526,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1";
List<String> localNames = new ArrayList<>();
@@ -546,7 +558,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -555,7 +567,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224";
List<String> localNames = new ArrayList<>();
@@ -586,7 +599,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -595,7 +608,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256";
List<String> localNames = new ArrayList<>();
@@ -626,7 +640,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -635,7 +649,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384";
List<String> localNames = new ArrayList<>();
@@ -666,7 +681,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -675,7 +690,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512";
List<String> localNames = new ArrayList<>();
@@ -706,7 +722,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -717,7 +733,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
String signatureAlgorithm = "http://www.w3.org/2007/05/xmldsig-more#ecdsa-ripemd160";
List<String> localNames = new ArrayList<>();
@@ -748,7 +765,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/PhaosTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/PhaosTest.java
index b5e0ba8..d5b200c 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/PhaosTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/PhaosTest.java
@@ -30,12 +30,14 @@
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.utils.XMLUtils;
import org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -50,16 +52,11 @@
import java.net.Proxy;
import java.nio.charset.StandardCharsets;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* This is a testcase to validate all "phaos-xmldsig-three"
* testcases from Phaos
*/
-public class PhaosTest {
+public class PhaosTest extends Assert {
private XMLInputFactory xmlInputFactory;
private TransformerFactory transformerFactory = TransformerFactory.newInstance();
@@ -94,7 +91,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-dsa-detached.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -115,7 +113,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -129,7 +127,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-dsa-enveloped.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -150,7 +149,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -159,7 +158,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-dsa-enveloping.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -180,7 +180,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
// See SANTUARIO-319
@@ -202,7 +202,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-hmac-sha1-exclusive-c14n-comments-detached.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the key
byte[] hmacKey = "test".getBytes(StandardCharsets.US_ASCII);
@@ -228,7 +229,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -242,7 +243,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-hmac-sha1-exclusive-c14n-enveloped.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the key
byte[] hmacKey = "test".getBytes(StandardCharsets.US_ASCII);
@@ -268,7 +270,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -277,7 +279,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-rsa-detached-b64-transform.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the key
byte[] hmacKey = "test".getBytes(StandardCharsets.US_ASCII);
@@ -305,7 +308,7 @@
try {
TestUtils.switchDoNotThrowExceptionForManifests(true);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchDoNotThrowExceptionForManifests(false);
}
@@ -330,7 +333,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-rsa-detached.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -351,7 +355,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -365,7 +369,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-rsa-enveloped-bad-digest-val.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -385,11 +390,11 @@
TestSecurityEventListener securityEventListener = new TestSecurityEventListener();
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a bad digest");
} catch (XMLStreamException ex) {
- assertTrue(ex.getCause() instanceof XMLSecurityException);
- assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
+ Assert.assertTrue(ex.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
}
}
@@ -400,7 +405,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-rsa-enveloped.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -421,7 +427,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -430,7 +436,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/phaos/phaos-xmldsig-three/signature-rsa-enveloping.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -451,7 +458,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/RSASecurityTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/RSASecurityTest.java
index 84f2aad..2591cdc 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/RSASecurityTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/RSASecurityTest.java
@@ -22,6 +22,7 @@
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -66,7 +67,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/rsasecurity/bdournaee/certj201_enveloping.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -87,7 +89,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, null, null,
@@ -101,7 +103,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"com/rsasecurity/bdournaee/certj201_enveloped.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// XMLUtils.outputDOM(document, System.out);
@@ -122,7 +125,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSignatureToken(securityEventListener, null, null,
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureCreationReferenceURIResolverTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureCreationReferenceURIResolverTest.java
index ec48c22..3a08275 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureCreationReferenceURIResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureCreationReferenceURIResolverTest.java
@@ -45,15 +45,12 @@
import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
import org.apache.xml.security.utils.XMLUtils;
import org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP;
+import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
*/
public class SignatureCreationReferenceURIResolverTest extends AbstractSignatureCreationTest {
@@ -62,7 +59,7 @@
public void testSignatureCreationWithExternalFilesystemXMLReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -102,7 +99,7 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -113,7 +110,7 @@
public void testSignatureCreationWithExternalFilesystemBinaryReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -153,7 +150,7 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -174,7 +171,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -210,7 +207,7 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -224,7 +221,7 @@
public void testSignatureCreationWithSameDocumentXPointerIdApostropheReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -257,17 +254,17 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS("http://www.w3.org/2000/09/xmldsig#", "Reference");
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
String uri = ((Element) nodeList.item(0)).getAttribute("URI");
- assertNotNull(uri);
- assertTrue(uri.startsWith("#xpointer"));
+ Assert.assertNotNull(uri);
+ Assert.assertTrue(uri.startsWith("#xpointer"));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureCreationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureCreationTest.java
index ba57fe0..8d7cd83 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureCreationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureCreationTest.java
@@ -18,6 +18,32 @@
*/
package org.apache.xml.security.test.stax.signature;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.signature.XMLSignature;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.securityEvent.SecurityEventConstants;
+import org.apache.xml.security.stax.securityEvent.SignatureValueSecurityEvent;
+import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
+import org.apache.xml.security.test.dom.DSNamespaceContext;
+import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
+import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -30,43 +56,8 @@
import java.util.Arrays;
import java.util.List;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.apache.xml.security.exceptions.XMLSecurityException;
-import org.apache.xml.security.signature.XMLSignature;
-import org.apache.xml.security.stax.ext.OutboundXMLSec;
-import org.apache.xml.security.stax.ext.SecurePart;
-import org.apache.xml.security.stax.ext.XMLSec;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.securityEvent.SecurityEventConstants;
-import org.apache.xml.security.stax.securityEvent.SignatureValueSecurityEvent;
-import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
-import org.apache.xml.security.test.dom.DSNamespaceContext;
-import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
-import org.apache.xml.security.utils.XMLUtils;
-
-import org.junit.Test;
-
import static org.apache.xml.security.stax.ext.XMLSecurityConstants.NS_C14N_EXCL;
import static org.apache.xml.security.stax.ext.XMLSecurityConstants.NS_XMLDSIG_ENVELOPED_SIGNATURE;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
/**
* A set of test-cases for Signature creation.
@@ -77,7 +68,7 @@
public void testSignatureCreation() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -111,7 +102,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
//first child element must be the dsig:Signature @see SANTUARIO-324:
@@ -119,7 +110,7 @@
while (childNode != null) {
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)childNode;
- assertEquals(element.getLocalName(), "Signature");
+ Assert.assertEquals(element.getLocalName(), "Signature");
break;
}
childNode = childNode.getNextSibling();
@@ -133,7 +124,7 @@
public void testSignatureCreationRetrieveSignatureValue() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -169,7 +160,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Check Signature bytes
@@ -186,7 +177,7 @@
public void testExceptionOnElementToSignNotFound() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -217,10 +208,10 @@
try {
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- fail("Exception expected");
+ Assert.fail("Exception expected");
} catch (XMLStreamException e) {
- assertTrue(e.getCause() instanceof XMLSecurityException);
- assertEquals("Part to sign not found: {urn:example:po}NotExistingElement", e.getCause().getMessage());
+ Assert.assertTrue(e.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("Part to sign not found: {urn:example:po}NotExistingElement", e.getCause().getMessage());
}
}
@@ -228,7 +219,7 @@
public void testEnvelopedSignatureCreation() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -270,7 +261,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
//first child element must be the dsig:Signature @see SANTUARIO-324:
@@ -278,7 +269,7 @@
while (childNode != null) {
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)childNode;
- assertEquals(element.getLocalName(), "Signature");
+ Assert.assertEquals(element.getLocalName(), "Signature");
break;
}
childNode = childNode.getNextSibling();
@@ -292,7 +283,7 @@
public void testSignRootElementInRequest() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -334,7 +325,7 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
//first child element must be the dsig:Signature @see SANTUARIO-324:
@@ -342,7 +333,7 @@
while (childNode != null) {
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element)childNode;
- assertEquals(element.getLocalName(), "Signature");
+ Assert.assertEquals(element.getLocalName(), "Signature");
break;
}
childNode = childNode.getNextSibling();
@@ -377,7 +368,7 @@
private void signAtSpecificPosition(int position, QName positionQName, boolean start) throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -424,7 +415,7 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
//find first child element:
@@ -459,7 +450,7 @@
}
}
- assertEquals(childNode.getLocalName(), "Signature");
+ Assert.assertEquals(childNode.getLocalName(), "Signature");
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -469,7 +460,7 @@
public void testIdAttributeNS() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -514,7 +505,7 @@
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -526,7 +517,7 @@
public void testMultipleElements() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -563,7 +554,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -574,7 +565,7 @@
public void testMultipleSignatures() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -619,7 +610,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -630,7 +621,7 @@
String expression = "//dsig:Signature";
NodeList sigElements =
(NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
- assertTrue(sigElements.getLength() == 2);
+ Assert.assertTrue(sigElements.getLength() == 2);
for (SecurePart secPart : properties.getSignatureSecureParts()) {
if (secPart.getName() == null) {
@@ -639,13 +630,13 @@
expression = "//*[local-name()='" + secPart.getName().getLocalPart() + "']";
Element signedElement =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(signedElement);
+ Assert.assertNotNull(signedElement);
signedElement.setIdAttributeNS(null, "Id", true);
}
for (int i = 0; i < sigElements.getLength(); i++) {
XMLSignature signature = new XMLSignature((Element)sigElements.item(i), "");
- assertTrue(signature.checkSignatureValue(cert));
+ Assert.assertTrue(signature.checkSignatureValue(cert));
}
}
@@ -653,7 +644,7 @@
public void testHMACSignatureCreation() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -683,7 +674,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -694,7 +685,7 @@
public void testStrongSignatureCreation() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -731,7 +722,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -754,7 +745,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -791,7 +782,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -814,7 +805,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -852,7 +843,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -863,7 +854,7 @@
public void testDifferentC14nMethod() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -899,7 +890,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -910,7 +901,7 @@
public void testDifferentC14nMethodForReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -947,28 +938,28 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_CanonicalizationMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_CanonicalizationMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(NS_C14N_EXCL, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(NS_C14N_EXCL, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_Transform.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_Transform.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
element = (Element)nodeList.item(0);
- assertEquals("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_SignatureMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_SignatureMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
element = (Element)nodeList.item(0);
- assertEquals(XMLSecurityConstants.NS_XMLDSIG_RSASHA1, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(XMLSecurityConstants.NS_XMLDSIG_RSASHA1, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
element = (Element)nodeList.item(0);
- assertEquals(XMLSecurityConstants.NS_XMLDSIG_SHA1, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(XMLSecurityConstants.NS_XMLDSIG_SHA1, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -978,7 +969,7 @@
public void testDifferentDigestMethodForReference() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -1015,28 +1006,28 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_CanonicalizationMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_CanonicalizationMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(NS_C14N_EXCL, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(NS_C14N_EXCL, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_Transform.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_Transform.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
element = (Element)nodeList.item(0);
- assertEquals(NS_C14N_EXCL, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(NS_C14N_EXCL, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_SignatureMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_SignatureMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
element = (Element)nodeList.item(0);
- assertEquals(XMLSecurityConstants.NS_XMLDSIG_RSASHA1, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(XMLSecurityConstants.NS_XMLDSIG_RSASHA1, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
element = (Element)nodeList.item(0);
- assertEquals("http://www.w3.org/2001/04/xmlenc#sha256", element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals("http://www.w3.org/2001/04/xmlenc#sha256", element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -1046,7 +1037,7 @@
public void testC14n11Method() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -1082,7 +1073,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -1093,7 +1084,7 @@
public void testExcC14nInclusivePrefixes() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -1130,13 +1121,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_c14nExcl_InclusiveNamespaces.getNamespaceURI(), XMLSecurityConstants.TAG_c14nExcl_InclusiveNamespaces.getLocalPart());
- assertEquals(2, nodeList.getLength());
- assertEquals("", ((Element)nodeList.item(0)).getAttribute(XMLSecurityConstants.ATT_NULL_PrefixList.getLocalPart()));
- assertEquals("", ((Element)nodeList.item(1)).getAttribute(XMLSecurityConstants.ATT_NULL_PrefixList.getLocalPart()));
+ Assert.assertEquals(2, nodeList.getLength());
+ Assert.assertEquals("", ((Element)nodeList.item(0)).getAttribute(XMLSecurityConstants.ATT_NULL_PrefixList.getLocalPart()));
+ Assert.assertEquals("", ((Element)nodeList.item(1)).getAttribute(XMLSecurityConstants.ATT_NULL_PrefixList.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -1146,7 +1137,7 @@
public void testSignatureCreationKeyValue() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyValue);
@@ -1181,7 +1172,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -1200,7 +1191,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_SkiKeyIdentifier);
@@ -1236,7 +1227,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -1247,7 +1238,7 @@
public void testSignatureCreationX509Certificate() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_X509KeyIdentifier);
@@ -1282,7 +1273,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -1293,7 +1284,7 @@
public void testSignatureCreationX509SubjectName() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_X509SubjectName);
@@ -1328,7 +1319,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -1339,7 +1330,7 @@
public void testSignatureCreationMultipleKeyIdentifiers() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
List<SecurityTokenConstants.KeyIdentifier> signatureKeyIdentifiers =
@@ -1378,7 +1369,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -1389,7 +1380,7 @@
public void testSignatureCreationTransformBase64() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -1426,7 +1417,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -1437,7 +1428,7 @@
public void testNoKeyInfo() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -1474,7 +1465,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -1486,7 +1477,7 @@
public void testSignatureCreationKeyName() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyName);
@@ -1522,7 +1513,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_KeyName.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_KeyName.getLocalPart());
@@ -1537,7 +1528,7 @@
public void testSignatureCreationWithoutId() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyName);
@@ -1573,7 +1564,7 @@
//System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document =
- XMLUtils.read(new ByteArrayInputStream(baos.toByteArray()), false);
+ XMLUtils.createDocumentBuilder(false).parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_KeyName.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_KeyName.getLocalPart());
assertEquals(1, nodeList.getLength());
@@ -1587,7 +1578,7 @@
public void testSignatureCreationWithoutOmittedDefaultTransform() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
properties.setSignatureKeyIdentifier(SecurityTokenConstants.KeyIdentifier_KeyName);
@@ -1628,7 +1619,7 @@
//System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document =
- XMLUtils.read(new ByteArrayInputStream(baos.toByteArray()), false);
+ XMLUtils.createDocumentBuilder(false).parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_KeyName.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_KeyName.getLocalPart());
assertEquals(1, nodeList.getLength());
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestCreationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestCreationTest.java
index 8b6905e..7fbe11d 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestCreationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestCreationTest.java
@@ -46,11 +46,10 @@
import org.apache.xml.security.stax.ext.XMLSecurityProperties;
import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
/**
* A set of test-cases for Signature creation with various digest algorithms
*/
@@ -88,7 +87,7 @@
public void testSHA1() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -127,13 +126,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -143,7 +142,7 @@
public void testSHA224() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -182,13 +181,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -198,7 +197,7 @@
public void testSHA256() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -237,13 +236,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -253,7 +252,7 @@
public void testSHA384() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -292,13 +291,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -308,7 +307,7 @@
public void testSHA512() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -347,13 +346,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -365,7 +364,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -404,13 +403,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -422,7 +421,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -461,13 +460,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -479,7 +478,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -518,13 +517,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -536,7 +535,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -575,13 +574,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -593,7 +592,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -632,13 +631,13 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -650,7 +649,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -689,16 +688,16 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
NodeList nodeList = document.getElementsByTagNameNS(XMLSecurityConstants.TAG_dsig_DigestMethod.getNamespaceURI(), XMLSecurityConstants.TAG_dsig_DigestMethod.getLocalPart());
- assertEquals(1, nodeList.getLength());
+ Assert.assertEquals(1, nodeList.getLength());
Element element = (Element)nodeList.item(0);
- assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
+ Assert.assertEquals(digestAlgorithm, element.getAttribute(XMLSecurityConstants.ATT_NULL_Algorithm.getLocalPart()));
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java
index 7b12f5c..a7cf0d3 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureDigestVerificationTest.java
@@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.List;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -70,7 +71,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -112,7 +114,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -121,7 +123,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -163,7 +166,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -172,7 +175,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -214,7 +218,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -223,7 +227,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -265,7 +270,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -274,7 +279,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -316,7 +322,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -327,7 +333,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -369,7 +376,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -380,7 +387,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -422,7 +430,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -433,7 +441,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -475,7 +484,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -486,7 +495,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -528,7 +538,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -539,7 +549,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -581,7 +592,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -592,7 +603,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -634,7 +646,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureEncryptionTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureEncryptionTest.java
index 3b29d9b..d013c31 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureEncryptionTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureEncryptionTest.java
@@ -18,6 +18,25 @@
*/
package org.apache.xml.security.test.stax.signature;
+import org.apache.xml.security.encryption.XMLCipher;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.securityEvent.SecurityEventConstants;
+import org.apache.xml.security.test.stax.utils.StAX2DOM;
+import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
+import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESedeKeySpec;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -29,35 +48,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.DESedeKeySpec;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.apache.xml.security.encryption.XMLCipher;
-import org.apache.xml.security.stax.ext.InboundXMLSec;
-import org.apache.xml.security.stax.ext.OutboundXMLSec;
-import org.apache.xml.security.stax.ext.SecurePart;
-import org.apache.xml.security.stax.ext.XMLSec;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.securityEvent.SecurityEventConstants;
-import org.apache.xml.security.test.stax.utils.StAX2DOM;
-import org.apache.xml.security.test.stax.utils.XmlReaderToWriter;
-import org.apache.xml.security.utils.XMLUtils;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
/**
* A set of test-cases for Signature + Encryption.
*/
@@ -67,7 +57,7 @@
public void testSignatureEncryption() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -111,7 +101,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Decrypt using DOM API
@@ -120,7 +110,7 @@
// Check the CreditCard decrypted ok
NodeList nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -128,15 +118,15 @@
TestSecurityEventListener testSecurityEventListener =
verifyUsingStAX(baos.toByteArray(), encryptionKey, cert.getPublicKey());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.ContentEncrypted).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.ContentEncrypted).size());
}
@Test
public void testSignatureEncryptionSameElement() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -180,7 +170,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Decrypt using DOM API
@@ -189,7 +179,7 @@
// Check the CreditCard decrypted ok
NodeList nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -197,15 +187,15 @@
TestSecurityEventListener testSecurityEventListener =
verifyUsingStAX(baos.toByteArray(), encryptionKey, cert.getPublicKey());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.EncryptedElement).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.EncryptedElement).size());
}
@Test
public void testEnvelopedSignatureEncryptionElement() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -257,7 +247,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Decrypt using DOM API
@@ -266,7 +256,7 @@
// Check the CreditCard decrypted ok
NodeList nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -274,15 +264,15 @@
TestSecurityEventListener testSecurityEventListener =
verifyUsingStAX(baos.toByteArray(), encryptionKey, cert.getPublicKey());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.EncryptedElement).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.EncryptedElement).size());
}
@Test
public void testEnvelopedSignatureEncryptionContent() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
actions.add(XMLSecurityConstants.ENCRYPT);
properties.setActions(actions);
@@ -334,7 +324,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Decrypt using DOM API
@@ -343,7 +333,7 @@
// Check the CreditCard decrypted ok
NodeList nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
// Verify using DOM
verifyUsingDOM(document, cert, properties.getSignatureSecureParts());
@@ -351,15 +341,15 @@
TestSecurityEventListener testSecurityEventListener =
verifyUsingStAX(baos.toByteArray(), encryptionKey, cert.getPublicKey());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.ContentEncrypted).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.ContentEncrypted).size());
}
@Test
public void testEncryptionSignature() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.ENCRYPT);
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -411,7 +401,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -423,13 +413,13 @@
// Check the CreditCard decrypted ok
NodeList nodeList = doc.getElementsByTagNameNS("urn:example:po", "CreditCard");
- assertEquals(nodeList.getLength(), 1);
+ Assert.assertEquals(nodeList.getLength(), 1);
TestSecurityEventListener testSecurityEventListener =
verifyUsingStAX(baos.toByteArray(), encryptionKey, cert.getPublicKey());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
- assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.ContentEncrypted).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement).size());
+ Assert.assertEquals(1, testSecurityEventListener.getSecurityEvents(SecurityEventConstants.ContentEncrypted).size());
}
@Test
@@ -451,9 +441,9 @@
try {
verifyUsingStAX(sourceDocument, encryptionKey, cert.getPublicKey());
- fail("Exception expected");
+ Assert.fail("Exception expected");
} catch (XMLStreamException e) {
- assertEquals("Unsecured message. Neither a Signature nor a EncryptedData element found.",
+ Assert.assertEquals("Unsecured message. Neither a Signature nor a EncryptedData element found.",
e.getCause().getMessage());
}
}
@@ -513,13 +503,13 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, testSecurityEventListener);
- Document document = StAX2DOM.readDoc(securityStreamReader);
+ Document document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// javax.xml.transform.Transformer transformer = TransformerFactory.newInstance().newTransformer();
// transformer.transform(new DOMSource(document), new StreamResult(System.out));
NodeList nodeList = document.getElementsByTagNameNS("http://www.w3.org/2001/04/xmlenc#", "EncryptedData");
- assertEquals(nodeList.getLength(), 0);
+ Assert.assertEquals(nodeList.getLength(), 0);
return testSecurityEventListener;
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACCreationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACCreationTest.java
index c6ede30..18ba243 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACCreationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACCreationTest.java
@@ -83,7 +83,7 @@
public void testHMACSHA1() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -117,7 +117,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -128,7 +128,7 @@
public void testHMACSHA_224() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -162,7 +162,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -173,7 +173,7 @@
public void testHMACSHA_256() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -207,7 +207,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -218,7 +218,7 @@
public void testHMACSHA_384() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -252,7 +252,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -263,7 +263,7 @@
public void testHMACSHA_512() throws Exception {
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -297,7 +297,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
@@ -310,7 +310,7 @@
// Set up the Configuration
XMLSecurityProperties properties = new XMLSecurityProperties();
- List<XMLSecurityConstants.Action> actions = new ArrayList<>();
+ List<XMLSecurityConstants.Action> actions = new ArrayList<XMLSecurityConstants.Action>();
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
@@ -344,7 +344,7 @@
// System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
- document = XMLUtils.read(is, false);
+ document = XMLUtils.createDocumentBuilder(false).parse(is);
}
// Verify using DOM
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACVerificationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACVerificationTest.java
index 72aefa2..8b83ff4 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACVerificationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACVerificationTest.java
@@ -30,6 +30,7 @@
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerFactory;
@@ -98,7 +99,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set the key up
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -134,7 +136,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -143,7 +145,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set the key up
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -179,7 +182,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -188,7 +191,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set the key up
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -224,7 +228,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -233,7 +237,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set the key up
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -269,7 +274,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -278,7 +283,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set the key up
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -314,7 +320,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -325,7 +331,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set the key up
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -361,7 +368,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationReferenceURIResolverTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationReferenceURIResolverTest.java
index f28a93a..8a5efad 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationReferenceURIResolverTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationReferenceURIResolverTest.java
@@ -31,6 +31,7 @@
import java.util.List;
import java.util.UUID;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
@@ -49,12 +50,11 @@
import org.apache.xml.security.test.stax.utils.TestUtils;
import org.apache.xml.security.utils.XMLUtils;
import org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP;
+import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertNotNull;
-
/**
*/
public class SignatureVerificationReferenceURIResolverTest extends AbstractSignatureVerificationTest {
@@ -65,7 +65,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -121,7 +122,7 @@
try {
TestUtils.switchAllowNotSameDocumentReferences(true);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
}
@@ -133,7 +134,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -190,7 +192,7 @@
try {
TestUtils.switchAllowNotSameDocumentReferences(true);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
}
@@ -214,7 +216,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -267,7 +270,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowNotSameDocumentReferences(false);
HttpRequestRedirectorProxy.stopHttpEngine();
@@ -280,7 +283,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -298,7 +302,7 @@
String expression = "//*[local-name()='ShippingAddress']";
Element elementToSign =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(elementToSign);
+ Assert.assertNotNull(elementToSign);
String id = UUID.randomUUID().toString();
elementToSign.setAttributeNS(null, "Id", id);
elementToSign.setIdAttributeNS(null, "Id", true);
@@ -344,7 +348,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -353,7 +357,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -371,7 +376,7 @@
String expression = "//*[local-name()='ShippingAddress']";
Element elementToSign =
(Element) xpath.evaluate(expression, document, XPathConstants.NODE);
- assertNotNull(elementToSign);
+ Assert.assertNotNull(elementToSign);
String id = UUID.randomUUID().toString();
elementToSign.setAttributeNS(null, "Id", id);
elementToSign.setIdAttributeNS(null, "Id", true);
@@ -417,7 +422,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -426,7 +431,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -482,6 +488,6 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java
index 30e5f55..ff95450 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java
@@ -33,6 +33,7 @@
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -40,9 +41,6 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
import org.apache.xml.security.c14n.Canonicalizer;
import org.apache.xml.security.c14n.implementations.Canonicalizer20010315OmitComments;
import org.apache.xml.security.exceptions.XMLSecurityException;
@@ -53,16 +51,8 @@
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.stax.config.Init;
import org.apache.xml.security.stax.config.TransformerAlgorithmMapper;
-import org.apache.xml.security.stax.ext.InboundXMLSec;
-import org.apache.xml.security.stax.ext.XMLSec;
-import org.apache.xml.security.stax.ext.XMLSecurityConstants;
-import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import org.apache.xml.security.stax.securityEvent.KeyNameTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.KeyValueTokenSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.SecurityEvent;
-import org.apache.xml.security.stax.securityEvent.SecurityEventConstants;
-import org.apache.xml.security.stax.securityEvent.SignedElementSecurityEvent;
-import org.apache.xml.security.stax.securityEvent.X509TokenSecurityEvent;
+import org.apache.xml.security.stax.ext.*;
+import org.apache.xml.security.stax.securityEvent.*;
import org.apache.xml.security.stax.securityToken.SecurityTokenConstants;
import org.apache.xml.security.test.stax.utils.StAX2DOM;
import org.apache.xml.security.test.stax.utils.TestUtils;
@@ -70,14 +60,11 @@
import org.apache.xml.security.transforms.Transform;
import org.apache.xml.security.transforms.implementations.TransformC14N;
import org.apache.xml.security.utils.XMLUtils;
-
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* A set of test-cases for Signature verification.
@@ -104,7 +91,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -144,7 +132,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener);
@@ -170,9 +158,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -182,7 +170,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -223,7 +212,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener);
@@ -232,7 +221,7 @@
SecurityTokenConstants.KeyIdentifier_X509KeyIdentifier);
List<SignedElementSecurityEvent> signedElementSecurityEventList = securityEventListener.getSecurityEvents(SecurityEventConstants.SignedElement);
- assertEquals(2, signedElementSecurityEventList.size());
+ Assert.assertEquals(2, signedElementSecurityEventList.size());
X509TokenSecurityEvent x509TokenSecurityEvent = securityEventListener.getSecurityEvent(SecurityEventConstants.X509Token);
String signedElementCorrelationID1 = signedElementSecurityEventList.get(0).getCorrelationID();
String signedElementCorrelationID2 = signedElementSecurityEventList.get(1).getCorrelationID();
@@ -254,10 +243,10 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents1.size());
- assertEquals(3, signedElementSecurityEvents2.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents1.size());
+ Assert.assertEquals(3, signedElementSecurityEvents2.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents1.size() + signedElementSecurityEvents2.size());
}
@@ -267,7 +256,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -317,9 +307,9 @@
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} catch (XMLStreamException ex) {
- assertEquals("Multiple signatures are not supported.", ex.getCause().getMessage());
+ Assert.assertEquals("Multiple signatures are not supported.", ex.getCause().getMessage());
}
}
@@ -329,7 +319,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -382,7 +373,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@@ -392,7 +383,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -430,7 +422,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener,
@@ -459,9 +451,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -471,7 +463,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
@@ -511,11 +504,11 @@
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a bad key");
} catch (XMLStreamException ex) {
- assertTrue(ex.getCause() instanceof XMLSecurityException);
- assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
+ Assert.assertTrue(ex.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
}
}
@@ -537,7 +530,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -578,7 +572,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener,
@@ -607,9 +601,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -619,7 +613,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -660,7 +655,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener,
@@ -689,9 +684,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -701,7 +696,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -742,7 +738,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener,
@@ -771,9 +767,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -783,7 +779,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -824,7 +821,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener,
@@ -853,9 +850,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -865,7 +862,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -911,7 +909,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener);
@@ -937,9 +935,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -949,7 +947,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -993,7 +992,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener);
@@ -1019,9 +1018,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -1039,7 +1038,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("JCEKS");
@@ -1083,7 +1083,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener);
@@ -1109,9 +1109,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -1121,7 +1121,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1162,7 +1163,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// Check the SecurityEvents
checkSecurityEvents(securityEventListener);
@@ -1188,9 +1189,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -1200,7 +1201,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext-base64.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1241,7 +1243,7 @@
XMLStreamReader securityStreamReader =
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
SignedElementSecurityEvent signedElementSecurityEvent = securityEventListener.getSecurityEvent(SecurityEventConstants.SignedElement);
X509TokenSecurityEvent x509TokenSecurityEvent = securityEventListener.getSecurityEvent(SecurityEventConstants.X509Token);
@@ -1261,9 +1263,9 @@
}
}
- assertEquals(4, signatureSecurityEvents.size());
- assertEquals(3, signedElementSecurityEvents.size());
- assertEquals(securityEventListener.getSecurityEvents().size(),
+ Assert.assertEquals(4, signatureSecurityEvents.size());
+ Assert.assertEquals(3, signedElementSecurityEvents.size());
+ Assert.assertEquals(securityEventListener.getSecurityEvents().size(),
signatureSecurityEvents.size() + signedElementSecurityEvents.size());
}
@@ -1273,7 +1275,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1316,7 +1319,7 @@
int oldval = 0;
try {
oldval = TestUtils.changeValueOfMaximumAllowedReferencesPerManifest(2);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Exception expected");
} catch (XMLStreamException e) {
assertTrue(e.getCause() instanceof XMLSecurityException);
@@ -1334,7 +1337,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1375,7 +1379,7 @@
int oldval = 0;
try {
oldval = TestUtils.changeValueOfMaximumAllowedTransformsPerReference(0);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Exception expected");
} catch (XMLStreamException e) {
assertTrue(e.getCause() instanceof XMLSecurityException);
@@ -1393,7 +1397,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1432,7 +1437,7 @@
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Exception expected");
} catch (XMLStreamException e) {
assertTrue(e.getCause() instanceof XMLSecurityException);
@@ -1455,7 +1460,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1495,7 +1501,7 @@
try {
TestUtils.switchAllowMD5Algorithm(true);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
} finally {
TestUtils.switchAllowMD5Algorithm(false);
}
@@ -1514,7 +1520,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1555,7 +1562,7 @@
int oldval = 0;
try {
oldval = TestUtils.changeValueOfMaximumAllowedXMLStructureDepth(5);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Exception expected");
} catch (XMLStreamException e) {
assertTrue(e.getCause() instanceof XMLSecurityException);
@@ -1584,7 +1591,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1625,7 +1633,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
}
@Test
@@ -1634,7 +1642,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1678,10 +1687,10 @@
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a modified document");
} catch (XMLStreamException ex) {
- assertTrue(ex.getMessage().contains("Invalid digest of reference"));
+ Assert.assertTrue(ex.getMessage().contains("Invalid digest of reference"));
}
}
@@ -1691,7 +1700,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1742,10 +1752,10 @@
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a modified document");
} catch (XMLStreamException ex) {
- assertTrue(ex.getMessage().contains("Invalid digest of reference"));
+ Assert.assertTrue(ex.getMessage().contains("Invalid digest of reference"));
}
}
@@ -1755,7 +1765,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1812,10 +1823,10 @@
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a modified document");
} catch (XMLStreamException ex) {
- assertTrue(ex.getMessage().contains("Invalid digest of reference"));
+ Assert.assertTrue(ex.getMessage().contains("Invalid digest of reference"));
}
}
@@ -1825,7 +1836,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -1889,10 +1901,10 @@
inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a modified document");
} catch (XMLStreamException ex) {
- assertTrue(ex.getMessage().contains("Invalid digest of reference"));
+ Assert.assertTrue(ex.getMessage().contains("Invalid digest of reference"));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/TestSecurityEventListener.java b/src/test/java/org/apache/xml/security/test/stax/signature/TestSecurityEventListener.java
index ff46e86..d55dacf 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/TestSecurityEventListener.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/TestSecurityEventListener.java
@@ -25,9 +25,7 @@
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
import org.apache.xml.security.stax.securityEvent.SecurityEventConstants.Event;
import org.apache.xml.security.stax.securityEvent.SecurityEventListener;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.Assert;
public class TestSecurityEventListener implements SecurityEventListener {
private List<SecurityEvent> events = new ArrayList<>();
@@ -36,8 +34,8 @@
public void registerSecurityEvent(SecurityEvent securityEvent)
throws XMLSecurityException {
- assertNotNull("CorrelationID of SecurityEvent is null: " + securityEvent.getSecurityEventType(), securityEvent.getCorrelationID());
- assertTrue("CorrelationID of SecurityEvent is empty: " + securityEvent.getSecurityEventType(), securityEvent.getCorrelationID().length() > 0);
+ Assert.assertNotNull("CorrelationID of SecurityEvent is null: " + securityEvent.getSecurityEventType(), securityEvent.getCorrelationID());
+ Assert.assertTrue("CorrelationID of SecurityEvent is empty: " + securityEvent.getSecurityEventType(), securityEvent.getCorrelationID().length() > 0);
events.add(securityEvent);
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/UnknownAlgoSignatureTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/UnknownAlgoSignatureTest.java
index 5cf5830..d11edd0 100644
--- a/src/test/java/org/apache/xml/security/test/stax/signature/UnknownAlgoSignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/signature/UnknownAlgoSignatureTest.java
@@ -24,6 +24,7 @@
import java.security.KeyStore;
import java.security.cert.X509Certificate;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -39,15 +40,11 @@
import org.apache.xml.security.test.stax.utils.StAX2DOM;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
import org.apache.xml.security.utils.XMLUtils;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
/**
* Tests cases where signature algorithms are unknown.
* <p>
@@ -55,7 +52,7 @@
* org.apache.xml.security.samples.signature.CreateEnvelopingSignature</code>
* </p>
*/
-public class UnknownAlgoSignatureTest {
+public class UnknownAlgoSignatureTest extends Assert {
private XMLInputFactory xmlInputFactory;
private TransformerFactory transformerFactory = TransformerFactory.newInstance();
@@ -77,7 +74,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"org/apache/xml/security/temp/signature/signature-good.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -102,7 +100,7 @@
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
- document = StAX2DOM.readDoc(securityStreamReader);
+ document = StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
// XMLUtils.outputDOM(document, System.out);
}
@@ -113,7 +111,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"org/apache/xml/security/temp/signature/signature-bad-c14n-algo.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -142,11 +141,11 @@
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a bad c14n algorithm");
} catch (XMLStreamException ex) {
- assertTrue(ex.getCause() instanceof XMLSecurityException);
- assertEquals("Unknown transformation. No handler installed for URI http://www.apache.org/bad-c14n-algo", ex.getCause().getMessage());
+ Assert.assertTrue(ex.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("Unknown transformation. No handler installed for URI http://www.apache.org/bad-c14n-algo", ex.getCause().getMessage());
}
// XMLUtils.outputDOM(document, System.out);
@@ -158,7 +157,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"org/apache/xml/security/temp/signature/signature-bad-sig-algo.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -187,11 +187,11 @@
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a bad signature algorithm");
} catch (XMLStreamException ex) {
- assertTrue(ex.getCause() instanceof XMLSecurityException);
- assertEquals("The algorithm URI \"http://www.apache.org/bad-sig-algo\" could not be mapped to a JCE algorithm",
+ Assert.assertTrue(ex.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("The algorithm URI \"http://www.apache.org/bad-sig-algo\" could not be mapped to a JCE algorithm",
ex.getCause().getMessage());
}
@@ -204,7 +204,8 @@
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
"org/apache/xml/security/temp/signature/signature-bad-transform-algo.xml");
- Document document = XMLUtils.read(sourceDocument, false);
+ DocumentBuilder builder = XMLUtils.createDocumentBuilder(false);
+ Document document = builder.parse(sourceDocument);
// Set up the Key
KeyStore keyStore = KeyStore.getInstance("jks");
@@ -233,11 +234,11 @@
XMLStreamReader securityStreamReader = inboundXMLSec.processInMessage(xmlStreamReader);
try {
- StAX2DOM.readDoc(securityStreamReader);
+ StAX2DOM.readDoc(XMLUtils.createDocumentBuilder(false), securityStreamReader);
fail("Failure expected on a bad transform algorithm");
} catch (XMLStreamException ex) {
- assertTrue(ex.getCause() instanceof XMLSecurityException);
- assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
+ Assert.assertTrue(ex.getCause() instanceof XMLSecurityException);
+ Assert.assertEquals("INVALID signature -- core validation failed.", ex.getCause().getMessage());
}
// XMLUtils.outputDOM(document, System.out);
diff --git a/src/test/java/org/apache/xml/security/test/stax/transformer/TransformBase64DecodeTest.java b/src/test/java/org/apache/xml/security/test/stax/transformer/TransformBase64DecodeTest.java
index 01b42a9..7a5c308 100644
--- a/src/test/java/org/apache/xml/security/test/stax/transformer/TransformBase64DecodeTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/transformer/TransformBase64DecodeTest.java
@@ -26,6 +26,7 @@
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.impl.transformer.TransformBase64Decode;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -42,12 +43,9 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
/**
*/
-public class TransformBase64DecodeTest {
+public class TransformBase64DecodeTest extends Assert {
private XMLInputFactory xmlInputFactory;
@@ -90,7 +88,7 @@
@Override
public void transform(InputStream inputStream) throws XMLStreamException {
- fail("unexpected call to transform(InputStream");
+ Assert.fail("unexpected call to transform(InputStream");
}
@Override
@@ -121,7 +119,7 @@
transformBase64Decode.doFinal();
- assertEquals(16, xmlSecEvents.size());
+ Assert.assertEquals(16, xmlSecEvents.size());
}
@Test
@@ -150,7 +148,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -190,7 +188,7 @@
transformBase64Decode.doFinal();
- assertEquals(153, byteArrayOutputStream.size());
+ Assert.assertEquals(153, byteArrayOutputStream.size());
}
@Test
@@ -221,7 +219,7 @@
transformBase64Decode.doFinal();
- assertEquals(153, byteArrayOutputStream.size());
+ Assert.assertEquals(153, byteArrayOutputStream.size());
}
@Test
@@ -233,7 +231,7 @@
transformBase64Decode.transform(this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/xml-stylesheet.b64"));
- assertEquals(13132, byteArrayOutputStream.size());
+ Assert.assertEquals(13132, byteArrayOutputStream.size());
}
@Test
@@ -266,7 +264,7 @@
@Override
public void transform(InputStream inputStream) throws XMLStreamException {
- fail("unexpected call to transform(InputStream");
+ Assert.fail("unexpected call to transform(InputStream");
}
@Override
@@ -281,7 +279,7 @@
transformBase64Decode.doFinal();
- assertEquals(44, xmlSecEvents.size());
+ Assert.assertEquals(44, xmlSecEvents.size());
}
@Test
@@ -309,7 +307,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -333,6 +331,6 @@
transformBase64Decode.doFinal();
- assertEquals(615, byteArrayOutputStream.size());
+ Assert.assertEquals(615, byteArrayOutputStream.size());
}
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/transformer/TransformCanonicalizerTest.java b/src/test/java/org/apache/xml/security/test/stax/transformer/TransformCanonicalizerTest.java
index 50a5828..953ddd0 100644
--- a/src/test/java/org/apache/xml/security/test/stax/transformer/TransformCanonicalizerTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/transformer/TransformCanonicalizerTest.java
@@ -26,6 +26,7 @@
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_OmitCommentsTransformer;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -39,12 +40,9 @@
import java.io.OutputStream;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
/**
*/
-public class TransformCanonicalizerTest {
+public class TransformCanonicalizerTest extends Assert {
private XMLInputFactory xmlInputFactory;
@@ -82,7 +80,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -112,7 +110,7 @@
canonicalizerTransformer.doFinal();
- assertEquals(554, byteArrayOutputStream.size());
+ Assert.assertEquals(554, byteArrayOutputStream.size());
}
@Test
@@ -141,7 +139,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -171,7 +169,7 @@
canonicalizerTransformer.doFinal();
- assertEquals(554, byteArrayOutputStream.size());
+ Assert.assertEquals(554, byteArrayOutputStream.size());
}
@Test
@@ -191,7 +189,7 @@
}
canonicalizerTransformer.doFinal();
- assertEquals(554, byteArrayOutputStream.size());
+ Assert.assertEquals(554, byteArrayOutputStream.size());
}
@Test
@@ -203,7 +201,7 @@
canonicalizerTransformer.transform(this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext-base64.xml"));
- assertEquals(554, byteArrayOutputStream.size());
+ Assert.assertEquals(554, byteArrayOutputStream.size());
}
@Test
@@ -231,7 +229,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -255,7 +253,7 @@
canonicalizerTransformer.doFinal();
- assertEquals(554, byteArrayOutputStream.size());
+ Assert.assertEquals(554, byteArrayOutputStream.size());
}
@Test
@@ -283,7 +281,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -307,6 +305,6 @@
canonicalizerTransformer.doFinal();
- assertEquals(554, byteArrayOutputStream.size());
+ Assert.assertEquals(554, byteArrayOutputStream.size());
}
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/transformer/TransformEnvelopedSignatureTest.java b/src/test/java/org/apache/xml/security/test/stax/transformer/TransformEnvelopedSignatureTest.java
index dd2feda..bfdfe5d 100644
--- a/src/test/java/org/apache/xml/security/test/stax/transformer/TransformEnvelopedSignatureTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/transformer/TransformEnvelopedSignatureTest.java
@@ -26,6 +26,7 @@
import org.apache.xml.security.stax.ext.stax.XMLSecEvent;
import org.apache.xml.security.stax.impl.transformer.TransformEnvelopedSignature;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -41,12 +42,9 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
/**
*/
-public class TransformEnvelopedSignatureTest {
+public class TransformEnvelopedSignatureTest extends Assert {
private XMLInputFactory xmlInputFactory;
@@ -89,7 +87,7 @@
@Override
public void transform(InputStream inputStream) throws XMLStreamException {
- fail("unexpected call to transform(InputStream");
+ Assert.fail("unexpected call to transform(InputStream");
}
@Override
@@ -110,7 +108,7 @@
transformEnvelopedSignature.doFinal();
- assertEquals(19, xmlSecEvents.size());
+ Assert.assertEquals(19, xmlSecEvents.size());
}
@Test
@@ -139,7 +137,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -169,7 +167,7 @@
transformEnvelopedSignature.doFinal();
- assertEquals(207, byteArrayOutputStream.size());
+ Assert.assertEquals(207, byteArrayOutputStream.size());
}
@Test
@@ -190,6 +188,6 @@
transformEnvelopedSignature.doFinal();
- assertEquals(207, byteArrayOutputStream.size());
+ Assert.assertEquals(207, byteArrayOutputStream.size());
}
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java b/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java
index b0b5328..94aa8fe 100644
--- a/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java
+++ b/src/test/java/org/apache/xml/security/test/stax/transformer/TransformIdentityTest.java
@@ -27,6 +27,7 @@
import org.apache.xml.security.stax.impl.transformer.TransformIdentity;
import org.apache.xml.security.test.stax.utils.UnixInputStream;
import org.apache.xml.security.test.stax.utils.XMLSecEventAllocator;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -43,12 +44,9 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
/**
*/
-public class TransformIdentityTest {
+public class TransformIdentityTest extends Assert {
private XMLInputFactory xmlInputFactory;
@@ -92,7 +90,7 @@
@Override
public void transform(InputStream inputStream) throws XMLStreamException {
- fail("unexpected call to transform(InputStream");
+ Assert.fail("unexpected call to transform(InputStream");
}
@Override
@@ -123,7 +121,7 @@
transformIdentity.doFinal();
- assertEquals(3, xmlSecEvents.size());
+ Assert.assertEquals(3, xmlSecEvents.size());
}
@Test
@@ -152,7 +150,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -192,7 +190,7 @@
transformIdentity.doFinal();
- assertEquals(255, byteArrayOutputStream.size());
+ Assert.assertEquals(255, byteArrayOutputStream.size());
}
@Test
@@ -223,7 +221,7 @@
transformIdentity.doFinal();
- assertEquals(255, byteArrayOutputStream.size());
+ Assert.assertEquals(255, byteArrayOutputStream.size());
}
@Test
@@ -235,7 +233,7 @@
transformIdentity.transform(new UnixInputStream(this.getClass().getClassLoader().getResourceAsStream(
"ie/baltimore/merlin-examples/merlin-xmldsig-twenty-three/xml-stylesheet.b64")));
- assertEquals(17786, byteArrayOutputStream.size());
+ Assert.assertEquals(17786, byteArrayOutputStream.size());
}
@Test
@@ -268,7 +266,7 @@
@Override
public void transform(InputStream inputStream) throws XMLStreamException {
- fail("unexpected call to transform(InputStream");
+ Assert.fail("unexpected call to transform(InputStream");
}
@Override
@@ -283,7 +281,7 @@
transformIdentity.doFinal();
- assertEquals(25, xmlSecEvents.size());
+ Assert.assertEquals(25, xmlSecEvents.size());
}
@Test
@@ -311,7 +309,7 @@
@Override
public void transform(XMLSecEvent xmlSecEvent) throws XMLStreamException {
- fail("unexpected call to transform(XMLSecEvent");
+ Assert.fail("unexpected call to transform(XMLSecEvent");
}
@Override
@@ -335,6 +333,6 @@
transformIdentity.doFinal();
- assertEquals(831, byteArrayOutputStream.size());
+ Assert.assertEquals(831, byteArrayOutputStream.size());
}
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/utils/KeyLoader.java b/src/test/java/org/apache/xml/security/test/stax/utils/KeyLoader.java
index b49caba..c0763ec 100644
--- a/src/test/java/org/apache/xml/security/test/stax/utils/KeyLoader.java
+++ b/src/test/java/org/apache/xml/security/test/stax/utils/KeyLoader.java
@@ -18,6 +18,8 @@
*/
package org.apache.xml.security.test.stax.utils;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
import java.io.FileInputStream;
import java.security.KeyFactory;
import java.security.PublicKey;
@@ -32,6 +34,16 @@
private static final String BASEDIR = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
private static final String SEP = System.getProperty("file.separator");
+ private static DocumentBuilder documentBuilder;
+
+ static {
+ try {
+ documentBuilder = XMLUtils.createDocumentBuilder(false);
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
private static String getControlFilePath(String fileName) {
return BASEDIR + SEP + "src" + SEP + "test" + SEP + "resources" +
SEP + "org" + SEP + "apache" + SEP + "xml" + SEP + "security" +
@@ -48,7 +60,7 @@
}
public static Document loadXML(String fileName) throws Exception {
- return XMLUtils.read(new FileInputStream(getControlFilePath(fileName)), false);
+ return documentBuilder.parse(new FileInputStream(getControlFilePath(fileName)));
}
}
diff --git a/src/test/java/org/apache/xml/security/test/stax/utils/StAX2DOM.java b/src/test/java/org/apache/xml/security/test/stax/utils/StAX2DOM.java
index cf6cf7b..bc0fd9a 100644
--- a/src/test/java/org/apache/xml/security/test/stax/utils/StAX2DOM.java
+++ b/src/test/java/org/apache/xml/security/test/stax/utils/StAX2DOM.java
@@ -18,10 +18,9 @@
*/
package org.apache.xml.security.test.stax.utils;
-import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.*;
-import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
@@ -32,11 +31,11 @@
public class StAX2DOM {
static final String XML_NS = "http://www.w3.org/2000/xmlns/";
- public static Document readDoc(XMLStreamReader xmlStreamReader) throws XMLStreamException, ParserConfigurationException {
+ public static Document readDoc(DocumentBuilder documentBuilder, XMLStreamReader xmlStreamReader) throws XMLStreamException {
//skip possible text at the beginning of a document and go directly to the root tag
while (xmlStreamReader.hasNext() && xmlStreamReader.next() != XMLStreamConstants.START_ELEMENT) { //NOPMD
}
- Document document = XMLUtils.newDocument();
+ Document document = documentBuilder.newDocument();
StAX2DOM.readDocElements(document, document, xmlStreamReader, false, false);
xmlStreamReader.close();
return document;
diff --git a/src/test/java/org/apache/xml/security/test/stax/utils/XMLSecEventAllocator.java b/src/test/java/org/apache/xml/security/test/stax/utils/XMLSecEventAllocator.java
index cadc250..07b852c 100644
--- a/src/test/java/org/apache/xml/security/test/stax/utils/XMLSecEventAllocator.java
+++ b/src/test/java/org/apache/xml/security/test/stax/utils/XMLSecEventAllocator.java
@@ -36,9 +36,11 @@
*/
public class XMLSecEventAllocator implements XMLEventAllocator {
+ private XMLEventAllocator xmlEventAllocator;
private XMLSecStartElement parentXmlSecStartElement;
public XMLSecEventAllocator() throws Exception {
+ xmlEventAllocator = com.ctc.wstx.evt.DefaultEventAllocator.getDefaultInstance();
}
@Override
@@ -53,16 +55,21 @@
@Override
public XMLEvent allocate(XMLStreamReader xmlStreamReader) throws XMLStreamException {
XMLSecEvent xmlSecEvent = XMLSecEventFactory.allocate(xmlStreamReader, parentXmlSecStartElement);
- if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType()) {
- parentXmlSecStartElement = (XMLSecStartElement) xmlSecEvent;
- } else if (XMLStreamConstants.START_ELEMENT == xmlSecEvent.getEventType() && parentXmlSecStartElement != null) {
- parentXmlSecStartElement = parentXmlSecStartElement.getParentXMLSecStartElement();
+ switch (xmlSecEvent.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT:
+ parentXmlSecStartElement = (XMLSecStartElement) xmlSecEvent;
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (parentXmlSecStartElement != null) {
+ parentXmlSecStartElement = parentXmlSecStartElement.getParentXMLSecStartElement();
+ }
+ break;
}
return xmlSecEvent;
}
@Override
public void allocate(XMLStreamReader reader, XMLEventConsumer consumer) throws XMLStreamException {
- // xmlEventAllocator.allocate(reader, consumer);
+ xmlEventAllocator.allocate(reader, consumer);
}
}