1package org.bouncycastle.asn1.ess; 2 3import org.bouncycastle.asn1.ASN1Encodable; 4import org.bouncycastle.asn1.ASN1OctetString; 5import org.bouncycastle.asn1.DERObject; 6import org.bouncycastle.asn1.DEROctetString; 7 8public class ContentIdentifier 9 extends ASN1Encodable 10{ 11 ASN1OctetString value; 12 13 public static ContentIdentifier getInstance(Object o) 14 { 15 if (o == null || o instanceof ContentIdentifier) 16 { 17 return (ContentIdentifier) o; 18 } 19 else if (o instanceof ASN1OctetString) 20 { 21 return new ContentIdentifier((ASN1OctetString) o); 22 } 23 24 throw new IllegalArgumentException( 25 "unknown object in 'ContentIdentifier' factory : " 26 + o.getClass().getName() + "."); 27 } 28 29 /** 30 * Create from OCTET STRING whose octets represent the identifier. 31 */ 32 public ContentIdentifier( 33 ASN1OctetString value) 34 { 35 this.value = value; 36 } 37 38 /** 39 * Create from byte array representing the identifier. 40 */ 41 public ContentIdentifier( 42 byte[] value) 43 { 44 this(new DEROctetString(value)); 45 } 46 47 public ASN1OctetString getValue() 48 { 49 return value; 50 } 51 52 /** 53 * The definition of ContentIdentifier is 54 * <pre> 55 * ContentIdentifier ::= OCTET STRING 56 * </pre> 57 * id-aa-contentIdentifier OBJECT IDENTIFIER ::= { iso(1) 58 * member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs9(9) 59 * smime(16) id-aa(2) 7 } 60 */ 61 public DERObject toASN1Object() 62 { 63 return value; 64 } 65} 66