public JAXBSignContext(Key signingKey){ if (signingKey == null) { throw new NullPointerException("signingKey cannot be null"); } setKeySelector(KeySelector.singletonKeySelector(signingKey)); }
KeySelector keySelector = validateContext.getKeySelector(); if (keySelector != null) { ksResult = keySelector.select (ki, KeySelector.Purpose.VERIFY, sm, validateContext); if (ksResult != null) {
KeySelectorResult keySelectorResult = signContext.getKeySelector().select(ki, KeySelector.Purpose.SIGN, si.getSignatureMethod(),
sm = si.getSignatureMethod(); if(verificationKey == null){ keySelectoResult = xMLValidateContext.getKeySelector().select(getKeyInfo(),KeySelector.Purpose.VERIFY,sm,xMLValidateContext); verificationKey = keySelectoResult.getKey();
/** * Check the xmldsig signature of the XML document. * * @param document * the document to test * @param publicKey * the public key corresponding to the key pair the document was signed with * @return true if a correct signature is present, false otherwise */ public static boolean validSignature(Document document, Key publicKey) { Node signatureNode = document.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature").item(0); KeySelector keySelector = KeySelector.singletonKeySelector(publicKey); try { String providerName = System.getProperty("jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI"); XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM", (Provider) Class.forName(providerName).newInstance()); DOMValidateContext valContext = new DOMValidateContext(keySelector, signatureNode); XMLSignature signature = fac.unmarshalXMLSignature(valContext); return signature.validate(valContext); } catch (Exception e) { Logger.warn("Error validating an XML signature.", e); return false; } }
try { sm = si.getSignatureMethod(); keySelectoResult = xMLSignContext.getKeySelector().select(getKeyInfo(),KeySelector.Purpose.SIGN,sm,xMLSignContext); signingKey = keySelectoResult.getKey(); if (signingKey == null) {