Hello

I'm having trouble creating a custom authentication scheme. The following
section advises that its possible, but doesn't suggest how:
http://ws.apache.org/axis2/1_1_1/http-transport.html#preemptive_auth

I've trawled both the axis2 and commons-httpclient code and believe the most
direct approach is:

       AuthPolicy.registerAuthScheme(MyScheme.NAME, MyScheme.class);
       Options options = new Options();
       HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();
       auth.setUsername("username");
       auth.setPassword("password");
       auth.setAuthSchemes(Arrays.asList(new String[]{MyScheme.NAME}));
       options.setProperty(HTTPConstants.AUTHENTICATE, auth);
       ConfigurationContext configContext = ...
       ClientStub service = ...
       ServiceClient client = service._getServiceClient();
       client.getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);

Wow, quite a lot of work!

But then execution gets to
org.apache.axis2.transport.http.AbstractHTTPSender#setAuthenticationInfo.
This method has the following comment:
   /*
   This will handle server Authentication, It could be either NTLM, Digest
or Basic Authentication.
   Apart from that user can change the priory or add a custom
authentication scheme.
   */

But it actually doesn't let me add a custom authentication scheme, as the
following code snippet illustrates:

               /* Customizing the priority Order */
               List schemes = authenticator.getAuthSchemes();
               if (schemes != null && schemes.size() > 0) {
                   List authPrefs = new ArrayList(3);
                   for (int i = 0; i < schemes.size(); i++) {
                       if (schemes.get(i) instanceof AuthPolicy) {
                           authPrefs.add(schemes.get(i));
                           continue;
                       }
                       String scheme = (String) schemes.get(i);
                       if (
HttpTransportProperties.Authenticator.BASIC.equals(scheme)) {
                           authPrefs.add(AuthPolicy.BASIC);
                       } else if (
HttpTransportProperties.Authenticator.NTLM.equals(scheme)) {
                           authPrefs.add(AuthPolicy.NTLM);
                       } else if (
HttpTransportProperties.Authenticator.DIGEST.equals(scheme)) {
                           authPrefs.add(AuthPolicy.DIGEST);
                       }
                   }
                   agent.getParams().setParameter(
AuthPolicy.AUTH_SCHEME_PRIORITY,
                                                  authPrefs);
               }

My scheme comes through as a String identifier and isn't 'basic', 'ntlm' or
'digest'.

It is also not an instance of AuthPolicy. This being a rather strange
abstract class from commons-httpclient with only static methods. It keeps an
ordered list of authentication methods which Axis doesn't access (at least
in my execution thread anyway).

So I'm quite lost now. Has anyone successfully implemented a custom auth
scheme with Axis2 1.1.1? Can I get some pointers?

TIA
Jem

--
http://seine.vox.com/
How's the serenity?

Reply via email to