com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Certificate Java Examples
The following examples show how to use
com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Certificate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RetrievalMethodResolver.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static X509Certificate getRawCertificate(XMLSignatureInput resource) throws CanonicalizationException, IOException, CertificateException { byte inputBytes[] = resource.getBytes(); // if the resource stores a raw certificate, we have to handle it CertificateFactory certFact = CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID); X509Certificate cert = (X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(inputBytes)); return cert; }
Example #2
Source File: PrivateKeyResolver.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #3
Source File: RetrievalMethodResolver.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static X509Certificate getRawCertificate(XMLSignatureInput resource) throws CanonicalizationException, IOException, CertificateException { byte inputBytes[] = resource.getBytes(); // if the resource stores a raw certificate, we have to handle it CertificateFactory certFact = CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID); X509Certificate cert = (X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(inputBytes)); return cert; }
Example #4
Source File: PrivateKeyResolver.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #5
Source File: PrivateKeyResolver.java From hottub with GNU General Public License v2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #6
Source File: RetrievalMethodResolver.java From hottub with GNU General Public License v2.0 | 5 votes |
private static X509Certificate getRawCertificate(XMLSignatureInput resource) throws CanonicalizationException, IOException, CertificateException { byte inputBytes[] = resource.getBytes(); // if the resource stores a raw certificate, we have to handle it CertificateFactory certFact = CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID); X509Certificate cert = (X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(inputBytes)); return cert; }
Example #7
Source File: X509Data.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Method itemCertificate * * @param i * @return the X509Certifacte, null if not present * @throws XMLSecurityException */ public XMLX509Certificate itemCertificate(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_X509CERTIFICATE, i); if (e != null) { return new XMLX509Certificate(e, this.baseURI); } return null; }
Example #8
Source File: X509CertificateResolver.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #9
Source File: PrivateKeyResolver.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #10
Source File: X509CertificateResolver.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #11
Source File: X509CertificateResolver.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #12
Source File: X509Data.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Method itemCertificate * * @param i * @return the X509Certifacte, null if not present * @throws XMLSecurityException */ public XMLX509Certificate itemCertificate(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_X509CERTIFICATE, i); if (e != null) { return new XMLX509Certificate(e, this.baseURI); } return null; }
Example #13
Source File: PrivateKeyResolver.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #14
Source File: PrivateKeyResolver.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #15
Source File: X509CertificateResolver.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #16
Source File: X509CertificateResolver.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #17
Source File: PrivateKeyResolver.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #18
Source File: X509Data.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Method itemCertificate * * @param i * @return the X509Certifacte, null if not present * @throws XMLSecurityException */ public XMLX509Certificate itemCertificate(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_X509CERTIFICATE, i); if (e != null) { return new XMLX509Certificate(e, this.baseURI); } return null; }
Example #19
Source File: X509CertificateResolver.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #20
Source File: PrivateKeyResolver.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #21
Source File: RetrievalMethodResolver.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static X509Certificate getRawCertificate(XMLSignatureInput resource) throws CanonicalizationException, IOException, CertificateException { byte inputBytes[] = resource.getBytes(); // if the resource stores a raw certificate, we have to handle it CertificateFactory certFact = CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID); X509Certificate cert = (X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(inputBytes)); return cert; }
Example #22
Source File: X509Data.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Method itemCertificate * * @param i * @return the X509Certifacte, null if not present * @throws XMLSecurityException */ public XMLX509Certificate itemCertificate(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_X509CERTIFICATE, i); if (e != null) { return new XMLX509Certificate(e, this.baseURI); } return null; }
Example #23
Source File: X509CertificateResolver.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #24
Source File: X509CertificateResolver.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #25
Source File: X509Data.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Method itemCertificate * * @param i * @return the X509Certifacte, null if not present * @throws XMLSecurityException */ public XMLX509Certificate itemCertificate(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_X509CERTIFICATE, i); if (e != null) { return new XMLX509Certificate(e, this.baseURI); } return null; }
Example #26
Source File: X509CertificateResolver.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Method engineResolveX509Certificate * @inheritDoc * @param element * @param BaseURI * @param storage * * @throws KeyResolverException */ public X509Certificate engineLookupResolveX509Certificate( Element element, String BaseURI, StorageResolver storage ) throws KeyResolverException { try { Element[] els = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE); if ((els == null) || (els.length == 0)) { Element el = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0); if (el != null) { return engineLookupResolveX509Certificate(el, BaseURI, storage); } return null; } // populate Object array for (int i = 0; i < els.length; i++) { XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI); X509Certificate cert = xmlCert.getX509Certificate(); if (cert != null) { return cert; } } return null; } catch (XMLSecurityException ex) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex); } throw new KeyResolverException("generic.EmptyMessage", ex); } }
Example #27
Source File: PrivateKeyResolver.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private PrivateKey resolveX509Certificate( XMLX509Certificate x509Cert ) throws XMLSecurityException, KeyStoreException { log.log(java.util.logging.Level.FINE, "Can I resolve X509Certificate?"); byte[] x509CertBytes = x509Cert.getCertificateBytes(); Enumeration<String> aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); if (keyStore.isKeyEntry(alias)) { Certificate cert = keyStore.getCertificate(alias); if (cert instanceof X509Certificate) { byte[] certBytes = null; try { certBytes = cert.getEncoded(); } catch (CertificateEncodingException e1) { } if (certBytes != null && Arrays.equals(certBytes, x509CertBytes)) { log.log(java.util.logging.Level.FINE, "match !!! "); try { Key key = keyStore.getKey(alias, password); if (key instanceof PrivateKey) { return (PrivateKey) key; } } catch (Exception e) { log.log(java.util.logging.Level.FINE, "Cannot recover the key", e); // Keep searching } } } } } return null; }
Example #28
Source File: RetrievalMethodResolver.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static X509Certificate getRawCertificate(XMLSignatureInput resource) throws CanonicalizationException, IOException, CertificateException { byte inputBytes[] = resource.getBytes(); // if the resource stores a raw certificate, we have to handle it CertificateFactory certFact = CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID); X509Certificate cert = (X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(inputBytes)); return cert; }
Example #29
Source File: X509Data.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Method itemCertificate * * @param i * @return the X509Certifacte, null if not present * @throws XMLSecurityException */ public XMLX509Certificate itemCertificate(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_X509CERTIFICATE, i); if (e != null) { return new XMLX509Certificate(e, this.baseURI); } return null; }
Example #30
Source File: X509Data.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Method itemCertificate * * @param i * @return the X509Certifacte, null if not present * @throws XMLSecurityException */ public XMLX509Certificate itemCertificate(int i) throws XMLSecurityException { Element e = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_X509CERTIFICATE, i); if (e != null) { return new XMLX509Certificate(e, this.baseURI); } return null; }