当前位置: 首页>>代码示例>>PHP>>正文


PHP SAML2_Utils::validateElement方法代码示例

本文整理汇总了PHP中SAML2_Utils::validateElement方法的典型用法代码示例。如果您正苦于以下问题:PHP SAML2_Utils::validateElement方法的具体用法?PHP SAML2_Utils::validateElement怎么用?PHP SAML2_Utils::validateElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SAML2_Utils的用法示例。


在下文中一共展示了SAML2_Utils::validateElement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load_saml_response

 /**
  * @param string $saml_response Base64 Encoded SAML
  *
  * @throws Exception When no assertions are found or signature in invalid
  */
 public function load_saml_response($saml_response)
 {
     $response_element = SAML2_DOMDocumentFactory::fromString(base64_decode($saml_response))->documentElement;
     $signature_info = SAML2_Utils::validateElement($response_element);
     SAML2_Utils::validateSignature($signature_info, $this->security_key);
     $response = SAML2_StatusResponse::fromXML($response_element);
     $this->destination = $response->getDestination();
     $assertions = $response->getAssertions();
     $this->assertions = $assertions;
 }
开发者ID:aenglander,项目名称:launchkey-wordpress,代码行数:15,代码来源:class-launchkey-wp-saml2-response-service.php

示例2: load_saml_request

 /**
  * @param string $saml_request Base64 Encoded SAML
  *
  * @throws Exception When signature in invalid
  */
 public function load_saml_request($saml_request)
 {
     $request_element = SAML2_DOMDocumentFactory::fromString(base64_decode($saml_request))->documentElement;
     $signature_info = SAML2_Utils::validateElement($request_element);
     SAML2_Utils::validateSignature($signature_info, $this->security_key);
     /** @var SAML2_LogoutRequest $request */
     $request = SAML2_LogoutRequest::fromXML($request_element);
     $request->decryptNameId($this->security_key);
     $name_id = $request->getNameId();
     $this->notOnOrAfter = $request->getNotOnOrAfter();
     $this->name = $name_id ? $name_id['Value'] : null;
     $this->session_index = $request->getSessionIndex();
     $this->destination = $request->getDestination();
 }
开发者ID:aenglander,项目名称:launchkey-wordpress,代码行数:19,代码来源:class-launchkey-wp-saml2-request-service.php

示例3: __construct

 /**
  * Initialize the helper class.
  *
  * @param DOMElement|NULL $xml The XML element which may be signed.
  */
 protected function __construct(DOMElement $xml = NULL)
 {
     $this->certificates = array();
     $this->validators = array();
     if ($xml === NULL) {
         return;
     }
     /* Validate the signature element of the message. */
     try {
         $sig = SAML2_Utils::validateElement($xml);
         if ($sig !== FALSE) {
             $this->certificates = $sig['Certificates'];
             $this->validators[] = array('Function' => array('SAML2_Utils', 'validateSignature'), 'Data' => $sig);
         }
     } catch (Exception $e) {
         /* Ignore signature validation errors. */
     }
 }
开发者ID:danielkjfrog,项目名称:docker,代码行数:23,代码来源:SignedElementHelper.php

示例4: parseSignature

 /**
  * Parse signature on assertion.
  *
  * @param DOMElement $xml  The assertion XML element.
  */
 private function parseSignature(DOMElement $xml)
 {
     /* Validate the signature element of the message. */
     $sig = SAML2_Utils::validateElement($xml);
     if ($sig !== FALSE) {
         $this->certificates = $sig['Certificates'];
         $this->signatureData = $sig;
     }
 }
开发者ID:emma5021,项目名称:toba,代码行数:14,代码来源:Assertion.php

