AuthenticatedStream 类

定义

提供通过流传递凭据的方法,以及为客户端/服务器应用程序请求或执行身份验证的方法。

public ref class AuthenticatedStream abstract : System::IO::Stream
public abstract class AuthenticatedStream : System.IO.Stream
type AuthenticatedStream = class
    inherit Stream
Public MustInherit Class AuthenticatedStream
Inherits Stream
继承
AuthenticatedStream
继承
AuthenticatedStream
派生

示例

以下示例演示如何显示经过身份验证的流的属性。

// The following class displays the properties of an authenticatedStream.
public ref class AuthenticatedStreamReporter
{
public:
   static void DisplayProperties( AuthenticatedStream^ stream )
   {
      Console::WriteLine( L"IsAuthenticated: {0}", stream->IsAuthenticated );
      Console::WriteLine( L"IsMutuallyAuthenticated: {0}", stream->IsMutuallyAuthenticated );
      Console::WriteLine( L"IsEncrypted: {0}", stream->IsEncrypted );
      Console::WriteLine( L"IsSigned: {0}", stream->IsSigned );
      Console::WriteLine( L"IsServer: {0}", stream->IsServer );
   }

};
// The following class displays the properties of an authenticatedStream.
public class AuthenticatedStreamReporter
{
    public static void DisplayProperties(AuthenticatedStream stream)
    {
        Console.WriteLine("IsAuthenticated: {0}", stream.IsAuthenticated);
        Console.WriteLine("IsMutuallyAuthenticated: {0}", stream.IsMutuallyAuthenticated);
        Console.WriteLine("IsEncrypted: {0}", stream.IsEncrypted);
        Console.WriteLine("IsSigned: {0}", stream.IsSigned);
        Console.WriteLine("IsServer: {0}", stream.IsServer);
    }
}
' The following class displays the properties of an AuthenticatedStream.
Public Class AuthenticatedStreamReporter
    Public Shared Sub DisplayProperties(stream As AuthenticatedStream)
        Console.WriteLine("IsAuthenticated: {0}", stream.IsAuthenticated)
        Console.WriteLine("IsMutuallyAuthenticated: {0}", stream.IsMutuallyAuthenticated)
        Console.WriteLine("IsEncrypted: {0}", stream.IsEncrypted)
        Console.WriteLine("IsSigned: {0}", stream.IsSigned)
        Console.WriteLine("IsServer: {0}", stream.IsServer)
    End Sub
End Class

注解

此抽象类提供经过身份验证的流常用的方法和属性。

经过身份验证的流可以提供身份验证、数据签名和加密服务,以帮助维护使用 InnerStream该流传输的数据的完整性和机密性。

由派生自 AuthenticatedStream 客户端和服务器支持的安全协议的类实现的安全协议将确定应用程序可用的安全功能。 这些 NegotiateStreamSslStream 类分别继承自 AuthenticatedStream 并实现协商和安全套接字层安全协议。

实施者说明

必须在派生类中重写以下成员: IsAuthenticatedIsEncryptedIsMutuallyAuthenticatedIsServerIsSigned

构造函数

AuthenticatedStream(Stream, Boolean)

初始化 AuthenticatedStream 类的新实例。

属性

CanRead

当在派生类中重写时,获取指示当前流是否支持读取的值。

(继承自 Stream)
CanSeek

当在派生类中重写时,获取指示当前流是否支持查找功能的值。

(继承自 Stream)
CanTimeout

获取一个值,该值确定当前流是否可以超时。

(继承自 Stream)
CanWrite

当在派生类中重写时,获取指示当前流是否支持写入功能的值。

(继承自 Stream)
InnerStream

获取此 AuthenticatedStream 用来发送和接收数据的流。

IsAuthenticated

获取一个 Boolean 值,该值指示身份验证是否成功。

IsEncrypted

获取一个 Boolean 值,该值指示使用此 AuthenticatedStream 发送的数据是否加密。

IsMutuallyAuthenticated

获取一个 Boolean 值,该值指示服务器和客户端是否均已进行身份验证。

IsServer

获取一个 Boolean 值,该值指示连接的本地端是否已作为服务器经过了身份验证。

IsSigned

获取一个 Boolean 值,该值指示使用此流发送的数据是否进行签名。

LeaveInnerStreamOpen

获取此 AuthenticatedStream 用来发送和接收数据的流是否保持打开。

Length

当在派生类中重写时,获取流长度(以字节为单位)。

(继承自 Stream)
Position

当在派生类中重写时,获取或设置当前流中的位置。

(继承自 Stream)
ReadTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前将尝试读取的时间。

(继承自 Stream)
WriteTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前将尝试写入多长时间。

(继承自 Stream)

方法

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

开始异步读操作。 (请考虑改用 ReadAsync(Byte[], Int32, Int32)。)

(继承自 Stream)
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

开始异步写操作。 (请考虑改用 WriteAsync(Byte[], Int32, Int32)。)

(继承自 Stream)
Close()

关闭当前流并释放与之关联的所有资源(如套接字和文件句柄)。 不直接调用此方法,而应确保流得以正确释放。

