You are here

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

Returns the key from the DOM

Parameters

null|DOMNode $node:

Return value

null|XMLSecurityKey

File

includes/XMLSecurityKey.php, line 2181

Class

XMLSecEnc

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