Enhydra 5.1 API

org.enhydra.servlet.connectionMethods.https
Class HttpsConnectionMethod

java.lang.Object
  |
  +--org.enhydra.servlet.connectionMethods.StandardConnectionMethod
        |
        +--org.enhydra.servlet.connectionMethods.https.HttpsConnectionMethod
All Implemented Interfaces:
ConnectionMethod, java.lang.Runnable, java.io.Serializable

public class HttpsConnectionMethod
extends StandardConnectionMethod
implements java.lang.Runnable

This class implements the connection method used to accept request for servlets from an HTTP client.

Version:
1.8, 6/98
Author:
Mark Sanguinetti
, SSL added by Steve Latif
See Also:
org.enhydra.servlet.connectionMethods.BasicConnectionMethod, Serialized Form

Field Summary
protected  int backlog
          The backlog parameter for the server socket.
static java.lang.String BIND_ADDR
           
protected  java.lang.String bindAddress
          IP address to bind to.
static java.lang.String CLIENT_AUTHENTICATION
           
static java.lang.String CLIENT_TIMEOUT
           
protected  boolean clientAuthentication
          Client Authentication
protected  int clientTimeout
          The maximum time for a thread to keep a socket connection to the client for.
protected  java.lang.String cmType
          This is temporary, to support the CGI Connection method, which is simply another flavor of this class.
protected  org.enhydra.servlet.connectionMethods.https.Queue connections
          The queue for incoming connections.
protected  com.sun.net.ssl.SSLContext context
          The SSL context for deriving the SSL Socket Factory
static boolean DEFAULT_CLIENT_AUTHENTICATION
           
static int DEFAULT_CLIENT_TIMEOUT
           
static java.lang.String DEFAULT_KEY_MANAGER_ALGORITHM
           
static java.lang.String DEFAULT_KEY_MANAGER_PROVIDER
           
static java.lang.String DEFAULT_KEY_STORE_LOCATION
           
static java.lang.String DEFAULT_KEY_STORE_PROVIDER
           
static int DEFAULT_NUM_THREADS
           
static java.lang.String DEFAULT_PASSWORD
           
static int DEFAULT_QUEUE_SIZE
           
static java.lang.String DEFAULT_SECURE_RANDOM_ALGORITHM
           
static java.lang.String DEFAULT_SECURE_RANDOM_PROVIDER
           
static java.lang.String DEFAULT_SSL_CONTEXT_PROTOCOL
           
static java.lang.String DEFAULT_SSL_CONTEXT_PROVIDER
           
static int DEFAULT_THREAD_TIMEOUT
           
static java.lang.String DEFAULT_TRUST_MANAGER
           
protected  java.lang.Thread dispatcher
          Thread handling the connections.
protected  java.lang.ThreadGroup handlers
          The thread group for HttpHandler threads.
static java.lang.String HTTPS
           
static java.lang.String KEY_MANAGER_ALGORITHM
           
static java.lang.String KEY_MANAGER_PROVIDER
           
static java.lang.String KEY_STORE_LOCATION
           
static java.lang.String KEY_STORE_PROVIDER
           
protected  com.sun.net.ssl.KeyManager[] keyManager
          The list of key managers
protected  java.lang.String keyManagerAlgorithm
          The key manager algorithm
protected  com.sun.net.ssl.KeyManagerFactory keyManagerFactory
          The key manager factory
protected  java.lang.String keyManagerProvider
          The key manager provider
protected  java.security.KeyStore keyStore
          The keystore
protected  java.lang.String keyStoreLocation
          The key store location
protected  java.lang.String keyStoreProvider
          The key store provider
protected  java.util.Vector liveThreads
          A list of references to all HttpHandler threads (active and waiting).
protected static org.apache.log4j.Logger logger
          The logging channel.
protected static org.apache.log4j.Logger loggerSys
          The logger that logs on System.out.
protected  int maxHandlers
          The maximum number of HttpHandler threads.
protected  int maxQueue
          The maximum size of the connection queue.
static java.lang.String NUM_THREADS
           
protected  int numWaiting
          The total number HttpHandler threads (active and waiting).
protected  java.lang.String password
          The password
static java.lang.String PASSWORD
           
protected  int port
          The server port.
static java.lang.String PORT
           
static java.lang.String QUEUE_SIZE
           
static java.lang.String SECURE_RANDOM_ALGORITHM
           
static java.lang.String SECURE_RANDOM_PROVIDER
           
protected  java.security.SecureRandom secureRandom
          Secure random
