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 Lothar Nieswandt <lo...@gmx.de> on 2006/05/08 11:05:31 UTC
[Axis2] Http Basic Authentication
Hello all,
I am trying to write a *simple* web service client with axis2. The server
side requires http basic authentication. I can't find out how this is done
*easily* with axis2. Somebody on the list advised to do
call.setProperty(Call.USERNAME_PROPERTY, "user");
call.setProperty(Call.PASSWORD_PROPERTY, "pass");
but this seems to be deprecated. What is the proper way of doing this?
I took a look at the security example and read something about password
callbacks but that seemed too complicated.
Any hints?
Thanks in advance,
Lothar
--
GMX Produkte empfehlen und ganz einfach Geld verdienen!
Satte Provisionen f�r GMX Partner: http://www.gmx.net/de/go/partner
Re: [Axis2] Http Basic Authentication
Posted by Lothar Nieswandt <lo...@gmx.de>.
Saminda, thanks a lot for your help.
However, you are not exactly referring to what I mean. Proxy support is well
documented, I had come accross your example before. But how can the
credentials for the destination server - not the proxy - be supplied? I need
the request to contain an authorisation header like
Authorization: Basic SOME_HEX_CODE
Thank you again.
Lothar
> --- Ursprüngliche Nachricht ---
> Von: Saminda Abeyruwan <sa...@opensource.lk>
> An: axis-user@ws.apache.org
> Betreff: Re: [Axis2] Http Basic Authentication
> Datum: Mon, 08 May 2006 17:06:00 +0600
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Lothar Nieswandt wrote:
> > Hello all,
> >
> > I am trying to write a *simple* web service client with axis2. The
> server
> > side requires http basic authentication. I can't find out how this is
> done
> > *easily* with axis2. Somebody on the list advised to do
> >
> > call.setProperty(Call.USERNAME_PROPERTY, "user");
> > call.setProperty(Call.PASSWORD_PROPERTY, "pass");
> >
> > but this seems to be deprecated. What is the proper way of doing this?
> >
> > I took a look at the security example and read something about password
> > callbacks but that seemed too complicated.
> >
> > Any hints?
> >
> > Thanks in advance,
> > Lothar
> >
>
> Hi Lothar,
>
> Axis2 does transport level basic authentication as follows.
> ///// code snipet
>
> OMElement payload = TestingUtils.createDummyOMElement();
> /**
> * Proxy setting in runtime
> */
> HttpTransportProperties.ProxyProperties proxyproperties = new
> HttpTransportProperties().new ProxyProperties();
> proxyproperties.setProxyName("localhost");
> proxyproperties.setProxyPort(5555);
> proxyproperties.setDomain("domain");
> proxyproperties.setPassWord("password");
> proxyproperties.setUserName("userName");
>
> Options options = new Options();
> options.setProperty(HTTPConstants.PROXY, proxyproperties);
> options.setTo(targetEPR);
> options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> ConfigurationContext configContext =
>
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(
> null, null);
> ServiceClient sender = new ServiceClient(configContext, null);
> sender.setOptions(options);
>
> OMElement result = sender.sendReceive(payload);
>
> TestingUtils.campareWithCreatedOMElement(result);
>
> For more information please see the test case,
>
http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java?view=markup
>
> documentation,
> http://ws.apache.org/axis2/1_0/http-transport.html
>
> Thank you
>
> Saminda
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFEXyYYYmklbLuW6wYRAiZPAJ9ufhjx/tv7GH4SkWjpS8cYm7UVBQCfVLTQ
> b93pEsP8BryC1/sE5ZZZHVE=
> =UNFg
> -----END PGP SIGNATURE-----
>
--
Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
Re: [Axis2] Http Basic Authentication
Posted by Saminda Abeyruwan <sa...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Lothar,
Thank you for bringing "Http Basic Authentication" to Axis2's attention.
We've added Preemptive Basic Authentication schema to Axis2 codebase via
HttpClient.
For ex:
/////////////////////////////////////////////////////////////////
Options options = new Options();
options.setTo(targetEPR);
HttpTransportProperties.BasicAuthentication
basicAuthentication = new HttpTransportProperties().new
BasicAuthentication();
basicAuthentication.setUsername("username");
basicAuthentication.setPassword("password");
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATION,basicAuthentication);
//Blocking invocation
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMElement result = sender.sendReceive(payload);
//////////////////////////////////////////////////////////////
In addition to you can set server credentials such as port, host and
realm as well.
So if you monitor the messages with basic authentication through tcp
monitor you will able to see the {Authorization: Basic SOME_HEX_CODE}
http header.
Unfortunately the SVN has been down for two days and i could not be able
to commit the code. Thus, I've attached a diff here for you attention
and apply it to your code base for make the scenario work. I will commit
the code and updated the docs as soon as the SVN is up. Please play with
it and let we know the results. Apply the patch at
{axis2.home}/modules/core/src/org/apache/axis2/transport.
Thank you
Saminda
Saminda Abeyruwan wrote:
>
> Saminda Abeyruwan wrote:
>
>>>Lothar Nieswandt wrote:
>>>
>>>
>>>>>Hello all,
>>>>>
>>>>>I am trying to write a *simple* web service client with axis2. The server
>>>>>side requires http basic authentication. I can't find out how this is done
>>>>>*easily* with axis2. Somebody on the list advised to do
>>>>>
>>>>>call.setProperty(Call.USERNAME_PROPERTY, "user");
>>>>>call.setProperty(Call.PASSWORD_PROPERTY, "pass");
>>>>>
>>>>>but this seems to be deprecated. What is the proper way of doing this?
>>>>>
>>>>>I took a look at the security example and read something about password
>>>>>callbacks but that seemed too complicated.
>>>>>
>>>>>Any hints?
>>>>>
>>>>>Thanks in advance,
>>>>>Lothar
>>>>>
>>>
>>>
>>>Hi Lothar,
>>>
>>>Axis2 does transport level basic authentication as follows.
>>>///// code snipet
>>>
>>>OMElement payload = TestingUtils.createDummyOMElement();
>>> /**
>>> * Proxy setting in runtime
>>> */
>>> HttpTransportProperties.ProxyProperties proxyproperties = new
>>> HttpTransportProperties().new ProxyProperties();
>>> proxyproperties.setProxyName("localhost");
>>> proxyproperties.setProxyPort(5555);
>>> proxyproperties.setDomain("domain");
>>> proxyproperties.setPassWord("password");
>>> proxyproperties.setUserName("userName");
>>>
>>> Options options = new Options();
>>> options.setProperty(HTTPConstants.PROXY, proxyproperties);
>>> options.setTo(targetEPR);
>>> options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>>> ConfigurationContext configContext =
>>>
>>>ConfigurationContextFactory.createConfigurationContextFromFileSystem(
>>> null, null);
>>> ServiceClient sender = new ServiceClient(configContext, null);
>>> sender.setOptions(options);
>>>
>>> OMElement result = sender.sendReceive(payload);
>>>
>>> TestingUtils.campareWithCreatedOMElement(result);
>>>
>>>For more information please see the test case,
>>>http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java?view=markup
>>>
>>>documentation,
>>>http://ws.apache.org/axis2/1_0/http-transport.html
>>>
>>>Thank you
>>>
>>>Saminda
>>>
>>>
>
>
> Hi Lothar,
>
> Sorry for misinterpretation. In Axis2 1.0 we do proxy authentication.
> For http server authentication we'll have to do a little fix.
> I'll attend to this asap.
>
> Saminda
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEZDgZYmklbLuW6wYRAnxcAKDBfjAK6xW2QPNoNM6InL0fp6YfBACeKgi2
X2SigV+b2q9yljBGXUkoOLU=
=1X+T
-----END PGP SIGNATURE-----
Re: [Axis2] Http Basic Authentication
Posted by Davanum Srinivas <da...@gmail.com>.
If you need a way to do this in Axis2 1.0 release, please see
http://www.wso2.net/2006/05/reuse_share_http_connections
It shows you how to set up a MultiThreadedHttpConnectionManager, you
can set one up with basic preemptive just like in saminda's patch.
thanks,
dims
On 5/11/06, Saminda Abeyruwan <sa...@opensource.lk> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> Saminda Abeyruwan wrote:
> > Lothar Nieswandt wrote:
> >
> >>>Hello all,
> >>>
> >>>I am trying to write a *simple* web service client with axis2. The server
> >>>side requires http basic authentication. I can't find out how this is done
> >>>*easily* with axis2. Somebody on the list advised to do
> >>>
> >>>call.setProperty(Call.USERNAME_PROPERTY, "user");
> >>>call.setProperty(Call.PASSWORD_PROPERTY, "pass");
> >>>
> >>>but this seems to be deprecated. What is the proper way of doing this?
> >>>
> >>>I took a look at the security example and read something about password
> >>>callbacks but that seemed too complicated.
> >>>
> >>>Any hints?
> >>>
> >>>Thanks in advance,
> >>>Lothar
> >>>
> >
> >
> > Hi Lothar,
> >
> > Axis2 does transport level basic authentication as follows.
> > ///// code snipet
> >
> > OMElement payload = TestingUtils.createDummyOMElement();
> > /**
> > * Proxy setting in runtime
> > */
> > HttpTransportProperties.ProxyProperties proxyproperties = new
> > HttpTransportProperties().new ProxyProperties();
> > proxyproperties.setProxyName("localhost");
> > proxyproperties.setProxyPort(5555);
> > proxyproperties.setDomain("domain");
> > proxyproperties.setPassWord("password");
> > proxyproperties.setUserName("userName");
> >
> > Options options = new Options();
> > options.setProperty(HTTPConstants.PROXY, proxyproperties);
> > options.setTo(targetEPR);
> > options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> > ConfigurationContext configContext =
> >
> > ConfigurationContextFactory.createConfigurationContextFromFileSystem(
> > null, null);
> > ServiceClient sender = new ServiceClient(configContext, null);
> > sender.setOptions(options);
> >
> > OMElement result = sender.sendReceive(payload);
> >
> > TestingUtils.campareWithCreatedOMElement(result);
> >
> > For more information please see the test case,
> > http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java?view=markup
> >
> > documentation,
> > http://ws.apache.org/axis2/1_0/http-transport.html
> >
> > Thank you
> >
> > Saminda
> >
> >
>
> Hi Lothar,
>
> Sorry for misinterpretation. In Axis2 1.0 we do proxy authentication.
> For http server authentication we'll have to do a little fix.
> I'll attend to this asap.
>
> Saminda
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFEYyosYmklbLuW6wYRApboAKCaabIDQ3Cp0U8h6z3veLDMUmf+fgCeKFiq
> Ds0w76N+/ESLM0TTUOANYcE=
> =0rfH
> -----END PGP SIGNATURE-----
>
--
Davanum Srinivas : http://wso2.com/blogs/
Re: [Axis2] Http Basic Authentication
Posted by Saminda Abeyruwan <sa...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Saminda Abeyruwan wrote:
> Lothar Nieswandt wrote:
>
>>>Hello all,
>>>
>>>I am trying to write a *simple* web service client with axis2. The server
>>>side requires http basic authentication. I can't find out how this is done
>>>*easily* with axis2. Somebody on the list advised to do
>>>
>>>call.setProperty(Call.USERNAME_PROPERTY, "user");
>>>call.setProperty(Call.PASSWORD_PROPERTY, "pass");
>>>
>>>but this seems to be deprecated. What is the proper way of doing this?
>>>
>>>I took a look at the security example and read something about password
>>>callbacks but that seemed too complicated.
>>>
>>>Any hints?
>>>
>>>Thanks in advance,
>>>Lothar
>>>
>
>
> Hi Lothar,
>
> Axis2 does transport level basic authentication as follows.
> ///// code snipet
>
> OMElement payload = TestingUtils.createDummyOMElement();
> /**
> * Proxy setting in runtime
> */
> HttpTransportProperties.ProxyProperties proxyproperties = new
> HttpTransportProperties().new ProxyProperties();
> proxyproperties.setProxyName("localhost");
> proxyproperties.setProxyPort(5555);
> proxyproperties.setDomain("domain");
> proxyproperties.setPassWord("password");
> proxyproperties.setUserName("userName");
>
> Options options = new Options();
> options.setProperty(HTTPConstants.PROXY, proxyproperties);
> options.setTo(targetEPR);
> options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> ConfigurationContext configContext =
>
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(
> null, null);
> ServiceClient sender = new ServiceClient(configContext, null);
> sender.setOptions(options);
>
> OMElement result = sender.sendReceive(payload);
>
> TestingUtils.campareWithCreatedOMElement(result);
>
> For more information please see the test case,
> http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java?view=markup
>
> documentation,
> http://ws.apache.org/axis2/1_0/http-transport.html
>
> Thank you
>
> Saminda
>
>
Hi Lothar,
Sorry for misinterpretation. In Axis2 1.0 we do proxy authentication.
For http server authentication we'll have to do a little fix.
I'll attend to this asap.
Saminda
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEYyosYmklbLuW6wYRApboAKCaabIDQ3Cp0U8h6z3veLDMUmf+fgCeKFiq
Ds0w76N+/ESLM0TTUOANYcE=
=0rfH
-----END PGP SIGNATURE-----
Re: [Axis2] Http Basic Authentication
Posted by Xinjun Chen <xj...@gmail.com>.
Hi Saminda,
I am trying to set proxy for an Axis2 client. The code snippet is as
follows:
HttpTransportProperties htp = new HttpTransportProperties();
httpProxyProperties = htp.new ProxyProperties();
httpProxyProperties.setProxyName(httpProxyHost);
httpProxyProperties.setProxyPort(Integer.parseInt(httpProxyPort));
httpProxyProperties.setUserName(httpProxyUsername);
httpProxyProperties.setPassWord(httpProxyPassword);
httpProxyProperties.setDomain(httpProxyDomain);
MessageContext mc = new MessageContext();
mc.setServiceContext(serviceContext);
mc.setEnvelope(request);
mc.setTo(toEPR);
mc.setSoapAction(soapAction);
OperationClient mepClient = outOnlyOperation.createClient(
serviceContext, options);
mepClient.addMessageContext(mc);
// TODO: Add the call back handler
mepClient.execute(true);
Where the httpProxyUsername, httpProxyPassword, and httpProxyDomain are
"anonymous".
When i ran the client, I get the following exception.
*
java.rmi.RemoteException*: EJB Exception:; nested exception is:
*java.rmi.RemoteException*: Axis2 transport error : Not Implemented; nested
exception is:
org.apache.axis2.AxisFault: Axis2 *transport* error : Not Implemented;
nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Not Implemented; nested
exception is:
Caused by: *java.rmi.RemoteException*: Axis2 transport error : Not
Implemented; nested exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Not Implemented; nested
exception is:
org.apache.axis2.AxisFault: Axis2 transport error : Not Implemented; nested
exception is:
I have tried to find other log messages but there is no other error message.
Could you give me some idea why this error happens and what I have missed
out?
Regards,
Xinjun
On 5/8/06, Saminda Abeyruwan <sa...@opensource.lk> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Lothar Nieswandt wrote:
> > Hello all,
> >
> > I am trying to write a *simple* web service client with axis2. The
> server
> > side requires http basic authentication. I can't find out how this is
> done
> > *easily* with axis2. Somebody on the list advised to do
> >
> > call.setProperty(Call.USERNAME_PROPERTY, "user");
> > call.setProperty(Call.PASSWORD_PROPERTY, "pass");
> >
> > but this seems to be deprecated. What is the proper way of doing this?
> >
> > I took a look at the security example and read something about password
> > callbacks but that seemed too complicated.
> >
> > Any hints?
> >
> > Thanks in advance,
> > Lothar
> >
>
> Hi Lothar,
>
> Axis2 does transport level basic authentication as follows.
> ///// code snipet
>
> OMElement payload = TestingUtils.createDummyOMElement();
> /**
> * Proxy setting in runtime
> */
> HttpTransportProperties.ProxyProperties proxyproperties = new
> HttpTransportProperties().new ProxyProperties();
> proxyproperties.setProxyName("localhost");
> proxyproperties.setProxyPort(5555);
> proxyproperties.setDomain("domain");
> proxyproperties.setPassWord("password");
> proxyproperties.setUserName("userName");
>
> Options options = new Options();
> options.setProperty(HTTPConstants.PROXY, proxyproperties);
> options.setTo(targetEPR);
> options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> ConfigurationContext configContext =
>
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(
> null, null);
> ServiceClient sender = new ServiceClient(configContext, null);
> sender.setOptions(options);
>
> OMElement result = sender.sendReceive(payload);
>
> TestingUtils.campareWithCreatedOMElement(result);
>
> For more information please see the test case,
>
> http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java?view=markup
>
> documentation,
> http://ws.apache.org/axis2/1_0/http-transport.html
>
> Thank you
>
> Saminda
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFEXyYYYmklbLuW6wYRAiZPAJ9ufhjx/tv7GH4SkWjpS8cYm7UVBQCfVLTQ
> b93pEsP8BryC1/sE5ZZZHVE=
> =UNFg
> -----END PGP SIGNATURE-----
>
Re: [Axis2] Http Basic Authentication
Posted by Saminda Abeyruwan <sa...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lothar Nieswandt wrote:
> Hello all,
>
> I am trying to write a *simple* web service client with axis2. The server
> side requires http basic authentication. I can't find out how this is done
> *easily* with axis2. Somebody on the list advised to do
>
> call.setProperty(Call.USERNAME_PROPERTY, "user");
> call.setProperty(Call.PASSWORD_PROPERTY, "pass");
>
> but this seems to be deprecated. What is the proper way of doing this?
>
> I took a look at the security example and read something about password
> callbacks but that seemed too complicated.
>
> Any hints?
>
> Thanks in advance,
> Lothar
>
Hi Lothar,
Axis2 does transport level basic authentication as follows.
///// code snipet
OMElement payload = TestingUtils.createDummyOMElement();
/**
* Proxy setting in runtime
*/
HttpTransportProperties.ProxyProperties proxyproperties = new
HttpTransportProperties().new ProxyProperties();
proxyproperties.setProxyName("localhost");
proxyproperties.setProxyPort(5555);
proxyproperties.setDomain("domain");
proxyproperties.setPassWord("password");
proxyproperties.setUserName("userName");
Options options = new Options();
options.setProperty(HTTPConstants.PROXY, proxyproperties);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
ConfigurationContext configContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(
null, null);
ServiceClient sender = new ServiceClient(configContext, null);
sender.setOptions(options);
OMElement result = sender.sendReceive(payload);
TestingUtils.campareWithCreatedOMElement(result);
For more information please see the test case,
http://svn.apache.org/viewcvs.cgi/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/EchoRawRuntimeProxyTest.java?view=markup
documentation,
http://ws.apache.org/axis2/1_0/http-transport.html
Thank you
Saminda
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEXyYYYmklbLuW6wYRAiZPAJ9ufhjx/tv7GH4SkWjpS8cYm7UVBQCfVLTQ
b93pEsP8BryC1/sE5ZZZHVE=
=UNFg
-----END PGP SIGNATURE-----