public static XMLValidateContext getXMLValidateContext(String type, File input, String tag) throws Exception { if (type.equalsIgnoreCase("dom")) { DocumentBuilder docBuilder = XMLUtils.createDocumentBuilder(false, false); Document doc = docBuilder.parse(input); if (tag == null) { return new DOMValidateContext (TestUtils.getPublicKey("RSA", 512), doc.getDocumentElement()); } else { NodeList list = doc.getElementsByTagName(tag); return new DOMValidateContext (TestUtils.getPublicKey("RSA", 512), list.item(0)); } } else { throw new Exception("Unsupported XMLValidateContext type: " + type); } }
public boolean validate(XMLValidateContext vCtx) throws XMLSignatureException { this.dis = new ByteArrayInputStream(id.getBytes()); this.derefData = new OctetStreamData(this.dis); return status; }
public XMLSignature unmarshalXMLSignature(XMLValidateContext context) throws MarshalException { throw new UnsupportedOperationException(); }
/** * Verifies the passed-in signature with the specified key, using the * underlying Signature or Mac algorithm. * * @param key the verification key * @param si the SignedInfo * @param sig the signature bytes to be verified * @param context the XMLValidateContext * @return <code>true</code> if the signature verified successfully, * <code>false</code> if not * @throws NullPointerException if <code>key</code>, <code>si</code> or * <code>sig</code> are <code>null</code> * @throws InvalidKeyException if the key is improperly encoded, of * the wrong type, or parameters are missing, etc * @throws SignatureException if an unexpected error occurs, such * as the passed in signature is improperly encoded * @throws XMLSignatureException if an unexpected error occurs */ abstract boolean verify(Key key, SignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException;
/** * Verifies the passed-in signature with the specified key, using the * underlying Signature or Mac algorithm. * * @param key the verification key * @param si the SignedInfo * @param sig the signature bytes to be verified * @param context the XMLValidateContext * @return <code>true</code> if the signature verified successfully, * <code>false</code> if not * @throws NullPointerException if <code>key</code>, <code>si</code> or * <code>sig</code> are <code>null</code> * @throws InvalidKeyException if the key is improperly encoded, of * the wrong type, or parameters are missing, etc * @throws SignatureException if an unexpected error occurs, such * as the passed in signature is improperly encoded * @throws XMLSignatureException if an unexpected error occurs */ abstract boolean verify(Key key, DOMSignedInfo si, byte[] sig, XMLValidateContext context) throws InvalidKeyException, SignatureException, XMLSignatureException;