示例5: __construct

 /**
  * Initialize a message.
  *
  * This constructor takes an optional parameter with a DOMElement. If this
  * parameter is given, the message will be initialized with data from that
  * XML element.
  *
  * If no XML element is given, the message is initialized with suitable
  * default values.
  *
  * @param string $tagName  The tag name of the root element.
  * @param DOMElement|NULL $xml  The input message.
  */
 protected function __construct($tagName, DOMElement $xml = NULL)
 {
     assert('is_string($tagName)');
     $this->tagName = $tagName;
     $this->id = SimpleSAML_Utilities::generateID();
     $this->issueInstant = time();
     $this->certificates = array();
     $this->validators = array();
     if ($xml === NULL) {
         return;
     }
     if (!$xml->hasAttribute('ID')) {
         throw new Exception('Missing ID attribute on SAML message.');
     }
     $this->id = $xml->getAttribute('ID');
     if ($xml->getAttribute('Version') !== '2.0') {
         /* Currently a very strict check. */
         throw new Exception('Unsupported version: ' . $xml->getAttribute('Version'));
     }
     $this->issueInstant = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('IssueInstant'));
     if ($xml->hasAttribute('Destination')) {
         $this->destination = $xml->getAttribute('Destination');
     }
     $issuer = SAML2_Utils::xpQuery($xml, './saml_assertion:Issuer');
     if (!empty($issuer)) {
         $this->issuer = trim($issuer[0]->textContent);
     }
     /* Validate the signature element of the message. */
     try {
         $sig = SAML2_Utils::validateElement($xml);
         if ($sig !== FALSE) {
             $this->certificates = $sig['Certificates'];
             $this->validators[] = array('Function' => array('SAML2_Utils', 'validateSignature'), 'Data' => $sig);
         }
     } catch (Exception $e) {
         /* Ignore signature validation errors. */
     }
 }
开发者ID:hukumonline,项目名称:yii,代码行数:51,代码来源:Message.php

示例6: authenticate

 /**
  * Front controller for LaunchKey Native/White Label authentication
  *
  *
  * @param WP_User $user Unused parameter always passed first by authenticate filter
  * @param string $username Username specified by the user in the login screen
  * @param string $password Password specifiedby the user in the login screen
  *
  * @since 1.0.0
  * @return WP_User
  */
 public function authenticate($user, $username, $password)
 {
     if (empty($user) && empty($username) && empty($password) && !empty($_REQUEST['SAMLResponse'])) {
         $response_element = SAML2_DOMDocumentFactory::fromString(base64_decode($_REQUEST['SAMLResponse']))->documentElement;
         $signature_info = SAML2_Utils::validateElement($response_element);
         try {
             SAML2_Utils::validateSignature($signature_info, $this->security_key);
             $response = SAML2_StatusResponse::fromXML($response_element);
             /** @var SAML2_Assertion[] $assertions */
             $assertions = $response->getAssertions();
             if (empty($assertions)) {
                 throw new Exception("No assertions in SAML response");
             }
             $assertion = $assertions[0];
             $name_id = $assertion->getNameId();
             $username = $name_id['Value'];
             $session_id = $assertion->getSessionIndex();
             // Find the user by login
             $user = $this->wp_facade->get_user_by('login', $username);
             // If we don't have a user, create one
             if (!$user instanceof WP_User) {
                 $attributes = $assertion->getAttributes();
                 $user_data = array('user_login' => $username, 'user_pass' => '', 'role' => empty($attributes['role']) ? false : $this->translate_role($attributes['role'][0]));
                 $user_id = $this->wp_facade->wp_insert_user($user_data);
                 // Unset the password - wp_insert_user always generates a hash - it's misleading
                 $this->wp_facade->wp_update_user(array('ID' => $user_id, 'user_pass' => ''));
                 $user = new WP_User($user_id);
             }
             // Set the SSO session so we know we are logged in via SSSO
             $this->wp_facade->update_user_meta($user->ID, 'launchkey_sso_session', $session_id);
         } catch (Exception $e) {
             $this->wp_facade->wp_redirect($this->error_url);
             exit;
         }
         return $user;
     }
 }
开发者ID:ThemeSurgeon,项目名称:launchkey-wordpress,代码行数:48,代码来源:class-launchkey-wp-sso-client.php


注:本文中的SAML2_Utils::validateElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。