Esempio n. 1
0
 /**
  * Lookup nonce value for the tool consumer.
  *
  * @param OAuthConsumer $consumer  OAuthConsumer object
  * @param string        $token     Token value
  * @param string        $value     Nonce value
  * @param string        $timestamp Date/time of request
  *
  * @return boolean True if the nonce value already exists
  */
 function lookup_nonce($consumer, $token, $value, $timestamp)
 {
     $nonce = new ConsumerNonce($this->toolProvider->consumer, $value);
     $ok = !$nonce->load();
     if ($ok) {
         $ok = $nonce->save();
     }
     if (!$ok) {
         $this->toolProvider->reason = 'Invalid nonce.';
     }
     return !$ok;
 }
Esempio n. 2
0
 /**
  * Test for data_connector::loadConsumerNonce() for a nonce that has expired.
  */
 public function test_load_consumer_nonce_expired()
 {
     $dc = new data_connector();
     $consumer = new ToolConsumer(null, $dc);
     $consumer->name = 'TestName';
     $consumer->setKey('TestKey');
     $consumer->secret = 'TestSecret';
     $consumer->save();
     $nonce = new ConsumerNonce($consumer, 'testnonce');
     $nonce->expires = time() - 100;
     // Save the nonce.
     $nonce->save();
     // Expired nonce should have been deleted.
     $this->assertFalse($dc->loadConsumerNonce($nonce));
 }