AuthenticationSchemeSelector 대리자

정의

HttpListener 인스턴스에 대한 인증 체계를 선택합니다.

public delegate System::Net::AuthenticationSchemes AuthenticationSchemeSelector(HttpListenerRequest ^ httpRequest);
public delegate System.Net.AuthenticationSchemes AuthenticationSchemeSelector(HttpListenerRequest httpRequest);
type AuthenticationSchemeSelector = delegate of HttpListenerRequest -> AuthenticationSchemes
Public Delegate Function AuthenticationSchemeSelector(httpRequest As HttpListenerRequest) As AuthenticationSchemes 

매개 변수

httpRequest
HttpListenerRequest

인증 체계를 선택할 해당 HttpListenerRequest 인스턴스입니다.

반환 값

AuthenticationSchemes

지정된 클라이언트 요청에 대해 사용할 인증 방법을 나타내는 AuthenticationSchemes 값 중 하나입니다.

예제

다음 예제에서는 이 형식의 인스턴스를 사용하여 속성을 설정합니다 AuthenticationSchemeSelectorDelegate .

// Set up a listener.
HttpListener listener = new HttpListener();
HttpListenerPrefixCollection prefixes = listener.Prefixes;
prefixes.Add(@"http://localhost:8080/");
prefixes.Add(@"http://contoso.com:8080/");

// Specify the authentication delegate.
listener.AuthenticationSchemeSelectorDelegate =
    new AuthenticationSchemeSelector (AuthenticationSchemeForClient);

// Start listening for requests and process them
// synchronously.
listener.Start();
' Set up a listener.
Dim listener As New HttpListener()
Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes
prefixes.Add("http://localhost:8080/")
prefixes.Add("http://contoso.com:8080/")

' Specify the authentication delegate.
listener.AuthenticationSchemeSelectorDelegate = New AuthenticationSchemeSelector(AddressOf AuthenticationSchemeForClient)

' Start listening for requests and process them 
' synchronously.
listener.Start()

다음 예제에서는 이전 예제에서 대리자가 호출한 메서드의 AuthenticationSchemeSelector 구현을 보여줍니다.

static AuthenticationSchemes AuthenticationSchemeForClient(HttpListenerRequest request)
{
    Console.WriteLine("Client authentication protocol selection in progress...");
    // Do not authenticate local machine requests.
    if (request.RemoteEndPoint.Address.Equals (IPAddress.Loopback))
    {
        return AuthenticationSchemes.None;
    }
    else
    {
        return AuthenticationSchemes.IntegratedWindowsAuthentication;
    }
}
Private Shared Function AuthenticationSchemeForClient(ByVal request As HttpListenerRequest) As AuthenticationSchemes
    Console.WriteLine("Client authentication protocol selection in progress...")
    ' Do not authenticate local machine requests.
    If request.RemoteEndPoint.Address.Equals(IPAddress.Loopback) Then
        Return AuthenticationSchemes.None
    Else
        Return AuthenticationSchemes.IntegratedWindowsAuthentication
    End If
End Function

설명

이 형식의 대리자는 인스턴스에서 HttpListener 요청의 특성에 따라 인증 체계를 선택하는 데 사용됩니다.

AuthenticationSchemeSelector 대리자는 인증 정보를 제공하지 않은 들어오는 각 요청에 대한 개체를 전달 HttpListenerRequest 합니다. 대리자가 호출한 메서드는 개체 및 사용 가능한 다른 정보를 사용하여 HttpListenerRequest 필요한 인증 체계를 결정합니다. 대리자는 속성을 사용하여 지정됩니다 AuthenticationSchemeSelectorDelegate .

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상