You are here

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

Returns the key from the DOM

Parameters

null|DOMNode $node:

Return value

null|XMLSecurityKey

File

src/XMLSecurityKey.php, line 2149

Class

XMLSecEnc

Namespace

Drupal\miniorange_saml

Code

public function locateKey($node = null) {
  if (empty($node)) {
    $node = $this->rawNode;
  }
  if (!$node instanceof DOMNode) {
    return null;
  }
  if ($doc = $node->ownerDocument) {
    $xpath = new DOMXPath($doc);
    $xpath
      ->registerNamespace('xmlsecenc', self::XMLENCNS);
    $query = ".//xmlsecenc:EncryptionMethod";
    $nodeset = $xpath
      ->query($query, $node);
    if ($encmeth = $nodeset
      ->item(0)) {
      $attrAlgorithm = $encmeth
        ->getAttribute("Algorithm");
      try {
        $objKey = new XMLSecurityKey($attrAlgorithm, array(
          'type' => 'private',
        ));
      } catch (Exception $e) {
        return null;
      }
      return $objKey;
    }
  }
  return null;
}