org.bouncycastle.asn1.x509.SubjectKeyIdentifier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-ext-jdk15on Show documentation
Show all versions of bcprov-ext-jdk15on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8. Note: this package includes the NTRU encryption algorithms.
The newest version!
package org.bouncycastle.asn1.x509;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.util.Arrays;
/**
* 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 = Arrays.clone(keyid);
}
protected SubjectKeyIdentifier(
ASN1OctetString keyid)
{
this(keyid.getOctets());
}
public byte[] getKeyIdentifier()
{
return Arrays.clone(keyidentifier);
}
public ASN1Primitive toASN1Primitive()
{
return new DEROctetString(getKeyIdentifier());
}
}