public class HttpManagerClient extends ManagerTransport
HttpManagerClient works with HttpManagerServlet
to act as a proxy for requests to an Entrust PKI over HTTP.
The HttpManagerClient class is a subclass of the
ManagerTransport class, so you can use this class wherever
you would usually use ManagerTransport to communicate with
the Entrust PKI. The following code fragments show the typical usage of
the two classes.
Using ManagerTransport:
ManagerTransport emt = new ManagerTransport("47.97.235.29", 829);
Using HttpManagerClient through an HTTP tunnel:
ManagerTransport emt = new HttpManagerClient("http://wothdmontg.entrust.com:80/servlet/Manager", 0, "47.97.235.29");
The remainder of the client application is unchanged. In this example,
the Web server is on the wothdmontg.entrust.com computer
and the HttpManagerServlet class is in the servlet
folder. The IP address and port number of the Entrust PKI are specified
in the servlet's parameters.
HttpManagerClient constructor takes the PKI Manager's
IP address as a parameter even though it's messages to the PKI are
sent through a proxy. The managerIP parameter is required
by the PKIX protocol itself, so the ManagerTransport
superclass requires that address. If the address supplied by the
application does not match the IP address of the PKI Manager, the PKIX
protocol will fail. Ideally, the address should be specified in numeric
IP address 'dot' format, 47.97.235.29 for example, but if supplied as a
symbolic name, the constructor will attempt to resolve it using a DNS
lookup.HttpManagerServlet| Modifier and Type | Field and Description |
|---|---|
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 |
|---|
HttpManagerClient(java.lang.String urlString,
int port)
Creates an HttpManagerClient.
|
HttpManagerClient(java.lang.String urlString,
int proxyPort,
java.lang.String managerIP)
Deprecated.
managerIP is no longer required.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHttpHeader(java.lang.String name,
java.lang.String value)
Adds additional HTTP request 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 |
setWebProxy(java.lang.String ipAddress,
int port)
Sets the Web proxy.
|
calculateASNLength, checkStatus, dataReady, DNSLookup, getClientCredentials, getGeneralMessageInfo, getInputStream, getInstance, getInstance, getOutputStream, getPasswordBasedMacAlgorithm, getPasswordBasedMacAlgorithmWorks, getSoConnectTimeout, getSoLinger, getSoTimeout, getTrustRoots, isAvailable, periodicPoll, readManagerTransportMessage, readPKIX4Response, setClientCredentials, setClientCredentials, setPasswordBasedMacAlgorithm, setPasswordBasedMacCurrentAlgorithmWorks, 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 HttpManagerClient(java.lang.String urlString,
int proxyPort,
java.lang.String managerIP)
throws java.net.MalformedURLException,
java.net.UnknownHostException,
java.io.IOException
urlString - the URL string referring to the Manager servlet.proxyPort - the port number to connect to at the server. Ignored
if urlString specifies the port number.managerIP - the IP address of the Manager.java.net.MalformedURLException - if urlString is not a valid URL.java.net.UnknownHostExceptionjava.io.IOExceptionpublic HttpManagerClient(java.lang.String urlString,
int port)
throws java.net.MalformedURLException,
java.net.UnknownHostException,
java.io.IOException
urlString - the URL string referring to the Manager servlet.port - the port number to connect to at the server. Ignored
if urlString specifies the port number.java.net.MalformedURLException - if urlString is not a valid URL.java.net.UnknownHostExceptionjava.io.IOExceptionpublic 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 read data 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
getInputStream(). 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 setWebProxy(java.lang.String ipAddress,
int port)
throws java.net.UnknownHostException,
java.io.IOException
ipAddress - the IP address of the Web proxyport - the port number of the proxyjava.net.UnknownHostExceptionjava.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 request
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 ManagerTransporthttp://www.acme.compublic int getPort()
getPort in class ManagerTransport