src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java
equal
deleted
inserted
replaced
29 import java.security.PublicKey; |
29 import java.security.PublicKey; |
30 import java.security.cert.X509Certificate; |
30 import java.security.cert.X509Certificate; |
31 import java.util.HashMap; |
31 import java.util.HashMap; |
32 |
32 |
33 import javax.crypto.SecretKey; |
33 import javax.crypto.SecretKey; |
34 import javax.xml.parsers.DocumentBuilder; |
|
35 import javax.xml.parsers.ParserConfigurationException; |
34 import javax.xml.parsers.ParserConfigurationException; |
36 |
35 |
37 import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver; |
36 import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver; |
38 import com.sun.org.apache.xml.internal.security.utils.XMLUtils; |
37 import com.sun.org.apache.xml.internal.security.utils.XMLUtils; |
39 import org.w3c.dom.Document; |
38 import org.w3c.dom.Document; |
274 * @param bytes |
273 * @param bytes |
275 * @return the Document Element after parsing bytes |
274 * @return the Document Element after parsing bytes |
276 * @throws KeyResolverException if something goes wrong |
275 * @throws KeyResolverException if something goes wrong |
277 */ |
276 */ |
278 protected static Element getDocFromBytes(byte[] bytes, boolean secureValidation) throws KeyResolverException { |
277 protected static Element getDocFromBytes(byte[] bytes, boolean secureValidation) throws KeyResolverException { |
279 DocumentBuilder db = null; |
|
280 try (InputStream is = new ByteArrayInputStream(bytes)) { |
278 try (InputStream is = new ByteArrayInputStream(bytes)) { |
281 db = XMLUtils.createDocumentBuilder(false, secureValidation); |
279 Document doc = XMLUtils.read(is, secureValidation); |
282 Document doc = db.parse(is); |
|
283 return doc.getDocumentElement(); |
280 return doc.getDocumentElement(); |
284 } catch (SAXException ex) { |
281 } catch (SAXException ex) { |
285 throw new KeyResolverException(ex); |
282 throw new KeyResolverException(ex); |
286 } catch (IOException ex) { |
283 } catch (IOException ex) { |
287 throw new KeyResolverException(ex); |
284 throw new KeyResolverException(ex); |