2 Replies Latest reply on Mar 4, 2005 1:49 PM by Paul Nichols

    Mappoint Digest Authentication and JBoss Configuration

    Paul Nichols Newbie

      I need some assistance using Jboss' Axis implementation with JBoss. I am using JBosss 4.0.1

      To use the Microsoft Mappoint service, we need to be able to handle Digest Authentication. Using Tomcat 5.0, I can do this by implementing my own class, overriding the BasicHandler in Axis, and using a config file to set the deployment attributes. In TC 5, this works fine, and I do not have to modify Tomcat itself, I simply put the new Sender class extended from the Axis BasicHandler class in the WAR file, along with the Client Descriptor file.

      However, this will not work with JBoss. I even tried to change the JBoss default descriptor file in the jboss-ws4ee.sar directory, but to no avail.

      Has anyone encountered this problem before using JBoss and how do I correct it?


      A Million Thanks,

      Paul Nichols

        • 1. Re: Mappoint Digest Authentication and JBoss Configuration
          Thomas Diesler Master

          Are you saying that Digest Authentication does not work? If so, could you please create a sample deployment and a JIRA issue? Thanks.

          • 2. Re: Mappoint Digest Authentication and JBoss Configuration
            Paul Nichols Newbie

            Correct.. Digest Authentication did not work in Axis 1.1 (do not know about 1.2), so you needed to override the Basic Handler. Since MS uses Digest Authentication with the MapPoint Web Service, I must use it :)

            I am not sure what you are asking in terms of a sample deployment, since I am consuming a Web service, not creating one.

            As stated my work around works fine in Tomcat 5.0, but not so in JBoss. I am sure this is a configuration issue (on my part), but I do not knwo how to resolve it.

            I can include the src for the Override Sender I am using, and the config file.

            source for SimpleHttpSender:

            import java.io.*;
            import java.net.*;
            import org.apache.axis.*;
            import org.apache.axis.handlers.*;


            /**
            * SimpleHTTPSender is an HTTP transport handler for the Axis library, providing
            * basic HTTP communication with the server. This class is needed in order to use
            * MapPoint .NET, because Axis does not yet support digest authentication. The
            * CommonsHTTPSender almost works, but it currently fails with large POST requests,
            * such as those that are sent when calling GetRouteMap with a very long route.
            public class SimpleHTTPSender extends BasicHandler {

            /**
            * SimpleAuthenticator provides the user name and password to an URLConnection.
            */
            private static class SimpleAuthenticator extends Authenticator {
            private PasswordAuthentication m_authentication;

            SimpleAuthenticator(String userName, String password) {
            m_authentication = new PasswordAuthentication(userName, password.toCharArray());
            }

            protected PasswordAuthentication getPasswordAuthentication() {
            return m_authentication;
            }
            }


            /**
            * Invoke a remote call using an URLConnection. This method is called by Axis.
            */
            public void invoke(MessageContext messageContext)
            throws AxisFault {
            try {
            String userName = messageContext.getUsername();
            String password = messageContext.getPassword();
            if (userName != null && password != null) {
            Authenticator.setDefault(new SimpleAuthenticator(userName, password));
            }

            URL url = new URL(messageContext.getStrProp(MessageContext.TRANS_URL));
            URLConnection conn = url.openConnection();
            writeToConnection(conn, messageContext);
            readFromConnection(conn, messageContext);
            }
            catch (Exception e) {
            throw AxisFault.makeFault(e);
            }
            finally {
            Authenticator.setDefault(null);
            }
            }


            /**
            * Write the SOAP request message to an URLConnection.
            */
            private void writeToConnection(URLConnection conn, MessageContext messageContext)
            throws Exception {
            conn.setDoOutput(true);
            Message request = messageContext.getRequestMessage();
            String contentType = request.getContentType(messageContext.getSOAPConstants());
            conn.setRequestProperty("Content-Type", contentType);
            if (messageContext.useSOAPAction()) {
            conn.setRequestProperty("SOAPAction", messageContext.getSOAPActionURI());
            }
            OutputStream out = new BufferedOutputStream(conn.getOutputStream(), 8192);
            request.writeTo(out);
            out.flush();
            }


            /**
            * Read the SOAP response message from an URLConnection.
            */
            private void readFromConnection(URLConnection conn, MessageContext messageContext)
            throws Exception {
            String contentType = conn.getContentType();
            String contentLocation = conn.getHeaderField("Content-Location");

            InputStream in = ((HttpURLConnection) conn).getErrorStream();
            if (in == null) {
            in = conn.getInputStream();
            }
            in = new BufferedInputStream(in, 8192);
            Message response = new Message(in, false, contentType, contentLocation);
            response.setMessageType(Message.RESPONSE);
            messageContext.setResponseMessage(response);
            }
            }


            Config file:

            client-config.wsdd

            <?xml version="1.0" encoding="UTF-8"?>
            <deployment name="defaultClientConfig"
            xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">




            Hope this helps explain the situation.