コード例 #1
0
ファイル: user.class.php プロジェクト: jungepiraten/nntpboard
 public function __construct($username, $password, $address, $nntpusername, $nntppassword)
 {
     parent::__construct();
     $this->username = $username;
     $this->password = $password;
     $this->address = $address;
     $this->nntpusername = $nntpusername;
     $this->nntppassword = $nntppassword;
 }
コード例 #2
0
 /**
  * Initializes the object
  */
 public function __construct()
 {
     $this->nonce = uniqid();
     $this->opaque = md5($this->realm);
     parent::__construct();
 }
コード例 #3
0
ファイル: Table.php プロジェクト: popphp/pop-auth
 /**
  * Method to authenticate
  *
  * @param  string $username
  * @param  string $password
  * @return int
  */
 public function authenticate($username, $password)
 {
     parent::authenticate($username, $password);
     $table = $this->table;
     $this->result = 0;
     $this->user = $table::findBy([$this->usernameField => $this->username]);
     if (null !== $this->password && isset($this->user->{$this->passwordField}) && null !== $this->user->{$this->passwordField}) {
         $this->result = (int) $this->verify($this->password, $this->user->{$this->passwordField});
     }
     return $this->result;
 }
コード例 #4
0
ファイル: Http.php プロジェクト: popphp/pop-auth
 /**
  * Method to authenticate
  *
  * @param  string $username
  * @param  string $password
  * @return int
  */
 public function authenticate($username, $password)
 {
     parent::authenticate($username, $password);
     $this->generateRequest();
     $context = ['http' => ['method' => $this->method, 'header' => null]];
     switch ($this->type) {
         case 'Basic':
             $context['http']['header'] = 'Authorization: Basic ' . base64_encode($this->username . ':' . $this->password);
             break;
         case 'Digest':
             $a1 = md5($this->username . ':' . $this->scheme['realm'] . ':' . $this->password);
             $a2 = md5($this->method . ':' . $this->relativeUri);
             $r = md5($a1 . ':' . $this->scheme['nonce'] . ':' . $a2);
             $context['http']['header'] = 'Authorization: Digest username="******", realm="' . $this->scheme['realm'] . '", nonce="' . $this->scheme['nonce'] . '", uri="' . $this->relativeUri . '", response="' . $r . '"';
             break;
     }
     $this->sendRequest($context);
     $this->result = (int) ($this->code == 200);
     return $this->result;
 }
コード例 #5
0
ファイル: File.php プロジェクト: popphp/pop-auth
 /**
  * Method to authenticate
  *
  * @param  string $username
  * @param  string $password
  * @return int
  */
 public function authenticate($username, $password)
 {
     parent::authenticate($username, $password);
     $lines = file($this->filename);
     $hash = null;
     $this->result = 0;
     foreach ($lines as $line) {
         $line = trim($line);
         $user = explode($this->delimiter, $line);
         if (isset($user[0]) && $user[0] == $this->username) {
             if (null !== $this->realm && count($user) == 3) {
                 if ($this->username == $user[0] && $user[1] == $this->realm) {
                     $hash = $user[2];
                     break;
                 }
             } else {
                 if (count($user) == 2) {
                     if ($this->username == $user[0]) {
                         $hash = $user[1];
                         break;
                     }
                 }
             }
         }
     }
     if (null !== $this->password && null !== $hash) {
         $this->result = (int) $this->verify($this->password, $hash);
     }
     return $this->result;
 }
コード例 #6
0
ファイル: Ldap.php プロジェクト: popphp/pop-auth
 /**
  * Method to authenticate
  *
  * @param  string $username
  * @param  string $password
  * @return int
  */
 public function authenticate($username, $password)
 {
     parent::authenticate($username, $password);
     $this->result = (int) @ldap_bind($this->resource, $this->username, $this->password);
     return $this->result;
 }