public class SubjectKeyID extends java.lang.Object implements CertificateIdentifier
SubjectKeyIdentifier
type.
The Cryptographic Message Syntax (CMS) (RFC 5652)
uses the X.509 certificate SubjectKeyIdentifier
extension for identifying
a certificate (and thereby an entity and a public key):
SubjectKeyIdentifier ::= OCTET STRING
The SubjectKeyIdentifier
type maybe used for specifying the
signer certificate in the CMS SignerInfo
structure,
the recipient certificate in the CMS RecipientInfo
structure, or the originator in the CMS KeyAgreeRecipientInfo
structure.
SignerInfo
,
RecipientInfo
,
KeyAgreeRecipientInfo
ISSUER_AND_SERIALNUMBER, KEK_IDENTIFIER, ORIGINATOR_PUBLIC_KEY, RECIPIENT_KEY_IDENTIFIER, SUBJECT_KEY_IDENTIFIER
Constructor and Description |
---|
SubjectKeyID()
Default Constructor.
|
SubjectKeyID(iaik.asn1.ASN1Object obj)
Creates a new
SubjectKeyID from an ASN1Object. |
SubjectKeyID(byte[] keyIdentifier)
Creates a new
SubjectKeyID the given
identifier value. |
SubjectKeyID(iaik.x509.X509Certificate cert)
Creates a new
SubjectKeyID from a certificate. |
Modifier and Type | Method and Description |
---|---|
void |
decode(iaik.asn1.ASN1Object obj)
Decodes the given ASN.1
SubjectKeyIdentifier object for parsing
the internal structure. |
boolean |
equals(java.lang.Object obj)
Compares this
SubjectKeyID to the specified object. |
byte[] |
getKeyIdentifier()
Returns the keyIdentifier value of this SubjectKeyID.
|
int |
getKeyIdType()
Returns the key (certificate) identifier type this class represents.
|
java.lang.String |
getKeyIdTypeName()
Returns the key (certificate) identifier type this class represents as string.
|
int |
hashCode()
Returns a hashcode for this
SubjectKeyIdentifier . |
boolean |
identifiesCert(iaik.x509.X509Certificate certificate)
Checks if the given certificate is identified by this SubjectKeyID.
|
iaik.asn1.ASN1Object |
toASN1Object()
Returns this
SubjectKeyIdentifier as ASN1Object. |
java.lang.String |
toString()
Returns a string giving some information about this
SubjectKeyIdentifier object. |
public SubjectKeyID()
public SubjectKeyID(byte[] keyIdentifier)
SubjectKeyID
the given
identifier value.keyIdentifier
- the SubjectKeyIdentifier valuepublic SubjectKeyID(iaik.x509.X509Certificate cert) throws iaik.x509.X509ExtensionException
SubjectKeyID
from a certificate.
The KeyIdentifier value is read from the SubjectKeyIdentifier extension of the supplied certificate. If the certificate does not contain the SubjectKeyIdentifier extension an IllegalArgumetException is thrown indicating that a SubjectKeyIdentifier cannot be used for identfying the certificate within a CMS transaction.
cert
- the certificate this SubjectKeyID object shall be
initialized fromiaik.x509.X509ExtensionException
- if the given cert does not contain the
SubjectKeyIdentifier extension, or if the SubjectKeyIdentifier
extension cannot be parsedpublic SubjectKeyID(iaik.asn1.ASN1Object obj) throws iaik.asn1.CodingException
SubjectKeyID
from an ASN1Object.
The ASN1Object supplied to this constructor represents an
already exisiting SubjectKeyID
object that may
have been created by calling toASN1Object
.
obj
- the SubjectKeyID
as ASN1Objectiaik.asn1.CodingException
- if the ASN1Object could not be parsedpublic byte[] getKeyIdentifier()
public void decode(iaik.asn1.ASN1Object obj) throws iaik.asn1.CodingException
SubjectKeyIdentifier
object for parsing
the internal structure.
This method internally is called when creating a SubjectKeyID
object from an already existing SubjectKeyIdentifier
object,
supplied as ASN1Object.
decode
in interface iaik.asn1.ASN1Type
obj
- the SubjectKeyIdentifier as ASN1Objectiaik.asn1.CodingException
- if the object can not be parsedpublic iaik.asn1.ASN1Object toASN1Object()
SubjectKeyIdentifier
as ASN1Object.
The ASN1Object returned by this method may be used as parameter value
when creating an SubjectKeyID
object using the
SubjectKeyID(ASN1Object obj)
constructor.
toASN1Object
in interface iaik.asn1.ASN1Type
SubjectKeyIdentifier
as ASN1Objectpublic int getKeyIdType()
getKeyIdType
in interface KeyIdentifier
public java.lang.String getKeyIdTypeName()
getKeyIdTypeName
in interface KeyIdentifier
public boolean identifiesCert(iaik.x509.X509Certificate certificate)
true
if the given cert contains a
SubjectKeyIdentifier extension with the same value as represented by this
SubjectKeyIdentifier object.identifiesCert
in interface CertificateIdentifier
certificate
- the certificate to be checked of being identified by this
SubjectKeyIdentifier
true
if the given cert contains a SubjectKeyIdentifier
extension with the same value as represented by this SubjectKeyIdentifier
object, false
otherwisepublic boolean equals(java.lang.Object obj)
SubjectKeyID
to the specified object.equals
in interface KeyIdentifier
equals
in class java.lang.Object
obj
- the object to compare this SubjectKeyID
against.true
, if the given object is equal to this
SubjectKeyID
,
false
otherwisepublic int hashCode()
SubjectKeyIdentifier
.hashCode
in interface KeyIdentifier
hashCode
in class java.lang.Object
SubjectKeyIdentifier
public java.lang.String toString()
SubjectKeyIdentifier
object.toString
in interface KeyIdentifier
toString
in class java.lang.Object