本文整理汇总了C#中System.IdentityModel.Tokens.JwtSecurityTokenHandler.CreateSecurityTokenReference方法的典型用法代码示例。如果您正苦于以下问题:C# JwtSecurityTokenHandler.CreateSecurityTokenReference方法的具体用法?C# JwtSecurityTokenHandler.CreateSecurityTokenReference怎么用?C# JwtSecurityTokenHandler.CreateSecurityTokenReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IdentityModel.Tokens.JwtSecurityTokenHandler
的用法示例。
在下文中一共展示了JwtSecurityTokenHandler.CreateSecurityTokenReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JwtSecurityTokenHandler_Defaults
public void JwtSecurityTokenHandler_Defaults()
{
JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
Assert.IsTrue(handler.CanValidateToken, "!handler.CanValidateToken");
Assert.IsTrue(handler.CanWriteToken, "!handler.CanWriteToken");
Assert.IsNotNull(handler.SignatureProviderFactory, "handler.SignatureProviderFactory == null");
Assert.AreEqual(handler.TokenType, typeof(JwtSecurityToken), "handler.TokenType != typeof(JwtSecurityToken)");
try
{
handler.CreateSecurityTokenReference(new JwtSecurityToken(), false);
}
catch (NotSupportedException)
{
}
string[] tokenIdentifiers = handler.GetTokenTypeIdentifiers();
Assert.AreEqual(tokenIdentifiers.Length, 2, "tokenIdentifiers.Length != 2 ");
// this seemly simple order will break WebSSO if the first type is not an absolute URI
Assert.AreEqual(tokenIdentifiers[0], JwtConstants.TokenTypeAlt, "tokenIdentifiers[0] != JwtConstants.TokenTypeAlt ");
Uri result = null;
Assert.IsTrue(Uri.TryCreate(tokenIdentifiers[0], UriKind.Absolute, out result), "tokenIdentifiers[0] must be able to create an UriKind.Absolute");
Assert.AreEqual(tokenIdentifiers[1], JwtConstants.TokenType, "tokenIdentifiers[1] != JwtConstants.TokenType");
}
开发者ID:vebin,项目名称:azure-activedirectory-identitymodel-extensions-for-dotnet,代码行数:27,代码来源:JwtSecurityTokenHandlerTests.cs