Package com.google.gerrit.common.auth.userpass

Examples of com.google.gerrit.common.auth.userpass.LoginResult


  }

  @Override
  public void authenticate(String username, final String password,
      final AsyncCallback<LoginResult> callback) {
    LoginResult result = new LoginResult(authType);
    if (username == null || "".equals(username.trim()) //
        || password == null || "".equals(password)) {
      result.setError(LoginResult.Error.INVALID_LOGIN);
      callback.onSuccess(result);
      return;
    }

    username = username.trim();

    final AuthRequest req = AuthRequest.forUser(username);
    req.setPassword(password);

    final AuthResult res;
    try {
      res = accountManager.authenticate(req);
    } catch (AccountUserNameException e) {
      // entered user name and password were correct, but user name could not be
      // set for the newly created account and this is why the login fails,
      // error screen with error message should be shown to the user
      callback.onFailure(e);
      return;
    } catch (AuthenticationUnavailableException e) {
      result.setError(LoginResult.Error.AUTHENTICATION_UNAVAILABLE);
      callback.onSuccess(result);
      return;
    } catch (AccountException e) {
      log.info(String.format("'%s' failed to sign in: %s", username, e.getMessage()));
      result.setError(LoginResult.Error.INVALID_LOGIN);
      callback.onSuccess(result);
      return;
    }

    result.success = true;
View Full Code Here

TOP

Related Classes of com.google.gerrit.common.auth.userpass.LoginResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.