Exemplo n.º 1
0
        public static ClaimsPrincipal Principal(bool hasUserKey       = true,
                                                bool hasSecurityStamp = true, bool hasSecurityStampValidated = true,
                                                FakeSystemClock clock = null)
        {
            clock = clock ?? new FakeSystemClock(DateTimeOffset.UtcNow);
            var options = new ClaimOptions();
            var claims  = new List <Claim>();

            if (hasUserKey)
            {
                claims.Add(new Claim(options.ClaimTypes.UserKey, "key"));
            }

            if (hasSecurityStamp)
            {
                claims.Add(new Claim(options.ClaimTypes.SecurityStamp, "stamp"));
            }

            if (hasSecurityStampValidated)
            {
                claims.Add(new Claim(options.ClaimTypes.SecurityStampValidated,
                                     clock.UtcNow.UtcTicks.ToString()));
            }

            return(new ClaimsPrincipal(
                       new ClaimsIdentity(claims, options.AuthenticationScheme)));
        }
Exemplo n.º 2
0
 public FakeClaimsAuthenticationServiceBase(FakeUserStore userStore,
                                            ClaimOptions options, FakeSystemClock clock)
     : base(userStore, options, clock)
 {
 }
 public FakeClaimsAuthenticationService2(FakeHttpContextAccessor httpContextAccessor,
                                         FakeUserStore userStore, ClaimOptions options, FakeSystemClock clock)
     : base(httpContextAccessor, userStore, options, clock)
 {
 }