public class ResponderID
extends java.lang.Object
Within a BasicOCSPResponse
the
ResponderID identifies the responder either by its name or by a SHA-1 hash
calculated from the responder's public key (see RFC 2560,
RFC 6960):
ResponderID ::= CHOICE { byName [1] Name, byKey [2] KeyHash }After having created a new ResponderID, add it to
BasicOCSPResponse
by calling the
setResponderID
method, e.g.:
// the key of the responder: PublicKey responderKey = ...; ResponderID responderID = new ResponderID(responderKey); ... BasicOCSPResponse basicOCSPresponse = ...; ... basicOCSPResponse.setResponderID(responderID);As you can see from the example above, you immediately may supply the responder's key to the corresponding
constructor
of this call to let it do the hash calculation for a keyHash
responder id.BasicOCSPResponse
Constructor and Description |
---|
ResponderID(ASN1Object obj)
Creates ResponderID from an ASN1Object.
|
ResponderID(byte[] keyHash)
Creates a responder ID from a hash of its public key.
|
ResponderID(Name name)
Creates a responder ID from its name.
|
ResponderID(java.security.PublicKey responderKey)
Creates a responder ID from its public key.
|
Modifier and Type | Method and Description |
---|---|
boolean |
byName()
Checks whether this ResponderID represents the byName choice.
|
boolean |
equals(java.lang.Object obj)
Compares this ResponderID with the given ResponderID.
|
byte[] |
getKeyHash()
Returns the hash of the responder's public key.
|
Name |
getName()
Returns the Name of the responder.
|
int |
hashCode()
Returns a hash code value for this object.
|
boolean |
isResponderIdFor(X509Certificate responderCert)
Checks if this is a responder id for the given certificate.
|
ASN1Object |
toASN1Object()
Returns this ResponderID as an ASN1Object.
|
java.lang.String |
toString()
Gives a String representation of this ResponderID.
|
public ResponderID(Name name)
name
- the name of the responderpublic ResponderID(byte[] keyHash)
keyHash
- the hash of the responder's public keypublic ResponderID(java.security.PublicKey responderKey) throws java.security.NoSuchAlgorithmException
responderKey
- the public key of the responder from which a SHA-1 hash has to be
calculated for giving the value of this "byKey" responder IDjava.security.NoSuchAlgorithmException
- if SHA-1 is not supported by the installed providerspublic ResponderID(ASN1Object obj) throws CodingException
obj
- the ResponderID as ASN1ObjectCodingException
- if the ASN1Object has the wrong formatpublic boolean isResponderIdFor(X509Certificate responderCert) throws java.security.NoSuchAlgorithmException
responderCert
- the cert of the respondertrue
if this responderID identifies the responderjava.security.NoSuchAlgorithmException
- if SHA-1 is not supported by the installed providerspublic Name getName()
public byte[] getKeyHash()
public boolean byName()
true
if this ID identifies the responder by Name
false
if this ID identifies the responder by Keypublic ASN1Object toASN1Object()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the other ResponderIDtrue
, if the two ResponderID are equal,
false
otherwisepublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object