You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by ae...@apache.org on 2003/01/29 14:40:12 UTC

cvs commit: xml-rpc/src/java/org/apache/xmlrpc/secure/sunssl SunSSLTransportFactory.java

aevers      2003/01/29 05:40:10

  Modified:    src/java/org/apache/xmlrpc
                        DefaultXmlRpcTransportFactory.java
                        XmlRpcTransportFactory.java
               src/java/org/apache/xmlrpc/secure/sunssl
                        SunSSLTransportFactory.java
  Log:
  Add setProperty() method to XmlRpcTransportFactory to allow transport
  factories to be re-configured after creation.
  Make DefaultXmlRpcTransportFactory a bit easier to use, you can now create
  registered Transport Factories using createTransportFactory. The new
  setBasicAuthentication() method will set the authentication information
  for both http and https transports created via the factory.
  Cleaned up the naming of fields/methods associated with the https transport.
  Everything now uses HTTPS as the name instead of a hotch-potch of SSL, secure
  and HTTPS.
  
  Revision  Changes    Path
  1.3       +34 -18    xml-rpc/src/java/org/apache/xmlrpc/DefaultXmlRpcTransportFactory.java
  
  Index: DefaultXmlRpcTransportFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/DefaultXmlRpcTransportFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultXmlRpcTransportFactory.java	29 Jan 2003 00:46:37 -0000	1.2
  +++ DefaultXmlRpcTransportFactory.java	29 Jan 2003 13:40:08 -0000	1.3
  @@ -76,25 +76,31 @@
    */
   public class DefaultXmlRpcTransportFactory implements XmlRpcTransportFactory 
   {
  -    // Default properties to pass to transport factory
  +    // Default properties for new http transports
       protected URL url;
       protected String auth;
   
  -    protected static XmlRpcTransportFactory secureTransportFactory;
  +    protected static XmlRpcTransportFactory httpsTransportFactory;
   
  -    public static final String DEFAULT_SSL_PROVIDER = "comnetsun";
  +    public static final String DEFAULT_HTTPS_PROVIDER = "comnetsun";
   
  -    private static Hashtable sslTransports = new Hashtable (1);
  +    private static Hashtable transports = new Hashtable (1);
   
       static
       {
   	// A mapping of short identifiers to the fully qualified class names of
  -	// common SSL transport factories. If more mappings are added here,
  -	// increase the size of the sslTransports Hashtable used to store them.
  -        sslTransports.put("comnetsun", "org.apache.xmlrpc.secure.sunssl.SunSSLTransportFactory");
  +	// common transport factories. If more mappings are added here,
  +	// increase the size of the transports Hashtable used to store them.
  +        transports.put("comnetsun", "org.apache.xmlrpc.secure.sunssl.SunSSLTransportFactory");
       }
   
  -    public static void setTransport(String transport, Properties properties)
  +    public static void setHTTPSTransport(String transport, Properties properties)
  +        throws XmlRpcClientException
  +    {
  +      httpsTransportFactory = createTransportFactory(transport, properties);    
  +    }
  +
  +    public static XmlRpcTransportFactory createTransportFactory(String transport, Properties properties)
           throws XmlRpcClientException
       {
           String transportFactoryClassName = null;
  @@ -104,7 +110,7 @@
   
           try
           {
  -            transportFactoryClassName = (String) sslTransports.get(transport);
  +            transportFactoryClassName = (String) transports.get(transport);
               if (transportFactoryClassName == null)
               {
                   // Identifier lookup failed, assuming we were provided
  @@ -119,8 +125,7 @@
                   new Object [] { properties });
               if (transportFactoryInstance instanceof XmlRpcTransportFactory)
               {
  -                secureTransportFactory = (XmlRpcTransportFactory) 
  -                    transportFactoryInstance;
  +                return (XmlRpcTransportFactory) transportFactoryInstance;
               }
               else
               {
  @@ -178,17 +183,17 @@
       {
           if ("https".equals(url.getProtocol()))
           {
  -          if (secureTransportFactory == null)
  +          if (httpsTransportFactory == null)
             {
                Properties properties = new Properties();
   
                properties.put(XmlRpcTransportFactory.TRANSPORT_URL, url);
                properties.put(XmlRpcTransportFactory.TRANSPORT_AUTH, auth);
   
  -             setTransport(DEFAULT_SSL_PROVIDER, properties);
  +             setHTTPSTransport(DEFAULT_HTTPS_PROVIDER, properties);
             }
     
  -          return secureTransportFactory.createTransport();
  +          return httpsTransportFactory.createTransport();
           }
           
           return new DefaultXmlRpcTransport(url);
  @@ -202,11 +207,22 @@
        */
       public void setBasicAuthentication(String user, String password)
       {
  -        auth = HttpUtil.encodeBasicAuthentication(user, password);
  +        setProperty(TRANSPORT_AUTH, HttpUtil.encodeBasicAuthentication(user, password));
       }
   
  -    public URL getURL() 
  +    public void setProperty(String propertyName, Object value)
       {
  -        return url;
  +        if (httpsTransportFactory != null)
  +        {
  +           httpsTransportFactory.setProperty(propertyName, value);
  +        }
  +        if (TRANSPORT_AUTH.equals(propertyName))
  +        {
  +          auth = (String) value;
  +        }
  +        else if (TRANSPORT_URL.equals(propertyName))
  +        {
  +          url = (URL) value;
  +        }
       }
   }
  
  
  
  1.3       +9 -1      xml-rpc/src/java/org/apache/xmlrpc/XmlRpcTransportFactory.java
  
  Index: XmlRpcTransportFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/XmlRpcTransportFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XmlRpcTransportFactory.java	28 Jan 2003 10:34:36 -0000	1.2
  +++ XmlRpcTransportFactory.java	29 Jan 2003 13:40:08 -0000	1.3
  @@ -90,4 +90,12 @@
        */
       public XmlRpcTransport createTransport()
       throws XmlRpcClientException;
  +
  +    /**
  +     * Set a property for all newly created transports.
  +     *
  +     * @param propertyName the property to set.
  +     * @param value the value to set it to.
  +     */
  +    public void setProperty(String propertyName, Object value);
   }
  
  
  
  1.2       +13 -1     xml-rpc/src/java/org/apache/xmlrpc/secure/sunssl/SunSSLTransportFactory.java
  
  Index: SunSSLTransportFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/secure/sunssl/SunSSLTransportFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SunSSLTransportFactory.java	28 Jan 2003 10:34:40 -0000	1.1
  +++ SunSSLTransportFactory.java	29 Jan 2003 13:40:09 -0000	1.2
  @@ -176,4 +176,16 @@
       {
          return new DefaultXmlRpcTransport(url, auth);
       }
  +
  +    public void setProperty(String propertyName, Object value)
  +    {
  +        if (TRANSPORT_AUTH.equals(propertyName))
  +        {
  +          auth = (String) value;
  +        }
  +        else if (TRANSPORT_URL.equals(propertyName))
  +        {
  +          url = (URL) value;
  +        }
  +    }
   }
  
  
  

Re: cvs commit: xml-rpc/src/java/org/apache/xmlrpc/secure/sunssl SunSSLTransportFactory.java

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Are there tabs in here, or are you using a 2 char indent?  No tabs plz
-- it screws up diffs.  Thanks!

aevers@apache.org writes:

> aevers      2003/01/29 05:40:10
> 
>   Modified:    src/java/org/apache/xmlrpc
>                         DefaultXmlRpcTransportFactory.java
>                         XmlRpcTransportFactory.java
>                src/java/org/apache/xmlrpc/secure/sunssl
>                         SunSSLTransportFactory.java
>   Log:
>   Add setProperty() method to XmlRpcTransportFactory to allow transport
>   factories to be re-configured after creation.
>   Make DefaultXmlRpcTransportFactory a bit easier to use, you can now create
>   registered Transport Factories using createTransportFactory. The new
>   setBasicAuthentication() method will set the authentication information
>   for both http and https transports created via the factory.
>   Cleaned up the naming of fields/methods associated with the https transport.
>   Everything now uses HTTPS as the name instead of a hotch-potch of SSL, secure
>   and HTTPS.
>   
>   Revision  Changes    Path
>   1.3       +34 -18    xml-rpc/src/java/org/apache/xmlrpc/DefaultXmlRpcTransportFactory.java
>   
>   Index: DefaultXmlRpcTransportFactory.java
>   ===================================================================
>   RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/DefaultXmlRpcTransportFactory.java,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- DefaultXmlRpcTransportFactory.java	29 Jan 2003 00:46:37 -0000	1.2
>   +++ DefaultXmlRpcTransportFactory.java	29 Jan 2003 13:40:08 -0000	1.3
>   @@ -76,25 +76,31 @@
>     */
>    public class DefaultXmlRpcTransportFactory implements XmlRpcTransportFactory 
>    {
>   -    // Default properties to pass to transport factory
>   +    // Default properties for new http transports
>        protected URL url;
>        protected String auth;
>    
>   -    protected static XmlRpcTransportFactory secureTransportFactory;
>   +    protected static XmlRpcTransportFactory httpsTransportFactory;
>    
>   -    public static final String DEFAULT_SSL_PROVIDER = "comnetsun";
>   +    public static final String DEFAULT_HTTPS_PROVIDER = "comnetsun";
>    
>   -    private static Hashtable sslTransports = new Hashtable (1);
>   +    private static Hashtable transports = new Hashtable (1);
>    
>        static
>        {
>    	// A mapping of short identifiers to the fully qualified class names of
>   -	// common SSL transport factories. If more mappings are added here,
>   -	// increase the size of the sslTransports Hashtable used to store them.
>   -        sslTransports.put("comnetsun", "org.apache.xmlrpc.secure.sunssl.SunSSLTransportFactory");
>   +	// common transport factories. If more mappings are added here,
>   +	// increase the size of the transports Hashtable used to store them.
>   +        transports.put("comnetsun", "org.apache.xmlrpc.secure.sunssl.SunSSLTransportFactory");
>        }
>    
>   -    public static void setTransport(String transport, Properties properties)
>   +    public static void setHTTPSTransport(String transport, Properties properties)
>   +        throws XmlRpcClientException
>   +    {
>   +      httpsTransportFactory = createTransportFactory(transport, properties);    
>   +    }
>   +
>   +    public static XmlRpcTransportFactory createTransportFactory(String transport, Properties properties)
>            throws XmlRpcClientException
>        {
>            String transportFactoryClassName = null;
>   @@ -104,7 +110,7 @@
>    
>            try
>            {
>   -            transportFactoryClassName = (String) sslTransports.get(transport);
>   +            transportFactoryClassName = (String) transports.get(transport);
>                if (transportFactoryClassName == null)
>                {
>                    // Identifier lookup failed, assuming we were provided
>   @@ -119,8 +125,7 @@
>                    new Object [] { properties });
>                if (transportFactoryInstance instanceof XmlRpcTransportFactory)
>                {
>   -                secureTransportFactory = (XmlRpcTransportFactory) 
>   -                    transportFactoryInstance;
>   +                return (XmlRpcTransportFactory) transportFactoryInstance;
>                }
>                else
>                {
>   @@ -178,17 +183,17 @@
>        {
>            if ("https".equals(url.getProtocol()))
>            {
>   -          if (secureTransportFactory == null)
>   +          if (httpsTransportFactory == null)
>              {
>                 Properties properties = new Properties();
>    
>                 properties.put(XmlRpcTransportFactory.TRANSPORT_URL, url);
>                 properties.put(XmlRpcTransportFactory.TRANSPORT_AUTH, auth);
>    
>   -             setTransport(DEFAULT_SSL_PROVIDER, properties);
>   +             setHTTPSTransport(DEFAULT_HTTPS_PROVIDER, properties);
>              }
>      
>   -          return secureTransportFactory.createTransport();
>   +          return httpsTransportFactory.createTransport();
>            }
>            
>            return new DefaultXmlRpcTransport(url);
>   @@ -202,11 +207,22 @@
>         */
>        public void setBasicAuthentication(String user, String password)
>        {
>   -        auth = HttpUtil.encodeBasicAuthentication(user, password);
>   +        setProperty(TRANSPORT_AUTH, HttpUtil.encodeBasicAuthentication(user, password));
>        }
>    
>   -    public URL getURL() 
>   +    public void setProperty(String propertyName, Object value)
>        {
>   -        return url;
>   +        if (httpsTransportFactory != null)
>   +        {
>   +           httpsTransportFactory.setProperty(propertyName, value);
>   +        }
>   +        if (TRANSPORT_AUTH.equals(propertyName))
>   +        {
>   +          auth = (String) value;
>   +        }
>   +        else if (TRANSPORT_URL.equals(propertyName))
>   +        {
>   +          url = (URL) value;
>   +        }
>        }
>    }
>   
>   
>   
>   1.3       +9 -1      xml-rpc/src/java/org/apache/xmlrpc/XmlRpcTransportFactory.java
>   
>   Index: XmlRpcTransportFactory.java
>   ===================================================================
>   RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/XmlRpcTransportFactory.java,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- XmlRpcTransportFactory.java	28 Jan 2003 10:34:36 -0000	1.2
>   +++ XmlRpcTransportFactory.java	29 Jan 2003 13:40:08 -0000	1.3
>   @@ -90,4 +90,12 @@
>         */
>        public XmlRpcTransport createTransport()
>        throws XmlRpcClientException;
>   +
>   +    /**
>   +     * Set a property for all newly created transports.
>   +     *
>   +     * @param propertyName the property to set.
>   +     * @param value the value to set it to.
>   +     */
>   +    public void setProperty(String propertyName, Object value);
>    }
>   
>   
>   
>   1.2       +13 -1     xml-rpc/src/java/org/apache/xmlrpc/secure/sunssl/SunSSLTransportFactory.java
>   
>   Index: SunSSLTransportFactory.java
>   ===================================================================
>   RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/secure/sunssl/SunSSLTransportFactory.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- SunSSLTransportFactory.java	28 Jan 2003 10:34:40 -0000	1.1
>   +++ SunSSLTransportFactory.java	29 Jan 2003 13:40:09 -0000	1.2
>   @@ -176,4 +176,16 @@
>        {
>           return new DefaultXmlRpcTransport(url, auth);
>        }
>   +
>   +    public void setProperty(String propertyName, Object value)
>   +    {
>   +        if (TRANSPORT_AUTH.equals(propertyName))
>   +        {
>   +          auth = (String) value;
>   +        }
>   +        else if (TRANSPORT_URL.equals(propertyName))
>   +        {
>   +          url = (URL) value;
>   +        }
>   +    }
>    }
>   
>   
>   
> 

-- 

Daniel Rall <dl...@finemaltcoding.com>