use of javax.xml.crypto.XMLCryptoContext in project wildfly by wildfly.
the class TestServlet method validateSignature.
private static boolean validateSignature(final Document document, final PublicKey publicKey) throws Exception {
final KeySelector ks = new KeySelector() {
@Override
public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException {
return new KeySelectorResult() {
public Key getKey() {
return publicKey;
}
};
}
};
final DOMValidateContext context = new DOMValidateContext(ks, document.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature").item(0));
return XMLSignatureFactory.getInstance("DOM").unmarshalXMLSignature(context).validate(context);
}
Aggregations