4 * This is an authentication backend that uses a file to manage passwords.
6 * The backend file must conform to Apache's htdigest format
10 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
11 * @author Evert Pot (http://www.rooftopsolutions.nl/)
12 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
14 class Sabre_DAV_Auth_Backend_PDO extends Sabre_DAV_Auth_Backend_AbstractDigest {
17 * Reference to PDO connection
24 * PDO table name we'll be using
32 * Creates the backend object.
34 * If the filename argument is passed in, it will parse out the specified file fist.
37 * @param string $tableName The PDO table name to use
39 public function __construct(PDO $pdo, $tableName = 'users') {
42 $this->tableName = $tableName;
47 * Returns the digest hash for a user.
49 * @param string $realm
50 * @param string $username
53 public function getDigestHash($realm,$username) {
55 $stmt = $this->pdo->prepare('SELECT username, digesta1 FROM '.$this->tableName.' WHERE username = ?');
56 $stmt->execute(array($username));
57 $result = $stmt->fetchAll();
59 if (!count($result)) return;
61 return $result[0]['digesta1'];