當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Auth_OpenID_splitNonce函數代碼示例

本文整理匯總了PHP中Auth_OpenID_splitNonce函數的典型用法代碼示例。如果您正苦於以下問題:PHP Auth_OpenID_splitNonce函數的具體用法?PHP Auth_OpenID_splitNonce怎麽用?PHP Auth_OpenID_splitNonce使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Auth_OpenID_splitNonce函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Auth_OpenID_checkTimestamp

function Auth_OpenID_checkTimestamp($nonce_string,
                                    $allowed_skew = null,
                                    $now = null)
{
    // Is the timestamp that is part of the specified nonce string
    // within the allowed clock-skew of the current time?
    global $Auth_OpenID_SKEW;

    if ($allowed_skew === null) {
        $allowed_skew = $Auth_OpenID_SKEW;
    }

    $parts = Auth_OpenID_splitNonce($nonce_string);
    if ($parts == null) {
        return false;
    }

    if ($now === null) {
        $now = time();
    }

    $stamp = $parts[0];

    // Time after which we should not use the nonce
    $past = $now - $allowed_skew;

    // Time that is too far in the future for us to allow
    $future = $now + $allowed_skew;

    // the stamp is not too far in the future and is not too far
    // in the past
    return (($past <= $stamp) && ($stamp <= $future));
}
開發者ID:networksoft,項目名稱:seekerplus2.com,代碼行數:33,代碼來源:Nonce.php

示例2: runTest

 function runTest()
 {
     $result = Auth_OpenID_splitNonce($this->nonce_str);
     $this->assertNull($result);
 }
開發者ID:marcioyonamine,項目名稱:php-openid,代碼行數:5,代碼來源:Nonce.php

示例3: _idResCheckNonce

 /**
  * @access private
  */
 function _idResCheckNonce($message, $endpoint)
 {
     if ($message->isOpenID1()) {
         // This indicates that the nonce was generated by the consumer
         $nonce = $this->_idResGetNonceOpenID1($message, $endpoint);
         $server_url = '';
     } else {
         $nonce = $message->getArg(Auth_OpenID_OPENID2_NS, 'response_nonce');
         $server_url = $endpoint->server_url;
     }
     if ($nonce === null) {
         return new Auth_OpenID_FailureResponse($endpoint, "Nonce missing from response");
     }
     $parts = Auth_OpenID_splitNonce($nonce);
     if ($parts === null) {
         return new Auth_OpenID_FailureResponse($endpoint, "Malformed nonce in response");
     }
     list($timestamp, $salt) = $parts;
     if (!$this->store->useNonce($server_url, $timestamp, $salt)) {
         return new Auth_OpenID_FailureResponse($endpoint, "Nonce already used or out of range");
     }
     return null;
 }
開發者ID:raphox,項目名稱:php-openid,代碼行數:26,代碼來源:Consumer.php

示例4: index

 function index()
 {
     try {
         $member = Member::currentUser();
         if ($member) {
             // user is already logged in
             return $this->redirect(OpenStackIdCommon::getRedirectBackUrl());
         }
         $consumer = Injector::inst()->get('MyOpenIDConsumer');
         $query = Auth_OpenID::getQuery();
         $message = Auth_OpenID_Message::fromPostArgs($query);
         $nonce = $message->getArg(Auth_OpenID_OPENID2_NS, 'response_nonce');
         list($timestamp, $salt) = Auth_OpenID_splitNonce($nonce);
         $claimed_id = $message->getArg(Auth_OpenID_OPENID2_NS, 'claimed_id');
         error_log(sprintf('OpenStackIdAuthenticator : id %s - salt %s - timestamp %s', $claimed_id, $salt, $timestamp));
         // Complete the authentication process using the server's response.
         $response = $consumer->complete(OpenStackIdCommon::getReturnTo());
         if ($response->status == Auth_OpenID_CANCEL) {
             error_log('OpenStackIdAuthenticator : Auth_OpenID_CANCEL');
             SS_Log::log('OpenStackIdAuthenticator : Auth_OpenID_CANCEL', SS_Log::WARN);
             throw new Exception('The verification was cancelled. Please try again.');
         } else {
             if ($response->status == Auth_OpenID_FAILURE) {
                 error_log('OpenStackIdAuthenticator : Auth_OpenID_FAILURE');
                 SS_Log::log('OpenStackIdAuthenticator : Auth_OpenID_FAILURE', SS_Log::WARN);
                 throw new Exception("The OpenID authentication failed.");
             } else {
                 if ($response->status == Auth_OpenID_SUCCESS) {
                     error_log('OpenStackIdAuthenticator : Auth_OpenID_SUCCESS');
                     $openid = $response->getDisplayIdentifier();
                     $openid = OpenStackIdCommon::escape($openid);
                     if ($response->endpoint->canonicalID) {
                         $openid = escape($response->endpoint->canonicalID);
                     }
                     //get user info from openid response
                     $member = null;
                     list($email, $full_name) = $this->getUserProfileInfo($response);
                     if (!is_null($email)) {
                         //try to get user by email
                         $member = $this->member_repository->findByEmail($email);
                     }
                     if (!$member) {
                         // or by openid
                         $member = Member::get()->filter('IdentityURL', $openid)->first();
                     }
                     if ($member) {
                         $result = $member->canLogIn();
                         if ($result->valid()) {
                             $member->setIdentityUrl($openid);
                             $member->write();
                             $member->LogIn(true);
                             return $this->redirect(OpenStackIdCommon::getRedirectBackUrl());
                         }
                         throw new Exception("Inactive User!");
                     }
                     throw new Exception("The OpenID authentication failed: can not find user " . $openid);
                 }
             }
         }
     } catch (Exception $ex) {
         Session::set("Security.Message.message", $ex->getMessage());
         Session::set("Security.Message.type", "bad");
         SS_Log::log($ex, SS_Log::WARN);
         return $this->redirect("Security/badlogin");
     }
 }
