com.lightdev.app.filemanager.io
Class SecureProxyXmlRpcClient

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by redstone.xmlrpc.XmlRpcParser
          extended by com.lightdev.app.filemanager.io.SecureProxyXmlRpcClient
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, redstone.xmlrpc.XmlRpcInvocationHandler

public class SecureProxyXmlRpcClient
extends redstone.xmlrpc.XmlRpcParser
implements redstone.xmlrpc.XmlRpcInvocationHandler

An XmlRpcClient represents a connection to an XML-RPC enabled server. It implements the XmlRpcInvocationHandler so that it may be used as a relay to other XML-RPC servers when installed in an XmlRpcServer. Ulrich Hilger, September 18, 2008: This class is a copy of class XmlRpcClient from the Redstone XML-RPC library. Class XmlRpcClient does not support HTTPS or proxy connections and has relevant parts private which is why an extension of class XmlRpcClient was not possible.

Author:
Greger Olsson, Ulrich Hilger

Nested Class Summary
 class SecureProxyXmlRpcClient.MyTrustManager
          class to handle trust to certificates
 class SecureProxyXmlRpcClient.MyVerified
          class to verify hostnames
 
Field Summary
 
Fields inherited from class redstone.xmlrpc.XmlRpcParser
ARRAY, BASE64, BOOLEAN, DATE, DOUBLE, I4, I8, INT, MEMBER, NAME, STRING, STRUCT, VALUE
 
Constructor Summary
SecureProxyXmlRpcClient(String url, boolean streamMessages)
          Creates a new client with the ability to send XML-RPC messages to the the server at the given URL.
SecureProxyXmlRpcClient(URL url, boolean streamMessages)
          constructor
 
Method Summary
 boolean getEncryption()
          Ulrich Hilger, September 18, 2008: Added this method to allow to get information about whether or not HTTPS encryption should be used for connections
 String getProxyPort()
           
 String getProxyUrl()
           
protected  void handleParsedValue(Object value)
          Stores away the one and only value contained in XML-RPC responses.
 Object invoke(String method, List arguments)
          Invokes a method on the terminating XML-RPC end point.
 Object invoke(String method, Object[] arguments)
          Invokes a method on the terminating XML-RPC end point.
 void invokeAsynchronously(String method, Object arguments, redstone.xmlrpc.XmlRpcCallback callback)
          A asynchronous version of invoke performing the call in a separate thread and reporting responses, faults, and exceptions through the supplied XmlRpcCallback.
 void setExcryption(boolean connectUsingHttps)
          Ulrich Hilger, September 18, 2008: Added this method to allow to set whether or not HTTPS encryption should be used for connections
 void setProxyPort(String proxyPort)
           
 void setProxyUrl(String proxyUrl)
           
 void setRequestProperties(Map requestProperties)
          Sets the HTTP request properties that the client will use for the next invocation, and any invocations that follow until setRequestProperties() is invoked again.
 void setRequestProperty(String name, String value)
          Sets a single HTTP request property to be used in future invocations.
 void startElement(String uri, String name, String qualifiedName, Attributes attributes)
          Override the startElement() method inherited from XmlRpcParser.
 
Methods inherited from class redstone.xmlrpc.XmlRpcParser
characters, consumeCharData, endElement, parse
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureProxyXmlRpcClient

public SecureProxyXmlRpcClient(String url,
                               boolean streamMessages)
                        throws MalformedURLException
Creates a new client with the ability to send XML-RPC messages to the the server at the given URL.

Parameters:
url - the URL at which the XML-RPC service is locaed
streamMessages - Indicates whether or not to stream messages directly or if the messages should be completed locally before being sent all at once. Streaming is not directly supported by XML-RPC, since the Content-Length header is not included in the HTTP post. If the other end is not relying on Content-Length, streaming the message directly is much more efficient.
Throws:
MalformedURLException

SecureProxyXmlRpcClient

public SecureProxyXmlRpcClient(URL url,
                               boolean streamMessages)
constructor

Method Detail

getProxyPort

public String getProxyPort()

getProxyUrl

