]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/auth/class_CookieAuth.php
Continued:
[core.git] / framework / main / classes / auth / class_CookieAuth.php
index a98999f4c954eb7d7936d98db081612894b9e311..e14fd5df23344b23488149e7381afed152a54df1 100644 (file)
@@ -1,18 +1,19 @@
 <?php
 // Own namespace
-namespace CoreFramework\Auth;
+namespace Org\Mxchange\CoreFramework\Auth;
 
 // Import framework stuff
-use CoreFramework\Object\BaseFrameworkSystem;
-use CoreFramework\Registry\Registerable;
-use CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Response\Responseable;
 
 /**
  * A cookie-bases authorization class
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -35,7 +36,7 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera
         *
         * @return      void
         */
-       protected function __construct () {
+       private function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        }
@@ -50,9 +51,6 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera
                // Get a new instance
                $loginInstance = new CookieAuth();
 
-               // Set the response instance
-               $loginInstance->setResponseInstance($responseInstance);
-
                // Return the prepared instance
                return $loginInstance;
        }
@@ -63,8 +61,8 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera
         * @param       $userName       The username from request we shall set
         * @return      void
         */
-       public function setUserAuth ($userName) {
-               $this->getResponseInstance()->addCookie('username', $userName);
+       public function setUserAuth (string $userName) {
+               FrameworkBootstrap::getResponseInstance()->addCookie('username', $userName);
        }
 
        /**
@@ -73,8 +71,8 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera
         * @param       $passHash       The hashed password from request we shall set
         * @return      void
         */
-       public function setPasswordAuth ($passHash) {
-               $this->getResponseInstance()->addCookie('u_hash', $passHash);
+       public function setPasswordAuth (string $passHash) {
+               FrameworkBootstrap::getResponseInstance()->addCookie('u_hash', $passHash);
        }
 
        /**
@@ -84,7 +82,7 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera
         */
        public function getUserAuth () {
                // Get the username from cookie
-               $userName = $this->getRequestInstance()->readCookie('username');
+               $userName = FrameworkBootstrap::getRequestInstance()->readCookie('username');
 
                // Return the username
                return $userName;
@@ -97,7 +95,7 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera
         */
        public function getPasswordAuth () {
                // Get the username from cookie
-               $passHash = $this->getRequestInstance()->readCookie('u_hash');
+               $passHash = FrameworkBootstrap::getRequestInstance()->readCookie('u_hash');
 
                // Return the username
                return $passHash;
@@ -110,8 +108,8 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera
         */
        public function destroyAuthData () {
                // Expire both cookies
-               $this->getResponseInstance()->expireCookie('username');
-               $this->getResponseInstance()->expireCookie('u_hash');
+               FrameworkBootstrap::getResponseInstance()->expireCookie('username');
+               FrameworkBootstrap::getResponseInstance()->expireCookie('u_hash');
        }
 
        /**
@@ -120,8 +118,8 @@ class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registera
         * @return      void
         */
        public function updateAuthData () {
-               $this->getResponseInstance()->refreshCookie('username');
-               $this->getResponseInstance()->refreshCookie('u_hash');
+               FrameworkBootstrap::getResponseInstance()->refreshCookie('username');
+               FrameworkBootstrap::getResponseInstance()->refreshCookie('u_hash');
        }
 
 }