[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Using Jetty http client with basic authentication
|
Jesse,
Well, I still have a little problem.
Although I have set a SimpleRealmResolver:
HttpClient httpClient = new HttpClient();
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
httpClient.setRealmResolver(new SimpleRealmResolver(new Realm() {
public String getId() {
return "realm";
}
public String getPrincipal() {
return deviceUsername;
}
public String getCredentials() {
return deviceUserpassword;
}
}));
}
httpClient.start();
the first time, I send my httpExchange, there is no Authorization header added to my POST request and the server rejects my request (I see that the HttpClient retries with the Authorization header however but the server does not answer). The next time I send the request the Authorization header is added and it succeeds.
Here is the capture (request 1 fails, is retried but gets no answer), request 2 succeeds):
---- request 1 ---------
POST /titi HTTP/1.1
Content-Type: text/xml
Host: 192.168.0.31
Content-Length: 377
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope... the content... </SOAP-ENV:Envelope>
------ response 1 ----
HTTP/1.1 401 Unauthorized
Www-Authenticate: Basic REALM="realm"
Content-Type: text/plain
Content-Length: 22
Unauthorized request
------ resending of Httpclient -------
POST /titi HTTP/1.1
Content-Type: text/xml
Host: 192.168.0.31
Content-Length: 377
Authorization: Basic dXNlcjoxMjM0
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope ... the content...</SOAP-ENV:Envelope>
------- request 2 -----------
POST /titi HTTP/1.1
Content-Type: text/xml
Authorization: Basic dXNlcjoxMjM0
Host: 192.168.0.31
Content-Length: 377
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope ... the content...</SOAP-ENV:Envelope>
And this time it succeeds:
HTTP/1.1 200 Ok
Server: snom embedded
Cache-Control: no-cache
Content-Type: text/xml
Content-Length: 308
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope ... the response ... </SOAP-ENV:Envelope>
Maybe is the server not behaving correctly but I would like to know if there is a way to force the Authorization header on the first try.
Thanks,
Bruno
> -----Message d'origine-----
> De : jetty-users-bounces@xxxxxxxxxxx [mailto:jetty-users-bounces@xxxxxxxxxxx]
> De la part de Jesse McConnell
> Envoyé : mardi 28 septembre 2010 16:16
> À : JETTY user mailing list
> Objet : Re: [jetty-users] Using Jetty http client with basic authentication
>
> no problem, it can be a bit difficult but I like its flexibility in the long
> run :)
>
> jesse
>
> --
> jesse mcconnell
> jesse.mcconnell@xxxxxxxxx
>
>
>
> On Tue, Sep 28, 2010 at 08:55, Bruno.Konik <bruno.konik@xxxxxxxxxxx> wrote:
> > I see, thanks again.
> > Cheers,
> >
> > bruno
> >
> >> -----Message d'origine-----
> >> De : jetty-users-bounces@xxxxxxxxxxx
> >> [mailto:jetty-users-bounces@xxxxxxxxxxx]
> >> De la part de Jesse McConnell
> >> Envoyé : mardi 28 septembre 2010 15:49 À : JETTY user mailing list
> >> Objet : Re: [jetty-users] Using Jetty http client with basic
> >> authentication
> >>
> >> typically something like a username
> >>
> >> cheers,
> >> jesse
> >>
> >> --
> >> jesse mcconnell
> >> jesse.mcconnell@xxxxxxxxx
> >>
> >>
> >>
> >> On Tue, Sep 28, 2010 at 08:42, Bruno.Konik <bruno.konik@xxxxxxxxxxx>
> wrote:
> >> > Jesse,
> >> >
> >> > Maybe a little help from you again: what is the Principal in the
> >> > Realm
> >> class?
> >> >
> >> > Bruno
> >> >
> >> >> -----Message d'origine-----
> >> >> De : jetty-users-bounces@xxxxxxxxxxx [mailto:jetty-users-
> >> bounces@xxxxxxxxxxx]
> >> >> De la part de Jesse McConnell
> >> >> Envoyé : mardi 28 septembre 2010 15:36 À : JETTY user mailing list
> >> >> Objet : Re: [jetty-users] Using Jetty http client with basic
> >> authentication
> >> >>
> >> >> good deal!
> >> >>
> >> >> cheers,
> >> >> jesse
> >> >>
> >> >> --
> >> >> jesse mcconnell
> >> >> jesse.mcconnell@xxxxxxxxx
> >> >>
> >> >>
> >> >>
> >> >> On Tue, Sep 28, 2010 at 08:27, Bruno.Konik
> >> >> <bruno.konik@xxxxxxxxxxx>
> >> wrote:
> >> >> > Sorry Jesse, I have found them. I thank you much.
> >> >> > Cheers,
> >> >> > Bruno
> >> >> >
> >> >> >> -----Message d'origine-----
> >> >> >> De : jetty-users-bounces@xxxxxxxxxxx
> >> >> > [mailto:jetty-users-bounces@xxxxxxxxxxx]
> >> >> >> De la part de Jesse McConnell
> >> >> >> Envoyé : mardi 28 septembre 2010 15:02 À : JETTY user mailing
> >> >> >> list Objet : Re: [jetty-users] Using Jetty http client with
> >> >> >> basic
> >> >> > authentication
> >> >> >>
> >> >> >>
> >> >> >> there are some examples with the unit tests for jetty-client
> >> >> >> that should get you going
> >> >> >>
> >> >> >> cheers,
> >> >> >> jesse
> >> >> >>
> >> >> >> --
> >> >> >> jesse mcconnell
> >> >> >> jesse.mcconnell@xxxxxxxxx
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> On Tue, Sep 28, 2010 at 02:52, Bruno.Konik
> >> >> >> <bruno.konik@xxxxxxxxxxx>
> >> >> > wrote:
> >> >> >> > Hello,
> >> >> >> >
> >> >> >> > Could someone provide a simple example showing how to use the
> >> >> >> > Jetty
> >> >> >> HttpClient with a basic (username/password) authentication. I
> >> >> >> have read
> >> >> > the
> >> >> >> tutorial http://wiki.eclipse.org/Jetty/Tutorial/HttpClient but
> >> >> >> the authentication is not explained.
> >> >> >> >
> >> >> >> > Thanks a lot.
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > _______________________________________________
> >> >> >> > jetty-users mailing list
> >> >> >> > jetty-users@xxxxxxxxxxx
> >> >> >> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >> >> >> >
> >> >> >> _______________________________________________
> >> >> >> jetty-users mailing list
> >> >> >> jetty-users@xxxxxxxxxxx
> >> >> >> https://dev.eclipse.org/mailman/listinfo/jetty-users
> >> >> >>
> >> >> >>
> >> >> > ----------------------------------------------------------------
> >> >> > --------
> >> ---
> >> >> -
> >> >> > -
> >> >> >> ----------
> >> >> >> Orange vous informe que cet e-mail a ete controle par
> >> >> >> l'anti-virus
> >> mail.
> >> >> >> Aucun virus connu a ce jour par nos services n'a ete detecte.
> >> >> >
> >> >> >
> >> >> > _______________________________________________
> >> >> > jetty-users mailing list
> >> >> > jetty-users@xxxxxxxxxxx
> >> >> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >> >> >
> >> >> _______________________________________________
> >> >> jetty-users mailing list
> >> >> jetty-users@xxxxxxxxxxx
> >> >> https://dev.eclipse.org/mailman/listinfo/jetty-users
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > jetty-users mailing list
> >> > jetty-users@xxxxxxxxxxx
> >> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >> >
> >> _______________________________________________
> >> jetty-users mailing list
> >> jetty-users@xxxxxxxxxxx
> >> https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
> >
> >
> > _______________________________________________
> > jetty-users mailing list
> > jetty-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users