Ejemplo n.º 1
0
            public void Should_Add_Client_Record_ToDb()
            {
                // Arrange
                string pathToFile = @"С:\Users\Dakosia\source\repos\CSharp\KazTourApp\KazTourApp.DAL\LiteDb.db";
                var    client     = new ClientRecord
                                    (
                    1,
                    "Asuna",
                    "Yuuki",
                    "1234567890",
                    "*****@*****.**"
                                    );

                ClientStorage storage = new ClientStorage();
                int           itemsCountBeforeInsert = storage.ReadAllClients().Count;

                // Act
                storage.AddClient(client);

                // Assert
                Assert.IsTrue(File.Exists(pathToFile));

                int itemsCountAfterInsert = storage.ReadAllClients().Count;

                Assert.IsTrue(itemsCountBeforeInsert == itemsCountAfterInsert - 1);
            }
Ejemplo n.º 2
0
        public ProcessMonitor(ClientStorage storage)
        {
            this.storage = storage;
            this.instanceDeletionWatcher = new ManagementEventWatcher();
            this.refreshTimer.Elapsed   += refreshTimer_Elapsed;

            this.activityTimer = new System.Threading.Timer(this.MeasureActivity, null, TimeSpan.Zero, new TimeSpan(0, 0, 0, 0, 1000));
        }
 public FeedbackMonitorService(IHubContext <ProxyHub, ISignalrClient> hubContext,
                               MessageHistory messageHistory,
                               ClientStorage clientStorage,
                               ILogger <FeedbackMonitorService> logger)
 {
     _hubContext     = hubContext;
     _messageHistory = messageHistory;
     _clientStorage  = clientStorage;
     _logger         = logger;
 }
Ejemplo n.º 4
0
        public LogAppController(IReadOnlyDictionary <String, String> settings)
        {
            this.settings          = settings;
            this.connectionManager = new ConnectionManager();

            string        filepath      = this.settings[LogAppSettings.StorageFilePath];
            double        rewritingTime = double.Parse(settings[LogAppSettings.FileUpdateTime]);
            ClientStorage storage       = new ClientStorage(filepath, rewritingTime);

            this.monitor = new ProcessMonitor(storage);
        }
Ejemplo n.º 5
0
 public void Dispose()
 {
     if (!m_Disposed)
     {
         ClientIdentifier client = ClientStorage.GetInstance().RemoveClient(m_ListenSocket);
         this.m_PacketsHander.DirectionFilter.remove(client);
         m_ListenSocket.Disconnect(false);
         this.m_ListenSocket.Dispose();
         this.m_Disposed = true;
         this.m_Other.Dispose();
     }
 }
Ejemplo n.º 6
0
 public ProxyHub(ConnectionCounter counter,
                 ClientStorage clientStorage,
                 MessageHistory messageHistory,
                 IComponentContext context,
                 ILogger <ProxyHub> logger)
 {
     _counter          = counter;
     _clientStorage    = clientStorage;
     _messageHistory   = messageHistory;
     _componentContext = context;
     _logger           = logger;
 }
Ejemplo n.º 7
0
            public void Should_Remove_Client_Record_FromDb()
            {
                // Arrange
                string        pathToFile = @"С:\Users\Dakosia\source\repos\CSharp\KazTourApp\KazTourApp.DAL\LiteDb.db";
                int           id         = 0;
                ClientStorage storage    = new ClientStorage();
                int           itemsCountBeforeDeletion = storage.ReadAllClients().Count;

                // Act
                storage.RemoveClient(id);

                // Assert
                Assert.IsTrue(File.Exists(pathToFile));

                int itemsCountAfterDeletion = storage.ReadAllClients().Count;

                Assert.IsTrue(itemsCountBeforeDeletion == itemsCountAfterDeletion + 1);
            }
Ejemplo n.º 8
0
        public override void doAction(int readed)
        {
            EncodeOutgoingPacket(m_ListenSocket, ref data, ref readed);
            int newLenght = 0;

            byte[] asd      = Decompressor.Decompressor.Decompress(data, out newLenght);
            int    packetId = asd[0];

            if (packetId == 0x1C)
            {
                int    usernameLength = getIndex(asd, newLenght);
                String username       = UnicodeEncoding.ASCII.GetString(asd, 14, usernameLength).Replace((char)7, '?');
                String message        = UnicodeEncoding.ASCII.GetString(asd, 44, newLenght - 44).Replace((char)7, '?');
                Console.WriteLine("(((((((" + readed + "))))))))))" + "REMOTE" + "\n" + "NAME: " + username + " MESSAGE: " + message);

                if (worldSaveFinished(username, message))
                {
                    ClientIdentifier   client = ClientStorage.GetInstance().GetClient(m_ListenSocket);
                    Filter <Direction> f      = m_PacketsHander.DirectionFilter.get(client);
                    f.Reset();
                }
            }
        }
