add all
This commit is contained in:
51
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/cms/CMSProcessableInputStream.cs
vendored
Normal file
51
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/cms/CMSProcessableInputStream.cs
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
Reference in New Issue
Block a user