--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An action class for the admin "welcome" page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class WebAdminLoginWelcomeAction extends BaseAction implements PerformableAction, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this action
+ *
+ * @return $actionInstance An instance of this action class
+ */
+ public static final function createWebAdminLoginWelcomeAction () {
+ // Get a new instance
+ $actionInstance = new WebAdminLoginWelcomeAction();
+
+ // Return the instance
+ return $actionInstance;
+ }
+
+ /**
+ * Executes the command with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo Maybe we need to do something later here
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->partialStub("Unfinished part.");
+ }
+
+ /**
+ * Adds extra filters to the given controller instance
+ *
+ * @param $controllerInstance A controller instance
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @return void
+ * @todo 0% done
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ $this->partialStub("Need to add filters which looks for applications with "admin" directory.");
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class extends BaseFrameworkSystem {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command for user login
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class WebAdminUserLoginCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this command and sets the resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver
+ * @return $commandInstance The created command instance
+ */
+ public static final function createWebAdminUserLoginCommand (CommandResolver $resolverInstance) {
+ // Get a new instance
+ $commandInstance = new WebAdminUserLoginCommand();
+
+ // Set the resolver instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the command with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // First get a UserLogin instance
+ $loginInstance = ObjectFactory::createObjectByConfiguredName('user_login_class');
+
+ // First set request and response instance
+ $loginInstance->setRequestInstance($requestInstance);
+
+ // Encrypt the password
+ $loginInstance->encryptPassword('pass');
+
+ // Do the login here
+ $loginInstance->doLogin($requestInstance, $responseInstance);
+
+ // Was the login fine? Then redirect here
+ if ($loginInstance->ifLoginWasSuccessfull()) {
+ // Try to redirect here
+ try {
+ // Redirect...
+ $responseInstance->redirectToConfiguredUrl('app_login');
+
+ // Exit here
+ exit();
+ } catch (FrameworkException $e) {
+ // Something went wrong here!
+ $responseInstance->addFatalMessage($e->getMessage());
+ }
+ } else {
+ // Attach error message to the response
+ $responseInstance->addFatalMessage('failed_user_login');
+ }
+ }
+
+ /**
+ * Adds extra filters to the given controller instance
+ *
+ * @param $controllerInstance A controller instance
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @return void
+ * @todo Add more filters
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Which login type do we have?
+ switch ($this->getConfigInstance()->getConfigEntry('login_type')) {
+ case "username": // Login via username
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter'));
+ break;
+
+ case "email": // Login via email
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_filter'));
+ break;
+
+ default: // Wether username or email is set
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_filter'));
+ break;
+ }
+
+ // Password verifier filter
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_filter'));
+
+ // Add filter for CAPTCHA
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_user_verifier_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A special login class for administration area
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class AdminUserLogin extends BaseFrameworkSystem implements LoginableUser {
+ /**
+ * The hashed password
+ */
+ private $hashedPassword = "";
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this login class
+ *
+ * @return $loginInstance An instance of this login class
+ */
+ public static final function createAdminUserLogin () {
+ // Get a new instance
+ $loginInstance = new AdminUserLogin();
+
+ // Return the instance
+ return $loginInstance;
+ }
+
+ /**
+ * Logins the user with the given request containing the credential. The
+ * result of the login can be thrown by exception or, if prefered stored
+ * in a boolean attribute which is then readable by a matching getter.
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @param $responseInstance An instance of a Responseable class
+ * @return void
+ * @throws UserPasswordMismatchException If the supplied password did not
+ * match with the stored password
+ * @todo We need to add something here which will make more than one
+ * @todo guest logins, users who are online but based on the same
+ * @todo user account.
+ */
+ public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
+ // By default no method is selected
+ $method = null;
+ $data = "";
+
+ // Get member class
+ $userClass = $this->getConfigInstance()->getConfigEntry('user_class');
+
+ // Get a user instance
+ $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance));
+
+ // Remember this new instance in registry
+ Registry::getRegistry()->addInstance('user', $userInstance);
+
+ // Is the password correct?
+ if ($userInstance->ifPasswordHashMatches($requestInstance) === false) {
+ // Mismatching password
+ throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
+ } // END - if
+
+ // ToDo place
+
+ // Now do the real login. This can be cookie- or session-based login
+ // which depends on the admins setting then on the user's taste.
+ // 1) Get a login helper instance
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance));
+
+ // 2) Execute the login. This will now login...
+ $helperInstance->executeLogin($responseInstance);
+ }
+
+ /**
+ * Determines wether the login was fine. This is done by checking if 'login' instance is in registry
+ *
+ * @return $loginDone Wether the login was fine or not
+ */
+ public function ifLoginWasSuccessfull () {
+ // Is the registry key there?
+ $loginDone = (Registry::getRegistry()->getInstance('login') instanceof Registerable);
+
+ // Return the result
+ return $loginDone;
+ }
+
+ /**
+ * Encrypt given request key or throw an exception if key was not found in
+ * request
+ *
+ * @param $requestKey Key in request class
+ * @return void
+ */
+ public function encryptPassword ($requestKey) {
+ // Check if password is found in request
+ if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
+ // So encrypt the password and store it for later usage in
+ // the request:
+
+ // Get the plain password
+ $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
+
+ // Get user instance
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Get a crypto helper and hash the password
+ $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
+
+ // Store the hash back in request
+ $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
+ } // END - if
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A helper for administration area login. This login helper first checks what
+ * setting (cookie or session) the admin has choosen then overwrites it with the
+ * setting from current user. The registry instance should hold an instance of
+ * this user class at key 'user' else an exception will be thrown. After this
+ * the setting from a login form will be taken as login method and be stored
+ * in database for later usage.
+ *
+ * The user shall be able to choose "Default login method" or similar to use his
+ * own login method.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class AdminLoginHelper extends BaseLoginHelper implements HelpableLogin {
+ /**
+ * The login method we shall choose
+ */
+ private $authMethod = "";
+
+ // Exception constants
+ const EXCEPTION_INVALID_USER_INSTANCE = 0x190;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class by given request instance
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @return $helperInstance An instance of this helper class
+ * @throws UserInstanceMissingException If the user instance in registry
+ * is missing or invalid
+ */
+ public static final function createAdminLoginHelper (Requestable $requestInstance) {
+ // Get a new instance first
+ $helperInstance = new AdminLoginHelper();
+
+ // Get a user instance from registry
+ $userInstance = Registry::getRegistry()->getInstance('user');
+
+ // Is this instance valid?
+ if (!$userInstance instanceof ManageableAccount) {
+ // Thrown an exception here
+ throw new UserInstanceMissingException (array($helperInstance, 'user'), self::EXCEPTION_INVALID_USER_INSTANCE);
+ } // END - if
+
+ // Set default login method from config
+ $helperInstance->setDefaultAuthMethod();
+
+ // Set request instance
+ $helperInstance->setRequestInstance($requestInstance);
+
+ // Return the prepared instance
+ return $helperInstance;
+ }
+
+ /**
+ * Setter for default login method from config
+ *
+ * @return void
+ */
+ protected function setDefaultAuthMethod () {
+ $this->authMethod = $this->getConfigInstance()->getConfigEntry('auth_method_class');
+ }
+
+ /**
+ * Execute the login request by given response instance. This instance can
+ * be used for sending cookies or at least the session id out.
+ *
+ * @param $responseInstance An instance of a Responseable class
+ * @return void
+ */
+ public function executeLogin (Responseable $responseInstance) {
+ // Get an instance from the login method
+ $loginInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance));
+
+ // Set user cookie
+ $loginInstance->setUserAuth($this->getRequestInstance()->getRequestElement('username'));
+
+ // Set password cookie
+ $loginInstance->setPasswordAuth($this->getRequestInstance()->getRequestElement('pass_hash'));
+
+ // Remember this login instance for later usage
+ Registry::getRegistry()->addInstance('login', $loginInstance);
+ }
+}
+
+//
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? menu class for Admin-Area
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Admin???Menu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public final static function createAdmin???Menu () {
+ // Get a new instance
+ $menuInstance = new Admin???Menu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A Home menu class for Admin-Area
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class AdminHomeMenu extends BaseMenu implements RenderableMenu {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $menuInstance An instance of this class
+ */
+ public static final function createAdminHomeMenu () {
+ // Get a new instance
+ $menuInstance = new AdminHomeMenu();
+
+ // Return the prepared instance
+ return $menuInstance;
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * An action class for the admin "welcome" page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class WebAdminLoginWelcomeAction extends BaseAction implements PerformableAction, Registerable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this action
- *
- * @return $actionInstance An instance of this action class
- */
- public static final function createWebAdminLoginWelcomeAction () {
- // Get a new instance
- $actionInstance = new WebAdminLoginWelcomeAction();
-
- // Return the instance
- return $actionInstance;
- }
-
- /**
- * Executes the command with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo Maybe we need to do something later here
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- $this->partialStub("Unfinished part.");
- }
-
- /**
- * Adds extra filters to the given controller instance
- *
- * @param $controllerInstance A controller instance
- * @param $requestInstance An instance of a class with an Requestable interface
- * @return void
- * @todo 0% done
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- $this->partialStub("Need to add filters which looks for applications with "admin" directory.");
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- *
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class extends BaseFrameworkSystem {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A command for user login
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class WebAdminUserLoginCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this command and sets the resolver instance
- *
- * @param $resolverInstance An instance of a command resolver
- * @return $commandInstance The created command instance
- */
- public static final function createWebAdminUserLoginCommand (CommandResolver $resolverInstance) {
- // Get a new instance
- $commandInstance = new WebAdminUserLoginCommand();
-
- // Set the resolver instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the command with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // First get a UserLogin instance
- $loginInstance = ObjectFactory::createObjectByConfiguredName('user_login_class');
-
- // First set request and response instance
- $loginInstance->setRequestInstance($requestInstance);
-
- // Encrypt the password
- $loginInstance->encryptPassword('pass');
-
- // Do the login here
- $loginInstance->doLogin($requestInstance, $responseInstance);
-
- // Was the login fine? Then redirect here
- if ($loginInstance->ifLoginWasSuccessfull()) {
- // Try to redirect here
- try {
- // Redirect...
- $responseInstance->redirectToConfiguredUrl('app_login');
-
- // Exit here
- exit();
- } catch (FrameworkException $e) {
- // Something went wrong here!
- $responseInstance->addFatalMessage($e->getMessage());
- }
- } else {
- // Attach error message to the response
- $responseInstance->addFatalMessage('failed_user_login');
- }
- }
-
- /**
- * Adds extra filters to the given controller instance
- *
- * @param $controllerInstance A controller instance
- * @param $requestInstance An instance of a class with an Requestable interface
- * @return void
- * @todo Add more filters
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Which login type do we have?
- switch ($this->getConfigInstance()->getConfigEntry('login_type')) {
- case "username": // Login via username
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter'));
- break;
-
- case "email": // Login via email
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('email_verifier_filter'));
- break;
-
- default: // Wether username or email is set
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_email_verifier_filter'));
- break;
- }
-
- // Password verifier filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('password_verifier_filter'));
-
- // Add filter for CAPTCHA
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_user_verifier_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A special login class for administration area
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class AdminUserLogin extends BaseFrameworkSystem implements LoginableUser {
- /**
- * The hashed password
- */
- private $hashedPassword = "";
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this login class
- *
- * @return $loginInstance An instance of this login class
- */
- public static final function createAdminUserLogin () {
- // Get a new instance
- $loginInstance = new AdminUserLogin();
-
- // Return the instance
- return $loginInstance;
- }
-
- /**
- * Logins the user with the given request containing the credential. The
- * result of the login can be thrown by exception or, if prefered stored
- * in a boolean attribute which is then readable by a matching getter.
- *
- * @param $requestInstance An instance of a Requestable class
- * @param $responseInstance An instance of a Responseable class
- * @return void
- * @throws UserPasswordMismatchException If the supplied password did not
- * match with the stored password
- * @todo We need to add something here which will make more than one
- * @todo guest logins, users who are online but based on the same
- * @todo user account.
- */
- public function doLogin (Requestable $requestInstance, Responseable $responseInstance) {
- // By default no method is selected
- $method = null;
- $data = "";
-
- // Get member class
- $userClass = $this->getConfigInstance()->getConfigEntry('user_class');
-
- // Get a user instance
- $userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance));
-
- // Remember this new instance in registry
- Registry::getRegistry()->addInstance('user', $userInstance);
-
- // Is the password correct?
- if ($userInstance->ifPasswordHashMatches($requestInstance) === false) {
- // Mismatching password
- throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH);
- } // END - if
-
- // ToDo place
-
- // Now do the real login. This can be cookie- or session-based login
- // which depends on the admins setting then on the user's taste.
- // 1) Get a login helper instance
- $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper_class', array($requestInstance));
-
- // 2) Execute the login. This will now login...
- $helperInstance->executeLogin($responseInstance);
- }
-
- /**
- * Determines wether the login was fine. This is done by checking if 'login' instance is in registry
- *
- * @return $loginDone Wether the login was fine or not
- */
- public function ifLoginWasSuccessfull () {
- // Is the registry key there?
- $loginDone = (Registry::getRegistry()->getInstance('login') instanceof Registerable);
-
- // Return the result
- return $loginDone;
- }
-
- /**
- * Encrypt given request key or throw an exception if key was not found in
- * request
- *
- * @param $requestKey Key in request class
- * @return void
- */
- public function encryptPassword ($requestKey) {
- // Check if password is found in request
- if ($this->getRequestInstance()->isRequestElementSet($requestKey)) {
- // So encrypt the password and store it for later usage in
- // the request:
-
- // Get the plain password
- $plainPassword = $this->getRequestInstance()->getRequestElement($requestKey);
-
- // Get user instance
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Get a crypto helper and hash the password
- $this->hashedPassword = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($plainPassword, $userInstance->getPasswordHash());
-
- // Store the hash back in request
- $this->getRequestInstance()->setRequestElement('pass_hash', $this->hashedPassword);
- } // END - if
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A helper for administration area login. This login helper first checks what
- * setting (cookie or session) the admin has choosen then overwrites it with the
- * setting from current user. The registry instance should hold an instance of
- * this user class at key 'user' else an exception will be thrown. After this
- * the setting from a login form will be taken as login method and be stored
- * in database for later usage.
- *
- * The user shall be able to choose "Default login method" or similar to use his
- * own login method.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class AdminLoginHelper extends BaseLoginHelper implements HelpableLogin {
- /**
- * The login method we shall choose
- */
- private $authMethod = "";
-
- // Exception constants
- const EXCEPTION_INVALID_USER_INSTANCE = 0x190;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class by given request instance
- *
- * @param $requestInstance An instance of a Requestable class
- * @return $helperInstance An instance of this helper class
- * @throws UserInstanceMissingException If the user instance in registry
- * is missing or invalid
- */
- public static final function createAdminLoginHelper (Requestable $requestInstance) {
- // Get a new instance first
- $helperInstance = new AdminLoginHelper();
-
- // Get a user instance from registry
- $userInstance = Registry::getRegistry()->getInstance('user');
-
- // Is this instance valid?
- if (!$userInstance instanceof ManageableAccount) {
- // Thrown an exception here
- throw new UserInstanceMissingException (array($helperInstance, 'user'), self::EXCEPTION_INVALID_USER_INSTANCE);
- } // END - if
-
- // Set default login method from config
- $helperInstance->setDefaultAuthMethod();
-
- // Set request instance
- $helperInstance->setRequestInstance($requestInstance);
-
- // Return the prepared instance
- return $helperInstance;
- }
-
- /**
- * Setter for default login method from config
- *
- * @return void
- */
- protected function setDefaultAuthMethod () {
- $this->authMethod = $this->getConfigInstance()->getConfigEntry('auth_method_class');
- }
-
- /**
- * Execute the login request by given response instance. This instance can
- * be used for sending cookies or at least the session id out.
- *
- * @param $responseInstance An instance of a Responseable class
- * @return void
- */
- public function executeLogin (Responseable $responseInstance) {
- // Get an instance from the login method
- $loginInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance));
-
- // Set user cookie
- $loginInstance->setUserAuth($this->getRequestInstance()->getRequestElement('username'));
-
- // Set password cookie
- $loginInstance->setPasswordAuth($this->getRequestInstance()->getRequestElement('pass_hash'));
-
- // Remember this login instance for later usage
- Registry::getRegistry()->addInstance('login', $loginInstance);
- }
-}
-
-//
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? menu class for Admin-Area
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Admin???Menu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public final static function createAdmin???Menu () {
- // Get a new instance
- $menuInstance = new Admin???Menu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A Home menu class for Admin-Area
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Admin-Area Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class AdminHomeMenu extends BaseMenu implements RenderableMenu {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @return $menuInstance An instance of this class
- */
- public static final function createAdminHomeMenu () {
- // Get a new instance
- $menuInstance = new AdminHomeMenu();
-
- // Return the prepared instance
- return $menuInstance;
- }
-}
-
-// [EOF]
-?>
-Subproject commit a0551c30b2e11aadba3f0513ef67c36ca7e60552
+Subproject commit 7bc4014657a70dedfc38b9b28d134aa7c3a6158c