本文整理汇总了PHP中Auth_OpenID_mkNonce函数的典型用法代码示例。如果您正苦于以下问题:PHP Auth_OpenID_mkNonce函数的具体用法?PHP Auth_OpenID_mkNonce怎么用?PHP Auth_OpenID_mkNonce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Auth_OpenID_mkNonce函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_mkSplit
function test_mkSplit()
{
$t = 42;
$nonce_str = Auth_OpenID_mkNonce($t);
$this->assertTrue(preg_match(Tests_Auth_OpenID_nonce_re, $nonce_str));
list($et, $salt) = Auth_OpenID_splitNonce($nonce_str);
$this->assertEquals(6, strlen($salt));
$this->assertEquals($et, $t);
}
示例2: answer
//.........这里部分代码省略.........
}
if ($allow) {
if ($this->identity == Auth_OpenID_IDENTIFIER_SELECT) {
if (!$identity) {
return new Auth_OpenID_ServerError(null,
"This request uses IdP-driven identifier selection. " .
"You must supply an identifier in the response.");
}
$response_identity = $identity;
$response_claimed_id = $claimed_id;
} else if ($this->identity) {
if ($identity &&
($this->identity != $identity)) {
$fmt = "Request was for %s, cannot reply with identity %s";
return new Auth_OpenID_ServerError(null,
sprintf($fmt, $this->identity, $identity));
}
$response_identity = $this->identity;
$response_claimed_id = $this->claimed_id;
} else {
if ($identity) {
return new Auth_OpenID_ServerError(null,
"This request specified no identity and " .
"you supplied ".$identity);
}
$response_identity = null;
}
if (($this->message->isOpenID1()) &&
($response_identity === null)) {
return new Auth_OpenID_ServerError(null,
"Request was an OpenID 1 request, so response must " .
"include an identifier.");
}
$response->fields->updateArgs(Auth_OpenID_OPENID_NS,
array('mode' => $mode,
'return_to' => $this->return_to,
'response_nonce' => Auth_OpenID_mkNonce()));
if (!$this->message->isOpenID1()) {
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'op_endpoint', $server_url);
}
if ($response_identity !== null) {
$response->fields->setArg(
Auth_OpenID_OPENID_NS,
'identity',
$response_identity);
if ($this->message->isOpenID2()) {
$response->fields->setArg(
Auth_OpenID_OPENID_NS,
'claimed_id',
$response_claimed_id);
}
}
} else {
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'mode', $mode);
if ($this->immediate) {
if (($this->message->isOpenID1()) &&
(!$server_url)) {
return new Auth_OpenID_ServerError(null,
'setup_url is required for $allow=false \
in OpenID 1.x immediate mode.');
}
$setup_request =& new Auth_OpenID_CheckIDRequest(
$this->identity,
$this->return_to,
$this->trust_root,
false,
$this->assoc_handle,
$this->server,
$this->claimed_id);
$setup_request->message = $this->message;
$setup_url = $setup_request->encodeToURL($server_url);
if ($setup_url === null) {
return new Auth_OpenID_NoReturnToError();
}
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'user_setup_url',
$setup_url);
}
}
return $response;
}
示例3: begin
/**
* Called to begin OpenID authentication using the specified
* {@link Auth_OpenID_ServiceEndpoint}.
*
* @access private
*/
function begin($service_endpoint)
{
$assoc = $this->_getAssociation($service_endpoint);
$r = new Auth_OpenID_AuthRequest($service_endpoint, $assoc);
$r->return_to_args[$this->openid1_nonce_query_arg_name] = Auth_OpenID_mkNonce();
if ($r->message->isOpenID1()) {
$r->return_to_args[$this->openid1_return_to_identifier_name] = $r->endpoint->claimed_id;
}
return $r;
}
示例4: _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;
}
示例5: setUp
function setUp()
{
global $GOODSIG;
$this->store = new GoodAssocStore();
$this->consumer = new ConfigurableConsumer($this->store);
$this->server_url = "http://idp.unittest/";
$claimed_id = 'bogus.claimed';
$this->message = Auth_OpenID_Message::fromOpenIDArgs(array('mode' => 'id_res', 'return_to' => 'return_to (just anything)', 'identity' => $claimed_id, 'assoc_handle' => 'does not matter', 'sig' => $GOODSIG, 'response_nonce' => Auth_OpenID_mkNonce(), 'signed' => 'identity,return_to,response_nonce,assoc_handle,claimed_id,op_endpoint', 'claimed_id' => $claimed_id, 'op_endpoint' => $this->server_url, 'ns' => Auth_OpenID_OPENID2_NS));
$this->endpoint = new Auth_OpenID_ServiceEndpoint();
$this->endpoint->server_url = $this->server_url;
$this->endpoint->claimed_id = $claimed_id;
$this->consumer->disableReturnToChecking();
}
示例6: begin
/**
* Called to begin OpenID authentication using the specified
* {@link Auth_OpenID_ServiceEndpoint}.
*
* @access private
*/
function begin($service_endpoint)
{
$assoc = $this->_getAssociation($service_endpoint);
$r = new Auth_OpenID_AuthRequest($service_endpoint, $assoc);
$r->return_to_args[$this->openid1_nonce_query_arg_name] = Auth_OpenID_mkNonce();
return $r;
}