private ClaimsPrincipal GetPrincipal(string tokenString) { var tokenHandlerCollection = new SecurityTokenHandlerCollection(); tokenHandlerCollection.AddOrReplace(new JwtSecurityTokenHandler()); tokenHandlerCollection.AddOrReplace(new SamlSecurityTokenHandler()); var principal = tokenHandlerCollection.ValidateToken(tokenString, new TokenValidationParameters { RequireSignedTokens = false, ValidateLifetime = false, ValidateAudience = false, ValidateIssuer = false, ValidateActor = false, ValidateIssuerSigningKey = false }, out _); return(principal); }
private static SessionSecurityTokenHandler GetOrCreateSessionSecurityTokenHandler() { SecurityTokenHandlerCollection defaultHandlers = SecurityTokenHandlerCollection.CreateDefaultSecurityTokenHandlerCollection(); SessionSecurityTokenHandler ssth = defaultHandlers[typeof(SessionSecurityToken)] as SessionSecurityTokenHandler; if (ssth == null) { ssth = new SessionSecurityTokenHandler(); defaultHandlers.AddOrReplace(ssth); } return(ssth); }