src/java.xml.crypto/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
equal
deleted
inserted
replaced
29 * (C) Copyright IBM Corp. 2003 All Rights Reserved. |
29 * (C) Copyright IBM Corp. 2003 All Rights Reserved. |
30 * |
30 * |
31 * =========================================================================== |
31 * =========================================================================== |
32 */ |
32 */ |
33 /* |
33 /* |
34 * $Id: DOMRetrievalMethod.java 1854026 2019-02-21 09:30:01Z coheigea $ |
34 * $Id: DOMRetrievalMethod.java 1862080 2019-06-25 16:50:17Z coheigea $ |
35 */ |
35 */ |
36 package org.jcp.xml.dsig.internal.dom; |
36 package org.jcp.xml.dsig.internal.dom; |
37 |
37 |
38 import java.io.ByteArrayInputStream; |
38 import java.io.ByteArrayInputStream; |
39 import java.io.InputStream; |
39 import java.io.InputStream; |
55 import javax.xml.crypto.dom.DOMCryptoContext; |
55 import javax.xml.crypto.dom.DOMCryptoContext; |
56 import javax.xml.crypto.dom.DOMURIReference; |
56 import javax.xml.crypto.dom.DOMURIReference; |
57 import javax.xml.crypto.dsig.Transform; |
57 import javax.xml.crypto.dsig.Transform; |
58 import javax.xml.crypto.dsig.XMLSignature; |
58 import javax.xml.crypto.dsig.XMLSignature; |
59 import javax.xml.crypto.dsig.keyinfo.RetrievalMethod; |
59 import javax.xml.crypto.dsig.keyinfo.RetrievalMethod; |
60 import javax.xml.parsers.DocumentBuilder; |
|
61 |
60 |
62 import com.sun.org.apache.xml.internal.security.utils.XMLUtils; |
61 import com.sun.org.apache.xml.internal.security.utils.XMLUtils; |
63 import org.w3c.dom.Attr; |
62 import org.w3c.dom.Attr; |
64 import org.w3c.dom.Document; |
63 import org.w3c.dom.Document; |
65 import org.w3c.dom.Element; |
64 import org.w3c.dom.Element; |
273 } |
272 } |
274 |
273 |
275 public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context) |
274 public XMLStructure dereferenceAsXMLStructure(XMLCryptoContext context) |
276 throws URIReferenceException |
275 throws URIReferenceException |
277 { |
276 { |
278 DocumentBuilder db = null; |
|
279 boolean secVal = Utils.secureValidation(context); |
277 boolean secVal = Utils.secureValidation(context); |
280 ApacheData data = (ApacheData)dereference(context); |
278 ApacheData data = (ApacheData)dereference(context); |
281 try (InputStream is = new ByteArrayInputStream(data.getXMLSignatureInput().getBytes())) { |
279 try (InputStream is = new ByteArrayInputStream(data.getXMLSignatureInput().getBytes())) { |
282 db = XMLUtils.createDocumentBuilder(false, secVal); |
280 Document doc = XMLUtils.read(is, secVal); |
283 Document doc = db.parse(is); |
|
284 Element kiElem = doc.getDocumentElement(); |
281 Element kiElem = doc.getDocumentElement(); |
285 if (kiElem.getLocalName().equals("X509Data") |
282 if (kiElem.getLocalName().equals("X509Data") |
286 && XMLSignature.XMLNS.equals(kiElem.getNamespaceURI())) { |
283 && XMLSignature.XMLNS.equals(kiElem.getNamespaceURI())) { |
287 return new DOMX509Data(kiElem); |
284 return new DOMX509Data(kiElem); |
288 } else { |
285 } else { |