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


PHP Auth_OpenID_Association::fromExpiresIn方法代码示例

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


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

示例1: createAssociation

	/**
	 * Make a new association.
	 */
	function createAssociation($dumb = true, $assoc_type = 'HMAC-SHA1')
	{
		$secret = Auth_OpenID_CryptUtil::getBytes(
		Auth_OpenID_getSecretSize($assoc_type));

		$uniq = base64_encode(Auth_OpenID_CryptUtil::getBytes(4));
		$handle = sprintf('{%s}{%x}{%s}', $assoc_type, intval(time()), $uniq);

		$assoc = Auth_OpenID_Association::fromExpiresIn(
		$this->SECRET_LIFETIME, $handle, $secret, $assoc_type);

		if ($dumb) {
			$key = $this->dumb_key;
		} else {
			$key = $this->normal_key;
		}

		$this->store->storeAssociation($key, $assoc);
		return $assoc;
	}
开发者ID:hoalangoc,项目名称:ftf,代码行数:23,代码来源:Server.php

示例2: test_invalidate

 function test_invalidate()
 {
     $assoc_handle = '-squash-';
     $assoc = Auth_OpenID_Association::fromExpiresIn(60, $assoc_handle, 'sekrit', 'HMAC-SHA1');
     $this->store->storeAssociation($this->dumb_key, $assoc);
     $assoc = $this->signatory->getAssociation($assoc_handle, true);
     $this->assertTrue($assoc);
     $assoc = $this->signatory->getAssociation($assoc_handle, true);
     $this->assertTrue($assoc);
     $this->signatory->invalidate($assoc_handle, true);
     $assoc = $this->signatory->getAssociation($assoc_handle, true);
     $this->assertFalse($assoc);
 }
开发者ID:aprilchild,项目名称:aprilchild,代码行数:13,代码来源:Server.php

示例3: _extractAssociation

 /**
  * @access private
  */
 function _extractAssociation($assoc_response, $assoc_session)
 {
     // Extract the common fields from the response, raising an
     // exception if they are not found
     $assoc_type = $assoc_response->getArg(Auth_OpenID_OPENID_NS, 'assoc_type', Auth_OpenID_NO_DEFAULT);
     if (Auth_OpenID::isFailure($assoc_type)) {
         return $assoc_type;
     }
     $assoc_handle = $assoc_response->getArg(Auth_OpenID_OPENID_NS, 'assoc_handle', Auth_OpenID_NO_DEFAULT);
     if (Auth_OpenID::isFailure($assoc_handle)) {
         return $assoc_handle;
     }
     // expires_in is a base-10 string. The Python parsing will
     // accept literals that have whitespace around them and will
     // accept negative values. Neither of these are really in-spec,
     // but we think it's OK to accept them.
     $expires_in_str = $assoc_response->getArg(Auth_OpenID_OPENID_NS, 'expires_in', Auth_OpenID_NO_DEFAULT);
     if (Auth_OpenID::isFailure($expires_in_str)) {
         return $expires_in_str;
     }
     $expires_in = Auth_OpenID::intval($expires_in_str);
     if ($expires_in === false) {
         $err = sprintf("Could not parse expires_in from association " . "response %s", print_r($assoc_response, true));
         return new Auth_OpenID_FailureResponse(null, $err);
     }
     // OpenID 1 has funny association session behaviour.
     if ($assoc_response->isOpenID1()) {
         $session_type = $this->_getOpenID1SessionType($assoc_response);
     } else {
         $session_type = $assoc_response->getArg(Auth_OpenID_OPENID2_NS, 'session_type', Auth_OpenID_NO_DEFAULT);
         if (Auth_OpenID::isFailure($session_type)) {
             return $session_type;
         }
     }
     // Session type mismatch
     if ($assoc_session->session_type != $session_type) {
         if ($assoc_response->isOpenID1() && $session_type == 'no-encryption') {
             // In OpenID 1, any association request can result in
             // a 'no-encryption' association response. Setting
             // assoc_session to a new no-encryption session should
             // make the rest of this function work properly for
             // that case.
             $assoc_session = new Auth_OpenID_PlainTextConsumerSession();
         } else {
             // Any other mismatch, regardless of protocol version
             // results in the failure of the association session
             // altogether.
             return null;
         }
     }
     // Make sure assoc_type is valid for session_type
     if (!in_array($assoc_type, $assoc_session->allowed_assoc_types)) {
         return null;
     }
     // Delegate to the association session to extract the secret
     // from the response, however is appropriate for that session
     // type.
     $secret = $assoc_session->extractSecret($assoc_response);
     if ($secret === null) {
         return null;
     }
     return Auth_OpenID_Association::fromExpiresIn($expires_in, $assoc_handle, $secret, $assoc_type);
 }
开发者ID:raphox,项目名称:php-openid,代码行数:66,代码来源:Consumer.php

示例4: _parseAssociation

 /**
  * @access private
  */
 function _parseAssociation($results, $assoc_session, $server_url)
 {
     $required_keys = array('assoc_type', 'assoc_handle', 'expires_in');
     foreach ($required_keys as $key) {
         if (!array_key_exists($key, $results)) {
             return null;
         }
     }
     $assoc_type = $results['assoc_type'];
     $assoc_handle = $results['assoc_handle'];
     $expires_in_str = $results['expires_in'];
     if ($assoc_type != 'HMAC-SHA1') {
         return null;
     }
     $expires_in = intval($expires_in_str);
     if ($expires_in <= 0) {
         return null;
     }
     $session_type = Auth_OpenID::arrayGet($results, 'session_type');
     if ($session_type != $assoc_session->session_type) {
         if ($session_type === null) {
             $assoc_session = new Auth_OpenID_PlainTextConsumerSession();
         } else {
             return null;
         }
     }
     $secret = $assoc_session->extractSecret($results);
     if (!$secret) {
         return null;
     }
     $assoc = Auth_OpenID_Association::fromExpiresIn($expires_in, $assoc_handle, $secret, $assoc_type);
     $this->store->storeAssociation($server_url, $assoc);
     return $assoc;
 }
开发者ID:JJYing,项目名称:Anyway-Website,代码行数:37,代码来源:Consumer.php


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