Search in sources :

Example 21 with Credentials

use of org.apache.hc.client5.http.auth.Credentials in project wildfly-clustering-spring-session by wildfly-clustering.

the class AuthSmokeITCase method createClient.

private static CloseableHttpClient createClient(URL url1, URL url2) {
    CredentialsStore provider = new BasicCredentialsProvider();
    Credentials credentials = new UsernamePasswordCredentials("admin", "password".toCharArray());
    provider.setCredentials(new AuthScope(url1.getHost(), url1.getPort()), credentials);
    provider.setCredentials(new AuthScope(url2.getHost(), url2.getPort()), credentials);
    return HttpClients.custom().setDefaultCredentialsProvider(provider).build();
}
Also used : BasicCredentialsProvider(org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider) CredentialsStore(org.apache.hc.client5.http.auth.CredentialsStore) AuthScope(org.apache.hc.client5.http.auth.AuthScope) Credentials(org.apache.hc.client5.http.auth.Credentials) UsernamePasswordCredentials(org.apache.hc.client5.http.auth.UsernamePasswordCredentials) UsernamePasswordCredentials(org.apache.hc.client5.http.auth.UsernamePasswordCredentials)

Example 22 with Credentials

use of org.apache.hc.client5.http.auth.Credentials in project wildfly-clustering-spring-session by wildfly-clustering.

the class AuthSmokeITCase method createClient.

private static CloseableHttpClient createClient(URL url1, URL url2) {
    CredentialsStore provider = new BasicCredentialsProvider();
    Credentials credentials = new UsernamePasswordCredentials("admin", "password".toCharArray());
    provider.setCredentials(new AuthScope(url1.getHost(), url1.getPort()), credentials);
    provider.setCredentials(new AuthScope(url2.getHost(), url2.getPort()), credentials);
    return HttpClients.custom().setDefaultCredentialsProvider(provider).build();
}
Also used : BasicCredentialsProvider(org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider) CredentialsStore(org.apache.hc.client5.http.auth.CredentialsStore) AuthScope(org.apache.hc.client5.http.auth.AuthScope) Credentials(org.apache.hc.client5.http.auth.Credentials) UsernamePasswordCredentials(org.apache.hc.client5.http.auth.UsernamePasswordCredentials) UsernamePasswordCredentials(org.apache.hc.client5.http.auth.UsernamePasswordCredentials)

Aggregations

UsernamePasswordCredentials (org.apache.hc.client5.http.auth.UsernamePasswordCredentials)13 AuthScope (org.apache.hc.client5.http.auth.AuthScope)8 Credentials (org.apache.hc.client5.http.auth.Credentials)8 BasicCredentialsProvider (org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider)6 IOException (java.io.IOException)5 HttpGet (org.apache.hc.client5.http.classic.methods.HttpGet)5 RequestConfig (org.apache.hc.client5.http.config.RequestConfig)5 CloseableHttpClient (org.apache.hc.client5.http.impl.classic.CloseableHttpClient)5 CloseableHttpResponse (org.apache.hc.client5.http.impl.classic.CloseableHttpResponse)5 NTCredentials (org.apache.hc.client5.http.auth.NTCredentials)4 HttpHost (org.apache.hc.core5.http.HttpHost)4 CredentialsStore (org.apache.hc.client5.http.auth.CredentialsStore)3 HttpEntity (org.apache.hc.core5.http.HttpEntity)3 AltiriaGwException (com.altiria.app.exception.AltiriaGwException)2 ConnectionException (com.altiria.app.exception.ConnectionException)2 GeneralAltiriaException (com.altiria.app.exception.GeneralAltiriaException)2 JsonException (com.altiria.app.exception.JsonException)2 JsonObject (com.google.gson.JsonObject)2 TypeToken (com.google.gson.reflect.TypeToken)2 SocketTimeoutException (java.net.SocketTimeoutException)2