Esempio n. 1
0
        public Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken)
        {
            var token = context.Request.Headers.Authorization != null ? context.Request.Headers.Authorization.Parameter : null;

            if (!string.IsNullOrWhiteSpace((token)) && token != "000" && token != "undefined")
            {
                var uid    = DesCryptoUtil.Decrypt(token);
                var claims = new List <Claim>();
                claims.Add(new Claim(ClaimTypes.Name, uid));
                //claims.Add(new Claim(ClaimTypes.Role, "123"));
                var identity = new ClaimsIdentity(claims, context.Request.Headers.Authorization.Scheme);
                context.Principal = new ClaimsPrincipal(identity);
            }
            return(Task.FromResult(0));
        }
Esempio n. 2
0
 public void WhenCallDecrypt()
 {
     _plainText = DesCryptoUtil.Decrypt(_encryptedText);
 }