FileDocCategorySizeDatePackage
OtherCertID.javaAPI DocAndroid 1.5 API3602Wed May 06 22:41:06 BST 2009org.bouncycastle.asn1.ess

OtherCertID

public class OtherCertID extends org.bouncycastle.asn1.ASN1Encodable

Fields Summary
private org.bouncycastle.asn1.ASN1Encodable
otherCertHash
private org.bouncycastle.asn1.x509.IssuerSerial
issuerSerial
Constructors Summary
public OtherCertID(org.bouncycastle.asn1.ASN1Sequence seq)
constructor

        if (seq.size() < 1 || seq.size() > 2)
        {
            throw new IllegalArgumentException("Bad sequence size: "
                    + seq.size());
        }

        if (seq.getObjectAt(0).getDERObject() instanceof ASN1OctetString)
        {
            otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
        }
        else
        {
            otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));

        }

        if (seq.size() > 1)
        {
            issuerSerial = new IssuerSerial(ASN1Sequence.getInstance(seq.getObjectAt(1)));
        }
    
public OtherCertID(org.bouncycastle.asn1.x509.AlgorithmIdentifier algId, byte[] digest)

        this.otherCertHash = new DigestInfo(algId, digest);
    
public OtherCertID(org.bouncycastle.asn1.x509.AlgorithmIdentifier algId, byte[] digest, org.bouncycastle.asn1.x509.IssuerSerial issuerSerial)

        this.otherCertHash = new DigestInfo(algId, digest);
        this.issuerSerial = issuerSerial;
    
Methods Summary
public org.bouncycastle.asn1.x509.AlgorithmIdentifiergetAlgorithmHash()

        if (otherCertHash.getDERObject() instanceof ASN1OctetString)
        {
            // SHA-1
            return new AlgorithmIdentifier("1.3.14.3.2.26");
        }
        else
        {
            return DigestInfo.getInstance(otherCertHash).getAlgorithmId();
        }
    
public byte[]getCertHash()

        if (otherCertHash.getDERObject() instanceof ASN1OctetString)
        {
            // SHA-1
            return ((ASN1OctetString)otherCertHash.getDERObject()).getOctets();
        }
        else
        {
            return DigestInfo.getInstance(otherCertHash).getDigest();
        }
    
public static org.bouncycastle.asn1.ess.OtherCertIDgetInstance(java.lang.Object o)

        if (o == null || o instanceof OtherCertID)
        {
            return (OtherCertID) o;
        }
        else if (o instanceof ASN1Sequence)
        {
            return new OtherCertID((ASN1Sequence) o);
        }

        throw new IllegalArgumentException(
                "unknown object in 'OtherCertID' factory : "
                        + o.getClass().getName() + ".");
    
public org.bouncycastle.asn1.x509.IssuerSerialgetIssuerSerial()

        return issuerSerial;
    
public org.bouncycastle.asn1.DERObjecttoASN1Object()
OtherCertID ::= SEQUENCE {
otherCertHash OtherHash,
issuerSerial IssuerSerial OPTIONAL }

OtherHash ::= CHOICE {
sha1Hash OCTET STRING,
otherHash OtherHashAlgAndValue }

OtherHashAlgAndValue ::= SEQUENCE {
hashAlgorithm AlgorithmIdentifier,
hashValue OCTET STRING }

        ASN1EncodableVector v = new ASN1EncodableVector();

        v.add(otherCertHash);

        if (issuerSerial != null)
        {
            v.add(issuerSerial);
        }

        return new DERSequence(v);