com.waveset.util
Class HttpsUtil

java.lang.Object
  extended bycom.waveset.util.HttpsUtil

public abstract class HttpsUtil
extends java.lang.Object

Utility to provide Https connection functionality regardless of Java version.


Nested Class Summary
static class HttpsUtil.HttpsConnectionException
           
static class HttpsUtil.HttpsUtilException
          Allows differentiating between exceptions passed up from implementation code, and exceptions detected by the HttpsUtil itself.
static interface HttpsUtil.InputStreamHandler
          Enables client code to process data in the response from an HTTPS server after posting a message to it.
 
Field Summary
protected static Trace _trace
           
static java.lang.String CLASS
           
static java.lang.String IMPL_PROPERTY
           
protected  javax.net.SocketFactory mSslSocketFactory
          SocketFactory instance used by the JSSE implementations.
 
Constructor Summary
protected HttpsUtil()
           
 
Method Summary
static HttpsUtil createHttpsUtil(java.lang.String requestedImplementation, java.lang.String certificatePath, java.lang.String passPhrase, java.lang.String certificateType, java.lang.String rootCAPath)
           
protected  java.net.URL createURL(java.lang.String requestString)
          Create the server URL based on request String.
protected abstract  java.io.InputStream getInputStream(java.net.URL url, java.lang.String message)
          Given the (https) url for the server, send the specified message and return an input stream for the response.
protected  void initialize(java.lang.String certificatePath, java.lang.String passPhrase, java.lang.String certType, java.lang.String rootCAPath)
          Initialized the internal state needed to make a connection.
 java.lang.Object post(java.lang.String host, java.lang.String port, java.lang.String path, java.lang.String message, HttpsUtil.InputStreamHandler handler)
           
protected static void writeMessageToStream(java.io.OutputStream os, java.lang.String message)
          Output the specified message to the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS

public static final java.lang.String CLASS
See Also:
Constant Field Values

IMPL_PROPERTY

public static final java.lang.String IMPL_PROPERTY
See Also:
Constant Field Values

_trace

protected static Trace _trace

mSslSocketFactory

protected javax.net.SocketFactory mSslSocketFactory
SocketFactory instance used by the JSSE implementations. It can be used or not as the subclass needs.

Constructor Detail

HttpsUtil

protected HttpsUtil()
Method Detail

createHttpsUtil

public static HttpsUtil createHttpsUtil(java.lang.String requestedImplementation,
                                        java.lang.String certificatePath,
                                        java.lang.String passPhrase,
                                        java.lang.String certificateType,
                                        java.lang.String rootCAPath)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

getInputStream

protected abstract java.io.InputStream getInputStream(java.net.URL url,
                                                      java.lang.String message)
                                               throws java.lang.Exception
Given the (https) url for the server, send the specified message and return an input stream for the response.

Parameters:
url - Server url
message - Message to send to server.
Returns:
InputStream for the server's response.
Throws:
java.lang.Exception

post

public java.lang.Object post(java.lang.String host,
                             java.lang.String port,
                             java.lang.String path,
                             java.lang.String message,
                             HttpsUtil.InputStreamHandler handler)
                      throws java.lang.Exception
Throws:
java.lang.Exception

initialize

protected void initialize(java.lang.String certificatePath,
                          java.lang.String passPhrase,
                          java.lang.String certType,
                          java.lang.String rootCAPath)
                   throws java.security.NoSuchAlgorithmException,
                          java.security.KeyManagementException,
                          java.io.IOException,
                          java.security.cert.CertificateException,
                          java.security.UnrecoverableKeyException,
                          java.security.KeyStoreException
Initialized the internal state needed to make a connection. The supplied default is for JSSE implementations.

Throws:
java.security.NoSuchAlgorithmException
java.security.KeyManagementException
java.io.IOException
java.security.cert.CertificateException
java.security.UnrecoverableKeyException
java.security.KeyStoreException

createURL

protected java.net.URL createURL(java.lang.String requestString)
                          throws java.net.MalformedURLException
Create the server URL based on request String.

Returns:
URL
Throws:
java.net.MalformedURLException

writeMessageToStream

protected static void writeMessageToStream(java.io.OutputStream os,
                                           java.lang.String message)
                                    throws java.io.IOException
Output the specified message to the stream. Note: Closes output stream.

Parameters:
os - OutputStream to receive the message, closed on completion.
message - String to write to ActivCard server.
Throws:
java.io.IOException