NegotiateStream クラス

定義

ネゴシエート セキュリティ プロトコルを使用して、クライアントとサーバー間の通信でクライアントと必要に応じてサーバーを認証するストリームを提供します。

public ref class NegotiateStream : System::Net::Security::AuthenticatedStream
public class NegotiateStream : System.Net.Security.AuthenticatedStream
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public class NegotiateStream : System.Net.Security.AuthenticatedStream
type NegotiateStream = class
    inherit AuthenticatedStream
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
type NegotiateStream = class
    inherit AuthenticatedStream
Public Class NegotiateStream
Inherits AuthenticatedStream
継承
継承
属性

次の例は、NegotiateStreamを使用するクライアントとサーバーの接続のクライアント側を示しています。 クライアントは認証を行い、メッセージをサーバーに非同期的に送信します。

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Net::Security;
using namespace System::Net::Sockets;
using namespace System::Text;

// 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 );
   }

};


public ref class ASynchronousAuthenticatingTcpClient
{
private:
   static TcpClient^ client = nullptr;

public:
   void Main()
   {
      
      // Establish the remote endpoint for the socket.
      // For this example, use the local machine.
      IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() );
      IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ];
      
      // Client and server use port 11000. 
      IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 );
      
      // Create a TCP/IP socket.
      client = gcnew TcpClient;
      
      // Connect the socket to the remote endpoint.
      client->Connect( remoteEP );
      Console::WriteLine( L"Client connected to {0}.", remoteEP );
      
      // Ensure the client does not close when there is 
      // still data to be sent to the server.
      client->LingerState = (gcnew LingerOption( true,0 ));
      
      // Request authentication.
      NetworkStream^ clientStream = client->GetStream();
      NegotiateStream^ authStream = gcnew NegotiateStream( clientStream,false );
      
      // Pass the NegotiateStream as the AsyncState object 
      // so that it is available to the callback delegate.
      IAsyncResult^ ar = authStream->BeginAuthenticateAsClient( gcnew AsyncCallback( EndAuthenticateCallback ), authStream );
      
      Console::WriteLine( L"Client waiting for authentication..." );
      
      // Wait until the result is available.
      ar->AsyncWaitHandle->WaitOne();
      
      // Display the properties of the authenticated stream.
      AuthenticatedStreamReporter::DisplayProperties( authStream );
      
      // Send a message to the server.
      // Encode the test data into a byte array.
      array<Byte>^message = Encoding::UTF8->GetBytes( L"Hello from the client." );
      ar = authStream->BeginWrite( message, 0, message->Length, gcnew AsyncCallback( EndWriteCallback ), authStream );
      
      ar->AsyncWaitHandle->WaitOne();
      Console::WriteLine( L"Sent {0} bytes.", message->Length );
      
      // Close the client connection.
      authStream->Close();
      Console::WriteLine( L"Client closed." );
   }


   // The following method is called when the authentication completes.
   static void EndAuthenticateCallback( IAsyncResult^ ar )
   {
      Console::WriteLine( L"Client ending authentication..." );
      NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(ar->AsyncState);
      
      // End the asynchronous operation.
      authStream->EndAuthenticateAsClient( ar );
      
      //         Console.WriteLine("AllowedImpersonation: {0}", authStream.AllowedImpersonation);
   }


   // The following method is called when the write operation completes.
   static void EndWriteCallback( IAsyncResult^ ar )
   {
      Console::WriteLine( L"Client ending write operation..." );
      NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(ar->AsyncState);
      
      // End the asynchronous operation.
      authStream->EndWrite( ar );
   }

};

void main()
{
   ASynchronousAuthenticatingTcpClient^ aatc = gcnew ASynchronousAuthenticatingTcpClient;
   aatc->Main();
}
using System;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Text;

namespace Examples.NegotiateStreamExample
{
    public class ASynchronousAuthenticatingTcpClient
    {
        static TcpClient client = null;

