You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Plorks mail <pl...@hotmail.com> on 2005/08/26 15:27:52 UTC

basic authentication

hi all

i'm currntly getting username and password using basic authentication in my 
web service.

we are using a product that doesn't support basic authentaication in the 
http header, so now i have to re-write my web service.  Can anyone suggest 
an alternative way to do this?

Can i set the username and password in the SOAP Envelope/body?

Thsi is the code i'm curently using
String headerAuth = 
(String)msgContext.getProperty(HTTPConstants.HEADER_AUTHORIZATION);

if (headerAuth != null)
{
   headerAuth = headerAuth.trim();
}

if (headerAuth != null && headerAuth.startsWith("Basic "))
{
int i;

headerAuth = new String(Base64.decode(headerAuth.substring(6)));

String [] userNamePassword = headerAuth.split(":");

userName = userNamePassword[0];
password = userNamePassword[1];
}

thanks for  any help

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


Re: basic authentication

Posted by Plorks mail <pl...@hotmail.com>.

Thanks Guy

I think i'll stick to creating my own headers within the soap envelope - I'm 
still new to webservices/axis i don't really understand the wss4j

Thanks for your help


>From: Guy Rixon <gt...@ast.cam.ac.uk>
>Reply-To: axis-user@ws.apache.org
>To: axis-user@ws.apache.org
>Subject: Re: basic authentication
>Date: Fri, 26 Aug 2005 15:49:52 +0100 (BST)
>
>Hi,
>
>all my code is for the digital-signature mode of WSS4J. But the project's 
>own
>site has some deployment examples for UsernameToken.  See
>
>   http://ws.apache.org/wss4j/
>
>and
>
>   http://ws.apache.org/wss4j/axis.html
>
>Cheers,
>Guy
>
>On Fri, 26 Aug 2005, Plorks mail wrote:
>
> >
> >
> > Hi Guy
> >
> > Thanks fr getting back to me.  Do you haveor can you lead me to an WSS4J
> > example ?
> >
> > Thanks for your help
> >
> >
> >
> >
> >
> >
> > >From: Guy Rixon <gt...@ast.cam.ac.uk>
> > >Reply-To: axis-user@ws.apache.org
> > >To: axis-user@ws.apache.org
> > >Subject: Re: basic authentication
> > >Date: Fri, 26 Aug 2005 14:47:05 +0100 (BST)
> > >
> > >If you are able to change the WSDL contract, then you can indeed 
>include
> > >the
> > >username and password in the SOAP body. Just put them in a message 
>part,
> > >like
> > >any other parameter.
> > >
> > >If you want to put username and password in the SOAP header, then you 
>can
> > >use
> > >the UsernameToken mode of WSS4J to be compatible with the WS-Security
> > >standard; or you can invent your own header if you don't have to be
> > >standard
> > >or interoperable. Using WSS4J is probably better.
> > >
> > >On Fri, 26 Aug 2005, Plorks mail wrote:
> > >
> > > > hi all
> > > >
> > > > i'm currntly getting username and password using basic 
>authentication in
> > >my
> > > > web service.
> > > >
> > > > we are using a product that doesn't support basic authentaication in 
>the
> > > > http header, so now i have to re-write my web service.  Can anyone
> > >suggest
> > > > an alternative way to do this?
> > > >
> > > > Can i set the username and password in the SOAP Envelope/body?
> > > >
> > > > Thsi is the code i'm curently using
> > > > String headerAuth =
> > > > (String)msgContext.getProperty(HTTPConstants.HEADER_AUTHORIZATION);
> > > >
> > > > if (headerAuth != null)
> > > > {
> > > >    headerAuth = headerAuth.trim();
> > > > }
> > > >
> > > > if (headerAuth != null && headerAuth.startsWith("Basic "))
> > > > {
> > > > int i;
> > > >
> > > > headerAuth = new String(Base64.decode(headerAuth.substring(6)));
> > > >
> > > > String [] userNamePassword = headerAuth.split(":");
> > > >
> > > > userName = userNamePassword[0];
> > > > password = userNamePassword[1];
> > > > }
> > > >
> > > > thanks for  any help
> > > >
> > > > _________________________________________________________________
> > > > Express yourself instantly with MSN Messenger! Download today - it's
> > >FREE!
> > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > >
> > >
> > >Guy Rixon 				        gtr@ast.cam.ac.uk
> > >Institute of Astronomy   	                Tel: +44-1223-337542
> > >Madingley Road, Cambridge, UK, CB3 0HA		Fax: +44-1223-337523
> >
> > _________________________________________________________________
> > Winks & nudges are here - download MSN Messenger 7.0 today!
> > http://messenger.msn.co.uk
> >
>
>Guy Rixon 				        gtr@ast.cam.ac.uk
>Institute of Astronomy   	                Tel: +44-1223-337542
>Madingley Road, Cambridge, UK, CB3 0HA		Fax: +44-1223-337523