protected  java.lang.String secureRandomAlgorithm
          The secure random algorithm
protected  java.lang.String secureRandomProvider
          The secure Random provider
protected static java.lang.String SERVER_BUSY_MSG
           
static java.lang.String SERVER_CERTIFICATE
           
protected  javax.net.ssl.SSLServerSocket ss
          The SSL server socket
static java.lang.String SSL
           
static java.lang.String SSL_CONTEXT_PROTOCOL
           
static java.lang.String SSL_CONTEXT_PROVIDER
           
protected  java.lang.String SSLContextProtocol
          The SSL Context protocol
protected  java.lang.String SSLContextProvider
          The SSL Context provider
protected  javax.net.ssl.SSLServerSocketFactory sslServerSocketFactory
          the SSL server socket factories
static java.lang.String THREAD_TIMEOUT
           
protected  int threadTimeout
          The maximum time for an HttpHandler thread to wait for a connection.
static java.lang.String TRUST_MANAGER
           
protected  com.sun.net.ssl.TrustManager[] trustMan
          List of trust managers
protected  java.lang.String trustManager
          The trust manager
protected  com.sun.net.ssl.TrustManagerFactory trustManagerFactory
          The trust manager factory
static java.lang.String TYPE
           
 
Fields inherited from class org.enhydra.servlet.connectionMethods.StandardConnectionMethod
channelTable, filterManager, servletManager
 
Fields inherited from interface org.enhydra.servlet.connectionMethods.ConnectionMethod
disabledChannelHtml, errorHtml, noChannelHtml
 
Constructor Summary
HttpsConnectionMethod()
          Default constructor used for dynamic connection method creation.
 
Method Summary
 boolean channelURLIsValid(java.lang.String channelID)
          This connection method returns valid urls.
 void destroy()
          Shut down the connection method.
 boolean equivalent(ConnectionMethod compareObject)
          Compares the port number to determine equivalency
 java.lang.String getBindAddress()
          Gets the current Bind address, if any.
 Channel getChannelByURLPrefix(java.lang.String url)
          Gets Channel data assocated with a given URL Prefix.
 java.lang.String getChannelURL(java.lang.String channelID)
          Returns the URL that a user would use to connect to this channel.
 boolean getClientAuthentication()
           
 int getClientTimeout()
          Gets the client timeout associated with this connection method.
protected  java.net.Socket getConnection()
          Returns an socket from the connection queue.
 java.lang.String getKeyManagerAlgorithm()
           
 java.lang.String getKeyManagerProvider()
           
 java.lang.String getKeyStoreLocation()
           
 java.lang.String getKeyStoreProvider()
           
 int getMaxHandlers()
           
 int getMaxQueue()
           
 int getNumThreads()
          Gets the maximum number of handler thread associated with this connection method.
 java.lang.String getPassword()
           
 int getPort()
           
 int getQueueSize()
          Gets the maximum queue size associated with this connection method.
 java.lang.String getSecureRandomAlgorithm()
           
 java.lang.String getSecureRandomProvider()
           
 java.lang.String getServerCertificate()
           
 javax.servlet.Servlet getServlet(java.lang.String servletID)
          Gets a reference to the servlet associated with servletID.
 java.lang.String getSSLContextProtocol()
           
 java.lang.String getSSLContextProvider()
           
 int getThreadTimeout()
          Gets the thread timeout associated with this connection method.
 java.lang.String getTrustManager()
           
 java.lang.String getType()
           
 void initialize(Config connectionConfig, java.lang.String id, ServletManager servletManager, FilterManager filterManager)
          Start up.
 void initialize(java.lang.String id, ServletManager servletManager, FilterManager filterManager)
          Start up.
 void run()
          Runs the HttpConnectionMethod.
 void setBindAddress(java.lang.String addr)
          Sets the current Bind address, if any.
 void setClientAuthentication(boolean clientAuthentication)
           
 void setClientTimeout(int clientTimeout)
           
 void setKeyManagerAlgorithm(java.lang.String keyManagerAlgorithm)
           
 void setKeyManagerProvider(java.lang.String keyManagerProvider)
           
 void setKeyStoreLocation(java.lang.String keyStoreLocation)
           
 void setKeyStoreProvider(java.lang.String keyStoreProvider)
           
 void setMaxHandlers(int maxHandlers)
           
 void setMaxQueue(int maxQueue)
           
 void setPassword(java.lang.String password)
           
 void setPort(int port)
           
 void setSecureRandomAlgorithm(java.lang.String secureRandomAlgorithm)
           
 void setSecureRandomProvider(java.lang.String secureRandomProvider)
           
 void setServerCertificate(java.lang.String serverCertificate)
           
 void setSSLContextProtocol(java.lang.String SSLContextProtocol)
           
 void setSSLContextProvider(java.lang.String SSLContextProvider)
           
 void setThreadTimeout(int threadTimeout)
           
 void setTrustManager(java.lang.String trustManager)
           
 void writeToConfig(Config connectionConfig, java.lang.String base)
          Write out self into config fie
 