        public static void Main(String[] args)
        {
            // Establish the remote endpoint for the socket.
            // For this example, use the local machine.
            IPHostEntry ipHostInfo = Dns.GetHostEntry("localhost");
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            // Client and server use port 11000.
            IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);
            // Create a TCP/IP socket.
            client = new TcpClient();
            // Connect the socket to the remote endpoint.
            client.Connect(remoteEP);
            Console.WriteLine("Client connected to {0}.", remoteEP.ToString());
            // Ensure the client does not close when there is
            // still data to be sent to the server.
            client.LingerState = new LingerOption(true, 0);
            // Request authentication.
            NetworkStream clientStream = client.GetStream();
            NegotiateStream authStream = new NegotiateStream(clientStream, false);
            // Pass the NegotiateStream as the AsyncState object
            // so that it is available to the callback delegate.
            Task authenticateTask = authStream
                .AuthenticateAsClientAsync()
                .ContinueWith(task =>
                {
                    Console.WriteLine("Client ending authentication...");
                    Console.WriteLine("ImpersonationLevel: {0}", authStream.ImpersonationLevel);
                });

            Console.WriteLine("Client waiting for authentication...");
            // Wait until the result is available.
            authenticateTask.Wait();
            // Display the properties of the authenticated stream.
            AuthenticatedStreamReporter.DisplayProperties(authStream);
            // Send a message to the server.
            // Encode the test data into a byte array.
            byte[] message = Encoding.UTF8.GetBytes("Hello from the client.");
            Task writeTask = authStream
                .WriteAsync(message, 0, message.Length)
                .ContinueWith(task =>
                {
                    Console.WriteLine("Client ending write operation...");
                });

            writeTask.Wait();
            Console.WriteLine("Sent {0} bytes.", message.Length);
            // Close the client connection.
            authStream.Close();
            Console.WriteLine("Client closed.");
        }
    }

    // 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);
        }
    }
}
Imports System.Text
Imports System.Net.Sockets
Imports System.Net.Security
Imports System.Net

Namespace Examples.NegotiateStreamExample

    Public Class ASynchronousAuthenticatingTcpClient

        Shared client As TcpClient = Nothing

        Public Shared Sub Main(args As String())
            ' Establish the remote endpoint for the socket.
            ' For this example, use the local machine.
            Dim ipHostInfo = Dns.GetHostEntry("localhost")
            Dim ipAddress = ipHostInfo.AddressList(0)

            ' Client and server use port 11000. 
            Dim remoteEP As New IPEndPoint(ipAddress, 11000)

            ' Create a TCP/IP socket.
            client = New TcpClient()

            ' Connect the socket to the remote endpoint.
            client.Connect(remoteEP)
            Console.WriteLine("Client connected to {0}.", remoteEP.ToString())

            ' Ensure the client does not close when there is 
            ' still data to be sent to the server.
            client.LingerState = (New LingerOption(True, 0))

            ' Request authentication.
            Dim clientStream = client.GetStream()
            Dim authStream As New NegotiateStream(clientStream, False)

            ' Pass the NegotiateStream as the AsyncState object 
            ' so that it is available to the callback delegate.
            Dim ar = authStream.BeginAuthenticateAsClient(
                New AsyncCallback(AddressOf EndAuthenticateCallback), authStream)

            Console.WriteLine("Client waiting for authentication...")

            ' Wait until the result is available.
            ar.AsyncWaitHandle.WaitOne()

            ' Display the properties of the authenticated stream.
            AuthenticatedStreamReporter.DisplayProperties(authStream)

            ' Send a message to the server.
            ' Encode the test data into a byte array.
            Dim message = Encoding.UTF8.GetBytes("Hello from the client.")
            ar = authStream.BeginWrite(message, 0, message.Length, 
                New AsyncCallback(AddressOf EndWriteCallback), authStream)
            ar.AsyncWaitHandle.WaitOne()
            Console.WriteLine("Sent {0} bytes.", message.Length)

            ' Close the client connection.
            authStream.Close()
            Console.WriteLine("Client closed.")

        End Sub

        ' The following method is called when the authentication completes.
        Public Shared Sub EndAuthenticateCallback(ar As IAsyncResult)

            Console.WriteLine("Client ending authentication...")
            Dim authStream = CType(ar.AsyncState, NegotiateStream)
            Console.WriteLine("ImpersonationLevel: {0}", authStream.ImpersonationLevel)

            ' End the asynchronous operation.
            authStream.EndAuthenticateAsClient(ar)

        End Sub

        ' The following method is called when the write operation completes.
        Public Shared Sub EndWriteCallback(ar As IAsyncResult)

            Console.WriteLine("Client ending write operation...")
            Dim authStream = CType(ar.AsyncState, NegotiateStream)

            ' End the asynchronous operation.
            authStream.EndWrite(ar)

        End Sub
    End Class

    ' 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
End Namespace

