Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RequestConfig requestConfig = RequestConfig.custom()
- .setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC))
- .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.DIGEST))
- .build();
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- HttpClientContext localContext = HttpClientContext.create();
- HttpGet httpget = new HttpGet("http://localhost/");
- CloseableHttpResponse response = httpclient.execute(httpget, localContext);
- try {
- System.out.println(response.getStatusLine());
- EntityUtils.consume(response.getEntity());
- AuthState targetAuthState = localContext.getTargetAuthState();
- if (targetAuthState.getAuthScheme() != null) {
- System.out.println("Target auth scheme: " +
- targetAuthState.getAuthScheme().getSchemeName());
- }
- AuthState proxyAuthState = localContext.getProxyAuthState();
- if (proxyAuthState.getAuthScheme() != null) {
- System.out.println("Proxy auth scheme: " +
- proxyAuthState.getAuthScheme().getSchemeName());
- }
- } finally {
- response.close();
- }
- } finally {
- httpclient.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement