use of org.apache.knox.gateway.dispatch.KnoxSpnegoAuthSchemeFactory in project knox by apache.
the class BaseZookeeperURLManager method buildHttpClient.
/**
* Construct an Apache HttpClient with suitable timeout and authentication.
*
* @return Apache HttpClient
*/
private CloseableHttpClient buildHttpClient() {
CloseableHttpClient client;
// Construct a HttpClient with short term timeout
RequestConfig.Builder requestBuilder = RequestConfig.custom().setConnectTimeout(TIMEOUT).setSocketTimeout(TIMEOUT).setConnectionRequestTimeout(TIMEOUT);
// If Kerberos is enabled, allow for challenge/response transparent to client
if (Boolean.getBoolean(GatewayConfig.HADOOP_KERBEROS_SECURED)) {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new NullCredentials());
Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create().register(AuthSchemes.SPNEGO, new KnoxSpnegoAuthSchemeFactory(true)).build();
client = HttpClientBuilder.create().setDefaultRequestConfig(requestBuilder.build()).setDefaultAuthSchemeRegistry(authSchemeRegistry).setDefaultCredentialsProvider(credentialsProvider).build();
} else {
client = HttpClientBuilder.create().setDefaultRequestConfig(requestBuilder.build()).build();
}
return client;
}
Aggregations