author | mullan |
Thu, 25 Aug 2016 15:06:26 -0400 | |
changeset 40551 | 05eba5515cbb |
parent 27747 | 3a271dc8b758 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
1337 | 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:
18266
diff
changeset
|
5 |
/** |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
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:
18266
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:
18266
diff
changeset
|
8 |
* distributed with this work for additional information |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
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:
18266
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:
18266
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:
18266
diff
changeset
|
12 |
* with the License. You may obtain a copy of the License at |
2 | 13 |
* |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
14 |
* http://www.apache.org/licenses/LICENSE-2.0 |
2 | 15 |
* |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
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:
18266
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:
18266
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:
18266
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:
18266
diff
changeset
|
20 |
* specific language governing permissions and limitations |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
21 |
* under the License. |
2 | 22 |
*/ |
1337 | 23 |
/* |
40551
05eba5515cbb
8151893: Add security property to configure XML Signature secure validation mode
mullan
parents:
27747
diff
changeset
|
24 |
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. |
1337 | 25 |
*/ |
2 | 26 |
/* |
27 |
* =========================================================================== |
|
28 |
* |
|
29 |
* (C) Copyright IBM Corp. 2003 All Rights Reserved. |
|
30 |
* |
|
31 |
* =========================================================================== |
|
32 |
*/ |
|
33 |
/* |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
34 |
* $Id: DOMRetrievalMethod.java 1333415 2012-05-03 12:03:51Z coheigea $ |
2 | 35 |
*/ |
36 |
package org.jcp.xml.dsig.internal.dom; |
|
37 |
||
38 |
import java.io.ByteArrayInputStream; |
|
39 |
import java.net.URI; |
|
40 |
import java.net.URISyntaxException; |
|
1337 | 41 |
import java.security.Provider; |
2 | 42 |
import java.util.*; |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
43 |
|
18240 | 44 |
import javax.xml.XMLConstants; |
2 | 45 |
import javax.xml.crypto.*; |
46 |
import javax.xml.crypto.dsig.*; |
|
47 |
import javax.xml.crypto.dom.DOMCryptoContext; |
|
48 |
import javax.xml.crypto.dom.DOMURIReference; |
|
49 |
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod; |
|
50 |
import javax.xml.parsers.*; |
|
51 |
import org.w3c.dom.Attr; |
|
52 |
import org.w3c.dom.Document; |
|
53 |
import org.w3c.dom.Element; |
|
54 |
import org.w3c.dom.Node; |
|
55 |
||
56 |
/** |
|
57 |
* DOM-based implementation of RetrievalMethod. |
|
58 |
* |
|
59 |
* @author Sean Mullan |
|
60 |
* @author Joyce Leung |
|
61 |
*/ |
|
62 |
public final class DOMRetrievalMethod extends DOMStructure |
|
63 |
implements RetrievalMethod, DOMURIReference { |
|
64 |
||
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
65 |
private final List<Transform> transforms; |
2 | 66 |
private String uri; |
67 |
private String type; |
|
68 |
private Attr here; |
|
69 |
||
70 |
/** |
|
71 |
* Creates a <code>DOMRetrievalMethod</code> containing the specified |
|
72 |
* URIReference and List of Transforms. |
|
73 |
* |
|
74 |
* @param uri the URI |
|
75 |
* @param type the type |
|
76 |
* @param transforms a list of {@link Transform}s. The list is defensively |
|
77 |
* copied to prevent subsequent modification. May be <code>null</code> |
|
78 |
* or empty. |
|
79 |
* @throws IllegalArgumentException if the format of <code>uri</code> is |
|
80 |
* invalid, as specified by Reference's URI attribute in the W3C |
|
81 |
* specification for XML-Signature Syntax and Processing |
|
82 |
* @throws NullPointerException if <code>uriReference</code> |
|
83 |
* is <code>null</code> |
|
84 |
* @throws ClassCastException if <code>transforms</code> contains any |
|
85 |
* entries that are not of type {@link Transform} |
|
86 |
*/ |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
87 |
public DOMRetrievalMethod(String uri, String type, |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
88 |
List<? extends Transform> transforms) |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
89 |
{ |
2 | 90 |
if (uri == null) { |
91 |
throw new NullPointerException("uri cannot be null"); |
|
92 |
} |
|
27747 | 93 |
List<Transform> tempList = |
94 |
Collections.checkedList(new ArrayList<Transform>(), |
|
95 |
Transform.class); |
|
96 |
if (transforms != null) { |
|
97 |
tempList.addAll(transforms); |
|
2 | 98 |
} |
27747 | 99 |
this.transforms = Collections.unmodifiableList(tempList); |
2 | 100 |
this.uri = uri; |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
101 |
if (!uri.equals("")) { |
2 | 102 |
try { |
103 |
new URI(uri); |
|
104 |
} catch (URISyntaxException e) { |
|
105 |
throw new IllegalArgumentException(e.getMessage()); |
|
106 |
} |
|
107 |
} |
|
108 |
||
109 |
this.type = type; |
|
110 |
} |
|
111 |
||
112 |
/** |
|
113 |
* Creates a <code>DOMRetrievalMethod</code> from an element. |
|
114 |
* |
|
115 |
* @param rmElem a RetrievalMethod element |
|
116 |
*/ |
|
1337 | 117 |
public DOMRetrievalMethod(Element rmElem, XMLCryptoContext context, |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
118 |
Provider provider) |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
119 |
throws MarshalException |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
120 |
{ |
2 | 121 |
// get URI and Type attributes |
122 |
uri = DOMUtils.getAttributeValue(rmElem, "URI"); |
|
123 |
type = DOMUtils.getAttributeValue(rmElem, "Type"); |
|
124 |
||
125 |
// get here node |
|
126 |
here = rmElem.getAttributeNodeNS(null, "URI"); |
|
127 |
||
18240 | 128 |
boolean secVal = Utils.secureValidation(context); |
129 |
||
2 | 130 |
// get Transforms, if specified |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
131 |
List<Transform> transforms = new ArrayList<Transform>(); |
2 | 132 |
Element transformsElem = DOMUtils.getFirstChildElement(rmElem); |
18240 | 133 |
|
2 | 134 |
if (transformsElem != null) { |
19051
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
135 |
String localName = transformsElem.getLocalName(); |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
136 |
if (!localName.equals("Transforms")) { |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
137 |
throw new MarshalException("Invalid element name: " + |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
138 |
localName + ", expected Transforms"); |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
139 |
} |
2 | 140 |
Element transformElem = |
19051
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
141 |
DOMUtils.getFirstChildElement(transformsElem, "Transform"); |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
142 |
transforms.add(new DOMTransform(transformElem, context, provider)); |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
143 |
transformElem = DOMUtils.getNextSiblingElement(transformElem); |
2 | 144 |
while (transformElem != null) { |
19051
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
145 |
String name = transformElem.getLocalName(); |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
146 |
if (!name.equals("Transform")) { |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
147 |
throw new MarshalException("Invalid element name: " + |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
148 |
name + ", expected Transform"); |
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
149 |
} |
1337 | 150 |
transforms.add |
151 |
(new DOMTransform(transformElem, context, provider)); |
|
40551
05eba5515cbb
8151893: Add security property to configure XML Signature secure validation mode
mullan
parents:
27747
diff
changeset
|
152 |
if (secVal && Policy.restrictNumTransforms(transforms.size())) { |
05eba5515cbb
8151893: Add security property to configure XML Signature secure validation mode
mullan
parents:
27747
diff
changeset
|
153 |
String error = "A maximum of " + Policy.maxTransforms() |
05eba5515cbb
8151893: Add security property to configure XML Signature secure validation mode
mullan
parents:
27747
diff
changeset
|
154 |
+ " transforms per Reference are allowed when" |
05eba5515cbb
8151893: Add security property to configure XML Signature secure validation mode
mullan
parents:
27747
diff
changeset
|
155 |
+ " secure validation is enabled"; |
18240 | 156 |
throw new MarshalException(error); |
157 |
} |
|
19051
6c0cfc00b3ed
8012288: XML DSig API allows wrong tag names and extra elements in SignedInfo
mullan
parents:
18780
diff
changeset
|
158 |
transformElem = DOMUtils.getNextSiblingElement(transformElem); |
2 | 159 |
} |
160 |
} |
|
161 |
if (transforms.isEmpty()) { |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
162 |
this.transforms = Collections.emptyList(); |
2 | 163 |
} else { |
164 |
this.transforms = Collections.unmodifiableList(transforms); |
|
165 |
} |
|
166 |
} |
|
167 |
||
168 |
public String getURI() { |
|
169 |
return uri; |
|
170 |
} |
|
171 |
||
172 |
public String getType() { |
|
173 |
return type; |
|
174 |
} |
|
175 |
||
24970
094bfaa699c3
8046044: Fix raw and unchecked lint warnings in XML Signature Impl
mullan
parents:
23010
diff
changeset
|
176 |
public List<Transform> getTransforms() { |
2 | 177 |
return transforms; |
178 |
} |
|
179 |
||
180 |
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
181 |
throws MarshalException |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
182 |
{ |
2 | 183 |
Document ownerDoc = DOMUtils.getOwnerDocument(parent); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
184 |
Element rmElem = DOMUtils.createElement(ownerDoc, "RetrievalMethod", |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
185 |
XMLSignature.XMLNS, dsPrefix); |
2 | 186 |
|
187 |
// add URI and Type attributes |
|
188 |
DOMUtils.setAttribute(rmElem, "URI", uri); |
|
189 |
DOMUtils.setAttribute(rmElem, "Type", type); |
|
190 |
||
191 |
// add Transforms elements |
|
192 |
if (!transforms.isEmpty()) { |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
193 |
Element transformsElem = DOMUtils.createElement(ownerDoc, |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
194 |
"Transforms", |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
195 |
XMLSignature.XMLNS, |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
196 |
dsPrefix); |
2 | 197 |
rmElem.appendChild(transformsElem); |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
198 |
for (Transform transform : transforms) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
199 |
((DOMTransform)transform).marshal(transformsElem, |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
200 |
dsPrefix, context); |
2 | 201 |
} |
202 |
} |
|
203 |
||
204 |
parent.appendChild(rmElem); |
|
205 |
||
206 |
// save here node |
|
207 |
here = rmElem.getAttributeNodeNS(null, "URI"); |
|
208 |
} |
|
209 |
||
210 |
public Node getHere() { |
|
211 |
return here; |
|
212 |
} |
|
213 |
||
214 |
public Data dereference(XMLCryptoContext context) |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
215 |
throws URIReferenceException |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
216 |
{ |
2 | 217 |
if (context == null) { |
218 |
throw new NullPointerException("context cannot be null"); |
|
219 |
} |
|
220 |
||
221 |
/* |
|
222 |
* If URIDereferencer is specified in context; use it, otherwise use |
|
223 |
* built-in. |
|
224 |
*/ |
|
225 |
URIDereferencer deref = context.getURIDereferencer(); |
|
226 |
if (deref == null) { |
|
227 |
deref = DOMURIDereferencer.INSTANCE; |
|
228 |
} |
|
229 |
||
230 |
Data data = deref.dereference(this, context); |
|
231 |
||
232 |
// pass dereferenced data through Transforms |
|
233 |
try { |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
234 |
for (Transform transform : transforms) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
235 |
data = ((DOMTransform)transform).transform(data, context); |
2 | 236 |
} |
237 |
} catch (Exception e) { |
|
238 |
throw new URIReferenceException(e); |
|
239 |
} |
|
18266
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
240 |
|
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
241 |
// guard against RetrievalMethod loops |
40551
05eba5515cbb
8151893: Add security property to configure XML Signature secure validation mode
mullan
parents:
27747
diff
changeset
|
242 |
if ((data instanceof NodeSetData) && Utils.secureValidation(context) |
05eba5515cbb
8151893: Add security property to configure XML Signature secure validation mode
mullan
parents:
27747
diff
changeset
|
243 |
&& Policy.restrictRetrievalMethodLoops()) { |
27747 | 244 |
NodeSetData<?> nsd = (NodeSetData<?>)data; |
24970
094bfaa699c3
8046044: Fix raw and unchecked lint warnings in XML Signature Impl
mullan
parents:
23010
diff
changeset
|
245 |
Iterator<?> i = nsd.iterator(); |
18266
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
246 |
if (i.hasNext()) { |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
247 |
Node root = (Node)i.next(); |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
248 |
if ("RetrievalMethod".equals(root.getLocalName())) { |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
249 |
throw new URIReferenceException( |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
250 |
"It is forbidden to have one RetrievalMethod point " + |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
251 |
"to another when secure validation is enabled"); |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
252 |
} |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
253 |
} |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
254 |
} |
26e69da689b9
8010714: XML DSig API allows a RetrievalMethod to reference another RetrievalMethod
mullan
parents:
18240
diff
changeset
|
255 |
|
2 | 256 |
return data; |
257 |
} |
|
258 |
||
259 |
public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context) |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
260 |
throws URIReferenceException |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
261 |
{ |
2 | 262 |
try { |
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
263 |
ApacheData data = (ApacheData)dereference(context); |
2 | 264 |
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
265 |
dbf.setNamespaceAware(true); |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
266 |
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); |
2 | 267 |
DocumentBuilder db = dbf.newDocumentBuilder(); |
268 |
Document doc = db.parse(new ByteArrayInputStream |
|
269 |
(data.getXMLSignatureInput().getBytes())); |
|
270 |
Element kiElem = doc.getDocumentElement(); |
|
271 |
if (kiElem.getLocalName().equals("X509Data")) { |
|
272 |
return new DOMX509Data(kiElem); |
|
273 |
} else { |
|
274 |
return null; // unsupported |
|
275 |
} |
|
276 |
} catch (Exception e) { |
|
277 |
throw new URIReferenceException(e); |
|
278 |
} |
|
279 |
} |
|
280 |
||
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
281 |
@Override |
2 | 282 |
public boolean equals(Object obj) { |
283 |
if (this == obj) { |
|
284 |
return true; |
|
285 |
} |
|
286 |
if (!(obj instanceof RetrievalMethod)) { |
|
287 |
return false; |
|
288 |
} |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
289 |
RetrievalMethod orm = (RetrievalMethod)obj; |
2 | 290 |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
291 |
boolean typesEqual = (type == null ? orm.getType() == null |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
292 |
: type.equals(orm.getType())); |
2 | 293 |
|
294 |
return (uri.equals(orm.getURI()) && |
|
295 |
transforms.equals(orm.getTransforms()) && typesEqual); |
|
296 |
} |
|
18780
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
297 |
|
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
298 |
@Override |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
299 |
public int hashCode() { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
300 |
int result = 17; |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
301 |
if (type != null) { |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
302 |
result = 31 * result + type.hashCode(); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
303 |
} |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
304 |
result = 31 * result + uri.hashCode(); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
305 |
result = 31 * result + transforms.hashCode(); |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
306 |
|
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
307 |
return result; |
f47b920867e7
8011547: Update XML Signature implementation to Apache Santuario 1.5.4
mullan
parents:
18266
diff
changeset
|
308 |
} |
2 | 309 |
} |