com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi. 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: KeyInfo.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * This method uses each System-wide {@link KeyResolver} to search the
 * child elements. Each combination of {@link KeyResolver} and child element
 * is checked against all {@link StorageResolver}s.
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromStaticResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
            + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }
    return null;
}
 
Example #2
Source File: KeyInfo.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method getX509CertificateFromInternalResolvers
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromInternalResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromInternalResolvers() with "
            + this.lengthInternalKeyResolver() + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }

    return null;
}
 
Example #3
Source File: KeyInfo.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Method getX509CertificateFromInternalResolvers
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromInternalResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromInternalResolvers() with "
            + this.lengthInternalKeyResolver() + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }

    return null;
}
 
Example #4
Source File: KeyInfo.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Searches the library wide KeyResolvers for public keys
 *
 * @return The public key contained in this Node.
 * @throws KeyResolverException
 */
PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (StorageResolver storage : storageResolvers) {
                    PublicKey pk =
                        keyResolver.engineLookupAndResolvePublicKey(
                            (Element) currentChild, uri, storage
                        );

                    if (pk != null) {
                        return pk;
                    }
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }
    return null;
}
 
Example #5
Source File: KeyInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Searches the library wide KeyResolvers for public keys
 *
 * @return The public key contained in this Node.
 * @throws KeyResolverException
 */
PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (StorageResolver storage : storageResolvers) {
                    PublicKey pk =
                        keyResolver.engineLookupAndResolvePublicKey(
                            (Element) currentChild, uri, storage
                        );

                    if (pk != null) {
                        return pk;
                    }
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }
    return null;
}
 
Example #6
Source File: KeyInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private X509Certificate applyCurrentResolver(
    String uri, KeyResolverSpi keyResolver
) throws KeyResolverException {
    Node currentChild = this.constructionElement.getFirstChild();
    while (currentChild != null)      {
        if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
            for (StorageResolver storage : storageResolvers) {
                X509Certificate cert =
                    keyResolver.engineLookupResolveX509Certificate(
                        (Element) currentChild, uri, storage
                    );

                if (cert != null) {
                    return cert;
                }
            }
        }
        currentChild = currentChild.getNextSibling();
    }
    return null;
}
 
Example #7
Source File: KeyInfo.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private X509Certificate applyCurrentResolver(
    String uri, KeyResolverSpi keyResolver
) throws KeyResolverException {
    Node currentChild = this.constructionElement.getFirstChild();
    while (currentChild != null)      {
        if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
            for (StorageResolver storage : storageResolvers) {
                X509Certificate cert =
                    keyResolver.engineLookupResolveX509Certificate(
                        (Element) currentChild, uri, storage
                    );

                if (cert != null) {
                    return cert;
                }
            }
        }
        currentChild = currentChild.getNextSibling();
    }
    return null;
}
 
Example #8
Source File: KeyInfo.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private X509Certificate applyCurrentResolver(
    String uri, KeyResolverSpi keyResolver
) throws KeyResolverException {
    Node currentChild = this.constructionElement.getFirstChild();
    while (currentChild != null)      {
        if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
            for (StorageResolver storage : storageResolvers) {
                X509Certificate cert =
                    keyResolver.engineLookupResolveX509Certificate(
                        (Element) currentChild, uri, storage
                    );

                if (cert != null) {
                    return cert;
                }
            }
        }
        currentChild = currentChild.getNextSibling();
    }
    return null;
}
 
Example #9
Source File: KeyInfo.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Searches the library wide KeyResolvers for public keys
 *
 * @return The public key contained in this Node.
 * @throws KeyResolverException
 */
PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (StorageResolver storage : storageResolvers) {
                    PublicKey pk =
                        keyResolver.engineLookupAndResolvePublicKey(
                            (Element) currentChild, uri, storage
                        );

                    if (pk != null) {
                        return pk;
                    }
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }
    return null;
}
 
Example #10
Source File: KeyInfo.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method uses each System-wide {@link KeyResolver} to search the
 * child elements. Each combination of {@link KeyResolver} and child element
 * is checked against all {@link StorageResolver}s.
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromStaticResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
            + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }
    return null;
}
 
Example #11
Source File: KeyInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Searches the library wide KeyResolvers for public keys
 *
 * @return The public key contained in this Node.
 * @throws KeyResolverException
 */
PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (StorageResolver storage : storageResolvers) {
                    PublicKey pk =
                        keyResolver.engineLookupAndResolvePublicKey(
                            (Element) currentChild, uri, storage
                        );

                    if (pk != null) {
                        return pk;
                    }
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }
    return null;
}
 
Example #12
Source File: KeyInfo.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method getX509CertificateFromInternalResolvers
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromInternalResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromInternalResolvers() with "
            + this.lengthInternalKeyResolver() + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }

    return null;
}
 
Example #13
Source File: KeyInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method uses each System-wide {@link KeyResolver} to search the
 * child elements. Each combination of {@link KeyResolver} and child element
 * is checked against all {@link StorageResolver}s.
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromStaticResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
            + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }
    return null;
}
 
Example #14
Source File: KeyInfo.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Searches the library wide KeyResolvers for public keys
 *
 * @return The public key contained in this Node.
 * @throws KeyResolverException
 */
PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (StorageResolver storage : storageResolvers) {
                    PublicKey pk =
                        keyResolver.engineLookupAndResolvePublicKey(
                            (Element) currentChild, uri, storage
                        );

                    if (pk != null) {
                        return pk;
                    }
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }
    return null;
}
 
Example #15
Source File: KeyInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method uses each System-wide {@link KeyResolver} to search the
 * child elements. Each combination of {@link KeyResolver} and child element
 * is checked against all {@link StorageResolver}s.
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromStaticResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
            + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }
    return null;
}
 
Example #16
Source File: KeyInfo.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method getX509CertificateFromInternalResolvers
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromInternalResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromInternalResolvers() with "
            + this.lengthInternalKeyResolver() + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }

    return null;
}
 
Example #17
Source File: KeyInfo.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Method getX509CertificateFromInternalResolvers
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromInternalResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromInternalResolvers() with "
            + this.lengthInternalKeyResolver() + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }

    return null;
}
 
Example #18
Source File: KeyInfo.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method uses each System-wide {@link KeyResolver} to search the
 * child elements. Each combination of {@link KeyResolver} and child element
 * is checked against all {@link StorageResolver}s.
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromStaticResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
            + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }
    return null;
}
 
Example #19
Source File: KeyInfo.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * This method uses each System-wide {@link KeyResolver} to search the
 * child elements. Each combination of {@link KeyResolver} and child element
 * is checked against all {@link StorageResolver}s.
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromStaticResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
            + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }
    return null;
}
 
Example #20
Source File: KeyInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method uses each System-wide {@link KeyResolver} to search the
 * child elements. Each combination of {@link KeyResolver} and child element
 * is checked against all {@link StorageResolver}s.
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromStaticResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
            + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }
    return null;
}
 
Example #21
Source File: KeyInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method getX509CertificateFromInternalResolvers
 *
 * @return The certificate contained in this KeyInfo
 * @throws KeyResolverException
 */
X509Certificate getX509CertificateFromInternalResolvers()
    throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE,
            "Start getX509CertificateFromInternalResolvers() with "
            + this.lengthInternalKeyResolver() + " resolvers"
        );
    }
    String uri = this.getBaseURI();
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        X509Certificate cert = applyCurrentResolver(uri, keyResolver);
        if (cert != null) {
            return cert;
        }
    }

    return null;
}
 
Example #22
Source File: KeyInfo.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Searches the library wide KeyResolvers for public keys
 *
 * @return The public key contained in this Node.
 * @throws KeyResolverException
 */
PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (StorageResolver storage : storageResolvers) {
                    PublicKey pk =
                        keyResolver.engineLookupAndResolvePublicKey(
                            (Element) currentChild, uri, storage
                        );

                    if (pk != null) {
                        return pk;
                    }
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }
    return null;
}
 
Example #23
Source File: KeyInfo.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Searches the per-KeyInfo KeyResolvers for secret keys
 *
 * @return the secret key contained in this KeyInfo
 * @throws KeyResolverException
 */

SecretKey getSecretKeyFromInternalResolvers() throws KeyResolverException {
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null)      {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                for (StorageResolver storage : storageResolvers) {
                    SecretKey sk =
                        keyResolver.engineLookupAndResolveSecretKey(
                            (Element) currentChild, uri, storage
                        );

                    if (sk != null) {
                        return sk;
                    }
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }

    return null;
}
 
