コード例 #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 LTI_Consumer_Nonce($this->tool_provider->consumer, $value);
     $ok = !$nonce->load();
     if ($ok) {
         $ok = $nonce->save();
     }
     if (!$ok) {
         $this->tool_provider->reason = 'Invalid nonce.';
     }
     return !$ok;
 }
コード例 #2
0
 /**
  * Save the consumer nonce in the database
  *
  * @param LTI_Consumer_Nonce $nonce
  * @return bool
  */
 public function Consumer_Nonce_save($nonce)
 {
     $key = $nonce->getKey();
     $value = $nonce->getValue();
     $expires = date('Y-m-d H:i:s', $nonce->expires);
     $sql = 'INSERT INTO ' . $this->dbTableNamePrefix . LTI_Data_Connector::NONCE_TABLE_NAME . ' (consumer_key, value, expires) VALUES (:key, :value, :expires)';
     $query = $this->db->prepare($sql);
     $query->bindValue('key', $key, PDO::PARAM_STR);
     $query->bindValue('value', $value, PDO::PARAM_STR);
     $query->bindValue('expires', $expires, PDO::PARAM_STR);
     $ok = $query->execute();
     return $ok;
 }