次のコード例は、NegotiateStream を使用してクライアントを認証し、クライアントから送信されたメッセージを読み取る、クライアントとサーバーの接続のサーバー側を示しています。

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Net::Security;
using namespace System::Net::Sockets;
using namespace System::Security::Authentication;
using namespace System::Security::Principal;
using namespace System::Text;
using namespace System::IO;
using namespace System::Threading;

// ClientState is the AsyncState object.
private ref class ClientState
{
private:
   AuthenticatedStream^ authStream;
   TcpClient^ client;
   array<Byte>^buffer;
   StringBuilder^ message;
   ManualResetEvent^ waiter;

internal:
   ClientState( AuthenticatedStream^ a, TcpClient^ theClient )
   {
      authStream = a;
      client = theClient;
      message = nullptr;
      buffer = gcnew array<Byte>(2048);
      waiter = gcnew ManualResetEvent( false );
   }

internal:
   property TcpClient^ Client 
   {
      TcpClient^ get()
      {
         return client;
      }
   }

   property AuthenticatedStream^ AuthStream 
   {
      AuthenticatedStream^ get()
      {
         return authStream;
      }
  }

   property array<Byte>^ Buffer 
   {
      array<Byte>^ get()
      {
         return buffer;
      }

   }

   property StringBuilder^ Message 
   {
      StringBuilder^ get()
      {
         if ( message == nullptr )
                  message = gcnew StringBuilder;

         return message;
      }

   }

   property ManualResetEvent^ Waiter 
   {
      ManualResetEvent^ get()
      {
         return waiter;
      }

   }

};

public ref class AsynchronousAuthenticatingTcpListener
{
public:
   int Main()
   {
      
      // Create an IPv4 TCP/IP socket. 
      TcpListener^ listener = gcnew TcpListener( IPAddress::Any,11000 );
      
      // Listen for incoming connections.
      listener->Start();
      while ( true )
      {
         TcpClient^ clientRequest = nullptr;
         
         // Application blocks while waiting for an incoming connection.
         // Type CNTL-C to terminate the server.
         clientRequest = listener->AcceptTcpClient();
         Console::WriteLine( L"Client connected." );
         
         // A client has connected. 
         try
         {
            AuthenticateClient( clientRequest );
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( e );
            continue;
         }

      }
   }


   static void AuthenticateClient( TcpClient^ clientRequest )
   {
      NetworkStream^ stream = clientRequest->GetStream();
      
      // Create the NegotiateStream.
      NegotiateStream^ authStream = gcnew NegotiateStream( stream,false );
      
      // Save the current client and NegotiateStream instance 
      // in a ClientState object.
      ClientState^ cState = gcnew ClientState( authStream,clientRequest );
      
      // Listen for the client authentication request.
      authStream->BeginAuthenticateAsServer( gcnew AsyncCallback( EndAuthenticateCallback ), cState );
      
      // Wait until the authentication completes.
      cState->Waiter->WaitOne();
      cState->Waiter->Reset();
      authStream->BeginRead( cState->Buffer, 0, cState->Buffer->Length, gcnew AsyncCallback( EndReadCallback ), cState );
      cState->Waiter->WaitOne();
      
      // Finished with the current client.
      authStream->Close();
      clientRequest->Close();
   }


   // The following method is invoked by the
   // BeginServerAuthenticate callback delegate.
   static void EndAuthenticateCallback( IAsyncResult^ ar )
   {
      
      // Get the saved data.
      ClientState^ cState = dynamic_cast<ClientState^>(ar->AsyncState);
      TcpClient^ clientRequest = cState->Client;
      NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(cState->AuthStream);
      Console::WriteLine( L"Ending authentication." );
      
      // Any exceptions that occurred during authentication are
      // thrown by the EndServerAuthenticate method.
      try
      {
         
         // This call blocks until the authentication is complete.
         authStream->EndAuthenticateAsServer( ar );
      }
      catch ( AuthenticationException^ e ) 
      {
         Console::WriteLine( e );
         Console::WriteLine( L"Authentication failed - closing connection." );
         cState->Waiter->Set();
         return;
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( e );
         Console::WriteLine( L"Closing connection." );
         cState->Waiter->Set();
         return;
      }

      
      // Display properties of the authenticated client.
      IIdentity^ id = authStream->RemoteIdentity;
      Console::WriteLine( L"{0} was authenticated using {1}.", id->Name, id->AuthenticationType );
      cState->Waiter->Set();
   }


   static void EndReadCallback( IAsyncResult^ ar )
   {
      
      // Get the saved data.
      ClientState^ cState = dynamic_cast<ClientState^>(ar->AsyncState);
      TcpClient^ clientRequest = cState->Client;
      NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(cState->AuthStream);
      
      // Get the buffer that stores the message sent by the client.
      int bytes = -1;
      
      // Read the client message.
      try
      {
         bytes = authStream->EndRead( ar );
         cState->Message->Append( Encoding::UTF8->GetChars( cState->Buffer, 0, bytes ) );
         if ( bytes != 0 )
         {
            authStream->BeginRead( cState->Buffer, 0, cState->Buffer->Length, gcnew AsyncCallback( EndReadCallback ), cState );
            return;
         }
      }
      catch ( Exception^ e ) 
      {
         
         // A real application should do something
         // useful here, such as logging the failure.
         Console::WriteLine( L"Client message exception:" );
         Console::WriteLine( e );
         cState->Waiter->Set();
         return;
      }

      IIdentity^ id = authStream->RemoteIdentity;
      Console::WriteLine( L"{0} says {1}", id->Name, cState->Message );
      cState->Waiter->Set();
   }

};

