com.infoengine.soap
Class RPCHandler

java.lang.Object
  extended bycom.infoengine.soap.RPCHandler

public class RPCHandler
extends Object

this class should be used by Info*Engine SOAP services in a standard request/response situation (HTTP or similar)


Nested Class Summary
(package private)  class RPCHandler.XEchoSpaceTimer
           
(package private)  class RPCHandler.XEchoSpaceTimerTask
           
 
Field Summary
static String CLIMBER
           
private static String CONTENT_TYPE
           
private static byte[] CRLF
           
static long DEFAULT_XECHO_INTERVAL
           
private  String defaultDomain
           
static String GROUP_IN
           
private static String GROUP_OUT_NAME
           
static String GROUP_VDB
           
private  TrustedHostValidator hostValidator
           
private  KeyStore localKeyStore
           
private static byte[] ONE_BYTE_CHUNK
           
private static boolean PROXY_CHECKED
           
private static InetAddress[] PROXY_IPS
           
private  String remoteHost
           
static String RENDER_META
           
private static String RESOURCE
           
static String RETURN_UNTUNNELLED
           
private static String SERVLET_PROXY
           
private static byte SPACE
           
static String TUNNELLED_CLIENT_XHEADER
           
static String WILDFIRE
           
static String WILDFIRE_XECHO_PROPERTY
           
static String XECHO_HEADER
           
 
Constructor Summary
RPCHandler()
           
 
Method Summary
private  boolean _useSAX(Hashtable headers)
           
private static void addParameter(Element e, IeCollection vdb, String name, Object o)
           
private static void checkProxySetup()
           
static Timer finishTimer(Timer timer)
           
private  String getDomain(String cls)
          get the domain associated with a class
private  KeyStore getLocalKeyStore()
           
private static String getProperty(Properties props, String propName)
           
private static String getProperty(Properties props, String propName, String dflt)
           
private  Vector getReferenceList(javax.xml.soap.SOAPElement signature, javax.xml.soap.SOAPEnvelope env)
           
static String getServletProxy()
           
private  Task getTask(Hashtable headers)
          build a factory task with an @SERVER group that reflects the contents of headers
static String getTasks(String cls)
          where are the tasks associated with a class?
private  long getXechoSpaceInterval(Hashtable headers)
          Checks HTTP headers for a wildfire User-Agent or the presense of an X header (X-Echo-space-interval, value of seconds) signalling that spaces should be echoed for long running requests.
 RPCHandler.XEchoSpaceTimer getXEchoSpaceTimer(Hashtable headers, javax.servlet.http.HttpServletResponse response)
          Checks HTTP headers for a wildfire User-Agent or the presense of an X header (X-Echo-space-interval, value of seconds) signalling that spaces should be echoed for long running requests.
 RPCHandler.XEchoSpaceTimer getXEchoSpaceTimer(Hashtable headers, OutputStream os)
          Checks HTTP headers for a wildfire User-Agent or the presense of an X header (X-Echo-space-interval, value of seconds) signalling that spaces should be echoed for long running requests.
static boolean isProxyHost(String host)
           
static void parseSoapBody(javax.xml.soap.SOAPBody body, javax.xml.soap.SOAPMessage message, Group formGroup, IeCollection vdb, StringBuffer methodName)
          populate @FORM with the parameters for this method call
 javax.xml.soap.SOAPMessage postProcess(javax.xml.soap.SOAPMessage soapRequest, String className, String methodName, Hashtable headers, OutputStream errorStream)
          handle a "preProcessed" SOAP request using the standard Info*Engine process and serialize a SOAP response.
 javax.xml.soap.SOAPMessage postProcess(javax.xml.soap.SOAPMessage soapRequest, String className, String methodName, Hashtable headers, OutputStream errorStream, OutputStream streamMessageTo, Timer timer)
           
private  javax.xml.soap.SOAPMessage postProcess(String className, String methodName, Hashtable headers, Group formGroup, IeCollection vdb, SOAPAttachmentInputStream attachIS, OutputStream errorStream, OutputStream streamMessageTo, Timer timer)
           
 javax.xml.soap.SOAPMessage preProcess(Hashtable headers, InputStream is, OutputStream errorStream)
          get the SOAPMessage off of the stream, write a fault to os on failure
 javax.xml.soap.SOAPMessage preProcess(Hashtable headers, javax.xml.soap.SOAPMessage soapRequest, OutputStream errorStream)
           
 void process(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          handle an incoming SOAP request using the standard Info*Engine process and serialize a SOAP response.
 javax.xml.soap.SOAPMessage process(javax.xml.soap.SOAPMessage request)
          This is innefficient but sufficient for a POC
 javax.xml.soap.SOAPMessage process(String className, String methodName, Hashtable headers, InputStream is, OutputStream errorStream, OutputStream streamMessageTo, Timer timer)
          handle an incoming SOAP request using the standard Info*Engine process and serialize a SOAP response.
static void processHeader(javax.xml.soap.SOAPHeader header, Hashtable headers)
          copy headers from SOAPHeader into hashtable for easier manipulation
static void processHeader(javax.xml.soap.SOAPHeader header, Hashtable headers, boolean signed)
          copy headers from SOAPHeader into hashtable for easier manipulation
static boolean ranOnce(Timer timer)
           
static boolean renderMeta(String cls)
          output metadata for this class?
 void setDefaultDomain(String dflt)
          the default domain to use when domain is undefined
 void setHostValidator(TrustedHostValidator validator)
          TrustedHostValidator to use to make sure the incoming request can be trusted and doesn't need to be signed, etc.
 void setRemoteHost(String host)
          hostname of client
 boolean signed(javax.xml.soap.SOAPMessage request)
           
private  void validSignature(javax.xml.soap.SOAPMessage request, String soapSigElementName, String sigElementName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TUNNELLED_CLIENT_XHEADER

public static final String TUNNELLED_CLIENT_XHEADER
See Also:
Constant Field Values

GROUP_IN

public static final String GROUP_IN
See Also:
Constant Field Values

GROUP_VDB

public static final String GROUP_VDB
See Also:
Constant Field Values

CLIMBER

public static final String CLIMBER
See Also:
Constant Field Values

RENDER_META

public static final String RENDER_META
See Also:
Constant Field Values

RETURN_UNTUNNELLED

public static final String RETURN_UNTUNNELLED
See Also:
Constant Field Values

WILDFIRE

public static final String WILDFIRE
See Also:
Constant Field Values

WILDFIRE_XECHO_PROPERTY

public static final String WILDFIRE_XECHO_PROPERTY
See Also:
Constant Field Values

XECHO_HEADER

public static final String XECHO_HEADER
See Also:
Constant Field Values

DEFAULT_XECHO_INTERVAL

public static final long DEFAULT_XECHO_INTERVAL
See Also:
Constant Field Values

SPACE

private static final byte SPACE
See Also:
Constant Field Values

ONE_BYTE_CHUNK

private static final byte[] ONE_BYTE_CHUNK

CRLF

private static final byte[] CRLF

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

GROUP_OUT_NAME

private static final String GROUP_OUT_NAME
See Also:
Constant Field Values

CONTENT_TYPE

private static final String CONTENT_TYPE
See Also:
Constant Field Values

defaultDomain

private String defaultDomain

localKeyStore

private KeyStore localKeyStore

hostValidator

private TrustedHostValidator hostValidator

remoteHost

private String remoteHost

PROXY_CHECKED

private static boolean PROXY_CHECKED

SERVLET_PROXY

private static String SERVLET_PROXY

PROXY_IPS

private static InetAddress[] PROXY_IPS
Constructor Detail

RPCHandler

public RPCHandler()
Method Detail

setHostValidator

public void setHostValidator(TrustedHostValidator validator)
TrustedHostValidator to use to make sure the incoming request can be trusted and doesn't need to be signed, etc.


setRemoteHost

public void setRemoteHost(String host)
hostname of client


setDefaultDomain

public void setDefaultDomain(String dflt)
the default domain to use when domain is undefined


getDomain

private String getDomain(String cls)
get the domain associated with a class


getTasks

public static String getTasks(String cls)
where are the tasks associated with a class?


renderMeta

public static boolean renderMeta(String cls)
output metadata for this class?


getTask

private Task getTask(Hashtable headers)
build a factory task with an @SERVER group that reflects the contents of headers


parseSoapBody

public static void parseSoapBody(javax.xml.soap.SOAPBody body,
                                 javax.xml.soap.SOAPMessage message,
                                 Group formGroup,
                                 IeCollection vdb,
                                 StringBuffer methodName)
                          throws javax.xml.soap.SOAPException
populate @FORM with the parameters for this method call

Throws:
javax.xml.soap.SOAPException

addParameter

private static void addParameter(Element e,
                                 IeCollection vdb,
                                 String name,
                                 Object o)

getXechoSpaceInterval

private long getXechoSpaceInterval(Hashtable headers)
Checks HTTP headers for a wildfire User-Agent or the presense of an X header (X-Echo-space-interval, value of seconds) signalling that spaces should be echoed for long running requests.

Parameters:
headers - The HTTP headers.
Returns:
milliseconds, -1 if behavior should remain unchanged.

getXEchoSpaceTimer

public RPCHandler.XEchoSpaceTimer getXEchoSpaceTimer(Hashtable headers,
                                                     OutputStream os)
Checks HTTP headers for a wildfire User-Agent or the presense of an X header (X-Echo-space-interval, value of seconds) signalling that spaces should be echoed for long running requests. If it's decided that long running requests should be supported a timer will be created. Any caller of this method should be absolutely certain to call the finishTimer method with the resulting timer in a finally block.

Parameters:
headers - The HTTP headers.
os - The OutputStream to write spaces to.
Returns:
XEchoSpaceTimer A timer or null.

getXEchoSpaceTimer

public RPCHandler.XEchoSpaceTimer getXEchoSpaceTimer(Hashtable headers,
                                                     javax.servlet.http.HttpServletResponse response)
                                              throws IOException
Checks HTTP headers for a wildfire User-Agent or the presense of an X header (X-Echo-space-interval, value of seconds) signalling that spaces should be echoed for long running requests. If it's decided that long running requests should be supported a timer will be created. Any caller of this method should be absolutely certain to call the finishTimer method with the resulting timer in a finally block.

Parameters:
headers - The HTTP headers.
response - The HttpServletResponse to write spaces to.
Returns:
XEchoSpaceTimer A timer or null.
Throws:
IOException

finishTimer

public static Timer finishTimer(Timer timer)

ranOnce

public static boolean ranOnce(Timer timer)

process

public void process(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
             throws IOException
handle an incoming SOAP request using the standard Info*Engine process and serialize a SOAP response.

Parameters:
request - - incoming request to a servlet
response - - outgoing response to SOAP client
Throws:
IOException - if there is an error retrieving servlet streams

processHeader

public static void processHeader(javax.xml.soap.SOAPHeader header,
                                 Hashtable headers)
copy headers from SOAPHeader into hashtable for easier manipulation

Parameters:
header - the soap header
headers - the hashtable to store values in

processHeader

public static void processHeader(javax.xml.soap.SOAPHeader header,
                                 Hashtable headers,
                                 boolean signed)
copy headers from SOAPHeader into hashtable for easier manipulation

Parameters:
header - the soap header
headers - the hashtable to store values in
signed - whether or not the message was signed (auth-user will not persist if false)

_useSAX

private boolean _useSAX(Hashtable headers)

preProcess

public javax.xml.soap.SOAPMessage preProcess(Hashtable headers,
                                             InputStream is,
                                             OutputStream errorStream)
get the SOAPMessage off of the stream, write a fault to os on failure

Parameters:
headers - MIME headers
is - stream to read message from
Returns:
SOAPMessage or null on failure

preProcess

public javax.xml.soap.SOAPMessage preProcess(Hashtable headers,
                                             javax.xml.soap.SOAPMessage soapRequest,
                                             OutputStream errorStream)

process

public javax.xml.soap.SOAPMessage process(javax.xml.soap.SOAPMessage request)
                                   throws javax.xml.soap.SOAPException,
                                          IOException
This is innefficient but sufficient for a POC

Throws:
javax.xml.soap.SOAPException
IOException

process

public javax.xml.soap.SOAPMessage process(String className,
                                          String methodName,
                                          Hashtable headers,
                                          InputStream is,
                                          OutputStream errorStream,
                                          OutputStream streamMessageTo,
                                          Timer timer)
handle an incoming SOAP request using the standard Info*Engine process and serialize a SOAP response. meant for use outside of a servlet. all exceptions are handled internally and serialized as a SOAPFault to the supplied OutputStream.

Parameters:
className - the class defined containing task delegates. May be null, if not supplied will look for a SOAPAction header to derive this from.
methodName - the method defined within the class, supplied by className, to be called. May be null, if not supplied will look for a SOAPAction header and then within the request body itself.
headers - a list of HTTP headers associated with this request. these will be passed along to the task delegate in @SERVER;
is - InputStream to read the request from
errorStream - OutputStream to serialize a fault to.

postProcess

public javax.xml.soap.SOAPMessage postProcess(javax.xml.soap.SOAPMessage soapRequest,
                                              String className,
                                              String methodName,
                                              Hashtable headers,
                                              OutputStream errorStream)
handle a "preProcessed" SOAP request using the standard Info*Engine process and serialize a SOAP response. meant for use outside of a servlet. all exceptions are handled internally and serialized as a SOAPFault to the supplied OutputStream.

Parameters:
className - the class defined containing task delegates. May be null, if not supplied will look for a SOAPAction header to derive this from.
methodName - the method defined within the class, supplied by className, to be called. May be null, if not supplied will look for a SOAPAction header and then within the request body itself.
headers - a list of HTTP headers associated with this request. these will be passed along to the task delegate in @SERVER;
errorStream - OutputStream to serialize a fault to.

postProcess

public javax.xml.soap.SOAPMessage postProcess(javax.xml.soap.SOAPMessage soapRequest,
                                              String className,
                                              String methodName,
                                              Hashtable headers,
                                              OutputStream errorStream,
                                              OutputStream streamMessageTo,
                                              Timer timer)

postProcess

private javax.xml.soap.SOAPMessage postProcess(String className,
                                               String methodName,
                                               Hashtable headers,
                                               Group formGroup,
                                               IeCollection vdb,
                                               SOAPAttachmentInputStream attachIS,
                                               OutputStream errorStream,
                                               OutputStream streamMessageTo,
                                               Timer timer)

signed

public boolean signed(javax.xml.soap.SOAPMessage request)
               throws Exception
Throws:
Exception

getReferenceList

private Vector getReferenceList(javax.xml.soap.SOAPElement signature,
                                javax.xml.soap.SOAPEnvelope env)
                         throws javax.xml.soap.SOAPException
Throws:
javax.xml.soap.SOAPException

validSignature

private void validSignature(javax.xml.soap.SOAPMessage request,
                            String soapSigElementName,
                            String sigElementName)
                     throws Exception
Throws:
Exception

getLocalKeyStore

private KeyStore getLocalKeyStore()
                           throws Exception
Throws:
Exception

checkProxySetup

private static void checkProxySetup()

isProxyHost

public static boolean isProxyHost(String host)

getServletProxy

public static String getServletProxy()

getProperty

private static String getProperty(Properties props,
                                  String propName)

getProperty

private static String getProperty(Properties props,
                                  String propName,
                                  String dflt)