You are here

public function XMLSecurityDSig::verify in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7

Returns: Bool when verifying HMAC_SHA1; Int otherwise, with following meanings: 1 on succesful signature verification, 0 when signature verification failed, -1 if an error occurred during processing.

NOTE: be very careful when checking the int return value, because in PHP, -1 will be cast to True when in boolean context. Always check the return value in a strictly typed way, e.g. "$obj->verify(...) === 1".

Parameters

XMLSecurityKey $objKey:

Return value

bool|int

Throws

Exception

File

includes/XMLSecurityKey.php, line 1501

Class

XMLSecurityDSig

Code

public function verify($objKey) {
  $doc = $this->sigNode->ownerDocument;
  $xpath = new DOMXPath($doc);
  $xpath
    ->registerNamespace('secdsig', self::XMLDSIGNS);
  $query = "string(./secdsig:SignatureValue)";
  $sigValue = $xpath
    ->evaluate($query, $this->sigNode);
  if (empty($sigValue)) {
    throw new Exception("Unable to locate SignatureValue");
  }
  return $objKey
    ->verifySignature($this->signedInfo, base64_decode($sigValue));
}