On Wed, Jun 24, 2009 at 09:45:10AM -0500, Patricia Goldweic wrote:
> I'm afraid I AM using the hostname already - as extracted with
> URL.getHost()- (my use of "mydomain" in my code below was actually
> misleading).
> Essentially, I have no trouble using the exact same code/credentials to
> communicate from server A to server B, but it fails only when communicate
> from B to itself (that is, from one servlet in B, to another servlet in B).
> -Patricia
>
I still suspect credentials cannot be found because the hostname of host B and
that of the AuthScope do not match.
Oleg
>
> > -----Original Message-----
> > From: Oleg Kalnichevski [mailto:
olegk@...]
> > Sent: Wednesday, June 24, 2009 7:47 AM
> > To: HttpClient User Discussion
> > Subject: Re: any suggestions as to what could be wrong here?
> >
> > On Mon, Jun 22, 2009 at 05:12:11PM -0500, Patricia Goldweic wrote:
> > > Hi,
> > > I've (very) recently started using httpclient (3.1) in my Java app.
> > > I've successfully been able to make connections from a
> > program running
> > > on server A to another program (servlet) running on server
> > B, where B
> > > uses Tomcat as the servlet container, and DIGEST authentication is
> > > used to authenticate between A and B.
> > > Now, here is the problem: within server B, I need to make
> > another http
> > > request to a different servlet running also on B, in the same web
> > > application as A. I used exactly the same code to create the
> > > Httpclient instance, set credentials, and execute a GetMethod that
> > > does what I need on that second servlet on B, that what
> > I've used for
> > > connections between A and B.
> > > However, when this new httpclient connection is created and
> > run within
> > > B, I get a 'No credentials available for DIGEST: '<REALM
> > NAME>&<DOMAIN NAME>'.
> > > One thing to note (perhaps): on the web application on B, the http
> > > client instances are created within a background thread
> > that is part
> > > of the web application.
> > >
> > > Does anybody have any suggestions as to what could be causing this
> > > credentials issue? (BTW, I'm printing out my own debugging
> > statements
> > > when I set the credentials in the httpclient instance, right before
> > > the call to executeMethod).
> > > My code is as follows:
> > >
> > > private HttpClient getHttpClient() {
> > > HttpClient client = new HttpClient();
> > > List<String> authPrefs = new ArrayList<String>(1);
> > > authPrefs.add(AuthPolicy.DIGEST);
> > > client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
> > > authPrefs);
> > > client.getState().setCredentials(new AuthScope("mydomain", -1,
> >
> > Patricia,
> >
> > The first parameter of AuthScope is expected to be a
> > hostname, not a domain name.
> >
> > Hope this helps
> >
> > Oleg
> >
> >
> > > "myrealm"), new UsernamePasswordCredentials("myaccount",
> > "mypassword")));
> > > return client;
> > > }
> > >
> > > And I'm using it as follows :
> > >
> > > HttpClient client = getHttpClient();
> > > GetMethod get = new GetMethod("someurlWithinB");
> > > get.setDoAuthentication(true); int responseCode = 0; String
> > > responseString = null; try {
> > > responseCode = client.executeMethod(get);
> > > ... (here I check the response code and find '401' )
> > > } catch (Exception)
> > > ...
> > > }
> > >
> > >
> > > -Patricia
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
httpclient-users-unsubscribe@...
> > For additional commands, e-mail:
httpclient-users-help@...
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
httpclient-users-unsubscribe@...
> For additional commands, e-mail:
httpclient-users-help@...
>
---------------------------------------------------------------------
To unsubscribe, e-mail:
httpclient-users-unsubscribe@...
For additional commands, e-mail:
httpclient-users-help@...