Search in sources :

Example 1 with RSAKeyValue

use of com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue in project jdk8u_jdk by JetBrains.

the class RSAKeyValueResolver method engineLookupAndResolvePublicKey.

/** @inheritDoc */
public PublicKey engineLookupAndResolvePublicKey(Element element, String BaseURI, StorageResolver storage) {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
    }
    if (element == null) {
        return null;
    }
    boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYVALUE);
    Element rsaKeyElement = null;
    if (isKeyValue) {
        rsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_RSAKEYVALUE, 0);
    } else if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_RSAKEYVALUE)) {
        // this trick is needed to allow the RetrievalMethodResolver to eat a
        // ds:RSAKeyValue directly (without KeyValue)
        rsaKeyElement = element;
    }
    if (rsaKeyElement == null) {
        return null;
    }
    try {
        RSAKeyValue rsaKeyValue = new RSAKeyValue(rsaKeyElement, BaseURI);
        return rsaKeyValue.getPublicKey();
    } catch (XMLSecurityException ex) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
        }
    }
    return null;
}
Also used : RSAKeyValue(com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue) Element(org.w3c.dom.Element) XMLSecurityException(com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException)

Example 2 with RSAKeyValue

use of com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue in project jdk8u_jdk by JetBrains.

the class KeyValue method getPublicKey.

/**
     * Method getPublicKey
     *
     * @return the public key
     * @throws XMLSecurityException
     */
public PublicKey getPublicKey() throws XMLSecurityException {
    Element rsa = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(), Constants._TAG_RSAKEYVALUE, 0);
    if (rsa != null) {
        RSAKeyValue kv = new RSAKeyValue(rsa, this.baseURI);
        return kv.getPublicKey();
    }
    Element dsa = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(), Constants._TAG_DSAKEYVALUE, 0);
    if (dsa != null) {
        DSAKeyValue kv = new DSAKeyValue(dsa, this.baseURI);
        return kv.getPublicKey();
    }
    return null;
}
Also used : RSAKeyValue(com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue) DSAKeyValue(com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue) Element(org.w3c.dom.Element)

Aggregations

RSAKeyValue (com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue)2 Element (org.w3c.dom.Element)2 XMLSecurityException (com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException)1 DSAKeyValue (com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue)1