public class ResponseBytes
extends java.lang.Object
ResponseBytes
.
The X.509 Online Certificate Status Protocol
( RFC 2560),
RFC 6960) 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.
Response
,
UnknownResponseException
,
BasicOCSPResponse
,
OCSPResponse
Constructor and Description |
---|
ResponseBytes(ASN1Object obj)
Creates ResponseBytes from its ASN.1 representation.
|
ResponseBytes(Response response)
Creates ResponseBytes for the given response.
|
Modifier and Type | Method and Description |
---|---|
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,
java.lang.Class cl)
Registers a class for implementing a particular response type.
|
ASN1Object |
toASN1Object()
Returns this ResponseBytes as ASN1Object.
|
java.lang.String |
toString()
Returns a String representation of the ResponseBytes.
|
public ResponseBytes(Response response)
response
- the responsepublic ResponseBytes(ASN1Object obj) throws CodingException, UnknownResponseException
UnknownResponseException
is thrown to be queried for information
about the unknown response.obj
- the ResponseBytes as ASN1ObjectCodingException
- if the ASN1Object cannot be parsedUnknownResponseException
- if this ResponseBytes contains
an response of unknown (= unsupported) typepublic static Response create(ObjectID responseType) throws java.lang.InstantiationException
This method belongs to the static part of this class.
responseType
- the responseType OIDjava.lang.InstantiationException
- if the internal factory
couldn't create an instance of requested typepublic static void register(ObjectID responseType, java.lang.Class cl)
This method belongs to the static part of this class.
responseType
- the type of the response to be registeredcl
- the class which implements this response typepublic Response getResponse()
public ObjectID getResponseType()
public void decode(ASN1Object obj) throws CodingException, UnknownResponseException
UnknownResponseException
is thrown to be queried for information about the unknown response.obj
- the ResponseBytes as ASN1ObjectCodingException
- if the ASN1Object cannot be parsedUnknownResponseException
- if this ResponseBytes contains
an response of unknown (= unsupported) typepublic ASN1Object toASN1Object()
public java.lang.String toString()
toString
in class java.lang.Object