public void JwtSecurityTokenHandler_Extensibility() { DerivedJwtSecurityTokenHandler handler = new DerivedJwtSecurityTokenHandler() { DerivedTokenType = typeof(DerivedJwtSecurityToken) }; JwtSecurityToken jwt = new JwtSecurityToken ( issuer: Default.Issuer, audience: Default.Audience, claims: ClaimSets.Simple(Default.Issuer, Default.Issuer), signingCredentials: KeyingMaterial.DefaultX509SigningCreds_2048_RsaSha2_Sha2, expires: DateTime.UtcNow + TimeSpan.FromHours(10), notBefore: DateTime.UtcNow ); string encodedJwt = handler.WriteToken(jwt); TokenValidationParameters tvp = new TokenValidationParameters() { IssuerSigningKey = KeyingMaterial.DefaultX509Key_2048, ValidateAudience = false, ValidIssuer = Default.Issuer, }; List <string> errors = new List <string>(); ValidateDerived(encodedJwt, handler, tvp, ExpectedException.NoExceptionExpected, errors); }
public static JwtSecurityToken CreateJwtSecurityToken(string issuer = null, string originalIssuer = null) { string iss = issuer ?? IdentityUtilities.DefaultIssuer; string originalIss = originalIssuer ?? IdentityUtilities.DefaultOriginalIssuer; return(new JwtSecurityToken(issuer, "http://www.contoso.com", ClaimSets.Simple(iss, originalIss))); }