On Sun, 2011-03-06 at 06:49 -0800, Utopius wrote:
> I'm using HttpClient for basic and NTLM authentication. Therefore I configure
> a HttpClient with both types of credentials and based on the authentication
> challenge from the server it chooses the correct one. Now, after the
> authentication, I want to log (or show to the user) which authentication
> method was actually used but I don't have any idea how to do this. Has
> anyone any idea from where I could get the Authentication Scheme/Scope which
> was used for the connection?
>
> Thanks,
> f.
---
HttpContext localcontext = new BasicHttpContext();
HttpGet httpget = new HttpGet("http://localhost:8080/");
HttpResponse response = httpclient.execute(httpget, localcontext);
HttpEntity entity = response.getEntity();
EntityUtils.consume(entity);
AuthState targetState = (AuthState) localcontext.getAttribute(
ClientContext.TARGET_AUTH_STATE);
AuthScheme targetAuthScheme = targetState.getAuthScheme();
if (targetAuthScheme != null) {
System.out.println("Target auth scheme: " +
targetAuthScheme.getSchemeName());
}
AuthState proxyState = (AuthState) localcontext.getAttribute(
ClientContext.PROXY_AUTH_STATE);
AuthScheme proxyAuthScheme = proxyState.getAuthScheme();
if (proxyAuthScheme != null) {
System.out.println("Proxy auth scheme: " +
proxyAuthScheme.getSchemeName());
}
---
Hope this helps
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]