Methods inherited from class org.enhydra.servlet.connectionMethods.StandardConnectionMethod
addChannel, addTransactionFilter, deleteChannel, disableChannel, enableChannel, getChannelIDs, getChannelStatus, getTransactionFilterIDs, getUniqueChannelName, removeTransactionFilter, resetRequestCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTPS

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

TYPE

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

PORT

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

BIND_ADDR

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

NUM_THREADS

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

QUEUE_SIZE

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

THREAD_TIMEOUT

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

CLIENT_TIMEOUT

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

SSL

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

SERVER_CERTIFICATE

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

SECURE_RANDOM_ALGORITHM

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

SECURE_RANDOM_PROVIDER

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

SSL_CONTEXT_PROVIDER

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

SSL_CONTEXT_PROTOCOL

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

KEY_STORE_LOCATION

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

KEY_STORE_PROVIDER

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

KEY_MANAGER_ALGORITHM

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

KEY_MANAGER_PROVIDER

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

TRUST_MANAGER

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

PASSWORD

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

CLIENT_AUTHENTICATION

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

DEFAULT_NUM_THREADS

public static final int DEFAULT_NUM_THREADS
See Also:
Constant Field Values

DEFAULT_QUEUE_SIZE

public static final int DEFAULT_QUEUE_SIZE
See Also:
Constant Field Values

DEFAULT_THREAD_TIMEOUT

public static final int DEFAULT_THREAD_TIMEOUT
See Also:
Constant Field Values

DEFAULT_CLIENT_TIMEOUT

public static final int DEFAULT_CLIENT_TIMEOUT
See Also:
Constant Field Values

DEFAULT_SECURE_RANDOM_ALGORITHM

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

DEFAULT_SECURE_RANDOM_PROVIDER

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

DEFAULT_SSL_CONTEXT_PROVIDER

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

DEFAULT_SSL_CONTEXT_PROTOCOL

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

DEFAULT_KEY_STORE_LOCATION

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

DEFAULT_KEY_STORE_PROVIDER

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

DEFAULT_KEY_MANAGER_ALGORITHM

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

DEFAULT_KEY_MANAGER_PROVIDER

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

DEFAULT_TRUST_MANAGER

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

DEFAULT_PASSWORD

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

DEFAULT_CLIENT_AUTHENTICATION

public static final boolean DEFAULT_CLIENT_AUTHENTICATION
See Also:
Constant Field Values

SERVER_BUSY_MSG

protected static final java.lang.String SERVER_BUSY_MSG
See Also:
Constant Field Values

cmType

protected java.lang.String cmType
This is temporary, to support the CGI Connection method, which is simply another flavor of this class.


port

protected int port
The server port.


secureRandomAlgorithm

protected java.lang.String secureRandomAlgorithm
The secure random algorithm


secureRandomProvider

protected java.lang.String secureRandomProvider
The secure Random provider


SSLContextProvider

protected java.lang.String SSLContextProvider
The SSL Context provider


SSLContextProtocol

protected java.lang.String SSLContextProtocol
The SSL Context protocol


keyStoreLocation

protected java.lang.String keyStoreLocation
The key store location


keyStoreProvider

protected java.lang.String keyStoreProvider
The key store provider


keyManagerAlgorithm

protected java.lang.String keyManagerAlgorithm
The key manager algorithm


keyManagerProvider

protected java.lang.String keyManagerProvider
The key manager provider


trustManager

protected java.lang.String trustManager
The trust manager


password

protected java.lang.String password
The password


clientAuthentication

protected boolean clientAuthentication
Client Authentication


bindAddress

protected java.lang.String bindAddress
IP address to bind to.


logger

protected static org.apache.log4j.Logger logger
The logging channel.


loggerSys

protected static org.apache.log4j.Logger loggerSys
The logger that logs on System.out.


dispatcher

protected java.lang.Thread dispatcher
Thread handling the connections.


connections

protected org.enhydra.servlet.connectionMethods.https.Queue connections
The queue for incoming connections.


