diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-18 11:33:33 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-10-18 11:33:33 +0700 |
commit | d032037615fb28980f2d92dbe500fc2fcfdd37ee (patch) | |
tree | 4c420c923040de33bcd86b389ced071793335875 /crypto/src | |
parent | Added missing key generation code (diff) | |
download | BouncyCastle.NET-ed25519-d032037615fb28980f2d92dbe500fc2fcfdd37ee.tar.xz |
http://www.bouncycastle.org/jira/browse/BMA-90
- Make CmsReadable public - Make a few methods virtual
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/cms/CMSProcessableByteArray.cs | 10 | ||||
-rw-r--r-- | crypto/src/cms/CMSProcessableFile.cs | 19 | ||||
-rw-r--r-- | crypto/src/cms/CMSProcessableInputStream.cs | 22 | ||||
-rw-r--r-- | crypto/src/cms/CMSReadable.cs | 2 |
4 files changed, 24 insertions, 29 deletions
diff --git a/crypto/src/cms/CMSProcessableByteArray.cs b/crypto/src/cms/CMSProcessableByteArray.cs index 4bee4f8bd..a6ab9b6a2 100644 --- a/crypto/src/cms/CMSProcessableByteArray.cs +++ b/crypto/src/cms/CMSProcessableByteArray.cs @@ -11,23 +11,23 @@ namespace Org.BouncyCastle.Cms { private readonly byte[] bytes; - public CmsProcessableByteArray( - byte[] bytes) + public CmsProcessableByteArray(byte[] bytes) { this.bytes = bytes; } - public Stream GetInputStream() + public virtual Stream GetInputStream() { return new MemoryStream(bytes, false); } - public virtual void Write(Stream zOut) + public virtual void Write(Stream zOut) { zOut.Write(bytes, 0, bytes.Length); } - /// <returns>A clone of the byte array</returns> + /// <returns>A clone of the byte array</returns> + [Obsolete] public virtual object GetContent() { return bytes.Clone(); diff --git a/crypto/src/cms/CMSProcessableFile.cs b/crypto/src/cms/CMSProcessableFile.cs index cbc74f44b..01020df11 100644 --- a/crypto/src/cms/CMSProcessableFile.cs +++ b/crypto/src/cms/CMSProcessableFile.cs @@ -13,38 +13,33 @@ namespace Org.BouncyCastle.Cms { private const int DefaultBufSize = 32 * 1024; - private readonly FileInfo _file; + private readonly FileInfo _file; private readonly int _bufSize; - public CmsProcessableFile( - FileInfo file) + public CmsProcessableFile(FileInfo file) : this(file, DefaultBufSize) { } - public CmsProcessableFile( - FileInfo file, - int bufSize) + public CmsProcessableFile(FileInfo file, int bufSize) { _file = file; _bufSize = bufSize; } - public virtual Stream GetInputStream() + public virtual Stream GetInputStream() { - return new FileStream( - _file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, _bufSize); + return new FileStream(_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, _bufSize); } - public virtual void Write( - Stream zOut) + public virtual void Write(Stream zOut) { Stream inStr = GetInputStream(); Streams.PipeAll(inStr, zOut); inStr.Close(); } - /// <returns>The file handle</returns> + /// <returns>The file handle</returns> [Obsolete] public virtual object GetContent() { diff --git a/crypto/src/cms/CMSProcessableInputStream.cs b/crypto/src/cms/CMSProcessableInputStream.cs index 7fdd1dfef..6dff7c212 100644 --- a/crypto/src/cms/CMSProcessableInputStream.cs +++ b/crypto/src/cms/CMSProcessableInputStream.cs @@ -8,23 +8,23 @@ namespace Org.BouncyCastle.Cms public class CmsProcessableInputStream : CmsProcessable, CmsReadable { - private Stream input; - private bool used = false; + private readonly Stream input; - public CmsProcessableInputStream( - Stream input) + private bool used = false; + + public CmsProcessableInputStream(Stream input) { this.input = input; } - public Stream GetInputStream() + public virtual Stream GetInputStream() { CheckSingleUsage(); - return input; + return input; } - public void Write(Stream output) + public virtual void Write(Stream output) { CheckSingleUsage(); @@ -32,20 +32,20 @@ namespace Org.BouncyCastle.Cms input.Close(); } - [Obsolete] - public object GetContent() + [Obsolete] + public virtual object GetContent() { return GetInputStream(); } - private void CheckSingleUsage() + protected virtual void CheckSingleUsage() { lock (this) { if (used) throw new InvalidOperationException("CmsProcessableInputStream can only be used once"); - used = true; + used = true; } } } diff --git a/crypto/src/cms/CMSReadable.cs b/crypto/src/cms/CMSReadable.cs index 9507b920c..ad83ba068 100644 --- a/crypto/src/cms/CMSReadable.cs +++ b/crypto/src/cms/CMSReadable.cs @@ -3,7 +3,7 @@ using System.IO; namespace Org.BouncyCastle.Cms { - internal interface CmsReadable + public interface CmsReadable { Stream GetInputStream(); } |