Geir Amdal napsal(a):
On 11. apr. 2007, at 14:52, Belunek Karel wrote:
I have Axis2 1.1.1 under Tomcat 5.5.9 and I have correctly working
Axis service generated from WSDL file.
Now I'm trying to implement BASIC authenticacion.
On server side I'have se security constraint on the Tomcat level, it
works fine. I have tried it via WWW browser http://user:[EMAIL PROTECTED]
But I'm not able to write client with BASIC authentication.
Example from documentation does not work because
org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATE
constant simply does not exist.
(...)
I have tried to replace the constant by
HttpTransportProperties.Authenticator.BASIC but it does not work.
I configure the Options object as follows in my own ServiceClient-based
client implementation (also using Axis2 1.1.1, but on OC4J, not Tomcat):
//(...)
Authenticator authenticator = new Authenticator();
List<String> auth = new ArrayList<String>();
auth.add(Authenticator.BASIC);
authenticator.setAuthSchemes(auth);
authenticator.setUsername(username);
authenticator.setPassword(password);
options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
//(...)
Thanks guys, it solves the problem.
Your code snippet with Jarek's modification works.
Here is my code snippet:
...
//set authentication param
Options opt = stub._getServiceClient().getOptions();
Authenticator authenticator = new Authenticator();
List<String> auth = new ArrayList<String>();
auth.add(Authenticator.BASIC);
authenticator.setAuthSchemes(auth);
authenticator.setUsername(user);
authenticator.setPassword(pass);
authenticator.setPreemptiveAuthentication(true);
opt.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
...
Regards
Karel Belunek
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]