|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.x509.ocsp.ReqCert
This class implements the OCSPv2 type "ReqCert".
OCSPv2 specifies the ReqCert type for identifying a target
certificate when creating a Request
to be sent to an OCSP server by one of the following types
(the id also is included by the response
sent back from the server):
certID
)
IssuerAndSerialNumber
)
certificate
)
GeneralName
)
ASN.1 definition:
ReqCert ::= CHOICE { certID CertID, issuerSerial [0] IssuerandSerialNumber, pKCert [1] Certificate, name [2] GeneralName, certHash [3] OCTET STRING}When creating a
ReqCert
object, specify the intended type and
the value to be set, e.g.:
CertID certID = ...; ReqCert reqCert = new ReqCert(ReqCert.certID, certID);Depending on the type the value has to be an object according to the following assignment:
TYPE VALUE ==== ===== certID (0): iaik.x509.ocsp.CertID issuerSerial (1): iaik.pkcs.pkcs7.IssuerAndSerialNumber pKCert (2): iaik.x509.X509Certificate name (3): iaik.asn1.structures.GeneralName certHash (4): byte array or X509CertificatePlease be aware that for type certHash the value may be specified either as byte array (already calcualted SHA-1 hash), or as X509Certificate; if the latter applies the hash is calculated automatically.
An OCSP requestor will include the reqCert in a single Request
whereas a responder will include it in a single response
:
Request request = new Request(reqCert);respectively
SingleResponse singleResponse = new SingleResponse(reqCert, certStatus, thisUpdate);
CertID
,
IssuerAndSerialNumber
,
X509Certificate
,
GeneralName
,
Request
,
SingleResponse
Field Summary | |
static int |
certHash
ReqCert type certHash (4).
|
static int |
certID
ReqCert type CertID (0).
|
static int |
issuerSerial
ReqCert type issuerSerial (1).
|
static int |
name
ReqCert type name (3).
|
static int |
pKCert
ReqCert type pKCert (2).
|
Constructor Summary | |
ReqCert(ASN1Object obj)
Creates a ReqCert from an ASN1Object. |
|
ReqCert(int type,
Object reqCert)
Creates a ReqCert for given type and value. |
Method Summary | |
boolean |
equals(Object obj)
Compares this ReqCert with the given ReqCert. |
Object |
getReqCert()
Returns the value of this reqCert. |
int |
getType()
Returns the type of this reqCert which may lie between 0 and 4. |
String |
getTypeName()
Returns the type of this reqCert as String. |
int |
hashCode()
Returns a hash code value for this object. |
boolean |
isReqCertFor(X509Certificate targetCert,
X509Certificate issuerCert,
GeneralName generalName)
Checks if this is a ReqCert for the given certificate identifying information. |
ASN1Object |
toASN1Object()
Returns this ReqCert object as ASN1Object. |
String |
toString()
Returns a string that represents the contents of this reqCert. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int certID
CertID
(0).
(OCSP CertID
)public static final int issuerSerial
issuerSerial
(1).
(CMS, PKCS#7 IssuerAndSerialNumber
)public static final int pKCert
pKCert
(2).
(X.509 certificate
)public static final int name
name
(3).
(X.509 GeneralName
)public static final int certHash
certHash
(4).
(SHA-1 hash of certificate)Constructor Detail |
public ReqCert(int type, Object reqCert) throws IllegalArgumentException
When creating a new ReqCert object you have to specify type and corresponding value. The value has to be an object according to the following assignment:
TYPE VALUE ==== ===== certID (0): iaik.x509.ocsp.CertID issuerSerial (1): iaik.pkcs.pkcs7.IssuerAndSerialNumber pKCert (2): iaik.x509.X509Certificate name (3): iaik.asn1.structures.GeneralName certHash (4): byte array or X509CertificatePlease be aware that for type certHash the value may be specified either as byte array (already calcualted SHA-1 hash), or as X509Certificate; if the latter applies the hash is calculated automatically, e.g.:
X509Certificate targetCert = ...; ReqCert reqCert = new ReqCert(ReqCert.certHash, targetCert;to be distinguished from:
X509Certificate targetCert = ...; ReqCert reqCert = new ReqCert(ReqCert.pKCert, targetCert;where whole the cert is used for identification.
type
- the type of the reqCert; a valid type must be used (0 ... 4)reqCert
- the value for this type of reqCertIllegalArgumentException
- if the supplied type is not defined, i.e. the
int specificier is "out-of-range" (only 0...4 is allowed)public ReqCert(ASN1Object obj) throws CodingException
toASN1Object
method.obj
- the reqCert as ASN1ObjectCodingException
- if the ASN1Object is not a ReqCert or
some parsing error occurs; or the supplied ReqCert type
is not knownMethod Detail |
public ASN1Object toASN1Object() throws CodingException
CodingException
- if the ASN1Object cannot be created for
some reason, e.g. the type is not supportedpublic Object getReqCert()
Depending on the type this ReqCert represents this method returns an object according to the following assignment:
TYPE VALUE ==== ===== certID (0): iaik.x509.ocsp.CertID issuerSerial (1): iaik.pkcs.pkcs7.IssuerAndSerialNumber pKCert (2): iaik.x509.X509Certificate name (3): iaik.asn1.structures.GeneralName certHash (4): byte array
public int getType()
public String getTypeName()
public boolean equals(Object obj)
equals
in class Object
obj
- the other ReqCerttrue
, if the two ReqCerts are equal,
false
otherwisepublic boolean isReqCertFor(X509Certificate targetCert, X509Certificate issuerCert, GeneralName generalName) throws OCSPException
Since OCSP v2-01 (see draft-ietf-pkix-ocspv2-01) uses not less
than five alternatives (certID, issuerSerial, pKCert, name, certHash)
to identify the target cert for which status information shall be
obtained, it might be the -- hopefully not very probable -- case that
an OCSP server responds by using a different reqCert type (namely when
maintaining precompted responses) as the one sent with the client
request.
If the reqCert types are the same in request and response, method
equals
can be used for checking the two
reqCert IDs of referring to the same certificate. However, if the
two types are not the same (e.g. request: pkCert, response: certID)
or are two certIDs with different hash algorithms, this method may
be used for trying to "translate" the given cert data into a reqCert of
the type this reqCert represents for checking if they are equal.
Translation thereby is performed according to the following rules:
targetCert
and issuerCert
have to be supplied, generalName
is ignored. From the given certs, a certID is created and checked for
equality with the one of this reqCert.
targetCert
has to be supplied, issuerCert
and generalName
are ignored. From the given target cert, an IssuerAndSerialNumber object
is created and checked for equality with the issuerAndSerial of this
reqCert.
targetCert
has to be supplied, issuerCert
and generalName
are ignored. The given target cert is checked for equality with the
pKCert of this reqCert.
targetCert
or generalName
have to be supplied, issuerCert
is ignored. If generalName
is supplied, it is compared
with the GeneralName of this reqCert. If generalName
is null,
but targetCert
is supplied, a GeneralName of type directoryName
is created from the target certīs SubjectDN and checked for equality with the
generalName of this reqCert.
targetCert
has to be supplied, issuerCert
and generalName
are ignored. From the given target cert a SHA-1 hash is computed and compared
with the certHash of this reqCert.
true
if the supplied informations
fit to the type this ReqCert represents (according to the conditions above)
and identify the same certificate. In any other case this method returns
false
(e.g. this ReqCert represents a type for which
the supplied informations are not appropriate, or the type is ok but
another certificate is referenced).
Assumimg, for instance, that this ReqCert represents a certID, but you expect
a pKCert, method equals
will fail. Now you may
supply both target cert and its issuing cert for checking if this ReqCert
identifies the target certificate in mind, e.g.:
// the target cert chain X509Certificate[] targetCerts = ...; booelan isReqCertFor = reqCert.isReqCertFor(targetCerts[0], targetCerts[1], null);
targetCert
- the target cert, if requiredissuerCert
- the cert of the target cert issuer, if requiredgeneralName
- a general name (if required for reqCert type "name")true
if this ReqCert identifies the target certificate
asked for; or false
if this ReqCert does not identify the
target certificate in mind or not enough information is provided for
handling the cert type of this ReqCertOCSPException
- if some processing error occurs, e.g. if this
ReqCert represents a CertID but the certIDīs hash algorithm
is not supported by the installed providerspublic int hashCode()
hashCode
in class Object
public 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 |