blob: b2abd6f7157fc042366bd644f64fc79516e21d88 (
plain) (
blame)
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
|
using System;
using System.IO;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.IO;
namespace Org.BouncyCastle.Cms
{
public class CmsProcessableInputStream
: CmsProcessable, CmsReadable
{
private readonly Stream input;
private bool used = false;
public CmsProcessableInputStream(Stream input)
{
this.input = input;
}
public virtual Stream GetInputStream()
{
CheckSingleUsage();
return input;
}
public virtual void Write(Stream output)
{
CheckSingleUsage();
Streams.PipeAll(input, output);
Platform.Dispose(input);
}
[Obsolete]
public virtual object GetContent()
{
return GetInputStream();
}
protected virtual void CheckSingleUsage()
{
lock (this)
{
if (used)
throw new InvalidOperationException("CmsProcessableInputStream can only be used once");
used = true;
}
}
}
}
|