login() 공개 메소드

Note that subclasses that override the login method must set the loginOk var to TRUE if the login succeeds in order for the commit phase to populate the Subject. This implementation sets loginOk to TRUE if the login() method returns TRUE, otherwise, it sets loginOk to FALSE. Perform the authentication of username and password.
public login ( ) : boolean
리턴 boolean TRUE if the login credentials are available in the sharedMap, else FALSE
 /**
  * Perform the authentication of username and password.
  *
  * @return boolean TRUE when login has been successfull, else FALSE
  * @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if an error during login occured
  */
 public function login()
 {
     if (parent::login()) {
         // Setup our view of the user
         $name = new String($this->sharedState->get(SharedStateKeys::LOGIN_NAME));
         if ($name instanceof Principal) {
             $this->identity = name;
         } else {
             $name = $name->__toString();
             try {
                 $this->identity = $this->createIdentity($name);
             } catch (\Exception $e) {
                 // log.debug("Failed to create principal", e);
                 throw new LoginException(sprintf('Failed to create principal: %s', $e->getMessage()));
             }
         }
         $password = new String($this->sharedState->get(SharedStateKeys::LOGIN_PASSWORD));
         /* if ($password instanceof char[] ) {
                credential = (char[]) password;
            } elseif (password != null) {
                String tmp = password.toString();
                credential = tmp.toCharArray();
            } */
         return true;
     }
     $this->loginOk = false;
     // array containing the username and password from the user's input
     list($name, $password) = $this->getUsernameAndPassword();
     if ($name == null && $password == null) {
         $this->identity = $this->unauthenticatedIdentity;
         // super.log.trace("Authenticating as unauthenticatedIdentity="+identity);
     }
     if ($this->identity == null) {
         try {
             $this->identity = $this->createIdentity($name);
         } catch (\Exception $e) {
             // log.debug("Failed to create principal", e);
             throw new LoginException(sprintf('Failed to create principal: %s', $e->getMessage()));
         }
         // hash the user entered password if password hashing is in use
         if ($this->hashAlgorithm != null) {
             $password = $this->createPasswordHash($name, $password);
             // validate the password supplied by the subclass
             $expectedPassword = $this->getUsersPassword();
         }
         // validate the password
         if ($this->validatePassword($password, $expectedPassword) === false) {
             // super.log.debug("Bad password for username="******"User '" + identity + "' authenticated, loginOk="+loginOk);
     return true;
 }