use of org.apache.xml.security.keys.content.keyvalues.RSAKeyValue in project santuario-java by apache.
the class RSAKeyValueResolver method engineLookupAndResolvePublicKey.
/**
* {@inheritDoc}
*/
public PublicKey engineLookupAndResolvePublicKey(Element element, String baseURI, StorageResolver storage) {
if (element == null) {
return null;
}
LOG.debug("Can I resolve {}", element.getTagName());
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) {
LOG.debug("XMLSecurityException", ex);
}
return null;
}
Aggregations