SecurityTokenHandler.CreateToken(SecurityTokenDescriptor) 메서드

정의

파생 클래스에서 재정의되는 경우 지정된 설명자를 사용하여 보안 토큰을 만듭니다. 이 메서드는 STS(보안 토큰 서비스)에 의해 호출됩니다.

public:
 virtual System::IdentityModel::Tokens::SecurityToken ^ CreateToken(System::IdentityModel::Tokens::SecurityTokenDescriptor ^ tokenDescriptor);
public virtual System.IdentityModel.Tokens.SecurityToken CreateToken (System.IdentityModel.Tokens.SecurityTokenDescriptor tokenDescriptor);
abstract member CreateToken : System.IdentityModel.Tokens.SecurityTokenDescriptor -> System.IdentityModel.Tokens.SecurityToken
override this.CreateToken : System.IdentityModel.Tokens.SecurityTokenDescriptor -> System.IdentityModel.Tokens.SecurityToken
Public Overridable Function CreateToken (tokenDescriptor As SecurityTokenDescriptor) As SecurityToken

매개 변수

tokenDescriptor
SecurityTokenDescriptor

토큰이 만들어지는 보안 토큰 설명자입니다. 토큰 설명자의 속성이 이 메서드를 호출 하기 전에 설정됩니다.

반환

토큰 설명자의 속성과 일치하는 보안 토큰입니다.

예제

다음 코드를 재정의 하는 방법을 보여 줍니다는 CreateToken 메서드를 만들고 토큰 설명자에서 토큰을 반환 합니다. 코드에서 수행 되는 Custom Token 샘플입니다. 이 샘플의 간단한 웹 토큰 (SWT) 처리를 사용 하도록 설정 하는 사용자 지정 클래스를 제공 합니다. 이 샘플 및 WIF 및 다운로드할 위치에 사용할 수 있는 다른 샘플에 대 한 정보를 참조 하세요 WIF 코드 샘플 인덱스합니다.

public override SecurityToken CreateToken(SecurityTokenDescriptor tokenDescriptor)
{
    if (tokenDescriptor == null)
    {
        throw new ArgumentNullException("tokenDescriptor");
    }

    NameValueCollection properties = new NameValueCollection();
    properties.Add(SimpleWebTokenConstants.Id, Guid.NewGuid().ToString());
    properties.Add(SimpleWebTokenConstants.Issuer, tokenDescriptor.TokenIssuerName);
    properties.Add(SimpleWebTokenConstants.Audience, tokenDescriptor.AppliesToAddress);
    properties.Add(SimpleWebTokenConstants.ExpiresOn, SecondsFromSwtBaseTime(tokenDescriptor.Lifetime.Expires));
    properties.Add(SimpleWebTokenConstants.ValidFrom, SecondsFromSwtBaseTime(tokenDescriptor.Lifetime.Created));

    foreach (Claim claim in tokenDescriptor.Subject.Claims)
    {
        properties.Add(claim.Type, claim.Value);
    }

    SimpleWebToken token = new SimpleWebToken(properties);
    return token;
}

설명

기본적으로이 메서드에서 throw 한 NotImplementedException 예외입니다.

구현에서 호출 된 SecurityTokenService 클래스입니다.

적용 대상