code: public boolean login() throws LoginException {
      NameCallback user = new NameCallback("Login:");
      PasswordCallback pass = new PasswordCallback("Password:", false);
      PasswordEncryptionService enc = new PasswordEncryptionService();
  
      try {
        callback(user, pass);
  
        BufferedReader reader = new BufferedReader(new FileReader(passwordFile));
  
        while (reader.ready()) {
          String[] fields = reader.readLine().split(":");
          if (fields[0].equals(user.getName())) {
            String loginPassword = new String(pass.getPassword());
            byte[] salt = StringUtil.hexToByteArray(fields[2]);
            byte[] realDigest = StringUtil.hexToByteArray(fields[1]);
            if (enc.authenticate(loginPassword, realDigest, salt)) {
              addPrincipal(new UserPrincipal(fields[0]));
              for (int i = 3; i < fields.length; i++) {
                addPrincipal(new RolePrincipal(fields[i]));
              }
              return true;
            }
            break;
          }
        }
      } catch (FileNotFoundException e) {
        throw new RuntimeException(e);
      } catch (IOException e) {
        /* nothing to do. */
      } catch (UnsupportedCallbackException e) {
        /* nothing to do. */
      }
  
      throw new FailedLoginException();
    }
docs: /* (non-Javadoc)
  @see javax.security.auth.spi.LoginModule#login()