Thinktecture.IdentityModel.Tokens.AccessSecurityTokenHandler.ValidateToken C# (CSharp) Method

ValidateToken() public method

Validates the token.
public ValidateToken ( System.IdentityModel.Tokens.SecurityToken token ) : ClaimsIdentityCollection
token System.IdentityModel.Tokens.SecurityToken The token.
return ClaimsIdentityCollection
        public override ClaimsIdentityCollection ValidateToken(SecurityToken token)
        {
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }
            
            //Contract.Ensures(Contract.Result<ClaimsIdentityCollection>() != null);
            //Contract.EndContractBlock();

            var accToken = token as AccessSecurityToken;
            if (accToken == null)
            {
                throw new ArgumentException("token");
            }

            CheckExpiration(accToken);
            string issuer = ValidateIssuer(accToken.IssuerCertificate);
            return CreateClaims(accToken, issuer);
        }

Usage Example

        static void Main(string[] args)
        {
            var handler = new AccessSecurityTokenHandler() { Configuration = new SecurityTokenHandlerConfiguration() };
            ConfigureHandler(handler.Configuration);

            var token = CreateToken(handler);
            var tokenString = WriteToken(handler, token);

            Console.WriteLine(tokenString.ToString());
            Console.WriteLine("\nFull Length      : {0}", tokenString.Length);
            Console.WriteLine("Compressed Length: {0}\n", Compress(tokenString.ToString()).Length);

            var readToken = ReadToken(handler, tokenString.ToString());

            var identities = handler.ValidateToken(readToken);
            ClaimsViewer.ShowConsole(new ClaimsPrincipal(identities));
            
            TestHandlerCollection(tokenString);
            TestMalformedTokens();
            TestCompressedToken(token);
        }
All Usage Examples Of Thinktecture.IdentityModel.Tokens.AccessSecurityTokenHandler::ValidateToken