APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.provider.certpath

public final Class OCSPResponse

extends Object
Class Inheritance
Imports
java.io.*, java.security.*, java.security.cert.CertificateException, .CertificateParsingException, .CertPathValidatorException, .CertPathValidatorException.BasicReason, .CRLReason, .TrustAnchor, .X509Certificate, java.util.ArrayList, .Arrays, .Collections, .Date, .HashMap, .List, .Map, .Set, javax.security.auth.x500.X500Principal, sun.security.util.HexDumpEncoder, sun.security.util.*, sun.security.x509.*

This class is used to process an OCSP response. The OCSP Response is defined in RFC 2560 and the ASN.1 encoding is as follows:

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

  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
  }

  ResponseBytes ::=       SEQUENCE {
      responseType   OBJECT IDENTIFIER,
      response       OCTET STRING }

  BasicOCSPResponse       ::= SEQUENCE {
     tbsResponseData      ResponseData,
     signatureAlgorithm   AlgorithmIdentifier,
     signature            BIT STRING,
     certs                [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }

  The value for signature SHALL be computed on the hash of the DER
  encoding ResponseData.

  ResponseData ::= SEQUENCE {
     version              [0] EXPLICIT Version DEFAULT v1,
     responderID              ResponderID,
     producedAt               GeneralizedTime,
     responses                SEQUENCE OF SingleResponse,
     responseExtensions   [1] EXPLICIT Extensions OPTIONAL }

  ResponderID ::= CHOICE {
     byName               [1] Name,
     byKey                [2] KeyHash }

  KeyHash ::= OCTET STRING -- SHA-1 hash of responder's public key
  (excluding the tag and length fields)

  SingleResponse ::= SEQUENCE {
     certID                       CertID,
     certStatus                   CertStatus,
     thisUpdate                   GeneralizedTime,
     nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
     singleExtensions   [1]       EXPLICIT Extensions OPTIONAL }

  CertStatus ::= CHOICE {
      good        [0]     IMPLICIT NULL,
      revoked     [1]     IMPLICIT RevokedInfo,
      unknown     [2]     IMPLICIT UnknownInfo }

  RevokedInfo ::= SEQUENCE {
      revocationTime              GeneralizedTime,
      revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }

  UnknownInfo ::= NULL -- this can be replaced with an enumeration

Author
Ram Marti

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
OCSPResponse.IssuerInfo

Helper class that allows consumers to pass in issuer information.

public static enum
public static class

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private final List<X509CertImpl>
private static final Debug
private static final int
private static final boolean
private static final int
private static final int
MAX_CLOCK_SKEW

Integer value indicating the maximum allowable clock skew, in milliseconds, to be used for the OCSP check.

private static final int
private static final ObjectIdentifier
private Date
private final ResponderId
private final Map<String, Extension>
private final byte[]
private final OCSPResponse.ResponseStatus
private static final OCSPResponse.ResponseStatus[]
private final AlgorithmId
private final byte[]
private X509CertImpl
private final Map<CertId, OCSPResponse.SingleResponse>
private final byte[]
private static final CRLReason[]

Constructor Summary

AccessConstructor and Description
public
OCSPResponse(byte[] bytes)

Method Summary

Modifier and TypeMethod and Description
public Set<CertId>

Returns:

an unmodifiable set containing every CertId in this response.
getCertIds
()

Return a set of all CertIds in this OCSPResponse

public ResponderId

Returns:

the ResponderId from this response or null if no responder ID is in the body of the response, e.g. a response with a status other than SUCCESS.
getResponderId
()

Get the ResponderId from this OCSPResponse

public OCSPResponse.ResponseStatus

Returns:

the ResponseStatus for this OCSP response
getResponseStatus
()

Returns the OCSP ResponseStatus.

pack-priv X509Certificate
public OCSPResponse.SingleResponse

Returns:

the SingleResponse for the provided CertId, or null if it is not found.
getSingleResponse
(CertId
the CertId for a SingleResponse to be searched for in the OCSP response.
certId
)

Returns the SingleResponse of the specified CertId, or null if there is no response for that CertId.

private static int
initializeClockSkew()

Initialize the maximum allowable clock skew by getting the OCSP clock skew system property.

private static Map<String, Extension>

Returns:

a Map using the OID in string form as the keys. If no extensions are found or an empty SEQUENCE is passed in, then an empty Map will be returned.
parseExtensions
(DerValue
A DerValue object built from a SEQUENCE of extensions
derVal
)

Build a String-Extension map from DER encoded data.

public String

Returns:

a human-readable representation of the OCSPResponse
toString
()

Overrides java.lang.Object.toString.

Provide a String representation of an OCSPResponse

pack-priv void
verify(List<CertId> certIds, OCSPResponse.IssuerInfo issuerInfo, X509Certificate responderCert, Date date, byte[] nonce, String variant)

private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

CERT_STATUS_GOODback to summary
private static final int CERT_STATUS_GOOD
CERT_STATUS_REVOKEDback to summary
private static final int CERT_STATUS_REVOKED
CERT_STATUS_UNKNOWNback to summary
private static final int CERT_STATUS_UNKNOWN
certsback to summary
private final List<X509CertImpl> certs
debugback to summary
private static final Debug debug
DEFAULT_MAX_CLOCK_SKEWback to summary
private static final int DEFAULT_MAX_CLOCK_SKEW
dumpback to summary
private static final boolean dump
KEY_TAGback to summary
private static final int KEY_TAG
MAX_CLOCK_SKEWback to summary
private static final int MAX_CLOCK_SKEW

Integer value indicating the maximum allowable clock skew, in milliseconds, to be used for the OCSP check.

NAME_TAGback to summary
private static final int NAME_TAG
OCSP_BASIC_RESPONSE_OIDback to summary
private static final ObjectIdentifier OCSP_BASIC_RESPONSE_OID
producedAtDateback to summary
private Date producedAtDate
respIdback to summary
private final ResponderId respId
responseExtensionsback to summary
private final Map<String, Extension> responseExtensions
responseNonceback to summary
private final byte[] responseNonce
responseStatusback to summary
private final OCSPResponse.ResponseStatus responseStatus
rsvaluesback to summary
private static final OCSPResponse.ResponseStatus[] rsvalues
sigAlgIdback to summary
private final AlgorithmId sigAlgId
signatureback to summary
private final byte[] signature
signerCertback to summary
private X509CertImpl signerCert
singleResponseMapback to summary
private final Map<CertId, OCSPResponse.SingleResponse> singleResponseMap
tbsResponseDataback to summary
private final byte[] tbsResponseData
valuesback to summary
private static final CRLReason[] values

Constructor Detail

OCSPResponseback to summary
public OCSPResponse(byte[] bytes) throws IOException

Method Detail

getCertIdsback to summary
public Set<CertId> getCertIds()

Return a set of all CertIds in this OCSPResponse

Returns:Set<CertId>

an unmodifiable set containing every CertId in this response.

getResponderIdback to summary
public ResponderId getResponderId()

Get the ResponderId from this OCSPResponse

Returns:ResponderId

the ResponderId from this response or null if no responder ID is in the body of the response, e.g. a response with a status other than SUCCESS.

getResponseStatusback to summary
public OCSPResponse.ResponseStatus getResponseStatus()

Returns the OCSP ResponseStatus.

Returns:OCSPResponse.ResponseStatus

the ResponseStatus for this OCSP response

getSignerCertificateback to summary
pack-priv X509Certificate getSignerCertificate()
getSingleResponseback to summary
public OCSPResponse.SingleResponse getSingleResponse(CertId certId)

Returns the SingleResponse of the specified CertId, or null if there is no response for that CertId.

Parameters
certId:CertId

the CertId for a SingleResponse to be searched for in the OCSP response.

Returns:OCSPResponse.SingleResponse

the SingleResponse for the provided CertId, or null if it is not found.

initializeClockSkewback to summary
private static int initializeClockSkew()

Initialize the maximum allowable clock skew by getting the OCSP clock skew system property. If the property has not been set, or if its value is negative, set the skew to the default.

parseExtensionsback to summary
private static Map<String, Extension> parseExtensions(DerValue derVal) throws IOException

Build a String-Extension map from DER encoded data.

Parameters
derVal:DerValue

A DerValue object built from a SEQUENCE of extensions

Returns:Map<String, Extension>

a Map using the OID in string form as the keys. If no extensions are found or an empty SEQUENCE is passed in, then an empty Map will be returned.

Exceptions
IOException:
if any decoding errors occur.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Provide a String representation of an OCSPResponse

Returns:String

a human-readable representation of the OCSPResponse

Annotations
@Override
verifyback to summary
pack-priv void verify(List<CertId> certIds, OCSPResponse.IssuerInfo issuerInfo, X509Certificate responderCert, Date date, byte[] nonce, String variant) throws CertPathValidatorException
verifySignatureback to summary
private boolean verifySignature(X509Certificate cert) throws CertPathValidatorException
sun.security.provider.certpath back to summary

pack-priv final Class OCSPResponse.IssuerInfo

extends Object
Class Inheritance

Helper class that allows consumers to pass in issuer information. This will always consist of the issuer's name and public key, but may also contain a certificate if the originating data is in that form. The trust anchor for the certificate chain will be included for certpath disabled algorithm checking.

Field Summary

Modifier and TypeField and Description
private final TrustAnchor
private final X509Certificate
private final X500Principal
private final PublicKey

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv TrustAnchor

Returns:

a TrustAnchor.
getAnchor
()

Get the TrustAnchor for the certificate chain.

pack-priv X509Certificate

Returns:

the X509Certificate used to create this IssuerInfo object, or null if a certificate was not used in its creation.
getCertificate
()

Get the certificate in this IssuerInfo if present.

pack-priv X500Principal

Returns:

an X500Principal corresponding to this issuer's name. If derived from an issuer's X509Certificate this would be equivalent to the certificate subject name.
getName
()

Get the name of this issuer.

pack-priv PublicKey

Returns:

a PublicKey for this issuer.
getPublicKey
()

Get the public key for this issuer.

public String

Returns:

a String form of this IssuerInfo object.
toString
()

Overrides java.lang.Object.toString.

Create a string representation of this IssuerInfo.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

anchorback to summary
private final TrustAnchor anchor
certificateback to summary
private final X509Certificate certificate
nameback to summary
private final X500Principal name
pubKeyback to summary
private final PublicKey pubKey

Constructor Detail

IssuerInfoback to summary
pack-priv IssuerInfo(TrustAnchor anchor)
IssuerInfoback to summary
pack-priv IssuerInfo(X509Certificate issuerCert)
IssuerInfoback to summary
pack-priv IssuerInfo(TrustAnchor anchor, X509Certificate issuerCert)

Method Detail

getAnchorback to summary
pack-priv TrustAnchor getAnchor()

Get the TrustAnchor for the certificate chain.

Returns:TrustAnchor

a TrustAnchor.

getCertificateback to summary
pack-priv X509Certificate getCertificate()

Get the certificate in this IssuerInfo if present.

Returns:X509Certificate

the X509Certificate used to create this IssuerInfo object, or null if a certificate was not used in its creation.

getNameback to summary
pack-priv X500Principal getName()

Get the name of this issuer.

Returns:X500Principal

an X500Principal corresponding to this issuer's name. If derived from an issuer's X509Certificate this would be equivalent to the certificate subject name.

getPublicKeyback to summary
pack-priv PublicKey getPublicKey()

Get the public key for this issuer.

Returns:PublicKey

a PublicKey for this issuer.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Create a string representation of this IssuerInfo.

Returns:String

a String form of this IssuerInfo object.

Annotations
@Override
sun.security.provider.certpath back to summary

public final Enum OCSPResponse.ResponseStatus

extends Enum<OCSPResponse.ResponseStatus>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final OCSPResponse.ResponseStatus
public static final OCSPResponse.ResponseStatus
public static final OCSPResponse.ResponseStatus
public static final OCSPResponse.ResponseStatus
public static final OCSPResponse.ResponseStatus
public static final OCSPResponse.ResponseStatus
public static final OCSPResponse.ResponseStatus

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static OCSPResponse.ResponseStatus
public static OCSPResponse.ResponseStatus[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INTERNAL_ERRORback to summary
public static final OCSPResponse.ResponseStatus INTERNAL_ERROR
MALFORMED_REQUESTback to summary
public static final OCSPResponse.ResponseStatus MALFORMED_REQUEST
SIG_REQUIREDback to summary
public static final OCSPResponse.ResponseStatus SIG_REQUIRED
SUCCESSFULback to summary
public static final OCSPResponse.ResponseStatus SUCCESSFUL
TRY_LATERback to summary
public static final OCSPResponse.ResponseStatus TRY_LATER
UNAUTHORIZEDback to summary
public static final OCSPResponse.ResponseStatus UNAUTHORIZED
UNUSEDback to summary
public static final OCSPResponse.ResponseStatus UNUSED

Constructor Detail

ResponseStatusback to summary
private ResponseStatus()

Method Detail

valueOfback to summary
public static OCSPResponse.ResponseStatus valueOf(String name)
valuesback to summary
public static OCSPResponse.ResponseStatus[] values()
sun.security.provider.certpath back to summary

public final Class OCSPResponse.SingleResponse

extends Object
implements RevocationStatus
Class Inheritance
All Implemented Interfaces
sun.security.provider.certpath.OCSP.RevocationStatus

Field Summary

Modifier and TypeField and Description
private final CertId
private final OCSP.RevocationStatus.CertStatus
private final Date
private final CRLReason
private final Date
private final Map<String, Extension>
private final Date

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public CertId

Returns:

the CertId for this SingleResponse
getCertId
()

Get the Cert ID that this SingleResponse is for.

public OCSP.RevocationStatus.CertStatus
public Date

Returns:

a Date object containing the nexUpdate date or null if a nextUpdate field is not present in the response.
getNextUpdate
()

Get the nextUpdate field from this SingleResponse.

public CRLReason

Returns:

a CRLReason containing the revocation reason, or null if a revocation reason was not provided or the response status is not REVOKED.
getRevocationReason
()

Implements sun.security.provider.certpath.OCSP.RevocationStatus.getRevocationReason.

Get the revocationReason field for the SingleResponse.

public Date

Returns:

a Date object containing the revocationTime date or null if the SingleResponse does not have a status of REVOKED.
getRevocationTime
()

Implements sun.security.provider.certpath.OCSP.RevocationStatus.getRevocationTime.

Get the revocationTime field from this SingleResponse.

public Map<String, Extension>

Returns:

a Map of Extension objects, keyed by their OID value in string form.
getSingleExtensions
()

Implements sun.security.provider.certpath.OCSP.RevocationStatus.getSingleExtensions.

Get the singleExtensions for this SingleResponse.

public Date

Returns:

a Date object containing the thisUpdate date
getThisUpdate
()

Get the thisUpdate field from this SingleResponse.

public String
toString()

Overrides java.lang.Object.toString.

Construct a string representation of a single OCSP response.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

certIdback to summary
private final CertId certId
certStatusback to summary
private final OCSP.RevocationStatus.CertStatus certStatus
nextUpdateback to summary
private final Date nextUpdate
revocationReasonback to summary
private final CRLReason revocationReason
revocationTimeback to summary
private final Date revocationTime
singleExtensionsback to summary
private final Map<String, Extension> singleExtensions
thisUpdateback to summary
private final Date thisUpdate

Constructor Detail

SingleResponseback to summary
private SingleResponse(DerValue der) throws IOException

Method Detail

getCertIdback to summary
public CertId getCertId()

Get the Cert ID that this SingleResponse is for.

Returns:CertId

the CertId for this SingleResponse

getCertStatusback to summary
public OCSP.RevocationStatus.CertStatus getCertStatus()

Implements sun.security.provider.certpath.OCSP.RevocationStatus.getCertStatus.

Doc from sun.security.provider.certpath.OCSP.RevocationStatus.getCertStatus.

Returns the revocation status.

Annotations
@Override
getNextUpdateback to summary
public Date getNextUpdate()

Get the nextUpdate field from this SingleResponse.

Returns:Date

a Date object containing the nexUpdate date or null if a nextUpdate field is not present in the response.

getRevocationReasonback to summary
public CRLReason getRevocationReason()

Implements sun.security.provider.certpath.OCSP.RevocationStatus.getRevocationReason.

Get the revocationReason field for the SingleResponse.

Returns:CRLReason

a CRLReason containing the revocation reason, or null if a revocation reason was not provided or the response status is not REVOKED.

Annotations
@Override
getRevocationTimeback to summary
public Date getRevocationTime()

Implements sun.security.provider.certpath.OCSP.RevocationStatus.getRevocationTime.

Get the revocationTime field from this SingleResponse.

Returns:Date

a Date object containing the revocationTime date or null if the SingleResponse does not have a status of REVOKED.

Annotations
@Override
getSingleExtensionsback to summary
public Map<String, Extension> getSingleExtensions()

Implements sun.security.provider.certpath.OCSP.RevocationStatus.getSingleExtensions.

Get the singleExtensions for this SingleResponse.

Returns:Map<String, Extension>

a Map of Extension objects, keyed by their OID value in string form.

Annotations
@Override
getThisUpdateback to summary
public Date getThisUpdate()

Get the thisUpdate field from this SingleResponse.

Returns:Date

a Date object containing the thisUpdate date

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Construct a string representation of a single OCSP response.

Annotations
@Override