mirrored from https://www.bouncycastle.org/repositories/bc-csharp
-
Notifications
You must be signed in to change notification settings - Fork 602
Expand file tree
/
Copy pathCMSTypedStream.cs
More file actions
77 lines (62 loc) · 2.02 KB
/
Copy pathCMSTypedStream.cs
File metadata and controls
77 lines (62 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.IO;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Utilities.IO;
namespace Org.BouncyCastle.Cms
{
public class CmsTypedStream
: IDisposable
{
private readonly DerObjectIdentifier m_contentType;
private readonly Stream m_contentStream;
public CmsTypedStream(Stream inStream)
: this(PkcsObjectIdentifiers.Data, inStream)
{
}
[Obsolete("Use 'DerObjectIdentifier' variant instead")]
public CmsTypedStream(string oid, Stream inStream)
: this(oid, inStream, Streams.DefaultBufferSize)
{
}
[Obsolete("Use 'DerObjectIdentifier' variant instead")]
public CmsTypedStream(string oid, Stream inStream, int bufSize)
: this(new DerObjectIdentifier(oid), inStream, bufSize)
{
}
public CmsTypedStream(DerObjectIdentifier contentType, Stream contentStream)
: this(contentType, contentStream, Streams.DefaultBufferSize)
{
}
public CmsTypedStream(DerObjectIdentifier contentType, Stream contentStream, int bufSize)
{
m_contentType = contentType;
m_contentStream = new BufferedFilterStream(contentStream, bufSize);
}
[Obsolete("Use 'ContentTypeOid' instead")]
public string ContentType => m_contentType.GetID();
public DerObjectIdentifier ContentTypeOid => m_contentType;
public Stream ContentStream => m_contentStream;
public void Drain()
{
using (m_contentStream)
{
Streams.Drain(m_contentStream);
}
}
#region IDisposable
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
m_contentStream.Dispose();
}
}
#endregion
}
}