use of org.apache.hc.client5.http.auth.CredentialsStore in project geo-platform by geosdi.
the class AbstractSecurityConnector method bindCredentials.
/**
* Bind Credentials for {@link CredentialsStore} class
*
* @param credentialsStore
* @param targetURI
*/
protected void bindCredentials(@Nonnull(when = NEVER) CredentialsStore credentialsStore, @Nonnull(when = NEVER) URI targetURI) {
checkArgument(credentialsStore != null, "The Parameter credentialsProvider must not be null.");
checkArgument(targetURI != null, "The Parameter targetURI must not be null.");
if (this.authScope == null) {
this.authScope = new AuthScope(targetURI.getHost(), targetURI.getPort());
}
credentialsStore.setCredentials(authScope, this.usernamePasswordCredentials);
}
use of org.apache.hc.client5.http.auth.CredentialsStore in project gradle-download-task by michel-kraemer.
the class DownloadAction method addAuthentication.
/**
* Add authentication information for the given host
* @param host the host
* @param credentials the credentials
* @param context the context in which the authentication information
* should be saved
*/
private void addAuthentication(HttpHost host, Credentials credentials, HttpClientContext context) {
AuthCache authCache = context.getAuthCache();
if (authCache == null) {
authCache = new BasicAuthCache();
context.setAuthCache(authCache);
}
CredentialsProvider credsProvider = context.getCredentialsProvider();
if (credsProvider == null) {
credsProvider = new BasicCredentialsProvider();
context.setCredentialsProvider(credsProvider);
}
((CredentialsStore) credsProvider).setCredentials(new AuthScope(host), credentials);
}
use of org.apache.hc.client5.http.auth.CredentialsStore 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();
}
use of org.apache.hc.client5.http.auth.CredentialsStore 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();
}
Aggregations