Example #24
Source File: KeyInfo.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Searches the library wide KeyResolvers for Private keys
 *
 * @return the private key contained in this KeyInfo
 * @throws KeyResolverException
 */
PrivateKey getPrivateKeyFromStaticResolvers() throws KeyResolverException {
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);

        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null)      {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                // not using StorageResolvers at the moment
                // since they cannot return private keys
                PrivateKey pk =
                    keyResolver.engineLookupAndResolvePrivateKey(
                        (Element) currentChild, uri, null
                    );

                if (pk != null) {
                    return pk;
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }
    return null;
}
 
Example #25
Source File: KeyInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Searches the library wide KeyResolvers for Private keys
 *
 * @return the private key contained in this KeyInfo
 * @throws KeyResolverException
 */
PrivateKey getPrivateKeyFromStaticResolvers() throws KeyResolverException {
    Iterator<KeyResolverSpi> it = KeyResolver.iterator();
    while (it.hasNext()) {
        KeyResolverSpi keyResolver = it.next();
        keyResolver.setSecureValidation(secureValidation);

        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null)      {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                // not using StorageResolvers at the moment
                // since they cannot return private keys
                PrivateKey pk =
                    keyResolver.engineLookupAndResolvePrivateKey(
                        (Element) currentChild, uri, null
                    );

                if (pk != null) {
                    return pk;
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }
    return null;
}
 
Example #26
Source File: EncryptedKeyResolver.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method is used to add a custom {@link KeyResolverSpi} to help
 * resolve the KEK.
 *
 * @param realKeyResolver
 */
public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
    if (internalKeyResolvers == null) {
        internalKeyResolvers = new ArrayList<KeyResolverSpi>();
    }
    internalKeyResolvers.add(realKeyResolver);
}
 
Example #27
Source File: KeyInfo.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Searches the per-KeyInfo KeyResolvers for private keys
 *
 * @return the private key contained in this KeyInfo
 * @throws KeyResolverException
 */
PrivateKey getPrivateKeyFromInternalResolvers() throws KeyResolverException {
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                // not using StorageResolvers at the moment
                // since they cannot return private keys
                PrivateKey pk =
                    keyResolver.engineLookupAndResolvePrivateKey(
                        (Element) currentChild, uri, null
                    );

                if (pk != null) {
                    return pk;
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }

    return null;
}
 
Example #28
Source File: KeyInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Searches the per-KeyInfo KeyResolvers for private keys
 *
 * @return the private key contained in this KeyInfo
 * @throws KeyResolverException
 */
PrivateKey getPrivateKeyFromInternalResolvers() throws KeyResolverException {
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                // not using StorageResolvers at the moment
                // since they cannot return private keys
                PrivateKey pk =
                    keyResolver.engineLookupAndResolvePrivateKey(
                        (Element) currentChild, uri, null
                    );

                if (pk != null) {
                    return pk;
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }

    return null;
}
 
Example #29
Source File: KeyInfo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Searches the per-KeyInfo KeyResolvers for private keys
 *
 * @return the private key contained in this KeyInfo
 * @throws KeyResolverException
 */
PrivateKey getPrivateKeyFromInternalResolvers() throws KeyResolverException {
    for (KeyResolverSpi keyResolver : internalKeyResolvers) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
        }
        keyResolver.setSecureValidation(secureValidation);
        Node currentChild = this.constructionElement.getFirstChild();
        String uri = this.getBaseURI();
        while (currentChild != null) {
            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
                // not using StorageResolvers at the moment
                // since they cannot return private keys
                PrivateKey pk =
                    keyResolver.engineLookupAndResolvePrivateKey(
                        (Element) currentChild, uri, null
                    );

                if (pk != null) {
                    return pk;
                }
            }
            currentChild = currentChild.getNextSibling();
        }
    }

    return null;
}
 
Example #30
Source File: EncryptedKeyResolver.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * This method is used to add a custom {@link KeyResolverSpi} to help
 * resolve the KEK.
 *
 * @param realKeyResolver
 */
public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
    if (internalKeyResolvers == null) {
        internalKeyResolvers = new ArrayList<KeyResolverSpi>();
    }
    internalKeyResolvers.add(realKeyResolver);
}