AuthenticatedStream 类

定义

提供通过流传递凭据的方法,以及为客户端/服务器应用程序请求或执行身份验证的方法。Provides methods for passing credentials across a stream and requesting or performing authentication for client-server applications.

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
派生

示例

下面的示例演示如何显示已验证流的属性。The following example demonstrates displaying the properties of an authenticated stream.

// 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

注解

此抽象类提供经过身份验证的流所共有的方法和属性。This abstract class provides methods and properties that are common to authenticated streams.

经过身份验证的流可以提供身份验证、数据签名和加密服务, 从而有助于维护使用InnerStream传输的数据的完整性和保密性。Authenticated streams can provide authentication, data signing, and encryption services that can help maintain the integrity and confidentiality of data transmitted using the InnerStream.

与客户端和服务器上支持的安全协议AuthenticatedStream一起派生的类所实现的安全协议将确定可用于应用程序的安全功能。The security protocol implemented by a class that derives from AuthenticatedStream together with the security protocols supported on the client and server will determine the security features that are available to an application. 和类分别继承AuthenticatedStream并实现 Negotiate 和安全套接字层安全协议。 SslStream NegotiateStreamThe NegotiateStream and SslStream classes inherit from AuthenticatedStream and implement the Negotiate and Secure Sockets Layer security protocols, respectively.

实施者说明

必须在派生类中重写以下成员: IsAuthenticatedIsEncryptedIsMutuallyAuthenticatedIsServerIsSignedThe following members must be overridden in a derived class: IsAuthenticated, IsEncrypted, IsMutuallyAuthenticated, IsServer, and IsSigned.

构造函数

AuthenticatedStream(Stream, Boolean)

初始化 AuthenticatedStream 类的新实例。Initializes a new instance of the AuthenticatedStream class.

属性

CanRead

当在派生类中重写时,获取指示当前流是否支持读取的值。When overridden in a derived class, gets a value indicating whether the current stream supports reading.

(继承自 Stream)
CanSeek

当在派生类中重写时,获取指示当前流是否支持查找功能的值。When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

(继承自 Stream)
CanTimeout

获取一个值,该值确定当前流是否可以超时。Gets a value that determines whether the current stream can time out.

(继承自 Stream)
CanWrite

当在派生类中重写时,获取指示当前流是否支持写入功能的值。When overridden in a derived class, gets a value indicating whether the current stream supports writing.

(继承自 Stream)
InnerStream

获取此 AuthenticatedStream 用来发送和接收数据的流。Gets the stream used by this AuthenticatedStream for sending and receiving data.

IsAuthenticated

获取一个 Boolean 值,该值指示身份验证是否成功。Gets a Boolean value that indicates whether authentication was successful.

IsEncrypted

获取一个 Boolean 值,该值指示使用此 AuthenticatedStream 发送的数据是否加密。Gets a Boolean value that indicates whether data sent using this AuthenticatedStream is encrypted.

IsMutuallyAuthenticated

获取一个 Boolean 值,该值指示服务器和客户端是否均已进行身份验证。Gets a Boolean value that indicates whether both server and client have been authenticated.

IsServer

获取一个 Boolean 值,该值指示连接的本地端是否已作为服务器经过了身份验证。Gets a Boolean value that indicates whether the local side of the connection was authenticated as the server.

IsSigned

获取一个 Boolean 值,该值指示使用此流发送的数据是否进行签名。Gets a Boolean value that indicates whether the data sent using this stream is signed.

LeaveInnerStreamOpen

获取此 AuthenticatedStream 用来发送和接收数据的流是否保持打开。Gets whether the stream used by this AuthenticatedStream for sending and receiving data has been left open.

Length

当在派生类中重写时,获取流长度(以字节为单位)。When overridden in a derived class, gets the length in bytes of the stream.

(继承自 Stream)
Position

当在派生类中重写时,获取或设置当前流中的位置。When overridden in a derived class, gets or sets the position within the current stream.

(继承自 Stream)
ReadTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前尝试读取多长时间。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.

(继承自 Stream)
WriteTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前尝试写入多长时间。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.

(继承自 Stream)

方法

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

开始异步读操作。Begins an asynchronous read operation. (请考虑改用 ReadAsync(Byte[], Int32, Int32)。)(Consider using ReadAsync(Byte[], Int32, Int32) instead.)

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

