Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.asn1.cms;
  
RFC 5083: CMS AuthEnveloped Data object.

ASN.1:

 id-ct-authEnvelopedData OBJECT IDENTIFIER ::= { iso(1)
       member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)
       smime(16) ct(1) 23 }

 AuthEnvelopedData ::= SEQUENCE {
       version CMSVersion,
       originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL,
       recipientInfos RecipientInfos,
       authEncryptedContentInfo EncryptedContentInfo,
       authAttrs [1] IMPLICIT AuthAttributes OPTIONAL,
       mac MessageAuthenticationCode,
       unauthAttrs [2] IMPLICIT UnauthAttributes OPTIONAL }
 
 
 public class AuthEnvelopedData
     extends ASN1Object
 {
     private ASN1Integer version;
     private OriginatorInfo originatorInfo;
     private ASN1Set recipientInfos;
     private ASN1Set authAttrs;
     private ASN1OctetString mac;
     private ASN1Set unauthAttrs;
 
     public AuthEnvelopedData(
         OriginatorInfo originatorInfo,
         ASN1Set recipientInfos,
         EncryptedContentInfo authEncryptedContentInfo,
         ASN1Set authAttrs,
         ASN1OctetString mac,
         ASN1Set unauthAttrs)
     {
         // "It MUST be set to 0."
         this. = new ASN1Integer(0);
 
         this. = originatorInfo;
 
         // TODO
         // "There MUST be at least one element in the collection."
         this. = recipientInfos;
 
         this. = authEncryptedContentInfo;
 
         // TODO
         // "The authAttrs MUST be present if the content type carried in
         // EncryptedContentInfo is not id-data."
         this. = authAttrs;
 
         this. = mac;
 
         this. = unauthAttrs;
     }

    
Constructs AuthEnvelopedData by parsing supplied ASN1Sequence

Deprecated:
use getInstance().
Parameters:
seq An ASN1Sequence with AuthEnvelopedData
 
     public AuthEnvelopedData(
         ASN1Sequence seq)
     {
         int index = 0;
 
         // TODO
         // "It MUST be set to 0."
         ASN1Primitive tmp = seq.getObjectAt(index++).toASN1Primitive();
          = (ASN1Integer)tmp;
 
         tmp = seq.getObjectAt(index++).toASN1Primitive();
         if (tmp instanceof ASN1TaggedObject)
         {
              = OriginatorInfo.getInstance((ASN1TaggedObject)tmpfalse);
             tmp = seq.getObjectAt(index++).toASN1Primitive();
         }
 
         // TODO
         // "There MUST be at least one element in the collection."
         = ASN1Set.getInstance(tmp);
        tmp = seq.getObjectAt(index++).toASN1Primitive();
         = EncryptedContentInfo.getInstance(tmp);
        tmp = seq.getObjectAt(index++).toASN1Primitive();
        if (tmp instanceof ASN1TaggedObject)
        {
             = ASN1Set.getInstance((ASN1TaggedObject)tmpfalse);
            tmp = seq.getObjectAt(index++).toASN1Primitive();
        }
        else
        {
            // TODO
            // "The authAttrs MUST be present if the content type carried in
            // EncryptedContentInfo is not id-data."
        }
         = ASN1OctetString.getInstance(tmp);
        if (seq.size() > index)
        {
            tmp = seq.getObjectAt(index++).toASN1Primitive();
             = ASN1Set.getInstance((ASN1TaggedObject)tmpfalse);
        }
    }

    
Return an AuthEnvelopedData object from a tagged object.

Accepted inputs:

  • ASN1Sequence input formats

Parameters:
obj the tagged object holding the object we want.
explicit true if the object is meant to be explicitly tagged false otherwise.
Throws:
java.lang.IllegalArgumentException if the object held by the tagged object cannot be converted.
    public static AuthEnvelopedData getInstance(
        ASN1TaggedObject obj,
        boolean explicit)
    {
        return getInstance(ASN1Sequence.getInstance(objexplicit));
    }

    
Return an AuthEnvelopedData object from the given object.

Accepted inputs:

  • null → null
  • AuthEnvelopedData object
  • org.bouncycastle.asn1.ASN1Sequence input formats with AuthEnvelopedData structure inside

Parameters:
obj The object we want converted.
Throws:
java.lang.IllegalArgumentException if the object cannot be converted, or was null.
    public static AuthEnvelopedData getInstance(
        Object obj)
    {
        if (obj == null || obj instanceof AuthEnvelopedData)
        {
            return (AuthEnvelopedData)obj;
        }
        if (obj instanceof ASN1Sequence)
        {
            return new AuthEnvelopedData((ASN1Sequence)obj);
        }
        throw new IllegalArgumentException("Invalid AuthEnvelopedData: " + obj.getClass().getName());
    }
    public ASN1Integer getVersion()
    {
        return ;
    }
    {
        return ;
    }
    public ASN1Set getRecipientInfos()
    {
        return ;
    }
    {
        return ;
    }
    public ASN1Set getAuthAttrs()
    {
        return ;
    }
    public ASN1OctetString getMac()
    {
        return ;
    }
    public ASN1Set getUnauthAttrs()
    {
        return ;
    }

    
Produce an object suitable for an ASN1OutputStream.
    {
        ASN1EncodableVector v = new ASN1EncodableVector();
        v.add();
        if ( != null)
        {
            v.add(new DERTaggedObject(false, 0, ));
        }
        v.add();
        v.add();
        // "authAttrs optionally contains the authenticated attributes."
        if ( != null)
        {
            // "AuthAttributes MUST be DER encoded, even if the rest of the
            // AuthEnvelopedData structure is BER encoded."
            v.add(new DERTaggedObject(false, 1, ));
        }
        v.add();
        // "unauthAttrs optionally contains the unauthenticated attributes."
        if ( != null)
        {
            v.add(new DERTaggedObject(false, 2, ));
        }
        return new BERSequence(v);
    }
New to GrepCode? Check out our FAQ X