org.testifyproject.bouncycastle.asn1.x509.SubjectKeyIdentifier Maven / Gradle / Ivy
The newest version!
package org.testifyproject.bouncycastle.asn1.x509;
import org.testifyproject.bouncycastle.asn1.ASN1Object;
import org.testifyproject.bouncycastle.asn1.ASN1OctetString;
import org.testifyproject.bouncycastle.asn1.ASN1Primitive;
import org.testifyproject.bouncycastle.asn1.ASN1TaggedObject;
import org.testifyproject.bouncycastle.asn1.DEROctetString;
/**
* The SubjectKeyIdentifier object.
* * SubjectKeyIdentifier::= OCTET STRING
*
*/
public class SubjectKeyIdentifier
extends ASN1Object
{
private byte[] keyidentifier;
public static SubjectKeyIdentifier getInstance(
ASN1TaggedObject obj,
boolean explicit)
{
return getInstance(ASN1OctetString.getInstance(obj, explicit));
}
public static SubjectKeyIdentifier getInstance(
Object obj)
{
if (obj instanceof SubjectKeyIdentifier)
{
return (SubjectKeyIdentifier)obj;
}
else if (obj != null)
{
return new SubjectKeyIdentifier(ASN1OctetString.getInstance(obj));
}
return null;
}
public static SubjectKeyIdentifier fromExtensions(Extensions extensions)
{
return SubjectKeyIdentifier.getInstance(extensions.getExtensionParsedValue(Extension.subjectKeyIdentifier));
}
public SubjectKeyIdentifier(
byte[] keyid)
{
this.keyidentifier = keyid;
}
protected SubjectKeyIdentifier(
ASN1OctetString keyid)
{
this.keyidentifier = keyid.getOctets();
}
public byte[] getKeyIdentifier()
{
return keyidentifier;
}
public ASN1Primitive toASN1Primitive()
{
return new DEROctetString(keyidentifier);
}
}