1
package org.bouncycastle.cms;
3
import java.io.BufferedInputStream;
5
import java.io.FileInputStream;
6
import java.io.IOException;
7
import java.io.InputStream;
8
import java.io.OutputStream;
10
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
11
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;
14
* a holding class for a file of data to be processed.
16
public class CMSProcessableFile
17
implements CMSTypedData, CMSReadable
19
private static final int DEFAULT_BUF_SIZE = 32 * 1024;
21
private final ASN1ObjectIdentifier type;
22
private final File file;
23
private final byte[] buf;
25
public CMSProcessableFile(
28
this(file, DEFAULT_BUF_SIZE);
31
public CMSProcessableFile(
35
this(new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId()), file, bufSize);
38
public CMSProcessableFile(
39
ASN1ObjectIdentifier type,
45
buf = new byte[bufSize];
48
public InputStream getInputStream()
49
throws IOException, CMSException
51
return new BufferedInputStream(new FileInputStream(file), DEFAULT_BUF_SIZE);
54
public void write(OutputStream zOut)
55
throws IOException, CMSException
57
FileInputStream fIn = new FileInputStream(file);
60
while ((len = fIn.read(buf, 0, buf.length)) > 0)
62
zOut.write(buf, 0, len);
69
* Return the file handle.
71
public Object getContent()
76
public ASN1ObjectIdentifier getContentType()