You are here

public static function Utilities::checkSign in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7

1 call to Utilities::checkSign()
Utilities::processResponse in includes/Utilities.php

File

includes/Utilities.php, line 923

Class

Utilities
This file is part of miniOrange SAML plugin.

Code

public static function checkSign($certFingerprint, $signatureData, $relayState, $ResCert) {
  $certificates = $signatureData['Certificates'];
  if (count($certificates) === 0) {
    return FALSE;
  }
  $fpArray = array();
  $fpArray[] = $certFingerprint;
  $pemCert = self::findCertificate($fpArray, $certificates, $relayState, $ResCert);
  $lastException = NULL;
  $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array(
    'type' => 'public',
  ));
  $key
    ->loadKey($pemCert);
  try {

    /*
     * Make sure that we have a valid signature
     */

    //assert('$key->type === XMLSecurityKey::RSA_SHA1');
    self::validateSignature($signatureData, $key);
    return TRUE;
  } catch (Exception $e) {
    $lastException = $e;
  }

  /* We were unable to validate the signature with any of our keys. */
  if ($lastException !== NULL) {
    throw $lastException;
  }
  else {
    return FALSE;
  }
}