dev@jax-ws.java.net

Re: Using HTTPClient as a transport

From: Jitendra Kotamraju <Jitendra.Kotamraju_at_Sun.COM>
Date: Fri, 27 Jun 2008 18:12:28 -0700

I have never tried digest authentication. Since metro use
HttpURLConnection, whatever methods supported by JDK can be used.
So Authenticator should work. You could write a small code to try with
HttpURLConnection and see if that works.

Jitu

GlennS wrote:
> I am also attempting to use Metro to communicate with a web-service that
> supports HTTP Digest authentication. I have successfully used "Basic" HTTP
> authentication by setting the user and password on the binding provider of
> the web-service port , e.g.
>
> bp.getRequestContext().put(javax.xml.ws.BindingProvider.USERNAME_PROPERTY,
> "anonymous");
> bp.getRequestContext().put(javax.xml.ws.BindingProvider.PASSWORD_PROPERTY,
> "guest");
>
> There does not appear a method, however, for enabling digest authentication
> and setting the authentication realm. I've also attempted using a custom
> Authenticator class and overriding the getPasswordAuthentication() method to
> return the user/password information but from what I understand, this really
> only applies when the client is attempting to contact a web-service through
> an HTTP proxy (which is not what I'm trying to do with the Digest
> authentication mechanism).
>
> Finally, I tried setting the following system properties to "true":
>
> Properties sysProps = System.getProperties();
> sysProps.put("http.auth.digest.validateServer", "true");
> sysProps.put("http.auth.digest.validateProxy", "true");
>
> java.security.Security.setProperty("http.auth.digest.validateServer",
> "true");
> java.security.Security.setProperty("http.auth.digest.validateProxy",
> "true");
>
> Still, I don't seem to be able to get Metro to encode the HTTP Digest
> authentication information in the header. Has anyone been able to get this
> to work with Metro? It doesn't seem to currently support this form of
> authentication.
>
> Any suggestions would be appreciated. . .
>
>
>
> jJitendra Kotamraju wrote:
>
>> Barrie Selack wrote:
>>
>>> To authenticate against a digest-authentication web service, I’ve
>>> found the only way is using HTTPClient 3.
>>>
>>> 1) Is there a way to tell Metro to use HTTPClient as the HTTP
>>> transport instead of the default?
>>>
>>>
>> It is possible since transport is pluggable. But we need to write some
>> code using HTTPClient.
>>
>>> 2) Or is there a way to have the default do digest-authentication
>>>
>>>
>> Just use default JDK mechanism. So something like the following should
>> work for digest authentication.
>> http://java.sun.com/javase/6/docs/technotes/guides/net/http-auth.html
>> http://java.sun.com/javase/6/docs/technotes/guides/net/properties.html
>>
>> [code]
>>
>> public class RunHttp {
>>
>> static class MyAuthenticator extends Authenticator {
>> static final String kuser = "username"; // your account name
>> static final String kpass = "password"; // your password for the
>> account
>>
>> public PasswordAuthentication getPasswordAuthentication() {
>>
>> System.err.println("Feeding username and password for " +
>> getRequestingScheme());
>> return (new PasswordAuthentication(kuser,
>> kpass.toCharArray()));
>> }
>> }
>>
>> public static void main(String[] args) throws Exception {
>> Authenticator.setDefault(new MyAuthenticator());
>> ...
>> Hello proxy = new HelloService.getHelloPort();
>> proxy.echo();
>>
>> [/code]
>>
>>
>> Jitu
>>
>>> Thanks,
>>>
>>> Barrie
>>>
>>>
>>> ------------------------------------------------------------------------
>>> Disclaimer: This e-mail message is intended only for the personal use of
>>> the recipient(s) named above. If you are not an intended recipient, you
>>> may not review, copy or distribute this message. If you have received
>>> this
>>> communication in error, please notify us immediately by e-mail and delete
>>> the original message.
>>>
>>> This e-mail expresses views only of the sender, which are not to be
>>> attributed to Rite Aid Corporation and may not be copied or distributed
>>> without this statement.
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jax-ws.dev.java.net
>> For additional commands, e-mail: dev-help_at_jax-ws.dev.java.net
>>
>>
>>
>>
>
>