FileDocCategorySizeDatePackage
SignedData.javaAPI DocAndroid 1.5 API5639Wed May 06 22:41:06 BST 2009org.bouncycastle.asn1.cms

SignedData

public class SignedData extends org.bouncycastle.asn1.ASN1Encodable
a signed data object.

Fields Summary
private org.bouncycastle.asn1.DERInteger
version
private org.bouncycastle.asn1.ASN1Set
digestAlgorithms
private ContentInfo
contentInfo
private org.bouncycastle.asn1.ASN1Set
certificates
private org.bouncycastle.asn1.ASN1Set
crls
private org.bouncycastle.asn1.ASN1Set
signerInfos
private boolean
certBer
private boolean
crlsBer
Constructors Summary
public SignedData(org.bouncycastle.asn1.ASN1Set digestAlgorithms, ContentInfo contentInfo, org.bouncycastle.asn1.ASN1Set certificates, org.bouncycastle.asn1.ASN1Set crls, org.bouncycastle.asn1.ASN1Set signerInfos)

        if (contentInfo.getContentType().equals(CMSObjectIdentifiers.data))
        {
            //
            // we should also be looking for attribute certificates here,
            // later.
            //
            Enumeration e = signerInfos.getObjects();
            boolean     v3Found = false;

            while (e.hasMoreElements())
            {
                SignerInfo  s = SignerInfo.getInstance(e.nextElement());

                if (s.getVersion().getValue().intValue() == 3)
                {
                    v3Found = true;
                }
            }

            if (v3Found)
            {
                this.version = new DERInteger(3);
            }
            else
            {
                this.version = new DERInteger(1);
            }
        }
        else
        {
            this.version = new DERInteger(3);
        }

        this.digestAlgorithms = digestAlgorithms;
        this.contentInfo = contentInfo;
        this.certificates = certificates;
        this.crls = crls;
        this.signerInfos = signerInfos;
    
public SignedData(org.bouncycastle.asn1.ASN1Sequence seq)

        Enumeration     e = seq.getObjects();

        version = (DERInteger)e.nextElement();
        digestAlgorithms = ((ASN1Set)e.nextElement());
        contentInfo = ContentInfo.getInstance(e.nextElement());

        while (e.hasMoreElements())
        {
            DERObject o = (DERObject)e.nextElement();

            //
            // an interesting feature of SignedData is that there appear
            // to be varying implementations...
            // for the moment we ignore anything which doesn't fit.
            //
            if (o instanceof ASN1TaggedObject)
            {
                ASN1TaggedObject tagged = (ASN1TaggedObject)o;

                switch (tagged.getTagNo())
                {
                case 0:
                    certBer = tagged instanceof BERTaggedObject;
                    certificates = ASN1Set.getInstance(tagged, false);
                    break;
                case 1:
                    crlsBer = tagged instanceof BERTaggedObject;
                    crls = ASN1Set.getInstance(tagged, false);
                    break;
                default:
                    throw new IllegalArgumentException("unknown tag value " + tagged.getTagNo());
                }
            }
            else
            {
                signerInfos = (ASN1Set)o;
            }
        }
    
Methods Summary
public org.bouncycastle.asn1.ASN1SetgetCRLs()

        return crls;
    
public org.bouncycastle.asn1.ASN1SetgetCertificates()

        return certificates;
    
public org.bouncycastle.asn1.ASN1SetgetDigestAlgorithms()

        return digestAlgorithms;
    
public ContentInfogetEncapContentInfo()

        return contentInfo;
    
public static org.bouncycastle.asn1.cms.SignedDatagetInstance(java.lang.Object o)

        if (o instanceof SignedData)
        {
            return (SignedData)o;
        }
        else if (o instanceof ASN1Sequence)
        {
            return new SignedData((ASN1Sequence)o);
        }

        throw new IllegalArgumentException("unknown object in factory");
    
public org.bouncycastle.asn1.ASN1SetgetSignerInfos()

        return signerInfos;
    
public org.bouncycastle.asn1.DERIntegergetVersion()

        return version;
    
public org.bouncycastle.asn1.DERObjecttoASN1Object()
Produce an object suitable for an ASN1OutputStream.
SignedData ::= SEQUENCE {
version CMSVersion,
digestAlgorithms DigestAlgorithmIdentifiers,
encapContentInfo EncapsulatedContentInfo,
certificates [0] IMPLICIT CertificateSet OPTIONAL,
crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,
signerInfos SignerInfos
}

        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(version);
        v.add(digestAlgorithms);
        v.add(contentInfo);

        if (certificates != null)
        {
            if (certBer)
            {
                v.add(new BERTaggedObject(false, 0, certificates));
            }
            else
            {
                v.add(new DERTaggedObject(false, 0, certificates));
            }
        }

        if (crls != null)
        {
            if (crlsBer)
            {
                v.add(new BERTaggedObject(false, 1, crls));
            }
            else
            {
                v.add(new DERTaggedObject(false, 1, crls));
            }
        }

        v.add(signerInfos);

        return new BERSequence(v);