/**
  * Get the user identity and returns a user corresponding
  * to the given identity.
  * 
  * Note that the returned user contains his
  * credentials in order to be used by the security
  * framework
  * 
  */
 public function &loadUser(__IUserIdentity $user_identity)
 {
     $user = null;
     if ($user_identity instanceof __UsernameIdentity) {
         //connect to the database:
         $dbh = new PDO('mysql:host=localhost;dbname=my_db_name', $db_user, $db_password);
         //find the user by filtering by login:
         $statement = $dbh->prepare("SELECT * \n                                        FROM users \n                                        WHERE login = ?");
         $login = $user_identity->getUsername();
         $statement->execute(array($login));
         //if the query has result in a single row:
         if ($statement->rowCount() == 1) {
             $statement->setFetchMode(PDO::FETCH_ASSOC);
             $user_info = $arrValues = $stmt->fetch();
             //create a user instance and set the credentials:
             $user = new __User();
             $credentials = new __PasswordCredentials();
             $credentials->setPassword($user_info['password']);
             $user->setCredentials($credentials);
             //now load roles asssociated to him:
             $roles = $this->_loadRoles($dbh, $user_info['id']);
             //and finally assign them to the user:
             $user->setRoles($roles);
         }
         //close the connection
         $dbh = null;
     }
     return $user;
 }
 /**
  * This is the __IUser loader method.
  *
  * @return __IUser A new __IUser
  */
 public function &loadUser(__IUserIdentity $user_identity)
 {
     $user = new __User();
     $credentials = new __AnonymousCredentials();
     $user->setCredentials($credentials);
     $user->setIdentity($user_identity);
     return $user;
 }
 public function &loadAnonymousUser()
 {
     $return_value = new __User();
     //If there is not need to authenticate the user, will set the admin role:
     if (__ContextManager::getInstance()->getContext('LION_ADMIN_AREA')->getPropertyContent('LION_ADMIN_AUTH_REQUIRED') == false) {
         $admin_role = __RoleManager::getInstance()->getRole('ADMIN');
         $return_value->addRole($admin_role);
     }
     $return_value->setCredentials(new __AnonymousCredentials());
     return $return_value;
 }
 /**
  * Get the user identity and returns a user corresponding
  * to the given identity.
  * 
  * Note that the returned user contains his
  * credentials in order to be used by the security
  * framework
  * 
  */
 public function &loadUser(__IUserIdentity $user_identity)
 {
     $user = null;
     if ($user_identity instanceof __UsernameIdentity) {
         //get the login string from the user identity:
         $login = $user_identity->getUsername();
         //check if the login correspond to any of our
         //valid logins:
         if (key_exists($login, $this->_user_and_passwords)) {
             //create a user instance and set the credentials:
             $user = new __User();
             $credentials = new __PasswordCredentials();
             $credentials->setPassword($this->_user_and_passwords[$login]);
             $user->setCredentials($credentials);
         }
     }
     return $user;
 }
 /**
  * Get the user identity and returns a user corresponding
  * to the given identity.
  * 
  * Note that the returned user contains his
  * credentials in order to be used by the security
  * framework
  * 
  */
 public function &loadUser(__IUserIdentity $user_identity)
 {
     $user = null;
     if ($user_identity instanceof __UsernameIdentity) {
         //get the login string from the user identity:
         $login = $user_identity->getUsername();
         //check if the login correspond to any of our
         //valid logins:
         if (key_exists($login, $this->_user_and_passwords)) {
             //create a user instance and set the credentials:
             $user = new __User();
             $credentials = new __PasswordCredentials();
             $credentials->setPassword($this->_user_and_passwords[$login]);
             $user->setCredentials($credentials);
             //get the role identified as REGISTERED_USER:
             $role = __RoleManager::getInstance()->getRole('REGISTERED_USER');
             //assign the role to the user:
             $user->addRole($role);
         }
     }
     return $user;
 }