maxQueue

protected int maxQueue
The maximum size of the connection queue.


handlers

protected java.lang.ThreadGroup handlers
The thread group for HttpHandler threads.


maxHandlers

protected int maxHandlers
The maximum number of HttpHandler threads.


threadTimeout

protected int threadTimeout
The maximum time for an HttpHandler thread to wait for a connection.


clientTimeout

protected int clientTimeout
The maximum time for a thread to keep a socket connection to the client for.


backlog

protected int backlog
The backlog parameter for the server socket.


numWaiting

protected int numWaiting
The total number HttpHandler threads (active and waiting).


liveThreads

protected java.util.Vector liveThreads
A list of references to all HttpHandler threads (active and waiting).


secureRandom

protected java.security.SecureRandom secureRandom
Secure random


context

protected com.sun.net.ssl.SSLContext context
The SSL context for deriving the SSL Socket Factory


keyStore

protected java.security.KeyStore keyStore
The keystore


keyManagerFactory

protected com.sun.net.ssl.KeyManagerFactory keyManagerFactory
The key manager factory


keyManager

protected com.sun.net.ssl.KeyManager[] keyManager
The list of key managers


trustManagerFactory

protected com.sun.net.ssl.TrustManagerFactory trustManagerFactory
The trust manager factory


trustMan

protected com.sun.net.ssl.TrustManager[] trustMan
List of trust managers


sslServerSocketFactory

protected javax.net.ssl.SSLServerSocketFactory sslServerSocketFactory
the SSL server socket factories


ss

protected javax.net.ssl.SSLServerSocket ss
The SSL server socket

Constructor Detail

HttpsConnectionMethod

public HttpsConnectionMethod()
Default constructor used for dynamic connection method creation.

Method Detail

destroy

public void destroy()
             throws ConnectionMethodException
Shut down the connection method. Releases the socket, so the port will be free for others to use.

Specified by:
destroy in interface ConnectionMethod
Overrides:
destroy in class StandardConnectionMethod
Throws:
ConnectionMethodException - If an error occurs.

initialize

public void initialize(Config connectionConfig,
                       java.lang.String id,
                       ServletManager servletManager,
                       FilterManager filterManager)
                throws ConnectionMethodException
Start up. Initially there are no channels. Parse the config file for connection information Saves the ServletManager and FilterManager for later use. This initialize is called from the ConnectionMethodManager when the multiserver is started. The config file contain all relevant connection information.

Specified by:
initialize in interface ConnectionMethod
Overrides:
initialize in class StandardConnectionMethod
Parameters:
connectionConfig - The portion of the config file relevant to this connection method
id - The id associated with this connection method
servletManager - The ServletManager to use to convert servletIDs into Servlets.
filterManager - The FilterManager to use to convert filterIDs into Filters.
Throws:
ConnectionMethodException - If unable to start up.
See Also:
Filter, org.enhydra.servlet.StandardConnectionMethod

initialize

public void initialize(java.lang.String id,
                       ServletManager servletManager,
                       FilterManager filterManager)
                throws ConnectionMethodException
Description copied from class: StandardConnectionMethod
Start up. Initially there are no channels. Saves the ServletManager for later use.

This will be called before any other method in this class.

Specified by:
initialize in interface ConnectionMethod
Overrides:
initialize in class StandardConnectionMethod
Parameters:
id - The id associated with this connection method
servletManager - The ServletManager to use to convert servletIDs into Servlets.
filterManager - The FilterManager to use to convert filterIDs into Filters.
Throws:
ConnectionMethodException - If unable to start up. This class will not throw this exception, however classes which extend this class may.
See Also:
Filter

equivalent

public boolean equivalent(ConnectionMethod compareObject)
Compares the port number to determine equivalency

Specified by:
equivalent in interface ConnectionMethod
Overrides:
equivalent in class StandardConnectionMethod
Parameters:
compareObject - The object to compare this to
Throws:
ConnectionMethodException - If an error occurs.

writeToConfig

public void writeToConfig(Config connectionConfig,
                          java.lang.String base)
                   throws ConfigException,
                          KeywordValueException
Write out self into config fie

Specified by:
writeToConfig in interface ConnectionMethod
Overrides:
writeToConfig in class StandardConnectionMethod
Parameters:
base - The base key string
ConfigException
KeywordValueException

run

public void run()
Runs the HttpConnectionMethod.

Specified by:
run in interface java.lang.Runnable

getConnection

protected java.net.Socket getConnection()
Returns an socket from the connection queue.

