From 671b87a211de755a6b549e17ebb1905892019a86 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Fri, 30 Dec 2011 12:59:51 +0000 Subject: [PATCH] Add placeholder FlatFile Auth classes --- .../Auth/Plugin/FlatFile.class.php | 71 +++++++++++++++++++ .../Auth/Plugin/FlatFile/User.class.php | 35 +++++++++ 2 files changed, 106 insertions(+) create mode 100644 source/lib/SihnonFramework/Auth/Plugin/FlatFile.class.php create mode 100644 source/lib/SihnonFramework/Auth/Plugin/FlatFile/User.class.php diff --git a/source/lib/SihnonFramework/Auth/Plugin/FlatFile.class.php b/source/lib/SihnonFramework/Auth/Plugin/FlatFile.class.php new file mode 100644 index 0000000..7480d9e --- /dev/null +++ b/source/lib/SihnonFramework/Auth/Plugin/FlatFile.class.php @@ -0,0 +1,71 @@ +config = $config; + } + + /* + * IPlugin methods + */ + + public static function create(SihnonFramework_Config $config) { + return new self($config); + } + + public function userExists($username) { + return Sihnon_Auth_Plugin_FlatFile_User::exists($username); + } + + public function listUsers() { + return Sihnon_Auth_Plugin_FlatFile_User::all(); + } + + public function authenticate($username, $password) { + $user = Sihnon_Auth_Plugin_FlatFile_User::load($username); + + if ( ! $user->checkPassword($password)) { + throw new Sihnon_Exception_IncorrectPassword(); + } + + return $user; + } + + public function authenticateSession($username) { + return Sihnon_Auth_Plugin_FlatFile_User::load($username); + } + + /* + * IUpdateable methods + */ + + public function addUser($username, $password) { + return Sihnon_Auth_Plugin_Database_User::add($username, $password); + } + + public function removeUser(Sihnon_Auth_IUser $user) { + $user->delete(); + } + + public function changePassword(Sihnon_Auth_IUser $user, $new_password) { + $user->changePassword($new_password); + } + + /* + * IPermissionable methods + */ + + public function isAdministrator(Sihnon_Auth_IUser $user) { + return $user->isAdministrator(); + } + +} + +?> \ No newline at end of file diff --git a/source/lib/SihnonFramework/Auth/Plugin/FlatFile/User.class.php b/source/lib/SihnonFramework/Auth/Plugin/FlatFile/User.class.php new file mode 100644 index 0000000..4f5a80f --- /dev/null +++ b/source/lib/SihnonFramework/Auth/Plugin/FlatFile/User.class.php @@ -0,0 +1,35 @@ +username; + } + + public function checkPassword($password) { + return ($this->password == sha1($password)); + } + + public function changePassword($new_password) { + throw new SihnonFramework_Exception_NotImplemented(); + } + + public function isAdministrator() { + throw new SihnonFramework_Exception_NotImplemented(); + } + +} + +?> \ No newline at end of file