Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.asn1.cms;
  
RFC 5652: Content encryption key delivery mechanisms.

 RecipientInfo ::= CHOICE {
     ktri      KeyTransRecipientInfo,
     kari  [1] KeyAgreeRecipientInfo,
     kekri [2] KEKRecipientInfo,
     pwri  [3] PasswordRecipientInfo,
     ori   [4] OtherRecipientInfo }
 
 
 public class RecipientInfo
     extends ASN1Object
     implements ASN1Choice
 {
     ASN1Encodable    info;
 
     public RecipientInfo(
         KeyTransRecipientInfo info)
     {
         this. = info;
     }
 
     public RecipientInfo(
         KeyAgreeRecipientInfo info)
     {
         this. = new DERTaggedObject(false, 1, info);
     }
 
     public RecipientInfo(
         KEKRecipientInfo info)
     {
         this. = new DERTaggedObject(false, 2, info);
     }
 
     public RecipientInfo(
         PasswordRecipientInfo info)
     {
         this. = new DERTaggedObject(false, 3, info);
     }
 
     public RecipientInfo(
         OtherRecipientInfo info)
     {
         this. = new DERTaggedObject(false, 4, info);
     }
 
     public RecipientInfo(
         ASN1Primitive   info)
     {
         this. = info;
     }

    
Return a RecipientInfo object from the given object.

Accepted inputs:

  • null → null
  • RecipientInfo object
  • ASN1Sequence input formats with RecipientInfo structure inside
  • ASN1TaggedObject input formats with RecipientInfo structure inside

Parameters:
o the object we want converted.
Throws:
java.lang.IllegalArgumentException if the object cannot be converted.
 
     public static RecipientInfo getInstance(
         Object  o)
     {
         if (o == null || o instanceof RecipientInfo)
         {
             return (RecipientInfo)o;
         }
         else if (o instanceof ASN1Sequence)
         {
             return new RecipientInfo((ASN1Sequence)o);
         }
         else if (o instanceof ASN1TaggedObject)
         {
             return new RecipientInfo((ASN1TaggedObject)o);
         }
 
         throw new IllegalArgumentException("unknown object in factory: "
                                                     + o.getClass().getName());
     }
    public ASN1Integer getVersion()
    {
        if ( instanceof ASN1TaggedObject)
        {
            ASN1TaggedObject o = (ASN1TaggedObject);
            switch (o.getTagNo())
            {
            case 1:
                return KeyAgreeRecipientInfo.getInstance(ofalse).getVersion();
            case 2:
                return getKEKInfo(o).getVersion();
            case 3:
                return PasswordRecipientInfo.getInstance(ofalse).getVersion();
            case 4:
                return new ASN1Integer(0);    // no syntax version for OtherRecipientInfo
            default:
                throw new IllegalStateException("unknown tag");
            }
        }
        return KeyTransRecipientInfo.getInstance().getVersion();
    }
    public boolean isTagged()
    {
        return ( instanceof ASN1TaggedObject);
    }
    public ASN1Encodable getInfo()
    {
        if ( instanceof ASN1TaggedObject)
        {
            ASN1TaggedObject o = (ASN1TaggedObject);
            switch (o.getTagNo())
            {
            case 1:
                return KeyAgreeRecipientInfo.getInstance(ofalse);
            case 2:
                return getKEKInfo(o);
            case 3:
                return PasswordRecipientInfo.getInstance(ofalse);
            case 4:
                return OtherRecipientInfo.getInstance(ofalse);
            default:
                throw new IllegalStateException("unknown tag");
            }
        }
        return KeyTransRecipientInfo.getInstance();
    }
    {
        if (o.isExplicit())
        {                        // compatibilty with erroneous version
            return KEKRecipientInfo.getInstance(otrue);
        }
        else
        {
            return KEKRecipientInfo.getInstance(ofalse);
        }
    }

    
Produce an object suitable for an ASN1OutputStream.
    {
        return .toASN1Primitive();
    }
New to GrepCode? Check out our FAQ X