示例#1
0
 /**
  * Attempt to log in using the given username and password.
  *
  * On a successful login, this function should return the users attributes. On failure,
  * it should throw an exception. If the error was caused by the user entering the wrong
  * username or password, a SimpleSAML_Error_Error('WRONGUSERPASS') should be thrown.
  *
  * Note that both the username and the password are UTF-8 encoded.
  *
  * @param string $username  The username the user wrote.
  * @param string $password  The password the user wrote.
  * @return array  Associative array with the users attributes.
  */
 protected function login($otp)
 {
     assert('is_string($otp)');
     require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/libextinc/Yubico.php';
     $attributes = array();
     try {
         $yubi = new Auth_Yubico($this->yubi_id, $this->yubi_key);
         $auth = $yubi->verify($otp);
         $uid = self::getYubiKeyPrefix($otp);
         $attributes = array('uid' => array($uid));
     } catch (Exception $e) {
         SimpleSAML\Logger::info('YubiKey:' . $this->authId . ': Validation error (otp ' . $otp . '), debug output: ' . $yubi->getLastResponse());
         throw new SimpleSAML_Error_Error('WRONGUSERPASS', $e);
     }
     SimpleSAML\Logger::info('YubiKey:' . $this->authId . ': YubiKey otp ' . $otp . ' validated successfully: ' . $yubi->getLastResponse());
     return $attributes;
 }
示例#2
0
$auth = $yubi->verify($otp, false, $wait_for_all, $sl, $timeout);
?>

  <h2>Last Client Query</h2>

   <pre>
<?php 
print str_replace(" ", "\n", $yubi->getLastQuery() . " ");
?>
   </pre>

  <h2>Server Responses</h2>

   <pre>
<?php 
print $yubi->getLastResponse();
?>
  </pre>

<?php 
if (PEAR::isError($auth)) {
    ?>
<h2>Authentication Failed!</h2>
  <p>Error message: <?php 
    print $auth->getMessage();
    ?>
</p><?php 
} else {
    ?>
<h2>Authenticated Success!</h2><?php 
}