axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsi...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/transport/http CommonsHTTPSender.java
Date Fri, 16 Aug 2002 22:51:22 GMT
rsitze      2002/08/16 15:51:21

  Modified:    java/src/org/apache/axis AxisProperties.java
               java     .cvsignore
               java/src/org/apache/axis/components/net
                        JSSESocketFactory.java SocketFactoryFactory.java
                        DefaultSocketFactory.java SocketFactory.java
               java/src/org/apache/axis/utils DefaultAuthenticator.java
               java/src/org/apache/axis/handlers JWSProcessor.java
               java/src/org/apache/axis/transport/http
                        CommonsHTTPSender.java
  Added:       java/src/org/apache/axis/components/net
                        TransportClientProperties.java
                        TransportClientPropertiesFactory.java
                        DefaultHTTPTransportClientProperties.java
                        DefaultHTTPSTransportClientProperties.java
  Log:
  Pluggable transport client proxy properties... Please change the names if
  you have any opinion, I'm not sure they are quite right.  Adapted everything
  except tcpmon to use these.  Caching is hardwired on (minimize perf. hit).
  
  Revision  Changes    Path
  1.9       +65 -0     xml-axis/java/src/org/apache/axis/AxisProperties.java
  
  Index: AxisProperties.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisProperties.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AxisProperties.java	15 Aug 2002 17:54:08 -0000	1.8
  +++ AxisProperties.java	16 Aug 2002 22:51:21 -0000	1.9
  @@ -59,6 +59,13 @@
   import java.util.Map;
   import java.util.Properties;
   
  +import java.lang.reflect.InvocationTargetException;
  +
  +import org.apache.commons.discovery.DiscoverClass;
  +import org.apache.commons.discovery.DiscoveryException;
  +import org.apache.commons.discovery.base.Environment;
  +import org.apache.commons.discovery.base.ImplClass;
  +import org.apache.commons.discovery.base.SPInterface;
   import org.apache.commons.discovery.tools.ManagedProperties;
   
   
  @@ -93,6 +100,64 @@
    * @author Richard A. Sitze
    */
   public class AxisProperties {
  +    public static Environment getDiscoverEnvironment() {
  +        return new Environment(getCommonsGroupContext());
  +    }
  +    
  +    public static Object newInstance(Class spiClass, String defaultClass)
  +        throws DiscoveryException,
  +               InstantiationException,
  +               IllegalAccessException,
  +               NoSuchMethodException,
  +               InvocationTargetException
  +    {
  +        SPInterface spi = new SPInterface(spiClass);
  +        return DiscoverClass.newInstance(getDiscoverEnvironment(),
  +                                         spi,
  +                                         (String) null,
  +                                         spi.createImplClass(defaultClass));
  +    }
  +    
  +    public static Object newInstance(Class spiClass, Class defaultClass)
  +        throws DiscoveryException,
  +               InstantiationException,
  +               IllegalAccessException,
  +               NoSuchMethodException,
  +               InvocationTargetException
  +    {
  +        SPInterface spi = new SPInterface(spiClass);
  +        return DiscoverClass.newInstance(getDiscoverEnvironment(),
  +                                         spi,
  +                                         (String) null,
  +                                         spi.createImplClass(defaultClass));
  +    }
  +
  +    public static Object newInstance(SPInterface spi, String defaultClass)
  +        throws DiscoveryException,
  +               InstantiationException,
  +               IllegalAccessException,
  +               NoSuchMethodException,
  +               InvocationTargetException
  +    {
  +        return DiscoverClass.newInstance(getDiscoverEnvironment(),
  +                                         spi,
  +                                         (String) null,
  +                                         spi.createImplClass(defaultClass));
  +    }
  +
  +    public static Object newInstance(SPInterface spi, Class defaultClass)
  +        throws DiscoveryException,
  +               InstantiationException,
  +               IllegalAccessException,
  +               NoSuchMethodException,
  +               InvocationTargetException
  +    {
  +        return DiscoverClass.newInstance(getDiscoverEnvironment(),
  +                                         spi,
  +                                         (String) null,
  +                                         spi.createImplClass(defaultClass));
  +    }
  +
   
       private static String commonsGroupContext = null;
       
  
  
  
  1.6       +3 -0      xml-axis/java/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/.cvsignore,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- .cvsignore	4 Jun 2002 17:53:37 -0000	1.5
  +++ .cvsignore	16 Aug 2002 22:51:21 -0000	1.6
  @@ -4,3 +4,6 @@
   server-config.wsdd
   test-reports
   junit*
  +bin
  +.project
  +.classpath
  
  
  
  1.3       +18 -42    xml-axis/java/src/org/apache/axis/components/net/JSSESocketFactory.java
  
  Index: JSSESocketFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/net/JSSESocketFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JSSESocketFactory.java	2 Aug 2002 17:27:42 -0000	1.2
  +++ JSSESocketFactory.java	16 Aug 2002 22:51:21 -0000	1.3
  @@ -104,8 +104,8 @@
       private SSLSocketFactory sslFactory = null;
   
       /** Field defaultKeystoreFile           */
  -    static String defaultKeystoreFile = AxisProperties.getProperty("user.home")
  -            + "/.keystore";
  +    static String defaultKeystoreFile =
  +        System.getProperty("user.home") + "/.keystore";
   
       /** Field defaultKeyPass           */
       static String defaultKeyPass = "changeit";
  @@ -141,55 +141,29 @@
               port = 443;
           }
   
  -        // Get https.proxyXXX settings
  -        String tunnelHost = getGlobalProperty("https.proxyHost");
  -        String tunnelPortStr = getGlobalProperty("https.proxyPort");
  -        String nonProxyHosts = getGlobalProperty("https.nonProxyHosts");
  -
  -        // Use http.proxyXXX settings if https.proxyXXX is not set
  -        if (tunnelHost == null) {
  -            tunnelHost = getGlobalProperty("http.proxyHost");
  -        }
  -        if (tunnelPortStr == null) {
  -            tunnelPortStr = getGlobalProperty("http.proxyPort");
  -        }
  -        if (nonProxyHosts == null) {
  -            nonProxyHosts = getGlobalProperty("http.nonProxyHosts");
  -        }
  -        boolean hostInNonProxyList = isHostInNonProxyList(host, nonProxyHosts);
  +        TransportClientProperties tcp = TransportClientPropertiesFactory.create("https");
   
  -        if ((tunnelHost == null) || tunnelHost.equals("")
  -                || hostInNonProxyList) {
  +        boolean hostInNonProxyList = isHostInNonProxyList(host, tcp.getNonProxyHosts());
   
  +        if (tcp.getProxyHost().length() == 0 || hostInNonProxyList) {
               // direct SSL connection
               sslSocket = sslFactory.createSocket(host, port);
           } else {
   
               // Default proxy port is 80, even for https
  -            int tunnelPort = ((tunnelPortStr != null)
  -                    ? ((Integer.parseInt(tunnelPortStr) < 0)
  -                    ? 80
  -                    : Integer.parseInt(tunnelPortStr))
  -                    : 80);
  +            int tunnelPort = (tcp.getProxyPort().length() != 0)
  +                             ? Integer.parseInt(tcp.getProxyPort())
  +                             : 80;
  +            if (tunnelPort < 0)
  +                tunnelPort = 80;
   
               // Create the regular socket connection to the proxy
  -            Socket tunnel = new Socket(tunnelHost, tunnelPort);
  +            Socket tunnel = new Socket(tcp.getProxyHost(), tunnelPort);
   
               // The tunnel handshake method (condensed and made reflexive)
               OutputStream tunnelOutputStream = tunnel.getOutputStream();
               PrintWriter out = new PrintWriter(
                       new BufferedWriter(new OutputStreamWriter(tunnelOutputStream)));
  -            String tunnelUser =
  -                    getGlobalProperty("https.proxyUser");
  -            String tunnelPassword =
  -                    getGlobalProperty("https.proxyPassword");
  -
  -            if (tunnelUser == null) {
  -                tunnelUser = getGlobalProperty("http.proxyUser");
  -            }
  -            if (tunnelPassword == null) {
  -                tunnelPassword = getGlobalProperty("http.proxyPassword");
  -            }
   
               // More secure version... engage later?
               // PasswordAuthentication pa =
  @@ -205,12 +179,13 @@
               // }
               out.print("CONNECT " + host + ":" + port + " HTTP/1.0\r\n"
                       + "User-Agent: AxisClient");
  -            if ((tunnelUser != null) && (tunnelPassword != null)) {
  +            if (tcp.getProxyUser().length() != 0 &&
  +                tcp.getProxyPassword().length() != 0) {
   
                   // add basic authentication header for the proxy
  -                String encodedPassword = XMLUtils.base64encode((tunnelUser
  +                String encodedPassword = XMLUtils.base64encode((tcp.getProxyUser()
                           + ":"
  -                        + tunnelPassword).getBytes());
  +                        + tcp.getProxyPassword()).getBytes());
   
                   out.print("\nProxy-Authorization: Basic " + encodedPassword);
               }
  @@ -252,7 +227,7 @@
                       && !replyStr.startsWith("HTTP/1.1 200")) {
                   throw new IOException(JavaUtils.getMessage("cantTunnel00",
                           new String[]{
  -                            tunnelHost,
  +                            tcp.getProxyHost(),
                               "" + tunnelPort,
                               replyStr}));
               }
  @@ -260,7 +235,8 @@
               // End of condensed reflective tunnel handshake method
               sslSocket = sslFactory.createSocket(tunnel, host, port, true);
               if (log.isDebugEnabled()) {
  -                log.debug(JavaUtils.getMessage("setupTunnel00", tunnelHost,
  +                log.debug(JavaUtils.getMessage("setupTunnel00",
  +                          tcp.getProxyHost(),
                           "" + tunnelPort));
               }
           }
  
  
  
  1.4       +28 -61    xml-axis/java/src/org/apache/axis/components/net/SocketFactoryFactory.java
  
  Index: SocketFactoryFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/net/SocketFactoryFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SocketFactoryFactory.java	2 Aug 2002 17:27:42 -0000	1.3
  +++ SocketFactoryFactory.java	16 Aug 2002 22:51:21 -0000	1.4
  @@ -61,6 +61,9 @@
   import org.apache.axis.components.logger.LogFactory;
   import org.apache.commons.logging.Log;
   
  +import org.apache.commons.discovery.base.ImplClass;
  +import org.apache.commons.discovery.base.SPInterface;
  +
   import java.lang.reflect.Constructor;
   import java.util.Hashtable;
   
  @@ -90,38 +93,20 @@
        * @return
        */
       public static synchronized SocketFactory getFactory(Hashtable attributes) {
  -
  -        String socketFactoryClassName =
  -                AxisProperties.getProperty("axis.socketFactory",
  -                        "org.apache.axis.components.net.DefaultSocketFactory");
  -
  -        log.debug("axis.socketFactory:" + socketFactoryClassName);
  -        SocketFactory extractor = null;
  -
  -        try {
  -            if (theFactory == null) {
  -                Class extractorClass =
  -                        ClassUtils.forName(socketFactoryClassName);
  -
  -                if (SocketFactory.class.isAssignableFrom(extractorClass)) {
  -                    Class classes[] = new Class[1];
  -
  -                    classes[0] = Hashtable.class;
  -                    Object objects[] = new Object[1];
  -
  -                    objects[0] = attributes;
  -                    Constructor constructor =
  -                            extractorClass.getConstructor(classes);
  -
  -                    theFactory =
  -                            (SocketFactory) constructor.newInstance(objects);
  -                }
  +        if (theFactory == null) {
  +            try {
  +                Class classes[] = new Class[] { Hashtable.class };
  +                Object objects[] = new Object[] { attributes };
  +
  +                theFactory = (SocketFactory)AxisProperties.newInstance(
  +                         new SPInterface(SocketFactory.class,
  +                                         "axis.socketFactory",
  +                                         classes,
  +                                         objects),
  +                         "org.apache.axis.components.net.DefaultSocketFactory");
  +            } catch (Exception e) {
  +                log.error(JavaUtils.getMessage("exception00"), e);
               }
  -        } catch (Exception e) {
  -
  -            // If something goes wrong here, should we just fall
  -            // through and use the default one?
  -            log.error(JavaUtils.getMessage("exception00"), e);
           }
           return theFactory;
       }
  @@ -135,38 +120,20 @@
        */
       public static synchronized SocketFactory getSecureFactory(
               Hashtable attributes) {
  -
  -        String socketFactoryClassName =
  -                AxisProperties.getProperty("axis.socketSecureFactory",
  +        if (theSecureFactory == null) {
  +            try {
  +                Class classes[] = new Class[] { Hashtable.class };
  +                Object objects[] = new Object[] { attributes };
  +
  +                theSecureFactory = (SocketFactory)AxisProperties.newInstance(
  +                        new SPInterface(SocketFactory.class,
  +                                        "axis.socketSecureFactory",
  +                                        classes,
  +                                        objects),
                           "org.apache.axis.components.net.JSSESocketFactory");
  -
  -        log.debug("axis.socketSecureFactory:" + socketFactoryClassName);
  -        SocketFactory extractor = null;
  -
  -        try {
  -            if (theSecureFactory == null) {
  -                Class extractorClass =
  -                        ClassUtils.forName(socketFactoryClassName);
  -
  -                if (SocketFactory.class.isAssignableFrom(extractorClass)) {
  -                    Class classes[] = new Class[1];
  -
  -                    classes[0] = Hashtable.class;
  -                    Object objects[] = new Object[1];
  -
  -                    objects[0] = attributes;
  -                    Constructor constructor =
  -                            extractorClass.getConstructor(classes);
  -
  -                    theSecureFactory =
  -                            (SocketFactory) constructor.newInstance(objects);
  -                }
  +            } catch (Exception e) {
  +                log.error(JavaUtils.getMessage("exception00"), e);
               }
  -        } catch (Exception e) {
  -
  -            // If something goes wrong here, should we just fall
  -            // through and use the default one?
  -            log.error(JavaUtils.getMessage("exception00"), e);
           }
           return theSecureFactory;
       }
  
  
  
  1.3       +18 -30    xml-axis/java/src/org/apache/axis/components/net/DefaultSocketFactory.java
  
  Index: DefaultSocketFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/net/DefaultSocketFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultSocketFactory.java	2 Aug 2002 17:27:42 -0000	1.2
  +++ DefaultSocketFactory.java	16 Aug 2002 22:51:21 -0000	1.3
  @@ -104,55 +104,43 @@
               String host, int port, StringBuffer otherHeaders, BooleanHolder useFullURL)
               throws Exception {
   
  +        TransportClientProperties tcp = TransportClientPropertiesFactory.create("http");
  +
           Socket sock = null;
  -        String proxyHost = getGlobalProperty("http.proxyHost");
  -        String proxyPort = getGlobalProperty("http.proxyPort");
  -        String nonProxyHosts = getGlobalProperty("http.nonProxyHosts");
  -        boolean hostInNonProxyList = isHostInNonProxyList(host, nonProxyHosts);
  -        String proxyUsername = getGlobalProperty("http.proxyUser");
  -        String proxyPassword = getGlobalProperty("http.proxyPassword");
  +        boolean hostInNonProxyList = isHostInNonProxyList(host, tcp.getNonProxyHosts());
   
  -        if (proxyUsername != null) {
  +        if (tcp.getProxyUser().length() != 0) {
               StringBuffer tmpBuf = new StringBuffer();
   
  -            tmpBuf.append(proxyUsername).append(":").append((proxyPassword
  -                    == null)
  -                    ? ""
  -                    : proxyPassword);
  +            tmpBuf.append(tcp.getProxyUser())
  +                  .append(":")
  +                  .append(tcp.getProxyPassword());
               otherHeaders.append(HTTPConstants.HEADER_PROXY_AUTHORIZATION)
  -                    .append(": Basic ")
  -                    .append(Base64.encode(tmpBuf.toString().getBytes()))
  -                    .append("\r\n");
  +                        .append(": Basic ")
  +                        .append(Base64.encode(tmpBuf.toString().getBytes()))
  +                        .append("\r\n");
           }
           if (port == -1) {
               port = 80;
           }
  -        if ((proxyHost == null) || proxyHost.equals("") || (proxyPort == null)
  -                || proxyPort.equals("") || hostInNonProxyList) {
  +        if ((tcp.getProxyHost().length() == 0) ||
  +            (tcp.getProxyPort().length() == 0) ||
  +            hostInNonProxyList)
  +        {
               sock = new Socket(host, port);
               if (log.isDebugEnabled()) {
                   log.debug(JavaUtils.getMessage("createdHTTP00"));
               }
           } else {
  -            sock = new Socket(proxyHost, new Integer(proxyPort).intValue());
  +            sock = new Socket(tcp.getProxyHost(),
  +                              new Integer(tcp.getProxyPort()).intValue());
               if (log.isDebugEnabled()) {
  -                log.debug(JavaUtils.getMessage("createdHTTP01", proxyHost,
  -                        proxyPort));
  +                log.debug(JavaUtils.getMessage("createdHTTP01", tcp.getProxyHost(),
  +                          tcp.getProxyPort()));
               }
               useFullURL.value = true;
           }
           return sock;
  -    }
  -
  -    /**
  -     * Method getGlobalProperty
  -     *
  -     * @param property
  -     *
  -     * @return
  -     */
  -    protected String getGlobalProperty(String property) {
  -        return AxisProperties.getProperty(property);
       }
   
       /**
  
  
  
  1.2       +5 -3      xml-axis/java/src/org/apache/axis/components/net/SocketFactory.java
  
  Index: SocketFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/net/SocketFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SocketFactory.java	9 Jul 2002 12:54:53 -0000	1.1
  +++ SocketFactory.java	16 Aug 2002 22:51:21 -0000	1.2
  @@ -74,7 +74,9 @@
        *
        * @throws Exception
        */
  -    public Socket create(
  -            String host, int port, StringBuffer otherHeaders,
  -            BooleanHolder useFullURL) throws Exception;
  +    public Socket create(String host,
  +                         int port,
  +                         StringBuffer otherHeaders,
  +                         BooleanHolder useFullURL)
  +        throws Exception;
   }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/components/net/TransportClientProperties.java
  
  Index: TransportClientProperties.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.net;
  
  /**
   * @author Richard A. Sitze
   */
  public interface TransportClientProperties {
      
      /**
       * Returns a valid String, may be empty ("").
       */
      public String getProxyHost();
  
      /**
       * Returns a valid String, may be empty ("").
       */
      public String getNonProxyHosts();
  
      /**
       * Returns a valid String, may be empty ("").
       */
      public String getProxyPort();
  
      /**
       * Returns a valid String, may be empty ("").
       */
      public String getProxyUser();
  
      /**
       * Returns a valid String, may be empty ("").
       */
      public String getProxyPassword();
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/components/net/TransportClientPropertiesFactory.java
  
  Index: TransportClientPropertiesFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.net;
  
  import java.util.HashMap;
  
  import org.apache.axis.AxisProperties;
  import org.apache.axis.utils.JavaUtils;
  
  import org.apache.axis.components.logger.LogFactory;
  import org.apache.commons.logging.Log;
  
  
  /**
   * @author Richard A. Sitze
   */
  public class TransportClientPropertiesFactory {
      protected static Log log =
              LogFactory.getLog(SocketFactoryFactory.class.getName());
      
      private static HashMap cache = new HashMap();
      private static HashMap defaults = new HashMap();
      
      static {
          defaults.put("http", DefaultHTTPTransportClientProperties.class);
          defaults.put("https", DefaultHTTPSTransportClientProperties.class);
      }
  
      public static TransportClientProperties create(String protocol)
      {
          TransportClientProperties tcp = null;
          
          try {
              tcp = (TransportClientProperties)cache.get(protocol);
              
              if (tcp == null) {
                  tcp = (TransportClientProperties)
                      AxisProperties.newInstance(TransportClientProperties.class,
                                                 (Class)defaults.get(protocol));
  
                  if (tcp != null) {
                      cache.put(protocol, tcp);
                  }
              }
          } catch (Exception e) {
              log.error(JavaUtils.getMessage("exception00"), e);
              tcp = null;
          }
          
          return tcp;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/components/net/DefaultHTTPTransportClientProperties.java
  
  Index: DefaultHTTPTransportClientProperties.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.net;
  
  import org.apache.axis.AxisProperties;
  
  
  /**
   * @author Richard A. Sitze
   */
  public class DefaultHTTPTransportClientProperties
      implements TransportClientProperties {
          
      private final static String emptyString = "";
  
      protected String proxyHost = null;
      protected String nonProxyHosts = null;
      protected String proxyPort = null;
      protected String proxyUser = null;
      protected String proxyPassword = null;
  
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getProxyHost()
       */
      public String getProxyHost() {
          if (proxyHost == null) {
              proxyHost = AxisProperties.getProperty("http.proxyHost");
              if (proxyHost == null)
                  proxyHost = emptyString;
          }
          return proxyHost;
      }
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getNonProxyHosts()
       */
      public String getNonProxyHosts() {
          if (nonProxyHosts == null) {
              nonProxyHosts = AxisProperties.getProperty("http.nonProxyHosts");
              if (nonProxyHosts == null)
                  nonProxyHosts = emptyString;
          }
          return nonProxyHosts;
      }
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getPort()
       */
      public String getProxyPort() {
          if (proxyPort == null) {
              proxyPort = AxisProperties.getProperty("http.proxyPort");
              if (proxyPort == null)
                  proxyPort = emptyString;
          }
          return proxyPort;
      }
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getUser()
       */
      public String getProxyUser() {
          if (proxyUser == null) {
              proxyUser = AxisProperties.getProperty("http.proxyUser");
              if (proxyUser == null)
                  proxyUser = emptyString;
          }
          return proxyUser;
      }
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getPassword()
       */
      public String getProxyPassword() {
          if (proxyPassword == null) {
              proxyPassword = AxisProperties.getProperty("http.proxyPassword");
              if (proxyPassword == null)
                  proxyPassword = emptyString;
          }
          return proxyPassword;
      }
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/components/net/DefaultHTTPSTransportClientProperties.java
  
  Index: DefaultHTTPSTransportClientProperties.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *    Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.components.net;
  
  import org.apache.axis.AxisProperties;
  
  
  /**
   * @author Richard A. Sitze
   */
  public class DefaultHTTPSTransportClientProperties
      extends DefaultHTTPTransportClientProperties {
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getProxyHost()
       */
      public String getProxyHost() {
          if (proxyHost == null) {
              proxyHost = AxisProperties.getProperty("https.proxyHost");
              super.getProxyHost();
          }
          return proxyHost;
      }
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getNonProxyHosts()
       */
      public String getNonProxyHosts() {
          if (nonProxyHosts == null) {
              nonProxyHosts = AxisProperties.getProperty("https.nonProxyHosts");
              super.getNonProxyHosts();
          }
          return nonProxyHosts;
      }
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getPort()
       */
      public String getProxyPort() {
          if (proxyPort == null) {
              proxyPort = AxisProperties.getProperty("https.proxyPort");
              super.getProxyPort();
          }
          return proxyPort;
      }
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getUser()
       */
      public String getProxyUser() {
          if (proxyUser == null) {
              proxyUser = AxisProperties.getProperty("https.proxyUser");
              super.getProxyUser();
          }
          return proxyUser;
      }
  
      /**
       * @see org.apache.axis.components.net.TransportClientProperties#getPassword()
       */
      public String getProxyPassword() {
          if (proxyPassword == null) {
              proxyPassword = AxisProperties.getProperty("https.proxyPassword");
              super.getProxyPassword();
          }
          return proxyPassword;
      }
  }
  
  
  
  1.4       +14 -2     xml-axis/java/src/org/apache/axis/utils/DefaultAuthenticator.java
  
  Index: DefaultAuthenticator.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/DefaultAuthenticator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultAuthenticator.java	12 Aug 2002 22:52:13 -0000	1.3
  +++ DefaultAuthenticator.java	16 Aug 2002 22:51:21 -0000	1.4
  @@ -54,12 +54,17 @@
   
   package org.apache.axis.utils;
   
  +import org.apache.axis.components.net.TransportClientProperties;
  +import org.apache.axis.components.net.TransportClientPropertiesFactory;
  +
   
   /**
    * This class is used by WSDL2javaAntTask and WSDL2.
    * Supports the http.proxyUser and http.proxyPassword properties.
    */
   public class DefaultAuthenticator extends java.net.Authenticator {
  +    private TransportClientProperties tcp = null;
  +    
       private String user;
       private String password;
   
  @@ -71,11 +76,18 @@
       protected java.net.PasswordAuthentication getPasswordAuthentication() {
           // if user and password weren't provided, check the system properties
           if (user == null) {
  -            user = System.getProperty("http.proxyUser", "");
  +            user = getTransportClientProperties().getProxyUser();
           }
           if (password == null) {
  -            password = System.getProperty("http.proxyPassword", "");
  +            password = getTransportClientProperties().getProxyPassword();
           }
           return new java.net.PasswordAuthentication(user, password.toCharArray());
  +    }
  +    
  +    private TransportClientProperties getTransportClientProperties() {
  +        if (tcp == null) {
  +            tcp = TransportClientPropertiesFactory.create("http");
  +        }
  +        return tcp;
       }
   }
  
  
  
  1.61      +3 -2      xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
  
  Index: JWSProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- JWSProcessor.java	6 Aug 2002 03:55:04 -0000	1.60
  +++ JWSProcessor.java	16 Aug 2002 22:51:21 -0000	1.61
  @@ -436,8 +436,9 @@
           }
   
           // boot classpath isn't found in above search
  -        if(AxisProperties.getProperty("sun.boot.class.path") != null) {
  -            classpath.append(AxisProperties.getProperty("sun.boot.class.path"));
  +        String bootClassPath = AxisProperties.getProperty("sun.boot.class.path");
  +        if( bootClassPath != null) {
  +            classpath.append(bootClassPath);
           }
   
           return classpath.toString();
  
  
  
  1.4       +28 -50    xml-axis/java/src/org/apache/axis/transport/http/CommonsHTTPSender.java
  
  Index: CommonsHTTPSender.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/CommonsHTTPSender.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CommonsHTTPSender.java	4 Aug 2002 03:27:24 -0000	1.3
  +++ CommonsHTTPSender.java	16 Aug 2002 22:51:21 -0000	1.4
  @@ -55,7 +55,6 @@
   package org.apache.axis.transport.http;
   
   import org.apache.axis.AxisFault;
  -import org.apache.axis.AxisProperties;
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.components.logger.LogFactory;
  @@ -63,6 +62,8 @@
   import org.apache.axis.encoding.Base64;
   import org.apache.axis.handlers.BasicHandler;
   import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.components.net.TransportClientProperties;
  +import org.apache.axis.components.net.TransportClientPropertiesFactory;
   import org.apache.commons.httpclient.Credentials;
   import org.apache.commons.httpclient.Header;
   import org.apache.commons.httpclient.HttpConnection;
  @@ -234,56 +235,36 @@
        */
       private HttpConnection getSecureConnection(
               HttpState state, String host, int port) throws Exception {
  +        TransportClientProperties tcp = TransportClientPropertiesFactory.create("https");
   
           if (port == -1) {
               port = 443;
           }
   
  -        // Get https.proxyXXX settings
  -        String tunnelHost = AxisProperties.getProperty("https.proxyHost");
  -        String tunnelPortStr = AxisProperties.getProperty("https.proxyPort");
  -        String nonProxyHosts = AxisProperties.getProperty("https.nonProxyHosts");
  -
  -        // Use http.proxyXXX settings if https.proxyXXX is not set
  -        if (tunnelHost == null) {
  -            tunnelHost = AxisProperties.getProperty("http.proxyHost");
  -        }
  -        if (tunnelPortStr == null) {
  -            tunnelPortStr = AxisProperties.getProperty("http.proxyPort");
  -        }
  -        if (nonProxyHosts == null) {
  -            nonProxyHosts = AxisProperties.getProperty("http.nonProxyHosts");
  -        }
           boolean hostInNonProxyList =
  -                isHostInNonProxyList(host, nonProxyHosts);
  +                isHostInNonProxyList(host, tcp.getNonProxyHosts());
   
  -        if ((tunnelHost == null) || tunnelHost.equals("")
  -                || hostInNonProxyList) {
  +        if (tcp.getProxyHost().length() == 0 || hostInNonProxyList) {
               return new HttpConnection(host, port, true);
           } else {
   
               // Default proxy port is 80, even for https
  -            int tunnelPort = ((tunnelPortStr != null)
  -                    ? ((Integer.parseInt(tunnelPortStr) < 0)
  -                    ? 80
  -                    : Integer.parseInt(tunnelPortStr))
  -                    : 80);
  -            String tunnelUser = AxisProperties.getProperty("https.proxyUser");
  -            String tunnelPassword = AxisProperties.getProperty("https.proxyPassword");
  -
  -            if (tunnelUser == null) {
  -                tunnelUser = AxisProperties.getProperty("http.proxyUser");
  -            }
  -            if (tunnelPassword == null) {
  -                tunnelPassword = AxisProperties.getProperty("http.proxyPassword");
  -            }
  -            if (tunnelUser != null) {
  +            int tunnelPort = ((tcp.getProxyPort().length() != 0)
  +                              ? Integer.parseInt(tcp.getProxyPort())
  +                              : 80);
  +
  +            if (tunnelPort < 0)
  +                tunnelPort = 80;
  +                
  +            if (tcp.getProxyUser().length() != 0) {
                   Credentials proxyCred =
  -                        new UsernamePasswordCredentials(tunnelUser, tunnelPassword);
  +                        new UsernamePasswordCredentials(tcp.getProxyUser(),
  +                                                        tcp.getProxyPassword());
   
                   state.setProxyCredentials(null, proxyCred);
               }
  -            return new HttpConnection(tunnelHost, tunnelPort, host, port, true);
  +
  +            return new HttpConnection(tcp.getProxyHost(), tunnelPort, host, port, true);
           }
       }
   
  @@ -300,32 +281,29 @@
        */
       private HttpConnection getConnection(HttpState state, String host, int port)
               throws Exception {
  +        TransportClientProperties tcp = TransportClientPropertiesFactory.create("http");
   
  -        String proxyHost = AxisProperties.getProperty("http.proxyHost");
  -        String proxyPort = AxisProperties.getProperty("http.proxyPort");
  -        String nonProxyHosts = AxisProperties.getProperty("http.nonProxyHosts");
           boolean hostInNonProxyList =
  -                isHostInNonProxyList(host, nonProxyHosts);
  -        String proxyUsername = AxisProperties.getProperty("http.proxyUser");
  -        String proxyPassword = AxisProperties.getProperty("http.proxyPassword");
  +                isHostInNonProxyList(host, tcp.getNonProxyHosts());
   
           if (port == -1) {
               port = 80;
           }
  -        if ((proxyHost == null) || proxyHost.equals("") || (proxyPort == null)
  -                || proxyPort.equals("") || hostInNonProxyList) {
  +        if (tcp.getProxyHost().length() == 0 ||
  +            tcp.getProxyPort().length() == 0 ||
  +            hostInNonProxyList) {
               return new HttpConnection(host, port);
           } else {
  -            if (proxyUsername != null) {
  +            if (tcp.getProxyUser().length() != 0) {
                   Credentials proxyCred =
  -                        new UsernamePasswordCredentials(proxyUsername,
  -                                proxyPassword);
  +                        new UsernamePasswordCredentials(tcp.getProxyUser(),
  +                                                        tcp.getProxyPassword());
   
                   state.setProxyCredentials(null, proxyCred);
               }
  -            return new HttpConnection(proxyHost,
  -                    new Integer(proxyPort).intValue(), host,
  -                    port);
  +            return new HttpConnection(tcp.getProxyHost(),
  +                                      new Integer(tcp.getProxyPort()).intValue(), host,
  +                                      port);
           }
       }
   
  
  
  

Mime
View raw message