HttpCredentialsHeaderValue 클래스

정의

HTTP 요청에 대한 권한 부여 또는 프록시 권한 부여 HTTP 헤더의 값을 나타냅니다.

public ref class HttpCredentialsHeaderValue sealed : IStringable
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.Headers.IHttpCredentialsHeaderValueFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpCredentialsHeaderValue final : IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.Headers.IHttpCredentialsHeaderValueFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class HttpCredentialsHeaderValue final : IStringable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.Headers.IHttpCredentialsHeaderValueFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpCredentialsHeaderValue : IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.Headers.IHttpCredentialsHeaderValueFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class HttpCredentialsHeaderValue : IStringable
function HttpCredentialsHeaderValue(scheme, token)
Public NotInheritable Class HttpCredentialsHeaderValue
Implements IStringable
상속
Object Platform::Object IInspectable HttpCredentialsHeaderValue
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

다음 샘플 코드에서는 HttpCredentialsHeaderValue 클래스의 속성 및 메서드를 사용하여 HttpRequestMessage 개체에서 권한 부여 HTTP 헤더를 가져와서 설정하는 메서드를 보여 줍니다.

using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateHeaderRequestAuthorization() {
            var request = new HttpRequestMessage();

            // Set the header with a strong type.
            string username = "user";
            string password = "password";
            var buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary (username + ":" + password, Windows.Security.Cryptography.BinaryStringEncoding.Utf16LE);
            string base64token = Windows.Security.Cryptography.CryptographicBuffer.EncodeToBase64String(buffer);
            request.Headers.Authorization = new HttpCredentialsHeaderValue("Basic", base64token);


            // Get the strong type out
            System.Diagnostics.Debug.WriteLine("One of the Authorization values: {0}={1}", 
                request.Headers.Authorization.Scheme,
                request.Headers.Authorization.Token);

            // The ToString() is useful for diagnostics, too.
            System.Diagnostics.Debug.WriteLine("The Authorization ToString() results: {0}", request.Headers.Authorization.ToString());
        }

다음 샘플 코드에서는 HttpCredentialsHeaderValue 클래스의 속성 및 메서드를 사용하여 HttpRequestMessage 개체에서 Proxy-Authorization HTTP 헤더를 가져와서 설정하는 방법을 보여 줍니다.

using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateHeaderRequestProxyAuthorization() {
            var request = new HttpRequestMessage();

            // Set the header with a strong type.
            string username = "user";
            string password = "password";
            var buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(username + ":" + password, Windows.Security.Cryptography.BinaryStringEncoding.Utf16LE);
            string base64token = Windows.Security.Cryptography.CryptographicBuffer.EncodeToBase64String(buffer);
            request.Headers.ProxyAuthorization = new HttpCredentialsHeaderValue("Basic", base64token);


            // Get the strong type out
            System.Diagnostics.Debug.WriteLine("One of the ProxyAuthorixation values: {0}={1}",
                request.Headers.ProxyAuthorization.Scheme,
                request.Headers.ProxyAuthorization.Token);

            // The ToString() is useful for diagnostics, too.
            System.Diagnostics.Debug.WriteLine("The ProxyAuthorization ToString() results: {0}", request.Headers.ProxyAuthorization.ToString());
        }

설명

HttpCredentialsHeaderValue 클래스는 HTTP 요청의 Authorization 또는 Proxy-Authorization HTTP 헤더를 나타냅니다.

HttpRequestHeaderCollectionAuthorization 속성은 Authorization HTTP 헤더를 나타내는 HttpCredentialsHeaderValue 개체를 반환합니다. HttpRequestHeaderCollectionProxyAuthorization 속성은 Proxy-Authorization HTTP 헤더를 나타내는 HttpCredentialsHeaderValue 개체를 반환합니다.

생성자

HttpCredentialsHeaderValue(String)

인증에 사용할 체계를 사용하여 HttpCredentialsHeaderValue 클래스의 새 instance 초기화합니다.

HttpCredentialsHeaderValue(String, String)

인증에 사용할 스키마 및 사용자 토큰 정보를 사용하여 HttpCredentialsHeaderValue 클래스의 새 instance 초기화합니다.

속성

Parameters

Authorization 또는 Proxy-Authorization HTTP 헤더에 포함된 이름/값 쌍 집합을 가져옵니다.

Scheme

인증에 사용할 체계를 가져옵니다.

Token

권한 부여 또는 프록시 권한 부여 HTTP 헤더에 사용되는 사용자 토큰 정보를 가져옵니다.

메서드

Parse(String)

문자열을 HttpCredentialsHeaderValue instance 변환합니다.

ToString()

현재 HttpCredentialsHeaderValue 개체를 나타내는 문자열을 반환합니다.

TryParse(String, HttpCredentialsHeaderValue)

문자열이 유효한 HttpCredentialsHeaderValue 정보인지 여부를 확인합니다.

적용 대상

추가 정보