1 package org.bouncycastle.asn1.pkcs; 2 3 import org.bouncycastle.asn1.ASN1EncodableVector; 4 import org.bouncycastle.asn1.ASN1Object; 5 import org.bouncycastle.asn1.ASN1Primitive; 6 import org.bouncycastle.asn1.ASN1Sequence; 7 import org.bouncycastle.asn1.BERSequence; 8 import org.bouncycastle.asn1.DLSequence; 9 10 public class AuthenticatedSafe 11 extends ASN1Object 12 { 13 private ContentInfo[] info; 14 private boolean isBer = true; 15 AuthenticatedSafe( ASN1Sequence seq)16 private AuthenticatedSafe( 17 ASN1Sequence seq) 18 { 19 info = new ContentInfo[seq.size()]; 20 21 for (int i = 0; i != info.length; i++) 22 { 23 info[i] = ContentInfo.getInstance(seq.getObjectAt(i)); 24 } 25 26 isBer = seq instanceof BERSequence; 27 } 28 getInstance( Object o)29 public static AuthenticatedSafe getInstance( 30 Object o) 31 { 32 if (o instanceof AuthenticatedSafe) 33 { 34 return (AuthenticatedSafe)o; 35 } 36 37 if (o != null) 38 { 39 return new AuthenticatedSafe(ASN1Sequence.getInstance(o)); 40 } 41 42 return null; 43 } 44 AuthenticatedSafe( ContentInfo[] info)45 public AuthenticatedSafe( 46 ContentInfo[] info) 47 { 48 this.info = info; 49 } 50 getContentInfo()51 public ContentInfo[] getContentInfo() 52 { 53 return info; 54 } 55 toASN1Primitive()56 public ASN1Primitive toASN1Primitive() 57 { 58 ASN1EncodableVector v = new ASN1EncodableVector(); 59 60 for (int i = 0; i != info.length; i++) 61 { 62 v.add(info[i]); 63 } 64 65 if (isBer) 66 { 67 return new BERSequence(v); 68 } 69 else 70 { 71 return new DLSequence(v); 72 } 73 } 74 } 75