public virtual void Uninitialize()
 {
     _features = default(FeatureReferences<FeatureInterfaces>);
     if (_request != null)
     {
         UninitializeHttpRequest(_request);
         _request = null;
     }
     if (_response != null)
     {
         UninitializeHttpResponse(_response);
         _response = null;
     }
     if (_authenticationManager != null)
     {
         UninitializeAuthenticationManager(_authenticationManager);
         _authenticationManager = null;
     }
     if (_connection != null)
     {
         UninitializeConnectionInfo(_connection);
         _connection = null;
     }
     if (_websockets != null)
     {
         UninitializeWebSocketManager(_websockets);
         _websockets = null;
     }
 }
 public DefaultHttpContext(IFeatureCollection features)
 {
     _features = features;
     _request = new DefaultHttpRequest(this, features);
     _response = new DefaultHttpResponse(this, features);
     _connection = new DefaultConnectionInfo(features);
     _authenticationManager = new DefaultAuthenticationManager(features);
 }
        public static async Task SignIn(AuthenticationManager authentication, string monsterName)
        {
            // Create claims
            var identity = new ClaimsIdentity(new[]
            {
                new Claim(ClaimTypes.Name, monsterName),
                new Claim(CookieMonsterSecurity.MonsterTypeClaim, MonsterTypes.Good),
            }, CookieMonsterSecurity.CookieMonsterAuthenticationSchema);

            var user = new ClaimsPrincipal(identity);
            await authentication.SignInAsync(CookieMonsterSecurity.CookieMonsterAuthenticationSchema, user);
        }
        public DefaultHttpContext(IFeatureCollection features)
        {
            _features = features;
            _request = new DefaultHttpRequest(this, features);
            _response = new DefaultHttpResponse(this, features);
            _connection = new DefaultConnectionInfo(features);
            _authenticationManager = new DefaultAuthenticationManager(features);

            _items = FeatureReference<IItemsFeature>.Default;
            _serviceProviders = FeatureReference<IServiceProvidersFeature>.Default;
            _authentication = FeatureReference<IHttpAuthenticationFeature>.Default;
            _lifetime = FeatureReference<IHttpRequestLifetimeFeature>.Default;
            _session = FeatureReference<ISessionFeature>.Default;
        }
        public static void SignIn(AuthenticationManager authenticationManager, User user)
        {
            var claims = new List<Claim>
            {
                new Claim(ClaimTypes.Email, user.EMail, ClaimValueTypes.String, Issuer),
                new Claim(ClaimTypes.UserData, user.Id.ToString(), ClaimValueTypes.Integer32, Issuer)
            };
            var userIdentity = new ClaimsIdentity("Email");
            userIdentity.AddClaims(claims);
            var userPrincipal = new ClaimsPrincipal(userIdentity);

            authenticationManager.SignInAsync(AuthenticationSchema, userPrincipal,
                new AuthenticationProperties
                {
                    ExpiresUtc = DateTime.UtcNow.AddMinutes(20),
                    IsPersistent = false,
                    AllowRefresh = true
                }).Wait();
        }
 protected virtual void UninitializeAuthenticationManager(AuthenticationManager instance) { }
 public static async Task SignOut(AuthenticationManager authentication)
 {
     await authentication.SignOutAsync(CookieMonsterSecurity.CookieMonsterAuthenticationSchema);
 }
 public static void SignOut(AuthenticationManager authenticationManager)
 {
     authenticationManager.SignOutAsync(AuthenticationSchema);
 }