Non-blocking version of login() returning a CompletionStage with the token.
<p>
{@code POST /login}

@param username the username
@param password the password
@param eauth the eauth type
@return CompletionStage holding the authentication token
773028
public CompletionStage<Token> login(final String username,
            final String password, final AuthModule eauth) {
        Map<String, String> props = new LinkedHashMap<>();
        props.put("username", username);
        props.put("password", password);
        props.put("eauth", eauth.getValue());

        String payload = gson.toJson(props);

        CompletionStage<Token> result = asyncHttpClient
                .post(uri.resolve("login"), payload, JsonParser.TOKEN)
                .thenApply(r -> {
                    // They return a list of tokens here, take the first one
                    Token token = r.getResult().get(0);
                    return token;
                });

        return result;
    }
1042216
protected Account authenticate(String username, String password) {
        StandardCredentials authenticationToken = new StandardCredentials(username, password);
        Account account = securityManager.authenticate(authenticationToken);
        return account;
    }
411521
@Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        if (authentication == null) {
            return authentication;
        }
        UsernamePasswordAuthenticationToken output = null;
        if (authentication instanceof UsernamePasswordAuthenticationToken) {
            output = (UsernamePasswordAuthenticationToken) authentication;
        } else {
            output = new UsernamePasswordAuthenticationToken(authentication, authentication.getCredentials(),
                            authentication.getAuthorities());
            output.setAuthenticated(authentication.isAuthenticated());
            output.setDetails(authentication.getDetails());
        }
        return delegate.authenticate(output);
    }
451212
public void authenticateAndSignin(String username, String password) {
		logger.debug("authenticateAndSignin:" + username);

		Authentication request = new UsernamePasswordAuthenticationToken(username, password);
		Authentication result = authenticationManager.authenticate(request);
		SecurityContextHolder.getContext().setAuthentication(result);
	}
83837
private void loginUser(final String userId, final String password, final BooleanCallback callback) {
		LoginRequest request = new LoginRequest();
		request.setLogin(userId);
		request.setPassword(password);
		GwtCommand command = new GwtCommand(loginCommandName);
		command.setCommandRequest(request);
		GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<LoginResponse>() {

			public void execute(LoginResponse loginResponse) {
				if (loginResponse.getToken() == null) {
					if (callback != null) {
						callback.execute(false);
					}
					manager.fireEvent(new LoginFailureEvent(loginResponse.getErrorMessages()));
				} else {
					userToken = loginResponse.getToken();
					Authentication.this.userId = userId;
					UserDetail userDetail = GwtCommandDispatcher.getInstance().getUserDetail();
					userDetail.setUserId(loginResponse.getUserId());
					userDetail.setUserName(loginResponse.getUserName());
					userDetail.setUserOrganization(loginResponse.getUserOrganization());
					userDetail.setUserDivision(loginResponse.getUserDivision());
					userDetail.setUserLocale(loginResponse.getUserLocale());
					if (callback != null) {
						callback.execute(true);
					}
					manager.fireEvent(new LoginSuccessEvent(userToken));
				}
			}
		});
	}
121936
public Principal authenticate(String username, char password[]) 
    throws NamingException
	{
		DirContext ctx = null;
		try
		{
			String userDN = toDN(username);
			ctx = initContext(userDN, password);

			return new X500Principal(userDN);
		}
		finally
		{
			if(ctx != null)
				try{ ctx.close(); } catch(Exception e){e.printStackTrace();}
		}
	}
562892
public CouchDB auth(String username, String password) {
        return username(username).password(password);
    }
390568
public String login(String loginName, String password) throws AuthException{
    String loginResult = null;
    try{
      Debug.logVerbose("[JdonFramework] --> enter login", module);

      TargetMetaDef targetMetaDef = new POJOTargetMetaDef("authenticator",
           "com.jdon.bussinessproxy.remote.auth.Authenticator");

      Authenticator authenticator = (Authenticator) getService(targetMetaDef);
      loginResult = authenticator.login(loginName, password);
    }catch(Exception e){
      throw new AuthException(e);
    }
    return loginResult;

  }
41694
protected Http buildHttpPostUserPreAuthRequest(final String username) {
        val usersRequest = new Http(HttpMethod.POST.name(),
            duoProperties.getDuoApiHost(),
            String.format("/auth/v%s/preauth", AUTH_API_VERSION));
        usersRequest.addParam("username", username);
        return usersRequest;
    }
606506
public boolean login(final String username, final byte[] authResponse) {
        Optional<ProxyUser> user = getUser(username);
        return user.isPresent() && (Strings.isNullOrEmpty(user.get().getPassword()) || Arrays.equals(getAuthCipherBytes(user.get().getPassword()), authResponse));
    }