_________________________________________________________________
Want to block unwanted pop-ups? Download the free MSN Toolbar now!  
http://toolbar.msn.co.uk/


Re: basic authentication

Posted by Guy Rixon <gt...@ast.cam.ac.uk>.
Hi,

all my code is for the digital-signature mode of WSS4J. But the project's own
site has some deployment examples for UsernameToken.  See

  http://ws.apache.org/wss4j/

and

  http://ws.apache.org/wss4j/axis.html

Cheers,
Guy

On Fri, 26 Aug 2005, Plorks mail wrote:

>
>
> Hi Guy
>
> Thanks fr getting back to me.  Do you haveor can you lead me to an WSS4J
> example ?
>
> Thanks for your help
>
>
>
>
>
>
> >From: Guy Rixon <gt...@ast.cam.ac.uk>
> >Reply-To: axis-user@ws.apache.org
> >To: axis-user@ws.apache.org
> >Subject: Re: basic authentication
> >Date: Fri, 26 Aug 2005 14:47:05 +0100 (BST)
> >
> >If you are able to change the WSDL contract, then you can indeed include
> >the
> >username and password in the SOAP body. Just put them in a message part,
> >like
> >any other parameter.
> >
> >If you want to put username and password in the SOAP header, then you can
> >use
> >the UsernameToken mode of WSS4J to be compatible with the WS-Security
> >standard; or you can invent your own header if you don't have to be
> >standard
> >or interoperable. Using WSS4J is probably better.
> >
> >On Fri, 26 Aug 2005, Plorks mail wrote:
> >
> > > hi all
> > >
> > > i'm currntly getting username and password using basic authentication in
> >my
> > > web service.
> > >
> > > we are using a product that doesn't support basic authentaication in the
> > > http header, so now i have to re-write my web service.  Can anyone
> >suggest
> > > an alternative way to do this?
> > >
> > > Can i set the username and password in the SOAP Envelope/body?
> > >
> > > Thsi is the code i'm curently using
> > > String headerAuth =
> > > (String)msgContext.getProperty(HTTPConstants.HEADER_AUTHORIZATION);
> > >
> > > if (headerAuth != null)
> > > {
> > >    headerAuth = headerAuth.trim();
> > > }
> > >
> > > if (headerAuth != null && headerAuth.startsWith("Basic "))
> > > {
> > > int i;
> > >
> > > headerAuth = new String(Base64.decode(headerAuth.substring(6)));
> > >
> > > String [] userNamePassword = headerAuth.split(":");
> > >
> > > userName = userNamePassword[0];
> > > password = userNamePassword[1];
> > > }
> > >
> > > thanks for  any help
> > >
> > > _________________________________________________________________
> > > Express yourself instantly with MSN Messenger! Download today - it's
> >FREE!
> > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > >
> >
> >Guy Rixon 				        gtr@ast.cam.ac.uk
> >Institute of Astronomy   	                Tel: +44-1223-337542
> >Madingley Road, Cambridge, UK, CB3 0HA		Fax: +44-1223-337523
>
> _________________________________________________________________
> Winks & nudges are here - download MSN Messenger 7.0 today!
> http://messenger.msn.co.uk
>

Guy Rixon 				        gtr@ast.cam.ac.uk
Institute of Astronomy   	                Tel: +44-1223-337542
Madingley Road, Cambridge, UK, CB3 0HA		Fax: +44-1223-337523

