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. NegotiateStreamSslStream 類別會繼承自 AuthenticatedStream,並分別執行 Negotiate 和安全通訊端層安全性通訊協定。The 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)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。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 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。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()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。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()

傳回代表目前物件的字串。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)

適用於