Ejemplo n.º 9
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/oauth", coreApp =>
            {
                var factory               = new IdentityServerServiceFactory();
                factory.ClaimsProvider    = new Registration <IClaimsProvider, CustomClaimProvider>();
                var clientStorageProvider = new ClientStorage();
                factory.ClientStore       = new Registration <IClientStore>(resolver => clientStorageProvider);
                var scopeStorageProvider  = new ScopeProvider();
                factory.ScopeStore        = new Registration <IScopeStore>(resolver => scopeStorageProvider);

                //currently by defult supported for angular only
                factory.ViewService = new Registration <IViewService, CustomAngularViewService>();

                // different examples of custom user services
                //var userService = new RegisterFirstExternalRegistrationUserService();
                //var userService = new ExternalRegistrationUserService();
                var userService = new EulaAtLoginUserService();
                // var userService = new LocalRegistrationUserService();

                //for normal
                // factory.UserService = new Registration<IUserService, EulaAtLoginUserService>();
                factory.UserService = new Registration <IUserService>(resolver => userService);

                //for custom login service
                // factory.UserService = new Registration<IUserService, LocalRegistrationUserService>();

                factory.Register(new Registration <TestController>(typeof(TestController)));

                var options = new IdentityServerOptions
                {
                    EnableWelcomePage = false,
                    //Endpoints = new EndpointOptions()
                    //{
                    //    EnableUserInfoEndpoint = true,
                    //    EnableTokenEndpoint = true,
                    //    EnableAuthorizeEndpoint = true,
                    //    EnableClientPermissionsEndpoint = true,
                    //    EnableTokenRevocationEndpoint = true,
                    //    EnableAccessTokenValidationEndpoint = true

                    //},
                    SiteName           = "Identity Server",
                    SigningCertificate = Certificate.Get(),
                    Factory            = factory,
                    ////this line for custom login
                    //AuthenticationOptions = new AuthenticationOptions
                    //{
                    //},

                    AuthenticationOptions = new AuthenticationOptions
                    {
                        RequireSignOutPrompt = false,

                        // IdentityProviders = ConfigureAdditionalIdentityProviders,
                        //LoginPageLinks = new LoginPageLink[] {
                        //    new LoginPageLink{
                        //        Text = "Register",
                        //        //Href = "~/localregistration"
                        //        Href = "localregistration"
                        //    }
                        //}
                    },

                    EventsOptions = new EventsOptions
                    {
                        RaiseSuccessEvents     = true,
                        RaiseErrorEvents       = true,
                        RaiseFailureEvents     = true,
                        RaiseInformationEvents = true
                    }
                };

                coreApp.UseIdentityServer(options);
            });

            //JwtSecurityTokenHandler.InboundClaimTypeMap.Clear();

            //app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
            //{
            //    Authority = "https://localhost:44300/core",

            //    RequiredScopes = new[] { "openId","write","email","profile" },

            //    // client credentials for the introspection endpoint
            //    ClientId = "write",
            //    ClientSecret = "secret"
            //});

            //app.UseWebApi(WebApiConfig.Register());
        }
Ejemplo n.º 10
0
 public AllowLoginHandler(IHubContext <ProxyHub, ISignalrClient> hubCotnext, ClientStorage clientStorage, ILogger <StartHandler> logger)
 {
     this._hubContext    = hubCotnext;
     this._clientStorage = clientStorage;
     this._logger        = logger;
 }
Ejemplo n.º 11
0
 public ClientsController(IConfiguration config)
 {
     _storage = new ClientStorage(config);
 }
Ejemplo n.º 12
0
 public StatusHandler(IHubContext <ProxyHub, ISignalrClient> hubCotnext, ClientStorage storage, ILogger <StartHandler> logger)
 {
     _hubContext = hubCotnext;
     _storage    = storage;
     _logger     = logger;
 }