Re: basic authentication

Posted by Plorks mail <pl...@hotmail.com>.

Hi Guy

Thanks fr getting back to me.  Do you haveor can you lead me to an WSS4J 
example ?

Thanks for your help






>From: Guy Rixon <gt...@ast.cam.ac.uk>
>Reply-To: axis-user@ws.apache.org
>To: axis-user@ws.apache.org
>Subject: Re: basic authentication
>Date: Fri, 26 Aug 2005 14:47:05 +0100 (BST)
>
>If you are able to change the WSDL contract, then you can indeed include 
>the
>username and password in the SOAP body. Just put them in a message part, 
>like
>any other parameter.
>
>If you want to put username and password in the SOAP header, then you can 
>use
>the UsernameToken mode of WSS4J to be compatible with the WS-Security
>standard; or you can invent your own header if you don't have to be 
>standard
>or interoperable. Using WSS4J is probably better.
>
>On Fri, 26 Aug 2005, Plorks mail wrote:
>
> > hi all
> >
> > i'm currntly getting username and password using basic authentication in 
>my
> > web service.
> >
> > we are using a product that doesn't support basic authentaication in the
> > http header, so now i have to re-write my web service.  Can anyone 
>suggest
> > an alternative way to do this?
> >
> > Can i set the username and password in the SOAP Envelope/body?
> >
> > Thsi is the code i'm curently using
> > String headerAuth =
> > (String)msgContext.getProperty(HTTPConstants.HEADER_AUTHORIZATION);
> >
> > if (headerAuth != null)
> > {
> >    headerAuth = headerAuth.trim();
> > }
> >
> > if (headerAuth != null && headerAuth.startsWith("Basic "))
> > {
> > int i;
> >
> > headerAuth = new String(Base64.decode(headerAuth.substring(6)));
> >
> > String [] userNamePassword = headerAuth.split(":");
> >
> > userName = userNamePassword[0];
> > password = userNamePassword[1];
> > }
> >
> > thanks for  any help
> >
> > _________________________________________________________________
> > Express yourself instantly with MSN Messenger! Download today - it's 
>FREE!
> > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> >
>
>Guy Rixon 				        gtr@ast.cam.ac.uk
>Institute of Astronomy   	                Tel: +44-1223-337542
>Madingley Road, Cambridge, UK, CB3 0HA		Fax: +44-1223-337523

_________________________________________________________________
Winks & nudges are here - download MSN Messenger 7.0 today! 
http://messenger.msn.co.uk


Re: basic authentication

Posted by Guy Rixon <gt...@ast.cam.ac.uk>.
If you are able to change the WSDL contract, then you can indeed include the
username and password in the SOAP body. Just put them in a message part, like
any other parameter.

If you want to put username and password in the SOAP header, then you can use
the UsernameToken mode of WSS4J to be compatible with the WS-Security
standard; or you can invent your own header if you don't have to be standard
or interoperable. Using WSS4J is probably better.

On Fri, 26 Aug 2005, Plorks mail wrote:

> hi all
>
> i'm currntly getting username and password using basic authentication in my
> web service.
>
> we are using a product that doesn't support basic authentaication in the
> http header, so now i have to re-write my web service.  Can anyone suggest
> an alternative way to do this?
>
> Can i set the username and password in the SOAP Envelope/body?
>
> Thsi is the code i'm curently using
> String headerAuth =
> (String)msgContext.getProperty(HTTPConstants.HEADER_AUTHORIZATION);
>
> if (headerAuth != null)
> {
>    headerAuth = headerAuth.trim();
> }
>
> if (headerAuth != null && headerAuth.startsWith("Basic "))
> {
> int i;
>
> headerAuth = new String(Base64.decode(headerAuth.substring(6)));
>
> String [] userNamePassword = headerAuth.split(":");
>
> userName = userNamePassword[0];
> password = userNamePassword[1];
> }
>
> thanks for  any help
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today - it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>

Guy Rixon 				        gtr@ast.cam.ac.uk
Institute of Astronomy   	                Tel: +44-1223-337542
Madingley Road, Cambridge, UK, CB3 0HA		Fax: +44-1223-337523