You are here

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

Parameters

null|DOMNode $node:

Return value

null|XMLSecurityKey

File

src/XMLSecurityKey.php, line 1428

Class

XMLSecurityDSig

Namespace

Drupal\miniorange_saml

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;
}