1171720
public Login login(String username, String password) throws Exception {
    return login(username, password, null);
  }
1097060
public void loginWithEmail(String email, String password, final SimpleLoginAuthenticatedHandler completionHandler) {
    if (!Validation.isValidEmail(email)) {
      handleInvalidEmail(completionHandler);
    }
    else if (!Validation.isValidPassword(password)) {
      handleInvalidPassword(completionHandler);
    }
    else {
      HashMap<String, String> data = new HashMap<String, String>();
      data.put("email", email);
      data.put("password", password);

      makeRequest(Constants.FIREBASE_AUTH_PASSWORD_PATH, data, new RequestHandler() {
        public void handle(FirebaseSimpleLoginError error, JSONObject data) {
          if (error != null) {
            completionHandler.authenticated(error, null);
          }
          else {
            try {
              String token = data.has("token") ? data.getString("token") : null;
              if (token == null) {
                JSONObject errorDetails = data.has("error") ? data.getJSONObject("error") : null;
                FirebaseSimpleLoginError theError = FirebaseSimpleLoginError.errorFromResponse(errorDetails);
                completionHandler.authenticated(theError, null);
              }
              else {
                JSONObject userData = data.has("user") ? data.getJSONObject("user") : null;
                if (userData == null) {
                  FirebaseSimpleLoginError theError = FirebaseSimpleLoginError.errorFromResponse(null);
                  completionHandler.authenticated(theError, null);
                }
                else {
                  attemptAuthWithToken(token, Provider.PASSWORD, userData, completionHandler);
                }
              }
            }
            catch (JSONException e) {
              e.printStackTrace();
              FirebaseSimpleLoginError theError = FirebaseSimpleLoginError.errorFromResponse(null);
              completionHandler.authenticated(theError, null);
            }
          }
        }

      });
    }
  }
225885
public T authentication(String username, String password) {
        return authentication(username, password, false);
    }
1196603
public void authenticate(String username, String password) {
		logger.debug("Authenticate:" + username);

		Authentication request = new UsernamePasswordAuthenticationToken(username, password);
		authenticationManager.authenticate(request);
	}
13523
private UsernamePasswordToken usernamePassword(ServiceRequestContext ctx, AggregatedHttpMessage req) {
        // check the Basic HTTP authentication first (https://tools.ietf.org/html/rfc7617)
        final BasicToken basicToken = AuthTokenExtractors.BASIC.apply(req.headers());
        if (basicToken != null) {
            return new UsernamePasswordToken(basicToken.username(), basicToken.password());
        }

        final MediaType mediaType = req.headers().contentType();
        if (mediaType != MediaType.FORM_DATA) {
            return throwResponse(ctx, HttpStatus.BAD_REQUEST,
                                 "The content type of a login request must be '%s'.", MediaType.FORM_DATA);
        }

        final Map<String, List<String>> parameters = new QueryStringDecoder(req.contentUtf8(),
                                                                            false).parameters();
        // assume that the grant_type is "password"
        final List<String> usernames = parameters.get("username");
        final List<String> passwords = parameters.get("password");
        if (usernames != null && passwords != null) {
            final String username = usernames.get(0);
            final String password = passwords.get(0);
            return new UsernamePasswordToken(loginNameNormalizer.apply(username), password);
        }

        return throwResponse(ctx, HttpStatus.BAD_REQUEST,
                             "A login request must contain username and password.");
    }
1167973
public void login(String username, String password) throws IOException {
        String requestUrl = RESOURCE + "/login";
        Credentials creds = new Credentials();

        creds.setPassword(password);
        creds.setUsername(username);

        ArgusResponse response = getClient().executeHttpRequest(ArgusHttpClient.RequestType.POST, requestUrl, creds);

        try {
		assertValidResponse(response, requestUrl);
	} catch (TokenExpiredException e) {
		//This should never happen
		throw new RuntimeException("This should never happen. login() method should never throw a TokenExpiredException", e);
	}
        
        Map<String, String> tokens = fromJson(response.getResult(), new TypeReference<Map<String, String>>() {});
        getClient().accessToken = tokens.get("accessToken");
        getClient().refreshToken = tokens.get("refreshToken");
    }
306126
@Path("authenticate")
    @POST
    @Produces(MediaType.APPLICATION_JSON)
    public TokenDto authenticate(@FormParam("username") String username, @FormParam("password") String password) {
        UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
        Authentication authentication = this.authManager.authenticate(authenticationToken);
        SecurityContextHolder.getContext().setAuthentication(authentication);

        return new TokenDto(TokenUtils.createToken((UserDetails) authentication.getPrincipal()));
    }