WIF返回RP应用程序

时间:2011-09-02 12:41:47

标签: c# wif

我正在构建WIF STS并且我能够生成令牌。如何将令牌返回到原始URL。我注意到这个以ru =的形式存在于wctx参数中。如何在不手动将其解析为字符串的情况下提取此内容?

1 个答案:

答案 0 :(得分:0)

如果您想将令牌返回给依赖方,您可以使用与此类似的ProcessRequest方法:

    var claims = new List<Claim>
    {
        new Claim(WSIdentityConstants.ClaimTypes.Name, User.Identity.Name),
        new Claim(ClaimTypes.AuthenticationMethod, FormsAuthenticationHelper.GetAuthenticationMethod(User.Identity))
    };

        var identity = new ClaimsIdentity(claims, STS.TokenServiceIssueTypes.Native);
        var principal = ClaimsPrincipal.CreateFromIdentity(identity);

        FederatedPassiveSecurityTokenServiceOperations.ProcessRequest(
            Request,
            principal,
            StarterTokenServiceConfiguration.Current.CreateSecurityTokenService(),
            Response);

如果您只想提取网址参数,请查看WSFederationMessage.CreateFromUri