|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.x509.ocsp.OCSPResponse
This class implements the OCSP type OCSPResponse
.
The X.509 Online Certificate Status Protocol (RFC 2560) specifies the OCSPResponse type for giving the format of a response message that may be send to a OCSP requestor in response to a certificate status information request:
OCSPResponse ::= SEQUENCE { responseStatus OCSPResponseStatus, responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }An OCSP response at a minimum consists of a responseStatus field indicating the processing status of the prior request. If the value of responseStatus is one of the error conditions, responseBytes are not set. Note that responseStatus type "noMoreData" has been introduced by OCSPv2 (see draft-ietf-pkix-ocspv2-01.txt).
OCSPResponseStatus ::= ENUMERATED { successful (0), --Response has valid confirmations malformedRequest (1), --Illegal confirmation request internalError (2), --Internal error in issuer tryLater (3), --Try again later --(4) is not used sigRequired (5), --Must sign the request unauthorized (6) --Request unauthorized } noMoreData (7) --No more data available }OCSP responses can be of various types. An OCSP response consists of a response type and the bytes of the actual response. There is one
basic type
of OCSP response
that MUST be supported by all OCSP servers and clients. This OCSP
implementation supports the BasicOCSPResponse
, but also provides an easy machanism allowing
application to implement any other response type
and register the corresponding class by its object
identifier (see class ResponseBytes
for more information.
When creating
an OCSPResponse you have to
set the response status information, e.g.:
OCSPResponse ocspResponse = new OCSPResponse(OCSPResponse.malformedRequest);In the case of an successful OCSPResponse you immediately may supply the response component to the
constructor
.
The response status is set to "successful" and ResponseBytes are created
automatically, e.g.:
BasicOCSPResponse basicOCSPResponse = ...; ... OCSPResponse ocspResponse = new OCSPResponse(basicOCSPResponse);For DER encoding the OCSP response you may call method
writeTo
or getEncoded
:
OutputStream os = ...; ocspResponse.writeTo(os);A requestor receiving an ocsp response,
checks
the
response status and -- if successful -- gets
the response included:
// the stream supplying the encoded OCSP response: InputStream is = ...; OCSPResponse ocspResponse = new OCSPResponse(is); // get the response status: int responseStatus = ocspResponse.getResponseStatus(); if (responseStatus != OCSPResponse.successful) { System.out.println("Not successful; got response status: " + ocspResponse.getResponseStatusName()); ... } else { // get the included response Response response = ocspResponse.getResponse(); ...
OCSPRequest
,
Request
,
BasicOCSPResponse
,
ResponseBytes
,
SingleResponse
,
ReqCert
,
CertStatus
Field Summary | |
static int |
internalError
Response status "internalError" (2) indicating an internal responder error. |
static int |
malformedRequest
Response status "malformedRequest" (1) indicating that the request received is not OCSP-syntax-conform. |
static int |
noMoreData
Response status "noMoreData" (7) indicating that the server has previously returned the last positive response to a related sequence of requests |
static int |
sigRequired
Response status "sigRequired" (5) requiring a request to be signed. |
static int |
successful
Response status "successful" (0) indicating that the response has valid confirmation. |
static int |
tryLater
Response status "tryLater" (3) indicating that the request should be resend at later because the server temporarily cannot respond. |
static int |
unauthorized
Response status "unauthorized" (6) indicating an unauthorized request. |
Constructor Summary | |
OCSPResponse(ASN1Object obj)
Creates an OCSPResponse from its ASN.1 representation. |
|
OCSPResponse(byte[] array)
Creates an OCSPResponse from its DER encoding. |
|
OCSPResponse(InputStream is)
Creates an OCSPResponse from its DER encoding. |
|
OCSPResponse(int responseStatus)
Creates an OCSPResponse for the given response status. |
|
OCSPResponse(Response response)
Creates an OCSPResponse from the given response. |
|
OCSPResponse(ResponseBytes responseBytes)
Creates an OCSPResponse for the given response bytes. |
Method Summary | |
void |
decode(ASN1Object obj)
Decodes an OCSPResponse from its ASN.1 representation. |
void |
decode(InputStream is)
Decodes an OCSPResponse from its DER encoding. |
byte[] |
getEncoded()
DER encodes this OCSP response. |
Response |
getResponse()
Returns the response component of the ResponseBytes, if included. |
ResponseBytes |
getResponseBytes()
Returns the response bytes, if included. |
int |
getResponseStatus()
Returns the response status. |
String |
getResponseStatusName()
Returns the response status as String. |
ObjectID |
getResponseType()
Returns the response type oid of the ResponseBytes, if included. |
void |
setResponse(Response response)
Sets the response of this OCSPResponse. |
void |
setResponseBytes(ResponseBytes responseBytes)
Sets the response bytes of this OCSPResponse. |
ASN1Object |
toASN1Object()
Returns this OCSP response as ASN1Object. |
String |
toString()
Returns a String representation of this OCSP response. |
void |
writeTo(OutputStream os)
Writes this OCSPResponse DER encoded to the given output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int successful
public static final int malformedRequest
public static final int internalError
public static final int tryLater
public static final int sigRequired
public static final int unauthorized
public static final int noMoreData
Constructor Detail |
public OCSPResponse(int responseStatus) throws IllegalArgumentException
setResponseBytes
for setting
the resonse bytes.responseStatus
- the response statusIllegalArgumentException
- if the responseStatus is invalidpublic OCSPResponse(ResponseBytes responseBytes)
responseBytes
- the response bytespublic OCSPResponse(Response response)
response
- the responsepublic OCSPResponse(ASN1Object obj) throws CodingException, UnknownResponseException
If the reponse is a successful one, response bytes are present.
When parsing the response bytes, an unknown response type may
be included. In this case this constructor throws an UnknownResponseException
to be queried for information about the unknown response.
obj
- the OCSPResponse as ASN1ObjectCodingException
- if the ASN1Object cannot be parsed or the response status
is invalidUnknownResponseException
- if the response is a successful
response but the ResponseBytes included contain an response
of unknown (= unsupported) typepublic OCSPResponse(InputStream is) throws IOException, UnknownResponseException
If the reponse is a successful one, response bytes are present.
When parsing the response bytes, an unknown response type may
be included. In this case this constructor throws an UnknownResponseException
to be queried for information about the unknown response.
is
- the input stream supplying the DER encoded OCSPResponseIOException
- if the ASN1Object cannot be parsed or the response status
is invalidUnknownResponseException
- if the response is a successful
response but the ResponseBytes included contain an response
of unknown (= unsupported) typepublic OCSPResponse(byte[] array) throws CodingException, UnknownResponseException
If the reponse is a successful one, response bytes are present.
When parsing the response bytes, an unknown response type may
be included. In this case this constructor throws an UnknownResponseException
to be queried for information about the unknown response.
array
- the DER encoded OCSPResponse as byte arrayCodingException
- if the ASN1Object cannot be parsed or the response status
is invalidUnknownResponseException
- if the response is a successful
response but the ResponseBytes included contain an response
of unknown (= unsupported) typeMethod Detail |
public void setResponseBytes(ResponseBytes responseBytes)
responseBytes
- the response bytespublic void setResponse(Response response)
response
- the responsepublic ResponseBytes getResponseBytes()
public Response getResponse()
getResponseBytes().getResponse()
.
This method returns null
, if no response bytes are included.public ObjectID getResponseType()
getResponseBytes().getResponseType()
.
This method returns null
, if no response bytes are included.public int getResponseStatus()
public String getResponseStatusName()
public void decode(ASN1Object obj) throws CodingException, UnknownResponseException
If the reponse is a successful one, response bytes are present.
When parsing the response bytes, an unknown response type may
be included. In this case this method throws an UnknownResponseException
to be queried for information about the unknown response.
obj
- the OCSPResponse as ASN1ObjectCodingException
- if the ASN1Object cannot be parsed or the response status
is invalidUnknownResponseException
- if ResponseBytes are included
containing an response of unknown (= unsupported) typepublic void decode(InputStream is) throws IOException, UnknownResponseException
If the reponse is a successful one, response bytes are present.
When parsing the response bytes, an unknown response type may
be included. In this case this method throws an UnknownResponseException
to be queried for information about the unknown response.
is
- the input stream supplying the DER encoded OCSPResponseIOException
- if the ASN1Object cannot be parsed or the response status
is invalidUnknownResponseException
- if ResponseBytes are included
containing an response of unknown (= unsupported) typepublic ASN1Object toASN1Object()
public byte[] getEncoded()
public void writeTo(OutputStream os) throws IOException
os
- the output stream to which to write the responseIOException
- if an error occurs while writing to the streampublic String toString()
toString
in class Object
|
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). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |