author | jlahoda |
Tue, 24 Sep 2019 15:40:26 +0200 | |
branch | JDK-8226585-branch |
changeset 58290 | d885633d9de4 |
parent 53998 | d870bb08194a |
permissions | -rw-r--r-- |
1337 | 1 |
/* |
2 |
* reserved comment block |
|
3 |
* DO NOT REMOVE OR ALTER! |
|
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 |
/* |
|
50614
3810c9a2efa1
8177334: Update xmldsig implementation to Apache Santuario 2.1.1
weijun
parents:
47216
diff
changeset
|
24 |
* Copyright (c) 2008, 2018, 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$ |
1337 | 28 |
*/ |
29 |
package org.jcp.xml.dsig.internal.dom; |
|
30 |
||
31 |
import javax.xml.crypto.*; |
|
32 |
import javax.xml.crypto.dsig.*; |
|
33 |
import javax.xml.crypto.dsig.spec.TransformParameterSpec; |
|
34 |
||
35 |
import java.security.InvalidAlgorithmParameterException; |
|
36 |
||
37 |
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer; |
|
38 |
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException; |
|
39 |
||
40 |
/** |
|
41 |
* DOM-based implementation of CanonicalizationMethod for Canonical XML 1.1 |
|
42 |
* (with or without comments). Uses Apache XML-Sec Canonicalizer. |
|
43 |
* |
|
44 |
*/ |
|
45 |
public final class DOMCanonicalXMLC14N11Method extends ApacheCanonicalizer { |
|
46 |
||
47 |
public static final String C14N_11 = "http://www.w3.org/2006/12/xml-c14n11"; |
|
48 |
public static final String C14N_11_WITH_COMMENTS |
|
49 |
= "http://www.w3.org/2006/12/xml-c14n11#WithComments"; |
|
50 |
||
51 |
public void init(TransformParameterSpec params) |
|
52 |
throws InvalidAlgorithmParameterException { |
|
53 |
if (params != null) { |
|
54 |
throw new InvalidAlgorithmParameterException("no parameters " + |
|
55 |
"should be specified for Canonical XML 1.1 algorithm"); |
|
56 |
} |
|
57 |
} |
|
58 |
||
59 |
public Data transform(Data data, XMLCryptoContext xc) |
|
60 |
throws TransformException { |
|
61 |
||
62 |
// ignore comments if dereferencing same-document URI that requires |
|
63 |
// you to omit comments, even if the Transform says otherwise - |
|
64 |
// this is to be compliant with section 4.3.3.3 of W3C Rec. |
|
65 |
if (data instanceof DOMSubTreeData) { |
|
66 |
DOMSubTreeData subTree = (DOMSubTreeData) data; |
|
67 |
if (subTree.excludeComments()) { |
|
68 |
try { |
|
69 |
apacheCanonicalizer = Canonicalizer.getInstance(C14N_11); |
|
50614
3810c9a2efa1
8177334: Update xmldsig implementation to Apache Santuario 2.1.1
weijun
parents:
47216
diff
changeset
|
70 |
boolean secVal = Utils.secureValidation(xc); |
3810c9a2efa1
8177334: Update xmldsig implementation to Apache Santuario 2.1.1
weijun
parents:
47216
diff
changeset
|
71 |
apacheCanonicalizer.setSecureValidation(secVal); |
1337 | 72 |
} catch (InvalidCanonicalizerException ice) { |
73 |
throw new TransformException |
|
74 |
("Couldn't find Canonicalizer for: " + |
|
75 |
C14N_11 + ": " + ice.getMessage(), ice); |
|
76 |
} |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
return canonicalize(data, xc); |
|
81 |
} |
|
82 |
} |