Authenticates the user.

@param username the username
@param password the password
@return the default page if the authentication succeed, the login page otherwise.
430849
@Route(method = HttpMethod.POST, uri = "/monitor/login")
    public Result authenticate(@FormParameter("username") String username, @FormParameter("password") String password) {
        if (!configuration.getBooleanWithDefault("monitor.auth.enabled", true)) {
            // If the authentication is disabled, just jump to the dashboard page.
            return dashboard();
        }

        final String name = configuration.getOrDie("monitor.auth.username");
        final String pwd = configuration.getOrDie("monitor.auth.password");

        if (name.equals(username) && pwd.equals(password)) {
            session().put("wisdom.monitor.username", username);
            logger().info("Authentication successful - {}", username);
            return dashboard();
        } else {
            logger().info("Authentication failed - {}", username);
            context().flash().error("Authentication failed - check your credentials");
            return login();
        }
    }
780048
public TokenResult prepareLogin(String username) throws Exception {
    username = encode(username);
    Api apiResult = null;
    TokenResult token = new TokenResult();
    token.tokenName = "lgtoken";
    token.tokenMode = TokenMode.token1_19;
    // see https://github.com/WolfgangFahl/Mediawiki-Japi/issues/31
    if (this.isVersion128()) {
      apiResult = this.getQueryResult("&meta=tokens&type=login");
      super.handleError(apiResult);
      token.token = apiResult.getQuery().getTokens().getLogintoken();
    } else {
      apiResult = getActionResult("login", "&lgname=" + username, null, null);
      super.handleError(apiResult);
      Login login = apiResult.getLogin();
      token.token = login.getToken();
    }
    return token;
  }
1045840
public String encodeAuthAmqPlain(String username, String password)
    {

        AmqpBuffer bytes = new AmqpBuffer();       
        bytes.putShortString("LOGIN");
        bytes.putTypeIdentifier("Longstr");
        bytes.putLongString(username);

        bytes.putShortString("PASSWORD");
        bytes.putTypeIdentifier("Longstr");
        bytes.putLongString(password);
        bytes.flip();

        int len = bytes.remaining();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < len; i++)
        {
            builder.append((char)(bytes.getUnsigned()));
        }
        String s = builder.toString();
        return s;
    }
568300
public login login(String username, String password) throws Exception
	{
		this.set_credential(username, password);
		return this.login();
	}
1197142
public T authentication(String username, String password, boolean allowAnyHost) {
        if (StringUtils.isNotBlank(username)) {
            if (defaultHost == null || StringUtils.isBlank(defaultHost.getHostName())) {
                throw new IllegalStateException("Cannot configure authentication when host is not set.");
            }
            AuthScope authscope = allowAnyHost ?
                    new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM) :
                    new AuthScope(defaultHost.getHostName(), AuthScope.ANY_PORT, AuthScope.ANY_REALM);
            credsProvider.setCredentials(authscope, new UsernamePasswordCredentials(username, password));
        }
        return self();
    }
1284262
public function authenticateUser($username, $password)
    {
        try
        {
            return $this->httpHelper->post("customer_portal/auth", ['username' => $username, 'password' => $password]);
        }
        catch (ApiException $e)
        {
            throw new AuthenticationException($e->getMessage());
        }
    }
1157341
public Credentials toCredentials(String username, String password) {
	return CredentialsImpl.toCredentials(username, password);
    }
578454
@SuppressWarnings("unused")
    public void setSmtpAuth(String userName, String password) {
        setSmtpUsername(userName);
        setSmtpPassword(password);
    }
1301684
@Override
    public Principal authenticate(String username, String credentials) {
        GenericPrincipal principal = (GenericPrincipal) getPrincipal(username);
        if (null != principal) {
            try {
                if (!PasswordStorage.verifyPassword(credentials, principal.getPassword())) {
                    principal = null;
                }
            } catch (CannotPerformOperationException | InvalidHashException e) {
                LOGR.log(Level.WARNING, e.getMessage());
                principal = null;
            }
        }
        return principal;
    }
153420
@Override
    public void login(String username, String password)
            throws ServletException {
        this._getHttpServletRequest().login(username,password);
    }
57934
public static final HttpClientAuthProvider forUser(final String login, final String password)
    {
        return new HttpClientDefaultAuthProvider(null, null, -1, null, login, password);
    }
1087554
public String login(Authentication authentication) {
		String token = getToken();
		return login(token, authentication);
	}
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;

  }
592296
private static String generateBase64Authentication(String username, String password) {
    requireNonNull(username, password);
    String userPass = username + ":" + password;
    String userPassBase64 = Base64.getEncoder().encodeToString(userPass.getBytes(UTF_8));
    return "Basic " + userPassBase64;
  }
837237
def authenticate(self, username, password):
        

        r = self._query_('/users/authenticate', 'POST',
                         params={'username': username,
                                 'password': password})
        if r.status_code == 201:
            return r.text.strip('"')
        else:
            raise ValueError('Authentication invalid.')
632479
public static String encodeBasicAuth(final String username, final String password) {
        requireNonNull(username, "username");
        requireNonNull(password, "password");
        final String auth = username + ':' + password;
        byte[] encoded;
        try {
            encoded = Base64.getEncoder().encode(auth.getBytes(UTF_8));
        } catch (final IllegalArgumentException e) {
            throw new IllegalArgumentException("Failed to encode basic authentication token", e);
        }
        return BASIC_AUTH_PREFIX + new String(encoded, UTF_8);
    }
20553
public static AuthInfo typical(String username, String password) {
    return new AuthInfo(new PlainCallbackHandler(username, password),
        new String[] {"CRAM-MD5", "PLAIN"});
  }