author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 27747 | jdk/src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java@3a271dc8b758 |
child 50614 | 3810c9a2efa1 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
1337 | 2 |
* reserved comment block |
3 |
* DO NOT REMOVE OR ALTER! |
|
2 | 4 |
*/ |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
5 |
/** |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
6 |
* Licensed to the Apache Software Foundation (ASF) under one |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
7 |
* or more contributor license agreements. See the NOTICE file |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
8 |
* distributed with this work for additional information |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
9 |
* regarding copyright ownership. The ASF licenses this file |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
10 |
* to you under the Apache License, Version 2.0 (the |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
11 |
* "License"); you may not use this file except in compliance |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
12 |
* with the License. You may obtain a copy of the License at |
1337 | 13 |
* |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
14 |
* http://www.apache.org/licenses/LICENSE-2.0 |
1337 | 15 |
* |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
16 |
* Unless required by applicable law or agreed to in writing, |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
17 |
* software distributed under the License is distributed on an |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
18 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
19 |
* KIND, either express or implied. See the License for the |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
20 |
* specific language governing permissions and limitations |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
21 |
* under the License. |
1337 | 22 |
*/ |
23 |
/* |
|
24251
da7dc40edb67
8038349: Signing XML with DSA throws Exception when key is larger than 1024 bits
mullan
parents:
23010
diff
changeset
|
24 |
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
1337 | 25 |
*/ |
26 |
/* |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
27 |
* $Id: DOMXMLSignatureFactory.java 1333869 2012-05-04 10:42:44Z coheigea $ |
2 | 28 |
*/ |
29 |
package org.jcp.xml.dsig.internal.dom; |
|
30 |
||
31 |
import javax.xml.crypto.*; |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
32 |
import javax.xml.crypto.dom.DOMCryptoContext; |
2 | 33 |
import javax.xml.crypto.dsig.*; |
34 |
import javax.xml.crypto.dsig.dom.DOMValidateContext; |
|
35 |
import javax.xml.crypto.dsig.keyinfo.*; |
|
36 |
import javax.xml.crypto.dsig.spec.*; |
|
37 |
||
1337 | 38 |
import java.security.InvalidAlgorithmParameterException; |
39 |
import java.security.NoSuchAlgorithmException; |
|
2 | 40 |
import java.util.List; |
41 |
import org.w3c.dom.Document; |
|
42 |
import org.w3c.dom.Element; |
|
43 |
import org.w3c.dom.Node; |
|
44 |
||
45 |
/** |
|
46 |
* DOM-based implementation of XMLSignatureFactory. |
|
47 |
* |
|
48 |
* @author Sean Mullan |
|
49 |
*/ |
|
50 |
public final class DOMXMLSignatureFactory extends XMLSignatureFactory { |
|
51 |
||
52 |
/** |
|
53 |
* Initializes a new instance of this class. |
|
54 |
*/ |
|
55 |
public DOMXMLSignatureFactory() {} |
|
56 |
||
57 |
public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki) { |
|
58 |
return new DOMXMLSignature(si, ki, null, null, null); |
|
59 |
} |
|
60 |
||
61 |
public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, |
|
27747 | 62 |
List<? extends XMLObject> objects, String id, String signatureValueId) { |
2 | 63 |
return new DOMXMLSignature(si, ki, objects, id, signatureValueId); |
64 |
} |
|
65 |
||
66 |
public Reference newReference(String uri, DigestMethod dm) { |
|
67 |
return newReference(uri, dm, null, null, null); |
|
68 |
} |
|
69 |
||
27747 | 70 |
public Reference newReference(String uri, DigestMethod dm, |
71 |
List<? extends Transform> transforms, String type, String id) { |
|
1337 | 72 |
return new DOMReference(uri, type, dm, transforms, id, getProvider()); |
2 | 73 |
} |
74 |
||
75 |
public Reference newReference(String uri, DigestMethod dm, |
|
27747 | 76 |
List<? extends Transform> appliedTransforms, Data result, |
77 |
List<? extends Transform> transforms, String type, String id) { |
|
2 | 78 |
if (appliedTransforms == null) { |
79 |
throw new NullPointerException("appliedTransforms cannot be null"); |
|
80 |
} |
|
81 |
if (appliedTransforms.isEmpty()) { |
|
82 |
throw new NullPointerException("appliedTransforms cannot be empty"); |
|
83 |
} |
|
84 |
if (result == null) { |
|
85 |
throw new NullPointerException("result cannot be null"); |
|
86 |
} |
|
87 |
return new DOMReference |
|
1337 | 88 |
(uri, type, dm, appliedTransforms, result, transforms, id, getProvider()); |
2 | 89 |
} |
90 |
||
27747 | 91 |
public Reference newReference(String uri, DigestMethod dm, |
92 |
List<? extends Transform> transforms, String type, String id, |
|
93 |
byte[] digestValue) { |
|
2 | 94 |
if (digestValue == null) { |
95 |
throw new NullPointerException("digestValue cannot be null"); |
|
96 |
} |
|
97 |
return new DOMReference |
|
1337 | 98 |
(uri, type, dm, null, null, transforms, id, digestValue, getProvider()); |
2 | 99 |
} |
100 |
||
101 |
public SignedInfo newSignedInfo(CanonicalizationMethod cm, |
|
27747 | 102 |
SignatureMethod sm, List<? extends Reference> references) { |
2 | 103 |
return newSignedInfo(cm, sm, references, null); |
104 |
} |
|
105 |
||
106 |
public SignedInfo newSignedInfo(CanonicalizationMethod cm, |
|
27747 | 107 |
SignatureMethod sm, List<? extends Reference> references, String id) { |
2 | 108 |
return new DOMSignedInfo(cm, sm, references, id); |
109 |
} |
|
110 |
||
111 |
// Object factory methods |
|
27747 | 112 |
public XMLObject newXMLObject(List<? extends XMLStructure> content, |
113 |
String id, String mimeType, String encoding) { |
|
2 | 114 |
return new DOMXMLObject(content, id, mimeType, encoding); |
115 |
} |
|
116 |
||
27747 | 117 |
public Manifest newManifest(List<? extends Reference> references) { |
2 | 118 |
return newManifest(references, null); |
119 |
} |
|
120 |
||
27747 | 121 |
public Manifest newManifest(List<? extends Reference> references, |
122 |
String id) { |
|
2 | 123 |
return new DOMManifest(references, id); |
124 |
} |
|
125 |
||
27747 | 126 |
public SignatureProperties newSignatureProperties( |
127 |
List<? extends SignatureProperty> props, String id) { |
|
2 | 128 |
return new DOMSignatureProperties(props, id); |
129 |
} |
|
130 |
||
131 |
public SignatureProperty newSignatureProperty |
|
27747 | 132 |
(List<? extends XMLStructure> info, String target, String id) { |
2 | 133 |
return new DOMSignatureProperty(info, target, id); |
134 |
} |
|
135 |
||
136 |
public XMLSignature unmarshalXMLSignature(XMLValidateContext context) |
|
137 |
throws MarshalException { |
|
138 |
||
139 |
if (context == null) { |
|
140 |
throw new NullPointerException("context cannot be null"); |
|
141 |
} |
|
142 |
return unmarshal(((DOMValidateContext) context).getNode(), context); |
|
143 |
} |
|
144 |
||
145 |
public XMLSignature unmarshalXMLSignature(XMLStructure xmlStructure) |
|
146 |
throws MarshalException { |
|
147 |
||
148 |
if (xmlStructure == null) { |
|
149 |
throw new NullPointerException("xmlStructure cannot be null"); |
|
150 |
} |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
151 |
if (!(xmlStructure instanceof javax.xml.crypto.dom.DOMStructure)) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
152 |
throw new ClassCastException("xmlStructure must be of type DOMStructure"); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
153 |
} |
2 | 154 |
return unmarshal |
155 |
(((javax.xml.crypto.dom.DOMStructure) xmlStructure).getNode(), |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
156 |
new UnmarshalContext()); |
2 | 157 |
} |
158 |
||
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
159 |
private static class UnmarshalContext extends DOMCryptoContext { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
160 |
UnmarshalContext() {} |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
161 |
} |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
162 |
|
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
163 |
private XMLSignature unmarshal(Node node, XMLCryptoContext context) |
2 | 164 |
throws MarshalException { |
165 |
||
166 |
node.normalize(); |
|
167 |
||
168 |
Element element = null; |
|
169 |
if (node.getNodeType() == Node.DOCUMENT_NODE) { |
|
170 |
element = ((Document) node).getDocumentElement(); |
|
171 |
} else if (node.getNodeType() == Node.ELEMENT_NODE) { |
|
172 |
element = (Element) node; |
|
173 |
} else { |
|
174 |
throw new MarshalException |
|
175 |
("Signature element is not a proper Node"); |
|
176 |
} |
|
177 |
||
178 |
// check tag |
|
179 |
String tag = element.getLocalName(); |
|
180 |
if (tag == null) { |
|
181 |
throw new MarshalException("Document implementation must " + |
|
182 |
"support DOM Level 2 and be namespace aware"); |
|
183 |
} |
|
184 |
if (tag.equals("Signature")) { |
|
1337 | 185 |
return new DOMXMLSignature(element, context, getProvider()); |
2 | 186 |
} else { |
187 |
throw new MarshalException("invalid Signature tag: " + tag); |
|
188 |
} |
|
189 |
} |
|
190 |
||
191 |
public boolean isFeatureSupported(String feature) { |
|
192 |
if (feature == null) { |
|
193 |
throw new NullPointerException(); |
|
194 |
} else { |
|
195 |
return false; |
|
196 |
} |
|
197 |
} |
|
198 |
||
199 |
public DigestMethod newDigestMethod(String algorithm, |
|
200 |
DigestMethodParameterSpec params) throws NoSuchAlgorithmException, |
|
201 |
InvalidAlgorithmParameterException { |
|
202 |
if (algorithm == null) { |
|
203 |
throw new NullPointerException(); |
|
204 |
} |
|
205 |
if (algorithm.equals(DigestMethod.SHA1)) { |
|
206 |
return new DOMDigestMethod.SHA1(params); |
|
207 |
} else if (algorithm.equals(DigestMethod.SHA256)) { |
|
208 |
return new DOMDigestMethod.SHA256(params); |
|
209 |
} else if (algorithm.equals(DOMDigestMethod.SHA384)) { |
|
210 |
return new DOMDigestMethod.SHA384(params); |
|
211 |
} else if (algorithm.equals(DigestMethod.SHA512)) { |
|
212 |
return new DOMDigestMethod.SHA512(params); |
|
213 |
} else { |
|
214 |
throw new NoSuchAlgorithmException("unsupported algorithm"); |
|
215 |
} |
|
216 |
} |
|
217 |
||
218 |
public SignatureMethod newSignatureMethod(String algorithm, |
|
219 |
SignatureMethodParameterSpec params) throws NoSuchAlgorithmException, |
|
220 |
InvalidAlgorithmParameterException { |
|
221 |
if (algorithm == null) { |
|
222 |
throw new NullPointerException(); |
|
223 |
} |
|
224 |
if (algorithm.equals(SignatureMethod.RSA_SHA1)) { |
|
225 |
return new DOMSignatureMethod.SHA1withRSA(params); |
|
226 |
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA256)) { |
|
227 |
return new DOMSignatureMethod.SHA256withRSA(params); |
|
228 |
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA384)) { |
|
229 |
return new DOMSignatureMethod.SHA384withRSA(params); |
|
230 |
} else if (algorithm.equals(DOMSignatureMethod.RSA_SHA512)) { |
|
231 |
return new DOMSignatureMethod.SHA512withRSA(params); |
|
232 |
} else if (algorithm.equals(SignatureMethod.DSA_SHA1)) { |
|
233 |
return new DOMSignatureMethod.SHA1withDSA(params); |
|
24251
da7dc40edb67
8038349: Signing XML with DSA throws Exception when key is larger than 1024 bits
mullan
parents:
23010
diff
changeset
|
234 |
} else if (algorithm.equals(DOMSignatureMethod.DSA_SHA256)) { |
da7dc40edb67
8038349: Signing XML with DSA throws Exception when key is larger than 1024 bits
mullan
parents:
23010
diff
changeset
|
235 |
return new DOMSignatureMethod.SHA256withDSA(params); |
2 | 236 |
} else if (algorithm.equals(SignatureMethod.HMAC_SHA1)) { |
237 |
return new DOMHMACSignatureMethod.SHA1(params); |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
238 |
} else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA256)) { |
2 | 239 |
return new DOMHMACSignatureMethod.SHA256(params); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
240 |
} else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA384)) { |
2 | 241 |
return new DOMHMACSignatureMethod.SHA384(params); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
242 |
} else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA512)) { |
2 | 243 |
return new DOMHMACSignatureMethod.SHA512(params); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
244 |
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA1)) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
245 |
return new DOMSignatureMethod.SHA1withECDSA(params); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
246 |
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA256)) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
247 |
return new DOMSignatureMethod.SHA256withECDSA(params); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
248 |
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA384)) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
249 |
return new DOMSignatureMethod.SHA384withECDSA(params); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
250 |
} else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA512)) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
251 |
return new DOMSignatureMethod.SHA512withECDSA(params); |
2 | 252 |
} else { |
253 |
throw new NoSuchAlgorithmException("unsupported algorithm"); |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
public Transform newTransform(String algorithm, |
|
258 |
TransformParameterSpec params) throws NoSuchAlgorithmException, |
|
259 |
InvalidAlgorithmParameterException { |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
260 |
|
1337 | 261 |
TransformService spi; |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
262 |
if (getProvider() == null) { |
1337 | 263 |
spi = TransformService.getInstance(algorithm, "DOM"); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
264 |
} else { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
265 |
try { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
266 |
spi = TransformService.getInstance(algorithm, "DOM", getProvider()); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
267 |
} catch (NoSuchAlgorithmException nsae) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
268 |
spi = TransformService.getInstance(algorithm, "DOM"); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
269 |
} |
1337 | 270 |
} |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
271 |
|
2 | 272 |
spi.init(params); |
273 |
return new DOMTransform(spi); |
|
274 |
} |
|
275 |
||
276 |
public Transform newTransform(String algorithm, |
|
277 |
XMLStructure params) throws NoSuchAlgorithmException, |
|
278 |
InvalidAlgorithmParameterException { |
|
1337 | 279 |
TransformService spi; |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
280 |
if (getProvider() == null) { |
1337 | 281 |
spi = TransformService.getInstance(algorithm, "DOM"); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
282 |
} else { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
283 |
try { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
284 |
spi = TransformService.getInstance(algorithm, "DOM", getProvider()); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
285 |
} catch (NoSuchAlgorithmException nsae) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
286 |
spi = TransformService.getInstance(algorithm, "DOM"); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
287 |
} |
1337 | 288 |
} |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
289 |
|
2 | 290 |
if (params == null) { |
291 |
spi.init(null); |
|
292 |
} else { |
|
293 |
spi.init(params, null); |
|
294 |
} |
|
295 |
return new DOMTransform(spi); |
|
296 |
} |
|
297 |
||
298 |
public CanonicalizationMethod newCanonicalizationMethod(String algorithm, |
|
299 |
C14NMethodParameterSpec params) throws NoSuchAlgorithmException, |
|
300 |
InvalidAlgorithmParameterException { |
|
1337 | 301 |
TransformService spi; |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
302 |
if (getProvider() == null) { |
1337 | 303 |
spi = TransformService.getInstance(algorithm, "DOM"); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
304 |
} else { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
305 |
try { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
306 |
spi = TransformService.getInstance(algorithm, "DOM", getProvider()); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
307 |
} catch (NoSuchAlgorithmException nsae) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
308 |
spi = TransformService.getInstance(algorithm, "DOM"); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
309 |
} |
1337 | 310 |
} |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
311 |
|
2 | 312 |
spi.init(params); |
313 |
return new DOMCanonicalizationMethod(spi); |
|
314 |
} |
|
315 |
||
316 |
public CanonicalizationMethod newCanonicalizationMethod(String algorithm, |
|
317 |
XMLStructure params) throws NoSuchAlgorithmException, |
|
318 |
InvalidAlgorithmParameterException { |
|
1337 | 319 |
TransformService spi; |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
320 |
if (getProvider() == null) { |
1337 | 321 |
spi = TransformService.getInstance(algorithm, "DOM"); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
322 |
} else { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
323 |
try { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
324 |
spi = TransformService.getInstance(algorithm, "DOM", getProvider()); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
325 |
} catch (NoSuchAlgorithmException nsae) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
326 |
spi = TransformService.getInstance(algorithm, "DOM"); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
327 |
} |
1337 | 328 |
} |
2 | 329 |
if (params == null) { |
330 |
spi.init(null); |
|
331 |
} else { |
|
332 |
spi.init(params, null); |
|
333 |
} |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
5506
diff
changeset
|
334 |
|
2 | 335 |
return new DOMCanonicalizationMethod(spi); |
336 |
} |
|
337 |
||
338 |
public URIDereferencer getURIDereferencer() { |
|
339 |
return DOMURIDereferencer.INSTANCE; |
|
340 |
} |
|
341 |
} |