Skip to content

Commit ccac0cb

Browse files
authored
New version, Java 11, System.Logger, AutoCloseable, XmlSignatureInput types (#192)
* Start of the development od version 4.0.0 Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * POM Updates - JDK11 instead of JDK8 - Added failsafe (skipped by default) - Removed JDK profiles - Removed dependency on SLF4J and LOGJ, XML-APIs - Updated dependency: Jetty, Maven - To be continued ... Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Using System.Logger instead SLF4J - except tests - Allows to use also SLF4J2, previous version wasn't compatible Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Added module-info.java Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Fixed version in XMLDSigRI Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Added AutoCloseable to readers and writers Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Method getBytesFromFile made deprecated - Used just in tests, but might be used by users Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * BufferedStreams replaced by Files.new*Stream calls Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * JMH tests targetting performance (and leaks) - PerformanceIT is able to detect leaks - has limited memory - slows down with executions in a single batch - fails if executions significantly slow down - fails if iterations don't pass limits - now fails DOM tests, seems there is some leak. - replaces two ignored tests PerformanceMemoryTest and PerformanceTimingTest - is executed by the failsafe plugin just on demand: use -DskipIT=false Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Cleanups in tests - using Java11+ features - Created JmhUtils to help JMH - System.Logger usages instead of slf4j - Fixed some IO leaks in tests - unclosed streams - XMLUtilsPerformanceTest now uses JMH - Removed log4j2.properties Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Updated xml.bind versions Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Fixed dependencies based on tests with GlassFish and Metro Webservices Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Tolerate returning a null byte array Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Properly closing streams in tests - added readResource method - also added several utility methods just for tests - reduced copy and paste Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * First clean field references, then close - close may throw an exception Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Yet some resource leaks in tests fixed/prevented + fixed calls Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Sources and target Java version set to 11 without overriding Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Fixed license Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Cleanups based on PMD, javadoc Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * XMLUtils benchmark moved under the failsafe plugin too Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Added buffers to XmlUtils - nearly 10 times faster DOM benchmarks - lower variability in benchmark results Signed-off-by: David Matějček <david.matejcek@omnifish.ee> # Conflicts: # src/main/java/org/apache/xml/security/utils/XMLUtils.java * Updated PMD Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Larger buffers, 8K is quite standard these days Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * XMLSignatureInput vs. resource leaks - I have noticed that in tests a new FileInputStream is given as an argument to this class, and then there's no control over it's lifecycle. - Therefore I have added the finalize method to print warnings at least until I would be able to change it to more reliable implementation. Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * JaCoCo configuration Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Refactoring around XMLSignatureInput - It was split to several classes based on the type of the input data. - Shouldn't those backed by an InputStream be AutoCloseable? - I have seen unclosed file input streams in logs after some failures - The class is also extended in other projects (WSIT, for example) Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Refactored PerformanceIT - each class has own file Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * JUnit5 tests should not be public, says PMD Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Following PMD advices for tests Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * XMLSignatureStreamInput: finalize replaced by close - Safer implementation which allows better control over the stream closure. - Allows also different implementations. Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Fixed XMLSignatureEdDSATest Signed-off-by: David Matějček <david.matejcek@omnifish.ee> # Conflicts: # src/test/java/org/apache/xml/security/test/javax/xml/crypto/dsig/SignatureValidator.java # src/test/java/org/apache/xml/security/test/javax/xml/crypto/dsig/XMLSignatureEdDSATest.java * Making PMD happy - BeanMembersShouldSerialize was replaced by NonSerializableClass - TestClassWithoutTestCases has false positives - JUnit5 tests should be package protected Signed-off-by: David Matějček <david.matejcek@omnifish.ee> # Conflicts: # src/test/java/org/apache/xml/security/test/dom/signature/EDDSASignatureTest.java * Updated JAXB Runtime and Jakarta Activation Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Removed nonexisting sourceEncoding property from the PMD config Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * The test_sixteen_bad_signature made compliant with rules Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Fixed logging of Jetty + level in tests made configurable again - mvn clean install -Dtest.logging.level=FINEST - using nanoseconds in logs Signed-off-by: David Matějček <david.matejcek@omnifish.ee> # Conflicts: # pom.xml * Upgraded PMD to 3.21.0 Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Fixed lost @test (reported by PMD) Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Don't swallow exceptions Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Updated jaxb runtime to 4.0.3 Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Updated GitHub Actions configuration Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Reverted changes which are not necessary and just improved the code quality Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Pom cleanup - using activation-api.version - synced compiler, javadoc and modernizer release options - javadoc uses compiler settings by default - modernizer needs an explicit value - compiler uses the maven.compiler.release property - removed redundant junit version property Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Javadoc lost in rebase is back Signed-off-by: David Matějček <david.matejcek@omnifish.ee> * Fixed method name (canonicalize) Signed-off-by: David Matějček <david.matejcek@omnifish.ee> --------- Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
1 parent c868d91 commit ccac0cb

321 files changed

Lines changed: 6628 additions & 8192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pull-request-build.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ jobs:
1616
timeout-minutes: 130
1717
steps:
1818
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.0
19-
- name: Set up JDK 8
20-
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0
19+
- name: Set up JDK 11
20+
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
2121
with:
22-
java-version: '8'
22+
java-version: '11'
2323
distribution: 'temurin'
2424
cache: maven
2525
- name: Build with Apache Maven
2626
run: mvn -U clean install -Djava.awt.headless=true -fae -B
2727
env:
2828
MAVEN_OPTS: "-Xmx1024M"
29+

etc/santuario-pmd-ruleset.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
<exclude name="AvoidDuplicateLiterals" />
9292
<exclude name="AvoidFieldNameMatchingMethodName" />
9393
<exclude name="AvoidLiteralsInIfCondition" />
94-
<exclude name="BeanMembersShouldSerialize" />
9594
<exclude name="CompareObjectsWithEquals" />
9695
<exclude name="ConstructorCallsOverridableMethod" />
9796
<exclude name="DataflowAnomalyAnalysis" />
@@ -100,10 +99,13 @@
10099
<exclude name="InvalidLogMessageFormat" />
101100
<exclude name="JUnitSpelling" />
102101
<exclude name="MissingSerialVersionUID" />
102+
<exclude name="NonSerializableClass" />
103103
<exclude name="NullAssignment" />
104+
<exclude name="ReturnEmptyCollectionRatherThanNull" />
104105
<exclude name="SingletonClassReturningNewInstance" />
105106
<exclude name="SingleMethodSingleton" />
106107
<exclude name="SuspiciousEqualsMethodName" />
108+
<exclude name="TestClassWithoutTestCases" />
107109
<exclude name="UseLocaleWithCaseConversions" />
108110
<exclude name="UseProperClassLoader" />
109111
</rule>
@@ -129,5 +131,5 @@
129131
<rule ref="category/java/security.xml" >
130132
<exclude name="HardCodedCryptoKey" />
131133
</rule>
132-
134+
133135
</ruleset>

pom.xml

Lines changed: 131 additions & 93 deletions
Large diffs are not rendered by default.

src/main/java/module-info.java

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* @author David Matejcek
22+
*/
23+
module org.apache.santuario.xmlsec {
24+
25+
requires transitive jakarta.activation;
26+
requires transitive jakarta.xml.bind;
27+
requires java.base;
28+
requires java.management;
29+
requires java.xml;
30+
requires java.xml.crypto;
31+
requires org.apache.commons.codec;
32+
33+
exports org.apache.jcp.xml.dsig.internal.dom;
34+
exports org.apache.xml.security;
35+
exports org.apache.xml.security.algorithms;
36+
exports org.apache.xml.security.algorithms.implementations;
37+
exports org.apache.xml.security.c14n;
38+
exports org.apache.xml.security.c14n.helper;
39+
exports org.apache.xml.security.c14n.implementations;
40+
exports org.apache.xml.security.configuration;
41+
exports org.apache.xml.security.encryption;
42+
exports org.apache.xml.security.exceptions;
43+
exports org.apache.xml.security.keys;
44+
exports org.apache.xml.security.keys.content;
45+
exports org.apache.xml.security.keys.content.keyvalues;
46+
exports org.apache.xml.security.keys.content.x509;
47+
exports org.apache.xml.security.keys.keyresolver.implementations;
48+
exports org.apache.xml.security.keys.storage.implementations;
49+
exports org.apache.xml.security.signature;
50+
exports org.apache.xml.security.stax.ext;
51+
exports org.apache.xml.security.transforms;
52+
exports org.apache.xml.security.transforms.implementations;
53+
exports org.apache.xml.security.transforms.params;
54+
exports org.apache.xml.security.utils;
55+
exports org.apache.xml.security.utils.resolver;
56+
exports org.apache.xml.security.utils.resolver.implementations;
57+
58+
opens org.apache.jcp.xml.dsig.internal.dom;
59+
opens org.apache.xml.security;
60+
opens org.apache.xml.security.binding.excc14n;
61+
opens org.apache.xml.security.binding.xmldsig;
62+
opens org.apache.xml.security.binding.xmldsig11;
63+
opens org.apache.xml.security.binding.xmlenc;
64+
opens org.apache.xml.security.binding.xmlenc11;
65+
opens org.apache.xml.security.binding.xop;
66+
opens org.apache.xml.security.configuration;
67+
opens org.apache.xml.security.algorithms.implementations;
68+
opens org.apache.xml.security.c14n.implementations;
69+
opens org.apache.xml.security.keys.keyresolver.implementations;
70+
opens org.apache.xml.security.keys.storage.implementations;
71+
opens org.apache.xml.security.transforms.implementations;
72+
opens org.apache.xml.security.utils.resolver.implementations;
73+
}

src/main/java/org/apache/jcp/xml/dsig/internal/DigesterOutputStream.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import java.io.IOException;
2626
import java.io.InputStream;
2727
import java.io.OutputStream;
28+
import java.lang.System.Logger;
29+
import java.lang.System.Logger.Level;
2830
import java.security.MessageDigest;
2931

3032
import org.apache.xml.security.utils.UnsyncByteArrayOutputStream;
@@ -37,8 +39,8 @@
3739
*
3840
*/
3941
public class DigesterOutputStream extends OutputStream {
40-
private static final org.slf4j.Logger LOG =
41-
org.slf4j.LoggerFactory.getLogger(DigesterOutputStream.class);
42+
private static final Logger LOG = System.getLogger(DigesterOutputStream.class.getName());
43+
4244

4345
private final boolean buffer;
4446
private UnsyncByteArrayOutputStream bos;
@@ -80,13 +82,13 @@ public void write(byte[] input, int offset, int len) {
8082
if (buffer) {
8183
bos.write(input, offset, len);
8284
}
83-
if (LOG.isDebugEnabled()) {
84-
LOG.debug("Pre-digested input:");
85+
if (LOG.isLoggable(Level.DEBUG)) {
86+
LOG.log(Level.DEBUG, "Pre-digested input:");
8587
StringBuilder sb = new StringBuilder(len);
8688
for (int i = offset; i < (offset + len); i++) {
8789
sb.append((char)input[i]);
8890
}
89-
LOG.debug(sb.toString());
91+
LOG.log(Level.DEBUG, sb.toString());
9092
}
9193
md.update(input, offset, len);
9294
}

src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import java.io.ByteArrayInputStream;
2525
import java.io.ByteArrayOutputStream;
2626
import java.io.OutputStream;
27+
import java.lang.System.Logger;
28+
import java.lang.System.Logger.Level;
2729
import java.security.InvalidAlgorithmParameterException;
2830
import java.security.spec.AlgorithmParameterSpec;
2931
import java.util.Set;
@@ -42,6 +44,9 @@
4244
import org.apache.xml.security.c14n.Canonicalizer;
4345
import org.apache.xml.security.c14n.InvalidCanonicalizerException;
4446
import org.apache.xml.security.signature.XMLSignatureInput;
47+
import org.apache.xml.security.signature.XMLSignatureNodeInput;
48+
import org.apache.xml.security.signature.XMLSignatureNodeSetInput;
49+
import org.apache.xml.security.signature.XMLSignatureStreamInput;
4550
import org.apache.xml.security.transforms.Transform;
4651
import org.w3c.dom.Document;
4752
import org.w3c.dom.Element;
@@ -53,8 +58,7 @@ public abstract class ApacheCanonicalizer extends TransformService {
5358
org.apache.xml.security.Init.init();
5459
}
5560

56-
private static final org.slf4j.Logger LOG =
57-
org.slf4j.LoggerFactory.getLogger(ApacheCanonicalizer.class);
61+
private static final Logger LOG = System.getLogger(ApacheCanonicalizer.class.getName());
5862
protected Canonicalizer canonicalizer;
5963
private Transform apacheTransform;
6064
protected String inclusiveNamespaces;
@@ -118,7 +122,7 @@ public Data canonicalize(Data data, XMLCryptoContext xc, OutputStream os)
118122
if (canonicalizer == null) {
119123
try {
120124
canonicalizer = Canonicalizer.getInstance(getAlgorithm());
121-
LOG.debug("Created canonicalizer for algorithm: {}", getAlgorithm());
125+
LOG.log(Level.DEBUG, "Created canonicalizer for algorithm: {0}", getAlgorithm());
122126
} catch (InvalidCanonicalizerException ice) {
123127
throw new TransformException
124128
("Couldn't find Canonicalizer for: " + getAlgorithm() +
@@ -145,7 +149,7 @@ public Data canonicalize(Data data, XMLCryptoContext xc, OutputStream os)
145149
} else if (in.isNodeSet()) {
146150
nodeSet = in.getNodeSet();
147151
} else {
148-
canonicalizer.canonicalize(Utils.readBytesFromStream(in.getOctetStream()), writer, secVal);
152+
canonicalizer.canonicalize(Utils.readBytesFromStream(in.getUnprocessedInput()), writer, secVal);
149153
return new OctetStreamData(new ByteArrayInputStream(getC14nBytes(writer, isByteArrayOutputStream)));
150154
}
151155
} else if (data instanceof DOMSubTreeData) {
@@ -163,7 +167,7 @@ public Data canonicalize(Data data, XMLCryptoContext xc, OutputStream os)
163167
@SuppressWarnings("unchecked")
164168
Set<Node> ns = Utils.toNodeSet(nsd.iterator());
165169
nodeSet = ns;
166-
LOG.debug("Canonicalizing {} nodes", nodeSet.size());
170+
LOG.log(Level.DEBUG, "Canonicalizing {0} nodes", nodeSet.size());
167171
} else {
168172
canonicalizer.canonicalize(Utils.readBytesFromStream(((OctetStreamData)data).getOctetStream()), writer, secVal);
169173
return new OctetStreamData(new ByteArrayInputStream(getC14nBytes(writer, isByteArrayOutputStream)));
@@ -208,7 +212,7 @@ public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
208212
apacheTransform =
209213
new Transform(ownerDoc, getAlgorithm(), transformElem.getChildNodes());
210214
apacheTransform.setElement(transformElem, xc.getBaseURI());
211-
LOG.debug("Created transform for algorithm: {}", getAlgorithm());
215+
LOG.log(Level.DEBUG, "Created transform for algorithm: {0}", getAlgorithm());
212216
} catch (Exception ex) {
213217
throw new TransformException
214218
("Couldn't find Transform for: " + getAlgorithm(), ex);
@@ -217,25 +221,23 @@ public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
217221

218222
XMLSignatureInput in;
219223
if (data instanceof ApacheData) {
220-
LOG.debug("ApacheData = true");
224+
LOG.log(Level.DEBUG, "ApacheData = true");
221225
in = ((ApacheData)data).getXMLSignatureInput();
222226
} else if (data instanceof NodeSetData) {
223-
LOG.debug("isNodeSet() = true");
227+
LOG.log(Level.DEBUG, "isNodeSet() = true");
224228
if (data instanceof DOMSubTreeData) {
225229
DOMSubTreeData subTree = (DOMSubTreeData)data;
226-
in = new XMLSignatureInput(subTree.getRoot());
230+
in = new XMLSignatureNodeInput(subTree.getRoot());
227231
in.setExcludeComments(subTree.excludeComments());
228232
} else {
229-
@SuppressWarnings("unchecked")
230-
Set<Node> nodeSet =
231-
Utils.toNodeSet(((NodeSetData)data).iterator());
232-
in = new XMLSignatureInput(nodeSet);
233+
@SuppressWarnings({"unchecked", "rawtypes"})
234+
Set<Node> nodeSet = Utils.toNodeSet(((NodeSetData) data).iterator());
235+
in = new XMLSignatureNodeSetInput(nodeSet);
233236
}
234237
} else {
235-
LOG.debug("isNodeSet() = false");
238+
LOG.log(Level.DEBUG, "isNodeSet() = false");
236239
try {
237-
in = new XMLSignatureInput
238-
(((OctetStreamData)data).getOctetStream());
240+
in = new XMLSignatureStreamInput(((OctetStreamData) data).getOctetStream());
239241
} catch (Exception ex) {
240242
throw new TransformException(ex);
241243
}
@@ -246,7 +248,7 @@ public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
246248

247249
try {
248250
in = apacheTransform.performTransform(in, os, secVal);
249-
if (in.isOctetStream()) {
251+
if (in.hasUnprocessedInput()) {
250252
return new ApacheOctetStreamData(in);
251253
} else {
252254
return new ApacheNodeSetData(in);

src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class ApacheOctetStreamData extends OctetStreamData
3535
public ApacheOctetStreamData(XMLSignatureInput xi)
3636
throws IOException
3737
{
38-
super(xi.getOctetStream(), xi.getSourceURI(), xi.getMIMEType());
38+
super(xi.getUnprocessedInput(), xi.getSourceURI(), xi.getMIMEType());
3939
this.xi = xi;
4040
}
4141

src/main/java/org/apache/jcp/xml/dsig/internal/dom/ApacheTransform.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
package org.apache.jcp.xml.dsig.internal.dom;
2323

2424
import java.io.OutputStream;
25+
import java.lang.System.Logger;
26+
import java.lang.System.Logger.Level;
2527
import java.security.InvalidAlgorithmParameterException;
2628
import java.security.spec.AlgorithmParameterSpec;
2729
import java.util.Set;
@@ -38,6 +40,9 @@
3840
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
3941

4042
import org.apache.xml.security.signature.XMLSignatureInput;
43+
import org.apache.xml.security.signature.XMLSignatureNodeInput;
44+
import org.apache.xml.security.signature.XMLSignatureNodeSetInput;
45+
import org.apache.xml.security.signature.XMLSignatureStreamInput;
4146
import org.apache.xml.security.transforms.Transform;
4247
import org.apache.xml.security.transforms.Transforms;
4348
import org.w3c.dom.Document;
@@ -55,8 +60,8 @@ public abstract class ApacheTransform extends TransformService {
5560
org.apache.xml.security.Init.init();
5661
}
5762

58-
private static final org.slf4j.Logger LOG =
59-
org.slf4j.LoggerFactory.getLogger(ApacheTransform.class);
63+
private static final Logger LOG = System.getLogger(ApacheTransform.class.getName());
64+
6065
private Transform transform;
6166
protected Document ownerDoc;
6267
protected Element transformElem;
@@ -140,7 +145,7 @@ private Data transformIt(Data data, XMLCryptoContext xc, OutputStream os)
140145
transform =
141146
new Transform(ownerDoc, getAlgorithm(), transformElem.getChildNodes());
142147
transform.setElement(transformElem, xc.getBaseURI());
143-
LOG.debug("Created transform for algorithm: {}", getAlgorithm());
148+
LOG.log(Level.DEBUG, "Created transform for algorithm: {0}", getAlgorithm());
144149
} catch (Exception ex) {
145150
throw new TransformException("Couldn't find Transform for: " +
146151
getAlgorithm(), ex);
@@ -158,26 +163,25 @@ private Data transformIt(Data data, XMLCryptoContext xc, OutputStream os)
158163

159164
XMLSignatureInput in;
160165
if (data instanceof ApacheData) {
161-
LOG.debug("ApacheData = true");
166+
LOG.log(Level.DEBUG, "ApacheData = true");
162167
in = ((ApacheData)data).getXMLSignatureInput();
163168
} else if (data instanceof NodeSetData) {
164-
LOG.debug("isNodeSet() = true");
169+
LOG.log(Level.DEBUG, "isNodeSet() = true");
165170
if (data instanceof DOMSubTreeData) {
166-
LOG.debug("DOMSubTreeData = true");
171+
LOG.log(Level.DEBUG, "DOMSubTreeData = true");
167172
DOMSubTreeData subTree = (DOMSubTreeData)data;
168-
in = new XMLSignatureInput(subTree.getRoot());
173+
in = new XMLSignatureNodeInput(subTree.getRoot());
169174
in.setExcludeComments(subTree.excludeComments());
170175
} else {
171-
@SuppressWarnings("unchecked")
176+
@SuppressWarnings({"unchecked", "rawtypes"})
172177
Set<Node> nodeSet =
173178
Utils.toNodeSet(((NodeSetData)data).iterator());
174-
in = new XMLSignatureInput(nodeSet);
179+
in = new XMLSignatureNodeSetInput(nodeSet);
175180
}
176181
} else {
177-
LOG.debug("isNodeSet() = false");
182+
LOG.log(Level.DEBUG, "isNodeSet() = false");
178183
try {
179-
in = new XMLSignatureInput
180-
(((OctetStreamData)data).getOctetStream());
184+
in = new XMLSignatureStreamInput(((OctetStreamData) data).getOctetStream());
181185
} catch (Exception ex) {
182186
throw new TransformException(ex);
183187
}
@@ -194,7 +198,7 @@ private Data transformIt(Data data, XMLCryptoContext xc, OutputStream os)
194198
} else {
195199
in = transform.performTransform(in, secVal);
196200
}
197-
if (in.isOctetStream()) {
201+
if (in.hasUnprocessedInput()) {
198202
return new ApacheOctetStreamData(in);
199203
} else {
200204
return new ApacheNodeSetData(in);

src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
package org.apache.jcp.xml.dsig.internal.dom;
2323

24+
import java.lang.System.Logger;
25+
import java.lang.System.Logger.Level;
2426
import java.security.InvalidAlgorithmParameterException;
2527
import java.security.InvalidKeyException;
2628
import java.security.Key;
@@ -54,8 +56,8 @@ public abstract class DOMHMACSignatureMethod extends AbstractDOMSignatureMethod
5456

5557
private static final String DOM_SIGNATURE_PROVIDER = "org.jcp.xml.dsig.internal.dom.MacProvider";
5658

57-
private static final org.slf4j.Logger LOG =
58-
org.slf4j.LoggerFactory.getLogger(DOMHMACSignatureMethod.class);
59+
private static final Logger LOG = System.getLogger(DOMHMACSignatureMethod.class.getName());
60+
5961

6062
// see RFC 4051 for these algorithm definitions
6163
static final String HMAC_SHA224 =
@@ -115,7 +117,7 @@ void checkParams(SignatureMethodParameterSpec params)
115117
}
116118
outputLength = ((HMACParameterSpec)params).getOutputLength();
117119
outputLengthSet = true;
118-
LOG.debug("Setting outputLength from HMACParameterSpec to: {}", outputLength);
120+
LOG.log(Level.DEBUG, "Setting outputLength from HMACParameterSpec to: {0}", outputLength);
119121
}
120122
}
121123

@@ -134,7 +136,7 @@ SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
134136
throw new MarshalException("Invalid output length supplied: " + paramsElem.getFirstChild().getNodeValue());
135137
}
136138
outputLengthSet = true;
137-
LOG.debug("unmarshalled outputLength: {}", outputLength);
139+
LOG.log(Level.DEBUG, "unmarshalled outputLength: {0}", outputLength);
138140
return new HMACParameterSpec(outputLength);
139141
}
140142

0 commit comments

Comments
 (0)