Code Fragment 3

public boolean validate(Element signature){
   1 DOMValidateContext validationContext = new DOMValidateContext(new KeySelectorImpl(), signature);
   2 XMLSignatureFactory signatureFactory = XMLSignatureFactory.getInstance("DOM");
   3 XMLSignature signature =  signatureFactory.unmarshalXMLSignature(validationContext);
   4 validationContext.setURIDereferencer(new URIResolverImpl());
   5 boolean validMessage  = signature.validate(validationContext);
        if(validMessage){
            System.out.println("Signature Validation passed");
        }else{
            System.out.println("Signature Validation Failed");
        }
   return validMessage;
}