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

EnvelopedData

public class EnvelopedData extends org.bouncycastle.asn1.ASN1Encodable

Fields Summary
private org.bouncycastle.asn1.DERInteger
version
private OriginatorInfo
originatorInfo
private org.bouncycastle.asn1.ASN1Set
recipientInfos
private EncryptedContentInfo
encryptedContentInfo
private org.bouncycastle.asn1.ASN1Set
unprotectedAttrs
Constructors Summary
public EnvelopedData(OriginatorInfo originatorInfo, org.bouncycastle.asn1.ASN1Set recipientInfos, EncryptedContentInfo encryptedContentInfo, org.bouncycastle.asn1.ASN1Set unprotectedAttrs)

        if (originatorInfo != null || unprotectedAttrs != null)
        {
            version = new DERInteger(2);
        }
        else
        {
            version = new DERInteger(0);

            Enumeration e = recipientInfos.getObjects();

            while (e.hasMoreElements())
            {
                RecipientInfo   ri = RecipientInfo.getInstance(e.nextElement());

                if (!ri.getVersion().equals(version))
                {
                    version = new DERInteger(2);
                    break;
                }
            }
        }

        this.originatorInfo = originatorInfo;
        this.recipientInfos = recipientInfos;
        this.encryptedContentInfo = encryptedContentInfo;
        this.unprotectedAttrs = unprotectedAttrs;
    
public EnvelopedData(org.bouncycastle.asn1.ASN1Sequence seq)

        int     index = 0;
        
        version = (DERInteger)seq.getObjectAt(index++);
        
        Object  tmp = seq.getObjectAt(index++);

        if (tmp instanceof ASN1TaggedObject)
        {
            originatorInfo = OriginatorInfo.getInstance((ASN1TaggedObject)tmp, false);
            tmp = seq.getObjectAt(index++);
        }

        recipientInfos = ASN1Set.getInstance(tmp);
        
        encryptedContentInfo = EncryptedContentInfo.getInstance(seq.getObjectAt(index++));
        
        if(seq.size() > index)
        {
            unprotectedAttrs = ASN1Set.getInstance((ASN1TaggedObject)seq.getObjectAt(index), false);
        }
    
Methods Summary
public EncryptedContentInfogetEncryptedContentInfo()

        return encryptedContentInfo;
    
public static org.bouncycastle.asn1.cms.EnvelopedDatagetInstance(org.bouncycastle.asn1.ASN1TaggedObject obj, boolean explicit)
return an EnvelopedData object from a tagged object.

param
obj the tagged object holding the object we want.
param
explicit true if the object is meant to be explicitly tagged false otherwise.
exception
IllegalArgumentException if the object held by the tagged object cannot be converted.

        return getInstance(ASN1Sequence.getInstance(obj, explicit));
    
public static org.bouncycastle.asn1.cms.EnvelopedDatagetInstance(java.lang.Object obj)
return an EnvelopedData object from the given object.

param
obj the object we want converted.
exception
IllegalArgumentException if the object cannot be converted.

        if (obj == null || obj instanceof EnvelopedData)
        {
            return (EnvelopedData)obj;
        }
        
        if (obj instanceof ASN1Sequence)
        {
            return new EnvelopedData((ASN1Sequence)obj);
        }
        
        throw new IllegalArgumentException("Invalid EnvelopedData: " + obj.getClass().getName());
    
public OriginatorInfogetOriginatorInfo()

        return originatorInfo;
    
public org.bouncycastle.asn1.ASN1SetgetRecipientInfos()

        return recipientInfos;
    
public org.bouncycastle.asn1.ASN1SetgetUnprotectedAttrs()

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

        return version;
    
public org.bouncycastle.asn1.DERObjecttoASN1Object()
Produce an object suitable for an ASN1OutputStream.
EnvelopedData ::= SEQUENCE {
version CMSVersion,
originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL,
recipientInfos RecipientInfos,
encryptedContentInfo EncryptedContentInfo,
unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL
}

        ASN1EncodableVector  v = new ASN1EncodableVector();
        
        v.add(version);

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

        v.add(recipientInfos);
        v.add(encryptedContentInfo);

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