開發者ID:OpenStackweb,項目名稱:openstack-org,代碼行數:66,代碼來源:OpenStackIdAuthenticator.php

示例5: _testNonceCleanup

 function _testNonceCleanup(&$store)
 {
     if (!$store->supportsCleanup()) {
         return;
     }
     $server_url = 'http://www.myopenid.com/openid';
     $now = time();
     $old_nonce1 = Auth_OpenID_mkNonce($now - 20000);
     $old_nonce2 = Auth_OpenID_mkNonce($now - 10000);
     $recent_nonce = Auth_OpenID_mkNonce($now - 600);
     global $Auth_OpenID_SKEW;
     $orig_skew = $Auth_OpenID_SKEW;
     $Auth_OpenID_SKEW = 0;
     $store->cleanupNonces();
     // Set SKEW high so stores will keep our nonces.
     $Auth_OpenID_SKEW = 100000;
     $params = Auth_OpenID_splitNonce($old_nonce1);
     array_unshift($params, $server_url);
     $this->assertTrue(call_user_func_array(array(&$store, 'useNonce'), $params));
     $params = Auth_OpenID_splitNonce($old_nonce2);
     array_unshift($params, $server_url);
     $this->assertTrue(call_user_func_array(array(&$store, 'useNonce'), $params));
     $params = Auth_OpenID_splitNonce($recent_nonce);
     array_unshift($params, $server_url);
     $this->assertTrue(call_user_func_array(array(&$store, 'useNonce'), $params));
     $Auth_OpenID_SKEW = 3600;
     $cleaned = $store->cleanupNonces();
     $this->assertEquals(2, $cleaned);
     // , "Cleaned %r nonces." % (cleaned,)
     $Auth_OpenID_SKEW = 100000;
     // A roundabout method of checking that the old nonces were
     // cleaned is to see if we're allowed to add them again.
     $params = Auth_OpenID_splitNonce($old_nonce1);
     array_unshift($params, $server_url);
     $this->assertTrue(call_user_func_array(array(&$store, 'useNonce'), $params));
     $params = Auth_OpenID_splitNonce($old_nonce2);
     array_unshift($params, $server_url);
     $this->assertTrue(call_user_func_array(array(&$store, 'useNonce'), $params));
     // The recent nonce wasn't cleaned, so it should still fail.
     $params = Auth_OpenID_splitNonce($recent_nonce);
     array_unshift($params, $server_url);
     $this->assertFalse(call_user_func_array(array(&$store, 'useNonce'), $params));
     $Auth_OpenID_SKEW = $orig_skew;
 }
開發者ID:BGCX067,項目名稱:ezopenid-svn-to-git,代碼行數:44,代碼來源:StoreTest.php

示例6: test_badNonce

 function test_badNonce()
 {
     // remove the nonce from the store
     $nonce = Auth_OpenID_mkNonce();
     list($timestamp, $salt) = Auth_OpenID_splitNonce($nonce);
     $this->store->useNonce($this->server_url, $timestamp, $salt);
     $response = Auth_OpenID_Message::fromOpenIDArgs(array('response_nonce' => $nonce, 'ns' => Auth_OpenID_OPENID2_NS));
     $result = $this->consumer->_idResCheckNonce($response, $this->endpoint);
     $this->assertTrue(Auth_OpenID::isFailure($result));
 }
開發者ID:umbecr,項目名稱:camilaframework,代碼行數:10,代碼來源:Consumer.php


注:本文中的Auth_OpenID_splitNonce函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。