[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Kalnichevski resolved HTTPCLIENT-1364.
-------------------------------------------

    Resolution: Fixed

Dave
I added default (no arg) constructor to NTLMScheme. All AuthScheme 
implementations should now be consistent. Please review.

Oleg
                
> Consider reorganizing authentication schemes
> --------------------------------------------
>
>                 Key: HTTPCLIENT-1364
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1364
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>    Affects Versions: 4.3 Beta1
>         Environment: Fedora 15 java 1.6.0_30
>            Reporter: Dave Godbey
>            Priority: Minor
>
> The attached code is closely based on the 
> ClientPreemptiveDigestAuthentication example class. Compare this class to my 
> own code below that using NTLMv2 authentication.
> Notice the following between the two code sets: You cannot instantiate an 
> NTLMScheme object like you can a DigestScheme object, you need to go directly 
> to an AuthScheme through the NTLMSchmeFactory. And the NTLMSchemeFactory does 
> not have a getNTLMScheme method, just a method that returns an AuthScheme 
> object. I don't see any way of actually handling an NTLMScheme object. Or 
> perhaps you meant to hide the DigestScheme object behind a factory? I suppose 
> not a big deal, but maybe something you want to consider. Should all the 
> authentication schemes behave similarly?
> See code below:
>     private String getSoapReponse() {
>         String retStr = null;
>         CloseableHttpClient httpclient = null;
>         try {
>             String localIp = Inet4Address.getLocalHost().getHostAddress();
>             HttpHost targetHost = new HttpHost(_host, 443, "https");
>             CredentialsProvider credsProvider = new 
> BasicCredentialsProvider();
>             credsProvider.setCredentials(new AuthScope(targetHost), new 
> NTCredentials(_user, _password, localIp, _domain));
>             httpclient = 
> HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
> // Create AuthCache instance
>             AuthCache authCache = new BasicAuthCache();
> // NTLM-based AuthScheme
>             NTLMSchemeFactory f = new NTLMSchemeFactory();
>             HttpContext ctx = new BasicHttpContext();
>             AuthScheme ns = f.create(ctx);
>             authCache.put(targetHost, ns);
> // Add AuthCache to the execution context
>             HttpClientContext localContext = HttpClientContext.create();
>             localContext.setAuthCache(authCache);
>             HttpGet http = new HttpGet(_serviceEndpoint);
>             System.out.println("executing request: " + http.getRequestLine());
>             System.out.println("to target: " + targetHost);
>             CloseableHttpResponse response = httpclient.execute(targetHost, 
> http, localContext);
>             try {
>                 HttpEntity entity = response.getEntity();
>                 
> System.out.println("----------------------------------------");
>                 System.out.println(response.getStatusLine());
>                 if (entity != null) {
>                     System.out.println("Response content length: " + 
> entity.getContentLength());
>                     retStr = EntityUtils.toString(entity);
>                 }
>                 EntityUtils.consume(entity);
>             } finally {
>                 response.close();
>             }
>         } catch (Exception e) {
>             throw new RuntimeException(e);
>         } finally {
>             try {
>                 if (httpclient != null)
>                     httpclient.close();
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>         }
>         return retStr;
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to