FileDocCategorySizeDatePackage
AuthorityKeyIdentifierStructure.javaAPI DocAndroid 1.5 API4728Wed May 06 22:41:06 BST 2009org.bouncycastle.x509.extension

AuthorityKeyIdentifierStructure

public class AuthorityKeyIdentifierStructure extends org.bouncycastle.asn1.x509.AuthorityKeyIdentifier
A high level authority key identifier.

Fields Summary
Constructors Summary
public AuthorityKeyIdentifierStructure(byte[] encodedValue)
Constructor which will take the byte[] returned from getExtensionValue()

param
encodedValue a DER octet encoded string with the extension structure in it.
throws
IOException on parsing errors.

        super((ASN1Sequence)X509ExtensionUtil.fromExtensionValue(encodedValue));
    
public AuthorityKeyIdentifierStructure(X509Certificate certificate)
Create an AuthorityKeyIdentifier using the passed in certificate's public key, issuer and serial number.

param
certificate the certificate providing the information.
throws
CertificateParsingException if there is a problem processing the certificate

        super(fromCertificate(certificate));
    
public AuthorityKeyIdentifierStructure(PublicKey pubKey)
Create an AuthorityKeyIdentifier using just the hash of the public key.

param
pubKey the key to generate the hash from.
throws
InvalidKeyException if there is a problem using the key.

        super(fromKey(pubKey));
    
Methods Summary
private static org.bouncycastle.asn1.ASN1SequencefromCertificate(java.security.cert.X509Certificate certificate)

        try
        {
            if (certificate.getVersion() != 3)
            {
                GeneralName          genName = new GeneralName(PrincipalUtil.getIssuerX509Principal(certificate));
                SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(
                        (ASN1Sequence)new ASN1InputStream(certificate.getPublicKey().getEncoded()).readObject());
                
                return (ASN1Sequence)new AuthorityKeyIdentifier(
                               info, new GeneralNames(genName), certificate.getSerialNumber()).toASN1Object();
            }
            else
            {
                GeneralName             genName = new GeneralName(PrincipalUtil.getIssuerX509Principal(certificate));
                
                byte[]                  ext = certificate.getExtensionValue(X509Extensions.SubjectKeyIdentifier.getId());
                
                if (ext != null)
                {
                    ASN1OctetString     str = (ASN1OctetString)X509ExtensionUtil.fromExtensionValue(ext);
                
                    return (ASN1Sequence)new AuthorityKeyIdentifier(
                                    str.getOctets(), new GeneralNames(genName), certificate.getSerialNumber()).toASN1Object();
                }
                else
                {
                    SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(
                            (ASN1Sequence)new ASN1InputStream(certificate.getPublicKey().getEncoded()).readObject());
                    
                    return (ASN1Sequence)new AuthorityKeyIdentifier(
                            info, new GeneralNames(genName), certificate.getSerialNumber()).toASN1Object();
                }
            }
        }
        catch (Exception e)
        {
            throw new CertificateParsingException("Exception extracting certificate details: " + e.toString());
        }
    
private static org.bouncycastle.asn1.ASN1SequencefromKey(java.security.PublicKey pubKey)

        try
        {
            SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(
                                        (ASN1Sequence)new ASN1InputStream(pubKey.getEncoded()).readObject());
        
            return (ASN1Sequence)new AuthorityKeyIdentifier(info).toASN1Object();
        }
        catch (Exception e)
        {
            throw new InvalidKeyException("can't process key: " + e);
        }