blob: 1a80ccfd63c20b426209267baae9392bd8ee8f51 (
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
|
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);
input.Dispose();
}
protected virtual void CheckSingleUsage()
{
lock (this)
{
if (used)
throw new InvalidOperationException("CmsProcessableInputStream can only be used once");
used = true;
}
}
}
}
|