iaik.x509.ocsp.net
Class HttpOCSPRequest

java.lang.Object
  |
  +--iaik.x509.ocsp.net.HttpOCSPRequest

public class HttpOCSPRequest
extends Object

A simple wrapper class allowing to post an OCSP request to an OCSP server over HTTP.

This class uses a HttpURLConnection object for sending a request to an OCSP responder by using the POST method. When creating a HttpOCSPRequest object supply the URL of the OCSP responder and subsequently call method postRequest 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:
 HttpOCSPRequest httpOCSPRequest = new HttpOCSPRequest(url);
 // post the request
 int responseCode = httpOCSPRequest.postRequest(ocspRequest);
 if (responseCode/200 != 2) {
   System.out.println("Error connecting to " + responderUrl + ":"); 
   System.out.println(httpOCSPRequest.getResponseMessage());
 } else {
   System.out.println("Parse response: ");
   OCSPResponse ocspResponse = httpOCSPRequest.getOCSPResponse();
   ...
 }

Version:
File Revision 9
See Also:
OCSPRequest, OCSPResponse

Constructor Summary
HttpOCSPRequest(URL responderUrl)
          Creates a HttpOCSPRequest for the given responder url.
 
Method Summary
 OCSPResponse getOCSPResponse()
          Returns the ocsp response sent by the server.
 String getResponseMessage()
          Gets the http response message.
 int postRequest(OCSPRequest ocspRequest)
          Posts the given ocsp request to the responder of this HttpOCSPRequest.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpOCSPRequest

public HttpOCSPRequest(URL responderUrl)
Creates a HttpOCSPRequest for the given responder url.
Parameters:
responderUrl - the url of the OCSP responder
Method Detail

postRequest

public int postRequest(OCSPRequest ocspRequest)
                throws IOException,
                       UnknownResponseException
Posts the given ocsp request to the responder of this HttpOCSPRequest.
Parameters:
ocspRequest - the OCSPrequest to be posted
Returns:
the http response code indicating if the post has been successful
Throws:
IOException - if an I/O error occurs while reading the response
UnknownResponseException - if the post has been successful, but the server uses an not supported response type

getOCSPResponse

public OCSPResponse getOCSPResponse()
Returns the ocsp response sent by the server.
Returns:
the OCSP response sent by the server

getResponseMessage

public String getResponseMessage()
Gets the http response message. This may be useful to see the reason if the connection was not successful.
Returns:
the http response message

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK