FileDocCategorySizeDatePackage
AuthorityKeyIdentifier.javaAPI DocAndroid 1.5 API5917Wed May 06 22:41:06 BST 2009org.bouncycastle.asn1.x509

AuthorityKeyIdentifier

public class AuthorityKeyIdentifier extends ASN1Encodable
The AuthorityKeyIdentifier object.
id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 }

AuthorityKeyIdentifier ::= SEQUENCE {
keyIdentifier [0] IMPLICIT KeyIdentifier OPTIONAL,
authorityCertIssuer [1] IMPLICIT GeneralNames OPTIONAL,
authorityCertSerialNumber [2] IMPLICIT CertificateSerialNumber OPTIONAL }

KeyIdentifier ::= OCTET STRING

Fields Summary
ASN1OctetString
keyidentifier
GeneralNames
certissuer
DERInteger
certserno
Constructors Summary
public AuthorityKeyIdentifier(ASN1Sequence seq)

        Enumeration     e = seq.getObjects();

        while (e.hasMoreElements())
        {
            ASN1TaggedObject o = DERTaggedObject.getInstance(e.nextElement());

            switch (o.getTagNo())
            {
            case 0:
                this.keyidentifier = ASN1OctetString.getInstance(o, false);
                break;
            case 1:
                this.certissuer = GeneralNames.getInstance(o, false);
                break;
            case 2:
                this.certserno = DERInteger.getInstance(o, false);
                break;
            default:
                throw new IllegalArgumentException("illegal tag");
            }
        }
    
public AuthorityKeyIdentifier(SubjectPublicKeyInfo spki)
Calulates the keyidentifier using a SHA1 hash over the BIT STRING from SubjectPublicKeyInfo as defined in RFC2459. Example of making a AuthorityKeyIdentifier:
SubjectPublicKeyInfo apki = new SubjectPublicKeyInfo((ASN1Sequence)new ASN1InputStream(
publicKey.getEncoded()).readObject());
AuthorityKeyIdentifier aki = new AuthorityKeyIdentifier(apki);

        Digest  digest = new SHA1Digest();
        byte[]  resBuf = new byte[digest.getDigestSize()];

        byte[] bytes = spki.getPublicKeyData().getBytes();
        digest.update(bytes, 0, bytes.length);
        digest.doFinal(resBuf, 0);
        this.keyidentifier = new DEROctetString(resBuf);
    
public AuthorityKeyIdentifier(SubjectPublicKeyInfo spki, GeneralNames name, BigInteger serialNumber)
create an AuthorityKeyIdentifier with the GeneralNames tag and the serial number provided as well.

        Digest  digest = new SHA1Digest();
        byte[]  resBuf = new byte[digest.getDigestSize()];

        byte[] bytes = spki.getPublicKeyData().getBytes();
        digest.update(bytes, 0, bytes.length);
        digest.doFinal(resBuf, 0);

        this.keyidentifier = new DEROctetString(resBuf);
        this.certissuer = GeneralNames.getInstance(name.toASN1Object());
        this.certserno = new DERInteger(serialNumber);
    
public AuthorityKeyIdentifier(GeneralNames name, BigInteger serialNumber)
create an AuthorityKeyIdentifier with the GeneralNames tag and the serial number provided.

        this.keyidentifier = null;
        this.certissuer = GeneralNames.getInstance(name.toASN1Object());
        this.certserno = new DERInteger(serialNumber);
    
public AuthorityKeyIdentifier(byte[] keyIdentifier, GeneralNames name, BigInteger serialNumber)
create an AuthorityKeyIdentifier with a precomupted key identifier and the GeneralNames tag and the serial number provided as well.

        this.keyidentifier = new DEROctetString(keyIdentifier);
        this.certissuer = GeneralNames.getInstance(name.toASN1Object());
        this.certserno = new DERInteger(serialNumber);
    
Methods Summary
public GeneralNamesgetAuthorityCertIssuer()

        return certissuer;
    
public java.math.BigIntegergetAuthorityCertSerialNumber()

        if (certserno != null)
        {
            return certserno.getValue();
        }
        
        return null;
    
public static org.bouncycastle.asn1.x509.AuthorityKeyIdentifiergetInstance(ASN1TaggedObject obj, boolean explicit)


       
         
                  
    
        return getInstance(ASN1Sequence.getInstance(obj, explicit));
    
public static org.bouncycastle.asn1.x509.AuthorityKeyIdentifiergetInstance(java.lang.Object obj)

        if (obj instanceof AuthorityKeyIdentifier)
        {
            return (AuthorityKeyIdentifier)obj;
        }
        else if (obj instanceof ASN1Sequence)
        {
            return new AuthorityKeyIdentifier((ASN1Sequence)obj);
        }

        throw new IllegalArgumentException("unknown object in factory");
    
public byte[]getKeyIdentifier()

        if (keyidentifier != null)
        {
            return keyidentifier.getOctets();
        }

        return null;
    
public DERObjecttoASN1Object()
Produce an object suitable for an ASN1OutputStream.

        ASN1EncodableVector  v = new ASN1EncodableVector();

        if (keyidentifier != null)
        {
            v.add(new DERTaggedObject(false, 0, keyidentifier));
        }

        if (certissuer != null)
        {
            v.add(new DERTaggedObject(false, 1, certissuer));
        }

        if (certserno != null)
        {
            v.add(new DERTaggedObject(false, 2, certserno));
        }


        return new DERSequence(v);
    
public java.lang.StringtoString()

        return ("AuthorityKeyIdentifier: KeyID(" + this.keyidentifier.getOctets() + ")");