1
package org.bouncycastle.cms;
3
import java.io.BufferedInputStream;
4
import java.io.FilterInputStream;
5
import java.io.IOException;
6
import java.io.InputStream;
8
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
9
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
10
import org.bouncycastle.util.io.Streams;
12
public class CMSTypedStream
14
private static final int BUF_SIZ = 32 * 1024;
16
private final ASN1ObjectIdentifier _oid;
17
private final InputStream _in;
19
public CMSTypedStream(
22
this(PKCSObjectIdentifiers.data.getId(), in, BUF_SIZ);
25
public CMSTypedStream(
29
this(new ASN1ObjectIdentifier(oid), in, BUF_SIZ);
32
public CMSTypedStream(
37
this(new ASN1ObjectIdentifier(oid), in, bufSize);
40
public CMSTypedStream(
41
ASN1ObjectIdentifier oid,
44
this(oid, in, BUF_SIZ);
47
public CMSTypedStream(
48
ASN1ObjectIdentifier oid,
53
_in = new FullReaderStream(new BufferedInputStream(in, bufSize));
56
public ASN1ObjectIdentifier getContentType()
61
public InputStream getContentStream()
73
private static class FullReaderStream extends FilterInputStream
75
FullReaderStream(InputStream in)
80
public int read(byte[] buf, int off, int len) throws IOException
82
int totalRead = Streams.readFully(super.in, buf, off, len);
83
return totalRead > 0 ? totalRead : -1;