You are here

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

Parameters

null|DOMNode $node:

Return value

null|XMLSecurityKey

File

includes/XMLSecurityKey.php, line 1460

Class

XMLSecurityDSig

Code

public function locateKey($node = null) {
  if (empty($node)) {
    $node = $this->sigNode;
  }
  if (!$node instanceof DOMNode) {
    return null;
  }
  if ($doc = $node->ownerDocument) {
    $xpath = new DOMXPath($doc);
    $xpath
      ->registerNamespace('secdsig', self::XMLDSIGNS);
    $query = "string(./secdsig:SignedInfo/secdsig:SignatureMethod/@Algorithm)";
    $algorithm = $xpath
      ->evaluate($query, $node);
    if ($algorithm) {
      try {
        $objKey = new XMLSecurityKey($algorithm, array(
          'type' => 'public',
        ));
      } catch (Exception $e) {
        return null;
      }
      return $objKey;
    }
  }
  return null;
}