Start line:  
End line:  

Snippet Preview

Snippet HTML Code

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

 KEKIdentifier ::= SEQUENCE {
     keyIdentifier OCTET STRING,
     date GeneralizedTime OPTIONAL,
     other OtherKeyAttribute OPTIONAL 
 }
 
 
 public class KEKIdentifier
     extends ASN1Object
 {
     private ASN1OctetString    keyIdentifier;
     private ASN1GeneralizedTime date;
     private OtherKeyAttribute  other;
     
     public KEKIdentifier(
         byte[]              keyIdentifier,
         ASN1GeneralizedTime  date,
         OtherKeyAttribute   other)
     {
         this. = new DEROctetString(keyIdentifier);
         this. = date;
         this. = other;
     }
     
     private KEKIdentifier(
         ASN1Sequence seq)
     {
          = (ASN1OctetString)seq.getObjectAt(0);
         
         switch (seq.size())
         {
         case 1:
             break;
         case 2:
             if (seq.getObjectAt(1) instanceof ASN1GeneralizedTime)
             {
                  = (ASN1GeneralizedTime)seq.getObjectAt(1); 
             }
             else
             {
                  = OtherKeyAttribute.getInstance(seq.getObjectAt(1));
             }
             break;
         case 3:
               = (ASN1GeneralizedTime)seq.getObjectAt(1);
              = OtherKeyAttribute.getInstance(seq.getObjectAt(2));
             break;
         default:
                 throw new IllegalArgumentException("Invalid KEKIdentifier");
         }
     }

    
Return a KEKIdentifier object from a tagged object.

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 KEKIdentifier getInstance(
         ASN1TaggedObject obj,
         boolean explicit)
     {
         return getInstance(ASN1Sequence.getInstance(objexplicit));
     }
    
    
Return a KEKIdentifier object from the given object.

Accepted inputs:

  • null → null
  • KEKIdentifier object
  • ASN1Sequence input formats with KEKIdentifier structure inside

Parameters:
obj the object we want converted.
Throws:
java.lang.IllegalArgumentException if the object cannot be converted.
 
     public static KEKIdentifier getInstance(
        Object obj)
    {
        if (obj == null || obj instanceof KEKIdentifier)
        {
            return (KEKIdentifier)obj;
        }
        
        if (obj instanceof ASN1Sequence)
        {
            return new KEKIdentifier((ASN1Sequence)obj);
        }
        
        throw new IllegalArgumentException("Invalid KEKIdentifier: " + obj.getClass().getName());
    }
    {
        return ;
    }
    public ASN1GeneralizedTime getDate()
    {
        return ;
    }
    public OtherKeyAttribute getOther()
    {
        return ;
    }

    
Produce an object suitable for an ASN1OutputStream.
    {
        ASN1EncodableVector  v = new ASN1EncodableVector();
        v.add();
        
        if ( != null)
        {
            v.add();
        }
        if ( != null)
        {
            v.add();
        }
        
        return new DERSequence(v);
    }
New to GrepCode? Check out our FAQ X