Search in sources :

Example 1 with UsernamePasswordCredentials

use of cz.msebera.android.httpclient.auth.UsernamePasswordCredentials in project android-async-http by loopj.

the class DigestAuthSample method setCredentials.

private void setCredentials(AsyncHttpClient client, String URL) {
    Uri parsed = Uri.parse(URL);
    client.clearCredentialsProvider();
    client.setCredentials(new AuthScope(parsed.getHost(), parsed.getPort() == -1 ? 80 : parsed.getPort()), new UsernamePasswordCredentials(usernameField.getText().toString(), passwordField.getText().toString()));
}
Also used : AuthScope(cz.msebera.android.httpclient.auth.AuthScope) Uri(android.net.Uri) UsernamePasswordCredentials(cz.msebera.android.httpclient.auth.UsernamePasswordCredentials)

Example 2 with UsernamePasswordCredentials

use of cz.msebera.android.httpclient.auth.UsernamePasswordCredentials in project android-async-http by loopj.

the class AsyncHttpClient method setBasicAuth.

/**
     * Sets basic authentication for the request. You should pass in your AuthScope for security. It
     * should be like this setBasicAuth("username","password", new AuthScope("host",port,AuthScope.ANY_REALM))
     *
     * @param username   Basic Auth username
     * @param password   Basic Auth password
     * @param scope      an AuthScope object
     * @param preemptive sets authorization in preemptive manner
     */
public void setBasicAuth(String username, String password, AuthScope scope, boolean preemptive) {
    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
    setCredentials(scope, credentials);
    setAuthenticationPreemptive(preemptive);
}
Also used : UsernamePasswordCredentials(cz.msebera.android.httpclient.auth.UsernamePasswordCredentials)

Aggregations

UsernamePasswordCredentials (cz.msebera.android.httpclient.auth.UsernamePasswordCredentials)2 Uri (android.net.Uri)1 AuthScope (cz.msebera.android.httpclient.auth.AuthScope)1