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