1package org.bouncycastle.cms; 2 3import java.io.ByteArrayInputStream; 4import java.io.IOException; 5import java.io.InputStream; 6import java.io.OutputStream; 7 8import org.bouncycastle.asn1.ASN1ObjectIdentifier; 9import org.bouncycastle.asn1.cms.CMSObjectIdentifiers; 10 11/** 12 * a holding class for a byte array of data to be processed. 13 */ 14public class CMSProcessableByteArray 15 implements CMSTypedData, CMSReadable 16{ 17 private final ASN1ObjectIdentifier type; 18 private final byte[] bytes; 19 20 public CMSProcessableByteArray( 21 byte[] bytes) 22 { 23 this(new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId()), bytes); 24 } 25 26 public CMSProcessableByteArray( 27 ASN1ObjectIdentifier type, 28 byte[] bytes) 29 { 30 this.type = type; 31 this.bytes = bytes; 32 } 33 34 public InputStream getInputStream() 35 { 36 return new ByteArrayInputStream(bytes); 37 } 38 39 public void write(OutputStream zOut) 40 throws IOException, CMSException 41 { 42 zOut.write(bytes); 43 } 44 45 public Object getContent() 46 { 47 return bytes.clone(); 48 } 49 50 public ASN1ObjectIdentifier getContentType() 51 { 52 return type; 53 } 54} 55