void main()
{
   AsynchronousAuthenticatingTcpListener^ aatl = gcnew AsynchronousAuthenticatingTcpListener;
   aatl->Main();
}

using System;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Principal;
using System.Text;
using System.IO;
using System.Threading;

namespace Examples.NegotiateStreamExample
{
    public class AsynchronousAuthenticatingTcpListener
    {
        public static void Main()
        {
            // Create an IPv4 TCP/IP socket.
            TcpListener listener = new TcpListener(IPAddress.Any, 11000);
            // Listen for incoming connections.
            listener.Start();
            while (true)
            {
                TcpClient clientRequest;
                // Application blocks while waiting for an incoming connection.
                // Type CNTL-C to terminate the server.
                clientRequest = listener.AcceptTcpClient();
                Console.WriteLine("Client connected.");
                // A client has connected.
                try
                {
                    AuthenticateClient(clientRequest);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }

        public static void AuthenticateClient(TcpClient clientRequest)
        {
            NetworkStream stream = clientRequest.GetStream();
            // Create the NegotiateStream.
            NegotiateStream authStream = new NegotiateStream(stream, false);
            // Save the current client and NegotiateStream instance
            // in a ClientState object.
            ClientState cState = new ClientState(authStream, clientRequest);
            // Listen for the client authentication request.
            Task authTask = authStream
                .AuthenticateAsServerAsync()
                .ContinueWith(task => { EndAuthenticateCallback(cState); });

            // Any exceptions that occurred during authentication are
            // thrown by the EndAuthenticateAsServer method.
            try
            {
                // This call blocks until the authentication is complete.
                authTask.Wait();
            }
            catch (AuthenticationException e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Authentication failed - closing connection.");
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Closing connection.");
                return;
            }

            Task<int> readTask = authStream
                .ReadAsync(cState.Buffer, 0, cState.Buffer.Length);

            readTask
                .ContinueWith((task) => { EndReadCallback(cState, task.Result); })
                .Wait();
            // Finished with the current client.
            authStream.Close();
            clientRequest.Close();
        }

        private static void EndAuthenticateCallback(ClientState cState)
        {
            // Get the saved data.
            NegotiateStream authStream = (NegotiateStream)cState.AuthenticatedStream;
            Console.WriteLine("Ending authentication.");

            // Display properties of the authenticated client.
            IIdentity id = authStream.RemoteIdentity;
            Console.WriteLine("{0} was authenticated using {1}.",
                id.Name,
                id.AuthenticationType
            );
        }

        private static void EndReadCallback(ClientState cState, int bytes)
        {
            NegotiateStream authStream = (NegotiateStream)cState.AuthenticatedStream;
            // Read the client message.
            try
            {
                cState.Message.Append(Encoding.UTF8.GetChars(cState.Buffer, 0, bytes));
                if (bytes != 0)
                {
                    Task<int> readTask = authStream.ReadAsync(cState.Buffer, 0, cState.Buffer.Length);
                    readTask
                        .ContinueWith(task => { EndReadCallback(cState, task.Result); })
                        .Wait();

                    return;
                }
            }
            catch (Exception e)
            {
                // A real application should do something
                // useful here, such as logging the failure.
                Console.WriteLine("Client message exception:");
                Console.WriteLine(e);
                return;
            }
            IIdentity id = authStream.RemoteIdentity;
            Console.WriteLine("{0} says {1}", id.Name, cState.Message.ToString());
        }
    }
    // ClientState is the AsyncState object.
    internal class ClientState
    {
        private StringBuilder _message = null;

        internal ClientState(AuthenticatedStream a, TcpClient theClient)
        {
            AuthenticatedStream = a;
            Client = theClient;
        }
        internal TcpClient Client { get; }

        internal AuthenticatedStream AuthenticatedStream { get; }

        internal byte[] Buffer { get; } = new byte[2048];

        internal StringBuilder Message
        {
            get { return _message ??= new StringBuilder(); }
        }
    }
}

注釈

認証には NegotiateStream クラスを使用し、クライアントとサーバーの間で送信される情報をセキュリティで保護します。 NegotiateStreamを使用すると、次の操作を行うことができます。

