iaik.x509.ocsp
Class ResponseBytes

java.lang.Object
  |
  +--iaik.x509.ocsp.ResponseBytes

public class ResponseBytes
extends Object

This class implements the OCSP type ResponseBytes.

The X.509 Online Certificate Status Protocol (RFC 2560) specifies the ResponseBytes type for allowing to include specific response information in an OCSPResponse when the response status indicates a successful request processing:

 OCSPResponse ::= SEQUENCE {
    responseStatus         OCSPResponseStatus,
    responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }

 ResponseBytes ::=       SEQUENCE {
     responseType   OBJECT IDENTIFIER,
     response       OCTET STRING }
 
RFC 2560 itself only specifies one basic response type (BasicOCSPResponse) that has to be supported by any conforming implementation. Other response types are allowed and are identified by their object identifier to be included into the optional responseBytes field of an OCSPResponse message. This class includes a static part to be used for registering implementations for particular response types. A response type may be implemented by extending the abstract Response class and registering it by calling the static register method of this class, e.g.:
 public class MyResponse extends Response {
 ...
 // the response type
   public static final ObjectID responseType = ...;
 ...
 }
 ...
 // register the implementation:
 ResponseBytes.register(MyResponse.responseType, MyResponse.class);
 
When parsing the response sent by a server, this class tries to find an implementation for the response identified by the responseType OID. If no implementation for the particular response type is registered, an UnknownResponseException is thrown allowing an application to query for the response type oid and an ASN.1 epresentation of the unknown response.

Currently only one response type, BasicOCSPResponse is supported by this OCSP implementation.

Generaly an application will not have to use this class (except for registering its own response type implementations). A response can be added immediately to an OCSPResponse object which internally creates the required ResponseBytes.

Version:
File Revision 7
See Also:
Response, UnknownResponseException, BasicOCSPResponse, OCSPResponse

Constructor Summary
ResponseBytes(ASN1Object obj)
          Creates ResponseBytes from its ASN.1 representation.
ResponseBytes(Response response)
          Creates ResponseBytes for the given response.
 
Method Summary
static Response create(ObjectID responseType)
          Returns the implementation of the specified response type defined by an ASN.1 ObjectID.
 void decode(ASN1Object obj)
          Decodes ResponseBytes from its ASN.1 representation.
 Response getResponse()
          Gets the response included in this ResponseBytes.
 ObjectID getResponseType()
          Gets the type of the response of this ResponseBytes.
static void register(ObjectID responseType, Class cl)
          Registers a class for implementing a particular response type.
 ASN1Object toASN1Object()
          Returns this ResponseBytes as ASN1Object.
 String toString()
          Returns a String representation of the ResponseBytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResponseBytes

public ResponseBytes(Response response)
Creates ResponseBytes for the given response.
Parameters:
response - the response

ResponseBytes

public ResponseBytes(ASN1Object obj)
              throws CodingException,
                     UnknownResponseException
Creates ResponseBytes from its ASN.1 representation. The reponseType is parsed from the supplied ASN.1 representation. If no response implementation cis registered for the responseType parsed, an UnknownResponseException is thrown to be queried for information about the unknown response.
Parameters:
obj - the ResponseBytes as ASN1Object
Throws:
CodingException - if the ASN1Object cannot be parsed
UnknownResponseException - if this ResponseBytes contains an response of unknown (= unsupported) type
Method Detail

create

public static Response create(ObjectID responseType)
                       throws InstantiationException
Returns the implementation of the specified response type defined by an ASN.1 ObjectID.

This method belongs to the static part of this class.

Parameters:
oid - the responseType OID
Returns:
the implementation of the response with the requested type
Throws:
InstantiationException - if the internal factory couldn't create an instance of requested type

register

public static void register(ObjectID responseType,
                            Class cl)
Registers a class for implementing a particular response type.

This method belongs to the static part of this class.

Parameters:
responseType - the type of the response to be registered
class - the class which implements this response type

getResponse

public Response getResponse()
Gets the response included in this ResponseBytes.
Returns:
the response included in this ResponseBytes

getResponseType

public ObjectID getResponseType()
Gets the type of the response of this ResponseBytes.
Returns:
the type of the response included in this ResponseBytes

decode

public void decode(ASN1Object obj)
            throws CodingException,
                   UnknownResponseException
Decodes ResponseBytes from its ASN.1 representation. This method parses the reponseType from the supplied ASN.1 representation and tries to find an registered response implementation for the parsed type. If no response implementation can be found, an UnknownResponseException is thrown to be queried for information about the unknown response.
Parameters:
obj - the ResponseBytes as ASN1Object
Throws:
CodingException - if the ASN1Object cannot be parsed
UnknownResponseException - if this ResponseBytes contains an response of unknown (= unsupported) type

toASN1Object

public ASN1Object toASN1Object()
Returns this ResponseBytes as ASN1Object.
Returns:
this ResponseBytes as ASN1Object.

toString

public String toString()
Returns a String representation of the ResponseBytes.
Overrides:
toString in class Object
Returns:
a String representation of the ResponseBytes.

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