public static Saml2ResponseSecurityTokenHandler GetSaml2SecurityTokenHandler()
        {
            var handler = new Saml2ResponseSecurityTokenHandler();
            var identityConfiguration = FederatedAuthentication.FederationConfiguration.IdentityConfiguration;
            handler.Configuration = new SecurityTokenHandlerConfiguration
            {
                SaveBootstrapContext = identityConfiguration.SaveBootstrapContext,
                AudienceRestriction = identityConfiguration.AudienceRestriction,
                IssuerNameRegistry = new Saml2ResponseIssuerNameRegistry(),
                CertificateValidationMode = identityConfiguration.CertificateValidationMode,
                RevocationMode = identityConfiguration.RevocationMode,
                CertificateValidator = identityConfiguration.CertificateValidator,
                DetectReplayedTokens = identityConfiguration.DetectReplayedTokens,
            };

            handler.SamlSecurityTokenRequirement.NameClaimType = ClaimTypes.NameIdentifier;
            return handler;
        }
        public static Saml2ResponseSecurityTokenHandler GetSaml2SecurityTokenHandler()
        {
            var handler = new Saml2ResponseSecurityTokenHandler();
            var identityConfiguration = FederatedAuthentication.FederationConfiguration.IdentityConfiguration;

            handler.Configuration = new SecurityTokenHandlerConfiguration
            {
                SaveBootstrapContext      = identityConfiguration.SaveBootstrapContext,
                AudienceRestriction       = identityConfiguration.AudienceRestriction,
                IssuerNameRegistry        = new Saml2ResponseIssuerNameRegistry(),
                CertificateValidationMode = identityConfiguration.CertificateValidationMode,
                RevocationMode            = identityConfiguration.RevocationMode,
                CertificateValidator      = identityConfiguration.CertificateValidator,
                DetectReplayedTokens      = identityConfiguration.DetectReplayedTokens,
            };

            handler.SamlSecurityTokenRequirement.NameClaimType = ClaimTypes.NameIdentifier;
            return(handler);
        }