Ejemplo n.º 1
0
        public string GetEncryptedToken(string audience, string credentials)
        {
            JsonWebEncryptedToken token = new JsonWebEncryptedToken()
            {
                AsymmetricKey = audienceKeys[audience],
                Issuer        = "TokenIssuer",
                Audience      = audience
            };

            token.AddClaim(ClaimTypes.Name, credentials);

            return(token.ToString());
        }
Ejemplo n.º 2
0
        public void AuthenticateWithEncryptedToken(string token)
        {
            JsonWebEncryptedToken jwt = null;

            try
            {
                jwt = JsonWebEncryptedToken.Parse(token, this.secretKey);
                Thread.CurrentPrincipal = new ClaimsPrincipal(new ClaimsIdentity(jwt.Claims, "JWT"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }