private boolean validateSignature(KeySelector keySelector) throws MalformedTokenException {
  NodeList securityNodeList=_parsedToken.getElementsByTagNameNS(Constants.DIGITAL_SIGNATURE_NAMESPACE,SIGNATURE_ELEMENT_NAME);
  XMLSignatureFactory fac=XMLSignatureFactory.getInstance();
  DOMValidateContext valContext=new DOMValidateContext(keySelector,securityNodeList.item(0));
  boolean isValid=false;
  try {
    XMLSignature signature=fac.unmarshalXMLSignature(valContext);
    isValid=signature.validate(valContext);
  }
 catch (  MarshalException e) {
    _log.error(SIGNATURE_VALIDATION_ERROR_MSG,e);
    throw new MalformedTokenException(SIGNATURE_VALIDATION_ERROR_MSG,e);
  }
catch (  XMLSignatureException e) {
    _log.error(SIGNATURE_VALIDATION_ERROR_MSG,e);
    throw new MalformedTokenException(SIGNATURE_VALIDATION_ERROR_MSG,e);
  }
  _log.debug("SAML token signature is valid status: " + isValid);
  return isValid;
}

private boolean validateSignature ( KeySelector keySelector ) throws MalformedTokenException { NodeList securityNodeList = _parsedToken . getElementsByTagNameNS ( Constants . DIGITAL_SIGNATURE_NAMESPACE , SIGNATURE_ELEMENT_NAME ) ; XMLSignatureFactory fac = XMLSignatureFactory . getInstance ( ) ; DOMValidateContext valContext = new DOMValidateContext ( keySelector , securityNodeList . item ( 0 ) ) ; boolean isValid = false ; try { XMLSignature signature = fac . unmarshalXMLSignature ( valContext ) ; isValid = signature . validate ( valContext ) ; } catch ( MarshalException e ) { _log . error ( SIGNATURE_VALIDATION_ERROR_MSG , e ) ; throw new MalformedTokenException ( SIGNATURE_VALIDATION_ERROR_MSG , e ) ; } catch ( XMLSignatureException e ) { _log . error ( SIGNATURE_VALIDATION_ERROR_MSG , e ) ; throw new MalformedTokenException ( SIGNATURE_VALIDATION_ERROR_MSG , e ) ; } _log . debug ( "SAML token signature is valid status: " + isValid ) ; return isValid ; }
validates the signature element of the saml token .
