public class HttpsManagerClientJSSE extends ManagerTransport
HttpsManagerClientJSSE class uses the HttpURLConnection
class to make a connection to the HttpManagerServlet. This class will work
with both HTTP and HTTPS based URL's. The type will be selected automatically
based on the protocol specified in the urlString in the constructor.
This class differs from HttpsManagerClient because it uses the URLConnection class to make the network connection instead of using a Socket directly. This will allow the use of the JVM's default URLStreamHandler when making the connection (if desired).
For HTTP based URL's, the SSLSocketFactory and HostnameVerfier parameters may be set to null.
For HTTPS based URL's, the SSLSocketFactory and HostnameVerifier parameters may be used to configure the SSL connection (depending on the URLStreamHandler that is in use). If no SSLSocketFactory is used, the default SSLSocketFactory from the HttpsURLConnection class will be used. If no HostnameVerifier is supplied, the default HostnameVerifier from the HttpsURLConnection class will be used.
To use SSL tunneling:
HttpManagerServlet class.
The documentation for the HttpManagerServlet
class describes how to install this class.HttpManagerServlet,
HttpManagerClient| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_TIMEOUT
The default timeout value used for the http connection and read timeout values.
|
static java.lang.String |
PROTOCOL_PKIX4
Deprecated.
proto-PKIX is no longer supported.
|
static java.lang.String |
PROTOCOL_PKIXCMP |
static java.lang.String |
REQUEST_BEGIN |
static java.lang.String |
REQUEST_CONTINUE |
static java.lang.String |
REQUEST_ENDSESSION |
static java.lang.String |
RESPONSE_NOREAD |
static java.lang.String |
RESPONSE_READ |
DEFAULT_CONNECT_TIMEOUT, DEFAULT_SO_LINGER, DEFAULT_SO_TIMEOUT, in, out, recipientAddress| Constructor and Description |
|---|
HttpsManagerClientJSSE(java.lang.String urlString)
Creates an HttpsManagerClientJSSE object from the specified URLString
object.
|
HttpsManagerClientJSSE(java.lang.String urlString,
javax.net.ssl.SSLSocketFactory factory,
javax.net.ssl.HostnameVerifier hostnameVerifier,
java.net.URLStreamHandler streamHandler)
Creates an HttpsManagerClientJSSE object from the specified URLString
and port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHttpHeader(java.lang.String name,
java.lang.String value)
Adds additional HTTP header information.
|
void |
beginNewSession()
Implements the
beginNewSession() method of the
ManagerTransport class. |
void |
endSession()
Implements the
endSession() method of the
ManagerTransport class. |
java.lang.String |
getAddress()
Returns the PKI RA's URL address.
|
int |
getPort()
Returns the Port that will be used to connect to the Manager tunnel
|
void |
readNegPollRep()
This method simply posts any data contained in the internal
OutputStream, and reads the result.
|
byte[] |
readPKIXCMPResponse(boolean getResponse)
This method flushes the output stream, sends the flushed data
to the Manager, and (optionally) reads the response.
|
void |
setConnectionTimeout(int timeout)
Sets the connection timeout used when making the connection to the
HTTP servlet
|
void |
setReadTimeout(int timeout)
Sets the read timeout used when reading data from
the HTTP servlet.
|
calculateASNLength, checkStatus, dataReady, DNSLookup, getClientCredentials, getGeneralMessageInfo, getInputStream, getInstance, getInstance, getOutputStream, getSoConnectTimeout, getSoLinger, getSoTimeout, getTrustRoots, isAvailable, periodicPoll, readManagerTransportMessage, readPKIX4Response, setClientCredentials, setClientCredentials, setSoConnectTimeout, setSoLinger, setSoTimeout, setStreams, setTrustRootspublic static final java.lang.String REQUEST_BEGIN
public static final java.lang.String REQUEST_CONTINUE
public static final java.lang.String REQUEST_ENDSESSION
public static final java.lang.String RESPONSE_READ
public static final java.lang.String RESPONSE_NOREAD
public static final java.lang.String PROTOCOL_PKIX4
public static final java.lang.String PROTOCOL_PKIXCMP
public static final int DEFAULT_TIMEOUT
public HttpsManagerClientJSSE(java.lang.String urlString)
throws java.net.MalformedURLException,
java.net.UnknownHostException,
java.io.IOException
urlString - the URL string referring to the Manager servlet.java.net.MalformedURLException - if urlString is not a valid URLjava.io.IOException - if there is an IO problem after connecting to the host.java.net.UnknownHostExceptionpublic HttpsManagerClientJSSE(java.lang.String urlString,
javax.net.ssl.SSLSocketFactory factory,
javax.net.ssl.HostnameVerifier hostnameVerifier,
java.net.URLStreamHandler streamHandler)
throws java.net.MalformedURLException,
java.net.UnknownHostException,
java.io.IOException
If a null HostnameVerifier is supplied, the default HostnameVerifier setup for use with the HttpsURLConnection will be used.
If a null URLStreamHandler is supplied, the default URLStreamStreamHandler for the specified protocol will be used.
urlString - the URL string referring to the Manager servlet.SSLSocketFactory - The SSLSocketFactory that will be used to create the sockets used
byhostnameVerifier - the HostnameVerifier to use when performing hostname validation
on SSL requestsstreamHandler - The URLStreamHandler that will be used to perform the protocol
side of the connection.java.net.MalformedURLException - if urlString is not a valid URL.java.io.IOException - if there is an IO problem after connecting to the host.java.net.UnknownHostExceptionpublic void beginNewSession()
beginNewSession() method of the
ManagerTransport class.
This method is called whenever a new session or request to the PKI Manager is about to be made.
beginNewSession() attempts to establish a socket to the proxy
servlet on the Web server. If successful, it marks the connection
as available, so that subsequent calls to dataReady() or
readData() are allowed to proceed.
beginNewSession in class ManagerTransportpublic void endSession()
endSession() method of the
ManagerTransport class.
This method is called whenever a session is complete. It sends
an HTML POST request with the PKIX confirmation
to the proxy servlet notifying the
servlet that the session is complete. The servlet then closes
the connection to the PKI that was opened on behalf on this client.
endSession in class ManagerTransportpublic byte[] readPKIXCMPResponse(boolean getResponse)
throws java.security.GeneralSecurityException
If a response is expected, set the boolean readResponse
parameter to 'true' and read the response from the
ManagerTransport's input stream (accessed using the
getInputStream() method). Alternatively, use the
response returned by this method as a byte array.
readPKIXCMPResponse in class ManagerTransportjava.security.GeneralSecurityExceptionpublic void readNegPollRep()
throws java.io.IOException
readNegPollRep in class ManagerTransportjava.io.IOExceptionpublic void addHttpHeader(java.lang.String name,
java.lang.String value)
throws java.lang.IllegalArgumentException
This method does not check the validity of the HTTP request header.
The host, accept, content-type,
and content-length fields are ignored because they
are reserved for the tunneling request.
name - the header namevalue - the header valuejava.lang.IllegalArgumentExceptionpublic java.lang.String getAddress()
getAddress in class ManagerTransporthttps://www.acme.compublic int getPort()
getPort in class ManagerTransportpublic void setConnectionTimeout(int timeout)
timeout - The timeout value in secondspublic void setReadTimeout(int timeout)
timeout - The timeout value in seconds