Search in sources :

Example 1 with SPNegoScheme

use of org.apache.http.impl.auth.SPNegoScheme in project hadoop by apache.

the class AuthenticatorTestCase method getHttpClient.

private HttpClient getHttpClient() {
    HttpClientBuilder builder = HttpClientBuilder.create();
    // Register auth schema
    builder.setDefaultAuthSchemeRegistry(s -> httpContext -> new SPNegoScheme(true, true));
    Credentials useJaasCreds = new Credentials() {

        public String getPassword() {
            return null;
        }

        public Principal getUserPrincipal() {
            return null;
        }
    };
    CredentialsProvider jaasCredentialProvider = new BasicCredentialsProvider();
    jaasCredentialProvider.setCredentials(AuthScope.ANY, useJaasCreds);
    // Set credential provider
    builder.setDefaultCredentialsProvider(jaasCredentialProvider);
    return builder.build();
}
Also used : SPNegoScheme(org.apache.http.impl.auth.SPNegoScheme) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) Credentials(org.apache.http.auth.Credentials)

Aggregations

Credentials (org.apache.http.auth.Credentials)1 CredentialsProvider (org.apache.http.client.CredentialsProvider)1 SPNegoScheme (org.apache.http.impl.auth.SPNegoScheme)1 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)1 HttpClientBuilder (org.apache.http.impl.client.HttpClientBuilder)1