(继承自 Stream)
CopyTo(Stream)

从当前流中读取字节并将其写入到另一流中。

(继承自 Stream)
CopyTo(Stream, Int32)

使用指定的缓冲区大小,从当前流中读取字节并将其写入到另一流中。

(继承自 Stream)
CopyToAsync(Stream)

从当前流中异步读取字节并将其写入到另一个流中。

(继承自 Stream)
CopyToAsync(Stream, CancellationToken)

通过指定的取消令牌,从当前流中异步读取字节并将其写入到另一个流中。

(继承自 Stream)
CopyToAsync(Stream, Int32)

使用指定的缓冲区大小,从当前流中异步读取字节并将其写入到另一流中。

(继承自 Stream)
CopyToAsync(Stream, Int32, CancellationToken)

使用指定的缓冲区大小和取消令牌,从当前流中异步读取字节并将其写入到另一个流中。

(继承自 Stream)
CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。

(继承自 MarshalByRefObject)
CreateWaitHandle()
已过时。
已过时。

分配 WaitHandle 对象。

(继承自 Stream)
Dispose()

释放由 Stream 使用的所有资源。

(继承自 Stream)
Dispose(Boolean)

释放由 AuthenticatedStream 占用的非托管资源,还可以另外再释放托管资源。

DisposeAsync()

异步释放 AuthenticatedStream 使用的非托管资源和受管理资源。

DisposeAsync()

异步释放 Stream 使用的非托管资源。

(继承自 Stream)
EndRead(IAsyncResult)

等待挂起的异步读取完成。 (请考虑改用 ReadAsync(Byte[], Int32, Int32)。)

(继承自 Stream)
EndWrite(IAsyncResult)

结束异步写操作。 (请考虑改用 WriteAsync(Byte[], Int32, Int32)。)

(继承自 Stream)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
Flush()

当在派生类中重写时,将清除该流的所有缓冲区,并使得所有缓冲数据被写入到基础设备。

(继承自 Stream)
FlushAsync()

异步清除此流的所有缓冲区并导致所有缓冲数据都写入基础设备中。

(继承自 Stream)
FlushAsync(CancellationToken)

异步清理此流的所有缓冲区,导致所有缓冲数据都写入基础设备,并且监控取消请求。

(继承自 Stream)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetLifetimeService()
已过时。

检索控制此实例的生存期策略的当前生存期服务对象。

(继承自 MarshalByRefObject)
GetType()

获取当前实例的 Type

(继承自 Object)
InitializeLifetimeService()
已过时。

获取生存期服务对象来控制此实例的生存期策略。

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。

(继承自 MarshalByRefObject)
ObjectInvariant()
已过时。

提供对 Contract 的支持。

(继承自 Stream)
Read(Byte[], Int32, Int32)

当在派生类中重写时,从当前流读取字节序列,并将此流中的位置提升读取的字节数。

(继承自 Stream)
Read(Span<Byte>)

当在派生类中重写时,从当前流读取字节序列,并将此流中的位置提升读取的字节数。

(继承自 Stream)
ReadAsync(Byte[], Int32, Int32)

从当前流异步读取字节序列,并将流中的位置提升读取的字节数。

(继承自 Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken)

从当前流异步读取字节的序列,将流中的位置提升读取的字节数,并监视取消请求。

(继承自 Stream)
ReadAsync(Memory<Byte>, CancellationToken)

从当前流异步读取字节的序列,将流中的位置提升读取的字节数,并监视取消请求。

(继承自 Stream)
ReadByte()

从流中读取一个字节,并将流内的位置向前提升一个字节,或者如果已到达流结尾,则返回 -1。

(继承自 Stream)
Seek(Int64, SeekOrigin)

当在派生类中重写时,设置当前流中的位置。

(继承自 Stream)
SetLength(Int64)

当在派生类中重写时,设置当前流的长度。

(继承自 Stream)
ToString()

返回表示当前对象的字符串。

(继承自 Object)
Write(Byte[], Int32, Int32)

当在派生类中重写时,向当前流中写入字节序列,并将此流中的当前位置提升写入的字节数。

(继承自 Stream)
Write(ReadOnlySpan<Byte>)

当在派生类中重写时,向当前流中写入字节序列,并将此流中的当前位置提升写入的字节数。

(继承自 Stream)
WriteAsync(Byte[], Int32, Int32)

将字节序列异步写入当前流,并将流的当前位置提升写入的字节数。

(继承自 Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken)

将字节的序列异步写入当前流,将该流中的当前位置向前移动写入的字节数,并监视取消请求。

(继承自 Stream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

将字节的序列异步写入当前流,将该流中的当前位置向前移动写入的字节数,并监视取消请求。

(继承自 Stream)
WriteByte(Byte)

将一个字节写入流内的当前位置,并将流内的位置向前提升一个字节。

(继承自 Stream)

扩展方法

ConfigureAwait(IAsyncDisposable, Boolean)

配置如何执行从异步可处置项返回的任务的等待。

适用于