Автор: Tim Wagner (tw@appserver.io)
Наследование: implements AppserverIo\Psr\Security\Auth\Spi\LoginModuleInterface
 /**
  * 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;
 }