public class HTTPOCSPProtocolHandler extends OCSPProtocolHandler
This class uses a HttpURLConnection object for sending a request
to an OCSP responder by using the POST method. When creating a HTTPOCSPProtocolHandler object supply the URL of the
OCSP responder and subsequently call method sendRequest(OCSPRequest)
for sending the OCSPRequest
to the server. The response from the server can be obtained by calling
method getOCSPResponse, e.g.:
// the request to be send:
OCSPRequest ocspRequest = ...;
// the responder URL to post to:
URL url = ...;
// create the http request:
HTTPOCSPProtocolHandler httpOCSPRequest = new HTTPOCSPProtocolHandler(url);
// post the request
int responseCode = httpOCSPRequest.postRequest(ocspRequest);
if (responseCode != getSuccessCode()) {
System.out.println("Error connecting to " + m_responderUrl + ":");
System.out.println(httpOCSPRequest.getResponseMessage());
} else {
System.out.println("Parse response: ");
OCSPResponse ocspResponse = httpOCSPRequest.getOCSPResponse();
...
}OCSPRequest,
OCSPResponse| Constructor and Description |
|---|
HTTPOCSPProtocolHandler(java.net.URL location)
Sets the HTTPOCSPProtocolHandler based on the given URL.
|
| Modifier and Type | Method and Description |
|---|---|
OCSPResponse |
getOCSPResponse()
Once an OCSP request has been set, the Response should be available
if everything has gone as requested.
|
java.lang.String |
getResponseMessage()
Gets the Http response message.
|
int |
getSuccessCode()
Returns the implementations integer representation of a successcode,
For HTTP, HTTPS, and FTP it is 200, but it could be different for another
protocol.
|
int |
sendRequest(OCSPRequest ocspRequest)
Posts the given ocsp request to the responder of this HTTPOCSPProtocolHandler.
|
getConnectTimeout, getReadTimeout, getResponderURL, setConnectTimeout, setReadTimeout, setResponderURLpublic HTTPOCSPProtocolHandler(java.net.URL location)
location - The specified URL locationpublic int sendRequest(OCSPRequest ocspRequest) throws java.io.IOException, UnknownResponseException, java.lang.InterruptedException, CodingException
sendRequest in class OCSPProtocolHandlerocspRequest - the OCSPrequest
to be postedjava.io.IOException - if an I/O error occurs while reading the responseUnknownResponseException - if the post has been successful, but
the server responder with an unknown responsejava.lang.InterruptedExceptionCodingExceptionpublic OCSPResponse getOCSPResponse()
OCSPProtocolHandlergetOCSPResponse in class OCSPProtocolHandlerpublic java.lang.String getResponseMessage()
getResponseMessage in class OCSPProtocolHandlerpublic int getSuccessCode()
OCSPProtocolHandlergetSuccessCode in class OCSPProtocolHandler