use of com.iwave.ext.windows.winrm.encryption.EncryptedHttpRequestExecutor in project coprhd-controller by CoprHD.
the class WinRMTarget method createHttpClient.
/**
* HttpClient builder
* @return HttpClient
* @throws HttpException
*/
protected CloseableHttpClient createHttpClient() throws HttpException {
HttpClientBuilder httpClient = HttpClientBuilder.create();
// Build the request config identifying the target preferred authentication schemes and other socket connection parameters.
RequestConfig.Builder requestConfig = RequestConfig.custom().setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.SPNEGO, AuthSchemes.NTLM, AuthSchemes.DIGEST, AuthSchemes.BASIC));
requestConfig.setConnectTimeout(DEFAULT_CONNECTION_TIMEOUT);
requestConfig.setSocketTimeout(DEFAULT_CONNECTION_TIMEOUT);
httpClient.setDefaultRequestConfig(requestConfig.build());
// Set the request executor. The EncryptedHttpRequestExecutor is a custom request executor that is capable of encryption and works
// using the Windows NTLM authentication scheme.
httpClient.setRequestExecutor(new EncryptedHttpRequestExecutor());
// Build a list of the authentication schemes
Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create().register(AuthSchemes.NTLM, new NTLMSchemeFactory()).register(AuthSchemes.BASIC, new BasicSchemeFactory()).register(AuthSchemes.DIGEST, new DigestSchemeFactory()).register(AuthSchemes.KERBEROS, new KerberosSchemeFactory()).register(AuthSchemes.SPNEGO, new CustomSPNegoSchemeFactory()).build();
try {
httpClient.setConnectionManager(createClientConnectionManager());
} catch (Exception e) {
throw new HttpException(e.getMessage());
}
httpClient.setDefaultAuthSchemeRegistry(authSchemeRegistry);
return httpClient.build();
}
Aggregations