Search in sources :

Example 1 with DSAKeyValue

use of com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue 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)

Example 2 with DSAKeyValue

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

the class DSAKeyValueResolver method engineLookupAndResolvePublicKey.

/**
     * Method engineResolvePublicKey
     *
     * @param element
     * @param BaseURI
     * @param storage
     * @return null if no {@link PublicKey} could be obtained
     */
public PublicKey engineLookupAndResolvePublicKey(Element element, String BaseURI, StorageResolver storage) {
    if (element == null) {
        return null;
    }
    Element dsaKeyElement = null;
    boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYVALUE);
    if (isKeyValue) {
        dsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_DSAKEYVALUE, 0);
    } else if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_DSAKEYVALUE)) {
        // this trick is needed to allow the RetrievalMethodResolver to eat a
        // ds:DSAKeyValue directly (without KeyValue)
        dsaKeyElement = element;
    }
    if (dsaKeyElement == null) {
        return null;
    }
    try {
        DSAKeyValue dsaKeyValue = new DSAKeyValue(dsaKeyElement, BaseURI);
        PublicKey pk = dsaKeyValue.getPublicKey();
        return pk;
    } catch (XMLSecurityException ex) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, ex.getMessage(), ex);
        }
    //do nothing
    }
    return null;
}
Also used : DSAKeyValue(com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue) PublicKey(java.security.PublicKey) Element(org.w3c.dom.Element) XMLSecurityException(com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException)

Aggregations

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