  • 偽装または委任のために、クライアントの資格情報をサーバーに送信します。

  • サーバー認証を要求します。

  • データを送信する前に暗号化または署名します。

情報を送信する前に認証を実行する必要があります。 クライアントは、認証が完了するまでブロックする同期 AuthenticateAsClient メソッドまたは非同期 BeginAuthenticateAsClient メソッドを使用して認証を要求します。これは、認証の完了を待機している間はブロックされません。 サーバーは、同期 AuthenticateAsServer または非同期 BeginAuthenticateAsServer メソッドを使用して認証を要求します。 クライアント (必要に応じてサーバー) は、ネゴシエート セキュリティ プロトコルを使用して認証されます。 Kerberos プロトコルは、クライアントとサーバーの両方で認証がサポートされている場合に使用されます。それ以外の場合は NTLM が使用されます。 NegotiateStream クラスは、セキュリティ サポート プロバイダー インターフェイス (SSPI) を使用して認証を実行します。

認証が成功したら、IsEncrypted プロパティと IsSigned プロパティを確認して、転送中にデータをセキュリティで保護するために NegotiateStream で使用されるセキュリティ サービスを決定する必要があります。 IsMutuallyAuthenticated プロパティを調べて、相互認証が行われたかどうかを確認します。 RemoteIdentity プロパティを使用して、リモート クライアントまたはサーバーに関する情報を取得できます。

認証に失敗した場合は、AuthenticationException または InvalidCredentialExceptionを受け取ります。 この場合は、別の資格情報で認証を再試行できます。

同期 Write または非同期の BeginWrite または WriteAsync メソッドを使用してデータを送信します。 同期 Read または非同期 ReadAsync または BeginRead メソッドを使用してデータを受信します。 暗号化や署名などのセキュリティ サービスが有効になっている場合は、NegotiateStreamによって自動的にデータに適用されます。

NegotiateStream は、NegotiateStreamの作成時に指定したストリームを使用してデータを送信します。 この基になるストリームを指定すると、NegotiateStream を閉じて基になるストリームも閉じるかどうかを指定できます。

コンストラクター

NegotiateStream(Stream)

指定した Streamを使用して、NegotiateStream クラスの新しいインスタンスを初期化します。

NegotiateStream(Stream, Boolean)

指定した Stream とストリーム クロージャの動作を使用して、NegotiateStream クラスの新しいインスタンスを初期化します。

プロパティ

CanRead

基になるストリームが読み取り可能かどうかを示す Boolean 値を取得します。

CanSeek

基になるストリームがシーク可能かどうかを示す Boolean 値を取得します。

CanTimeout

基になるストリームがタイムアウトをサポートしているかどうかを示す Boolean 値を取得します。

CanWrite

基になるストリームが書き込み可能かどうかを示す Boolean 値を取得します。

ImpersonationLevel

サーバーがクライアントの資格情報を使用する方法を示す値を取得します。

InnerStream

この AuthenticatedStream がデータの送受信に使用するストリームを取得します。

(継承元 AuthenticatedStream)
IsAuthenticated

認証が成功したかどうかを示す Boolean 値を取得します。

IsEncrypted

この NegotiateStream がデータ暗号化を使用するかどうかを示す Boolean 値を取得します。

IsMutuallyAuthenticated

サーバーとクライアントの両方が認証されているかどうかを示す Boolean 値を取得します。

IsServer

この NegotiateStream によって使用される接続のローカル側がサーバーとして認証されたかどうかを示す Boolean 値を取得します。

IsSigned

このストリームを使用して送信されたデータに署名されているかどうかを示す Boolean 値を取得します。

LeaveInnerStreamOpen

データの送受信にこの AuthenticatedStream で使用されるストリームが開いたままになっているかどうかを取得します。

(継承元 AuthenticatedStream)
Length

基になるストリームの長さを取得します。

Position

基になるストリーム内の現在位置を取得または設定します。

ReadTimeout

読み取り操作がデータの待機をブロックする時間を取得または設定します。

RemoteIdentity

この認証済みストリームを共有するリモート パーティの ID に関する情報を取得します。

WriteTimeout

書き込み操作がデータの待機をブロックする時間を取得または設定します。

メソッド

AuthenticateAsClient()

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。

AuthenticateAsClient(NetworkCredential, ChannelBinding, String)

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。 認証プロセスでは、指定されたクライアント資格情報とチャネル バインドが使用されます。

AuthenticateAsClient(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。 認証プロセスでは、指定された資格情報、認証オプション、およびチャネル バインドが使用されます。

AuthenticateAsClient(NetworkCredential, String)

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。 認証プロセスでは、指定されたクライアント資格情報が使用されます。

AuthenticateAsClient(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。 認証プロセスでは、指定された資格情報と認証オプションが使用されます。

AuthenticateAsClientAsync()

非同期操作としてクライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。

AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String)

非同期操作としてクライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。 認証プロセスでは、指定されたクライアント資格情報とチャネル バインドが使用されます。

AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)

非同期操作としてクライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。 認証プロセスでは、指定された資格情報、認証オプション、およびチャネル バインドが使用されます。

AuthenticateAsClientAsync(NetworkCredential, String)

非同期操作としてクライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。 認証プロセスでは、指定されたクライアント資格情報が使用されます。

AuthenticateAsClientAsync(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)

非同期操作としてクライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにクライアントによって呼び出されます。 認証プロセスでは、指定された資格情報と認証オプションが使用されます。

AuthenticateAsServer()

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにサーバーによって呼び出されます。

AuthenticateAsServer(ExtendedProtectionPolicy)

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにサーバーによって呼び出されます。 認証プロセスでは、指定された拡張保護ポリシーが使用されます。

AuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにサーバーによって呼び出されます。 認証プロセスでは、指定されたサーバー資格情報、認証オプション、および拡張保護ポリシーが使用されます。

AuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

クライアントとサーバーの接続で、クライアントと必要に応じてサーバーを認証するためにサーバーによって呼び出されます。 認証プロセスでは、指定されたサーバー資格情報と認証オプションが使用されます。

AuthenticateAsServerAsync()

非同期操作としてクライアントとサーバーの接続でクライアントを認証するためにサーバーによって呼び出され、必要に応じてサーバーが呼び出されます。

AuthenticateAsServerAsync(ExtendedProtectionPolicy)

非同期操作としてクライアントとサーバーの接続でクライアントを認証するためにサーバーによって呼び出され、必要に応じてサーバーが呼び出されます。 認証プロセスでは、指定された拡張保護ポリシーが使用されます。

AuthenticateAsServerAsync(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

非同期操作としてクライアントとサーバーの接続でクライアントを認証するためにサーバーによって呼び出され、必要に応じてサーバーが呼び出されます。 認証プロセスでは、指定されたサーバー資格情報、認証オプション、および拡張保護ポリシーが使用されます。

AuthenticateAsServerAsync(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

非同期操作としてクライアントとサーバーの接続でクライアントを認証するためにサーバーによって呼び出され、必要に応じてサーバーが呼び出されます。 認証プロセスでは、指定されたサーバー資格情報と認証オプションが使用されます。

BeginAuthenticateAsClient(AsyncCallback, Object)

クライアントとサーバーの接続で、クライアントとサーバーを認証する非同期操作を開始するためにクライアントによって呼び出されます。 このメソッドはブロックしません。

BeginAuthenticateAsClient(NetworkCredential, ChannelBinding, String, AsyncCallback, Object)

クライアントとサーバーの接続で、クライアントとサーバーを認証する非同期操作を開始するためにクライアントによって呼び出されます。 認証プロセスでは、指定された資格情報とチャネル バインドが使用されます。 このメソッドはブロックしません。

BeginAuthenticateAsClient(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

クライアントとサーバーの接続で、クライアントとサーバーを認証する非同期操作を開始するためにクライアントによって呼び出されます。 認証プロセスでは、指定された資格情報、認証オプション、およびチャネル バインドが使用されます。 このメソッドはブロックしません。

BeginAuthenticateAsClient(NetworkCredential, String, AsyncCallback, Object)

クライアントとサーバーの接続で、クライアントとサーバーを認証する非同期操作を開始するためにクライアントによって呼び出されます。 認証プロセスでは、指定された資格情報が使用されます。 このメソッドはブロックしません。

BeginAuthenticateAsClient(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

クライアントとサーバーの接続で、クライアントとサーバーを認証する非同期操作を開始するためにクライアントによって呼び出されます。 認証プロセスでは、指定された資格情報と認証オプションが使用されます。 このメソッドはブロックしません。

BeginAuthenticateAsServer(AsyncCallback, Object)

クライアントとサーバーの接続でクライアントを認証するための非同期操作を開始するためにサーバーによって呼び出されます。必要に応じてサーバーが呼び出されます。 このメソッドはブロックしません。

BeginAuthenticateAsServer(ExtendedProtectionPolicy, AsyncCallback, Object)

クライアントとサーバーの接続でクライアントを認証するための非同期操作を開始するためにサーバーによって呼び出されます。必要に応じてサーバーが呼び出されます。 認証プロセスでは、指定された拡張保護ポリシーが使用されます。 このメソッドはブロックしません。

BeginAuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

クライアントとサーバーの接続でクライアントを認証するための非同期操作を開始するためにサーバーによって呼び出されます。必要に応じてサーバーが呼び出されます。 認証プロセスでは、指定されたサーバー資格情報、認証オプション、および拡張保護ポリシーが使用されます。 このメソッドはブロックしません。

BeginAuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

クライアントとサーバーの接続でクライアントを認証するための非同期操作を開始するためにサーバーによって呼び出されます。必要に応じてサーバーが呼び出されます。 認証プロセスでは、指定されたサーバー資格情報と認証オプションが使用されます。 このメソッドはブロックしません。

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

ストリームからデータを読み取り、指定した配列に格納する非同期読み取り操作を開始します。

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

非同期読み取り操作を開始します。 (代わりに ReadAsync(Byte[], Int32, Int32) を使用することを検討してください)。

(継承元 Stream)
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

指定したバッファーからストリームに Byteを書き込む非同期書き込み操作を開始します。

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)

NegotiateStream によって使用されるアンマネージ リソースを解放し、必要に応じてマネージド リソースを解放します。

Dispose(Boolean)

AuthenticatedStream によって使用されるアンマネージ リソースを解放し、必要に応じてマネージド リソースを解放します。

(継承元 AuthenticatedStream)
DisposeAsync()

NegotiateStreamによって使用されるアンマネージ リソースとマネージド リソースを非同期的に解放します。

DisposeAsync()

AuthenticatedStreamによって使用されるアンマネージ リソースとマネージド リソースを非同期的に解放します。

(継承元 AuthenticatedStream)
EndAuthenticateAsClient(IAsyncResult)

BeginAuthenticateAsClientの呼び出しで開始された保留中の非同期クライアント認証操作を終了します。

EndAuthenticateAsServer(IAsyncResult)

BeginAuthenticateAsServerの呼び出しで開始された保留中の非同期クライアント認証操作を終了します。

EndRead(IAsyncResult)

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)の呼び出しで開始された非同期読み取り操作を終了します。

EndRead(IAsyncResult)

保留中の非同期読み取りが完了するまで待機します。 (代わりに ReadAsync(Byte[], Int32, Int32) を使用することを検討してください)。

(継承元 Stream)
EndWrite(IAsyncResult)

BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)の呼び出しで開始された非同期書き込み操作を終了します。

EndWrite(IAsyncResult)

非同期書き込み操作を終了します。 (代わりに WriteAsync(Byte[], Int32, Int32) を使用することを検討してください)。

(継承元 Stream)
Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
Flush()

バッファー内のデータを基になるデバイスに書き込みます。

FlushAsync()

このストリームのすべてのバッファーを非同期的にクリアし、バッファー内のデータを基になるデバイスに書き込みます。

(継承元 Stream)
FlushAsync(CancellationToken)

バッファー内のデータを基になるデバイスに非同期的に書き込みます。

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)

このストリームからデータを読み取り、指定した配列に格納します。

Read(Span<Byte>)

派生クラスでオーバーライドされると、現在のストリームからバイトシーケンスを読み取り、読み取られたバイト数だけストリーム内の位置を進めます。

(継承元 Stream)
ReadAsync(Byte[], Int32, Int32)

現在のストリームからバイト シーケンスを非同期に読み取り、ストリーム内の位置を読み取ったバイト数だけ進めます。

(継承元 Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken)

このストリームから非同期的にデータを読み取り、指定した配列に格納します。

ReadAsync(Byte[], Int32, Int32, CancellationToken)

現在のストリームからバイト シーケンスを非同期に読み取り、読み取ったバイト数だけストリーム内の位置を進め、取り消し要求を監視します。

(継承元 Stream)
ReadAsync(Memory<Byte>, CancellationToken)

NegotiateStream から非同期的にデータを読み取り、非同期操作としてバイト メモリ範囲に格納します。

ReadAsync(Memory<Byte>, CancellationToken)

現在のストリームからバイト シーケンスを非同期に読み取り、読み取ったバイト数だけストリーム内の位置を進め、取り消し要求を監視します。

(継承元 Stream)
ReadAtLeast(Span<Byte>, Int32, Boolean)

現在のストリームから少なくともバイト数を読み取り、読み取ったバイト数だけストリーム内の位置を進めます。

(継承元 Stream)
ReadAtLeastAsync(Memory<Byte>, Int32, Boolean, CancellationToken)

現在のストリームから少なくとも最小バイト数を非同期に読み取り、読み取ったバイト数だけストリーム内の位置を進め、キャンセル要求を監視します。

(継承元 Stream)
ReadByte()

ストリームからバイトを読み取り、ストリーム内の位置を 1 バイト進めるか、ストリームの末尾にある場合は -1 を返します。

(継承元 Stream)
ReadExactly(Byte[], Int32, Int32)

現在のストリーム count バイト数を読み取り、ストリーム内の位置を進めます。

(継承元 Stream)
ReadExactly(Span<Byte>)

現在のストリームからバイトを読み取り、buffer がいっぱいになるまでストリーム内の位置を進めます。

(継承元 Stream)
ReadExactlyAsync(Byte[], Int32, Int32, CancellationToken)

現在のストリーム count バイト数を非同期に読み取り、ストリーム内の位置を進め、キャンセル要求を監視します。

(継承元 Stream)
ReadExactlyAsync(Memory<Byte>, CancellationToken)

現在のストリームからバイトを非同期に読み取り、buffer がいっぱいになるまでストリーム内の位置を進め、取り消し要求を監視します。

(継承元 Stream)
Seek(Int64, SeekOrigin)

NotSupportedExceptionをスローします。

SetLength(Int64)

基になるストリームの長さを設定します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
Write(Byte[], Int32, Int32)

指定したバッファーとオフセットを使用して、指定した数の Byteを基になるストリームに書き込みます。

Write(ReadOnlySpan<Byte>)

派生クラスでオーバーライドされると、現在のストリームにバイト シーケンスを書き込み、書き込まれたバイト数だけこのストリーム内の現在の位置を進めます。

(継承元 Stream)
WriteAsync(Byte[], Int32, Int32)

現在のストリームにバイト シーケンスを非同期に書き込み、書き込まれたバイト数だけこのストリーム内の現在位置を進めます。

(継承元 Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken)

指定した数の Byteを基になるストリームに非同期的に書き込みます。

WriteAsync(Byte[], Int32, Int32, CancellationToken)

現在のストリームにバイトシーケンスを非同期に書き込み、書き込まれたバイト数だけこのストリーム内の現在位置を進め、キャンセル要求を監視します。

(継承元 Stream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

指定した数の Byteを基になるストリームに非同期的に書き込みます。

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

現在のストリームにバイトシーケンスを非同期に書き込み、書き込まれたバイト数だけこのストリーム内の現在位置を進め、キャンセル要求を監視します。

(継承元 Stream)
WriteByte(Byte)

ストリーム内の現在位置にバイトを書き込み、ストリーム内の位置を 1 バイト進めます。

(継承元 Stream)

拡張メソッド

CopyToAsync(Stream, PipeWriter, CancellationToken)

キャンセル トークンを使用して、Stream からバイトを非同期に読み取り、指定した PipeWriterに書き込みます。

ConfigureAwait(IAsyncDisposable, Boolean)

非同期破棄から返されるタスクの待機を実行する方法を構成します。

適用対象

こちらもご覧ください