public String getProxyUrl()

setProxyPort

public void setProxyPort(String proxyPort)

setProxyUrl

public void setProxyUrl(String proxyUrl)

setExcryption

public void setExcryption(boolean connectUsingHttps)
Ulrich Hilger, September 18, 2008: Added this method to allow to set whether or not HTTPS encryption should be used for connections

Parameters:
connectUsingHttps - indicator of whether or not HTTPS encryption should be used for connections

getEncryption

public boolean getEncryption()
Ulrich Hilger, September 18, 2008: Added this method to allow to get information about whether or not HTTPS encryption should be used for connections

Returns:
true, when this class is set to use HTTPS encrypted connections, false if not

setRequestProperties

public void setRequestProperties(Map requestProperties)
Sets the HTTP request properties that the client will use for the next invocation, and any invocations that follow until setRequestProperties() is invoked again. Null is accepted and means that no special HTTP request properties will be used in any future XML-RPC invocations using this XmlRpcClient instance.

Parameters:
requestProperties - The HTTP request properties to use for future invocations made using this XmlRpcClient instance. These will replace any previous properties set using this method or the setRequestProperty() method.

setRequestProperty

public void setRequestProperty(String name,
                               String value)
Sets a single HTTP request property to be used in future invocations.

Parameters:
name - Name of the property to set
value - The value of the property
See Also:
setRequestProperties()

invoke

public Object invoke(String method,
                     List arguments)
              throws redstone.xmlrpc.XmlRpcException,
                     redstone.xmlrpc.XmlRpcFault
Invokes a method on the terminating XML-RPC end point. The supplied method name and argument collection is used to encode the call into an XML-RPC compatible message.

Specified by:
invoke in interface redstone.xmlrpc.XmlRpcInvocationHandler
Parameters:
method - The name of the method to call.
arguments - The arguments to encode in the call.
Returns:
The object returned from the terminating XML-RPC end point.
Throws:
redstone.xmlrpc.XmlRpcException - One or more of the supplied arguments are unserializable. That is, the built-in serializer connot parse it or find a custom serializer that can. There may also be problems with the socket communication.
redstone.xmlrpc.XmlRpcFault

invoke

public Object invoke(String method,
                     Object[] arguments)
              throws redstone.xmlrpc.XmlRpcException,
                     redstone.xmlrpc.XmlRpcFault
Invokes a method on the terminating XML-RPC end point. The supplied method name and argument vector is used to encode the call into XML-RPC.

Parameters:
method - The name of the method to call.
arguments - The arguments to encode in the call.
Returns:
The object returned from the terminating XML-RPC end point.
Throws:
redstone.xmlrpc.XmlRpcException - One or more of the supplied arguments are unserializable. That is, the built-in serializer connot parse it or find a custom serializer that can. There may also be problems with the socket communication.
redstone.xmlrpc.XmlRpcFault

invokeAsynchronously

public void invokeAsynchronously(String method,
                                 Object arguments,
                                 redstone.xmlrpc.XmlRpcCallback callback)
A asynchronous version of invoke performing the call in a separate thread and reporting responses, faults, and exceptions through the supplied XmlRpcCallback. TODO Determine on proper strategy for instantiating Threads.

Parameters:
method - The name of the method at the server.
arguments - The arguments for the call. This may be either a java.util.List descendant, or a java.lang.Object[] array.
callback - An object implementing the XmlRpcCallback interface. If callback is null, the call will be performed but any results, faults, or exceptions will be ignored (fire and forget).

startElement

public void startElement(String uri,
                         String name,
                         String qualifiedName,
                         Attributes attributes)
                  throws SAXException
Override the startElement() method inherited from XmlRpcParser. This way, we may set the error flag if we run into a fault-tag.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class redstone.xmlrpc.XmlRpcParser
Parameters:
See - SAX documentation
Throws:
SAXException

handleParsedValue

protected void handleParsedValue(Object value)
Stores away the one and only value contained in XML-RPC responses.

Specified by:
handleParsedValue in class redstone.xmlrpc.XmlRpcParser
Parameters:
value - The contained return value.