开始异步写操作。Begins an asynchronous write operation. (请考虑改用 WriteAsync(Byte[], Int32, Int32)。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

(继承自 Stream)
Close()

关闭当前流并释放与之关联的所有资源(如套接字和文件句柄)。Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. 不直接调用此方法,而应确保流得以正确释放。Instead of calling this method, ensure that the stream is properly disposed.

(继承自 Stream)
CopyTo(Stream)

从当前流中读取字节并将其写入到另一流中。Reads the bytes from the current stream and writes them to another stream.

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

使用指定的缓冲区大小,从当前流中读取字节并将其写入到另一流中。Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

(继承自 Stream)
CopyToAsync(Stream)

从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream.

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

通过指定的取消令牌,从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified cancellation token.

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

使用指定的缓冲区大小,从当前流中异步读取字节并将其写入到另一流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

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

使用指定的缓冲区大小和取消令牌,从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.

(继承自 Stream)
CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
CreateWaitHandle()

分配 WaitHandle 对象。Allocates a WaitHandle object.

(继承自 Stream)
Dispose()

释放由 Stream 使用的所有资源。Releases all resources used by the Stream.

(继承自 Stream)
Dispose(Boolean)

释放由 AuthenticatedStream 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the AuthenticatedStream and optionally releases the managed resources.

DisposeAsync()

异步释放 AuthenticatedStream 使用的非托管资源和受管理资源。Asynchronously releases the unmanaged and managed resources used by the AuthenticatedStream.

EndRead(IAsyncResult)

等待挂起的异步读取完成。Waits for the pending asynchronous read to complete. (请考虑改用 ReadAsync(Byte[], Int32, Int32)。)(Consider using ReadAsync(Byte[], Int32, Int32) instead.)

(继承自 Stream)
EndWrite(IAsyncResult)

结束异步写操作。Ends an asynchronous write operation. (请考虑改用 WriteAsync(Byte[], Int32, Int32)。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

(继承自 Stream)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
Flush()

当在派生类中重写时,将清除该流的所有缓冲区,并使得所有缓冲数据被写入到基础设备。When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

(继承自 Stream)
FlushAsync()

异步清除此流的所有缓冲区并导致所有缓冲数据都写入基础设备中。Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.

(继承自 Stream)
FlushAsync(CancellationToken)

异步清理这个流的所有缓冲区,并使所有缓冲数据写入基础设备,并且监控取消请求。Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

(继承自 Stream)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
ObjectInvariant()

提供对 Contract 的支持。Provides support for a Contract.

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

当在派生类中重写时,从当前流读取字节序列,并将此流中的位置提升读取的字节数。When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

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

当在派生类中重写时,从当前流读取字节序列,并将此流中的位置提升读取的字节数。When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

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

从当前流异步读取字节序列,并将流中的位置提升读取的字节数。Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

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

从当前流异步读取字节的序列,将流中的位置提升读取的字节数,并监视取消请求。Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

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

从当前流异步读取字节的序列,将流中的位置提升读取的字节数,并监视取消请求。Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

(继承自 Stream)
ReadByte()

从流中读取一个字节,并将流内的位置向前提升一个字节,或者如果已到达流结尾,则返回 -1。Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

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

当在派生类中重写时,设置当前流中的位置。When overridden in a derived class, sets the position within the current stream.

(继承自 Stream)
SetLength(Int64)

当在派生类中重写时,设置当前流的长度。When overridden in a derived class, sets the length of the current stream.

(继承自 Stream)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

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

当在派生类中重写时,向当前流中写入字节序列,并将此流中的当前位置提升写入的字节数。When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

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

当在派生类中重写时,向当前流中写入字节序列,并将此流中的当前位置提升写入的字节数。When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

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

将字节序列异步写入当前流,并将流的当前位置提升写入的字节数。Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

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

将字节的序列异步写入当前流,将该流中的当前位置向前移动写入的字节数,并监视取消请求。Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

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

将字节的序列异步写入当前流,将该流中的当前位置向前移动写入的字节数,并监视取消请求。Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

(继承自 Stream)
WriteByte(Byte)

将一个字节写入流内的当前位置,并将流内的位置向前提升一个字节。Writes a byte to the current position in the stream and advances the position within the stream by one byte.

(继承自 Stream)

显式界面实现

IDisposable.Dispose()

释放由 Stream 使用的所有资源。Releases all resources used by the Stream.

(继承自 Stream)

适用于