Returns:
a reference to the object if successful, null otherwise.

getChannelByURLPrefix

public Channel getChannelByURLPrefix(java.lang.String url)
Gets Channel data assocated with a given URL Prefix.

Parameters:
url - The URL Prefix.
Returns:
The Channel associated with the URL Prefix.

getServlet

public javax.servlet.Servlet getServlet(java.lang.String servletID)
Gets a reference to the servlet associated with servletID.

Parameters:
servletID - The Servlet ID.
Returns:
Reference to the servlet.

getChannelURL

public java.lang.String getChannelURL(java.lang.String channelID)
                               throws ConnectionMethodException
Returns the URL that a user would use to connect to this channel.

Specified by:
getChannelURL in interface ConnectionMethod
Parameters:
channelID - The channel
Returns:
A URL string.
Throws:
ConnectionMethodException - If an error occurs, for example if the channel does not exist.

channelURLIsValid

public boolean channelURLIsValid(java.lang.String channelID)
                          throws ConnectionMethodException
This connection method returns valid urls.

Specified by:
channelURLIsValid in interface ConnectionMethod
Parameters:
channelID - The channel
Returns:
This function always returns true.
Throws:
ConnectionMethodException - If an error occurs, for example if the channel does not exist.

getType

public java.lang.String getType()
Specified by:
getType in interface ConnectionMethod
Overrides:
getType in class StandardConnectionMethod

setPort

public void setPort(int port)

getPort

public int getPort()
Specified by:
getPort in interface ConnectionMethod

getBindAddress

public java.lang.String getBindAddress()
Gets the current Bind address, if any.


setBindAddress

public void setBindAddress(java.lang.String addr)
Sets the current Bind address, if any.


getMaxHandlers

public int getMaxHandlers()

setMaxHandlers

public void setMaxHandlers(int maxHandlers)

getMaxQueue

public int getMaxQueue()

setMaxQueue

public void setMaxQueue(int maxQueue)

getServerCertificate

public java.lang.String getServerCertificate()

setServerCertificate

public void setServerCertificate(java.lang.String serverCertificate)

getSecureRandomAlgorithm

public java.lang.String getSecureRandomAlgorithm()

setSecureRandomAlgorithm

public void setSecureRandomAlgorithm(java.lang.String secureRandomAlgorithm)

getSecureRandomProvider

public java.lang.String getSecureRandomProvider()

setSecureRandomProvider

public void setSecureRandomProvider(java.lang.String secureRandomProvider)

getSSLContextProvider

public java.lang.String getSSLContextProvider()

setSSLContextProvider

public void setSSLContextProvider(java.lang.String SSLContextProvider)

getSSLContextProtocol

public java.lang.String getSSLContextProtocol()

setSSLContextProtocol

public void setSSLContextProtocol(java.lang.String SSLContextProtocol)

getKeyStoreLocation

public java.lang.String getKeyStoreLocation()

setKeyStoreLocation

public void setKeyStoreLocation(java.lang.String keyStoreLocation)

getKeyStoreProvider

public java.lang.String getKeyStoreProvider()

setKeyStoreProvider

public void setKeyStoreProvider(java.lang.String keyStoreProvider)

getKeyManagerAlgorithm

public java.lang.String getKeyManagerAlgorithm()

setKeyManagerAlgorithm

public void setKeyManagerAlgorithm(java.lang.String keyManagerAlgorithm)

getKeyManagerProvider

public java.lang.String getKeyManagerProvider()

setKeyManagerProvider

public void setKeyManagerProvider(java.lang.String keyManagerProvider)

getTrustManager

public java.lang.String getTrustManager()

setTrustManager

public void setTrustManager(java.lang.String trustManager)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getClientAuthentication

public boolean getClientAuthentication()

setClientAuthentication

public void setClientAuthentication(boolean clientAuthentication)

getNumThreads

public int getNumThreads()
Gets the maximum number of handler thread associated with this connection method.

Returns:
numThreads.

getQueueSize

public int getQueueSize()
Gets the maximum queue size associated with this connection method.

Returns:
queueSize.

getClientTimeout

public int getClientTimeout()
Gets the client timeout associated with this connection method.

Returns:
clientTimeout.

setClientTimeout

public void setClientTimeout(int clientTimeout)

getThreadTimeout

public int getThreadTimeout()
Gets the thread timeout associated with this connection method.

Returns:
threadTimeout.

setThreadTimeout

public void setThreadTimeout(int threadTimeout)

Enhydra 5.1 API