Example #1
0
        /// <exception cref="Exception"></exception>
        private void populateData()
        {
            AppSensorClient appSensorClient = (AppSensorClient)contextClient.GetObject("AppSensorClient");
            AppSensorServer appSensorServer = (AppSensorServer)contextServer.GetObject("AppSensorServer");
            int             delay           = 500;

            detectionPoint1.setId("IE1");
            detectionSystems1.Add(detectionSystem1);

            ServerConfiguration updatedConfiguration = appSensorServer.getConfiguration();

            updatedConfiguration.setDetectionPoints(loadMockedDetectionPoints());
            appSensorServer.setConfiguration(updatedConfiguration);

            Thread.Sleep(delay);
            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));
            Thread.Sleep(delay);
            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));
            Thread.Sleep(delay);
            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));
            Thread.Sleep(delay);
            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));
            Thread.Sleep(delay);
            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));
            Thread.Sleep(delay);
            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));
            Thread.Sleep(delay);
            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));
            Thread.Sleep(delay);
        }
        public void testAttackCreation()
        {
            //IApplicationContext context = new XmlApplicationContext("Resources/appsensor-client-config.xml", "Resources/appsensor-server-config.xml");
            //IApplicationContext contextClient = new XmlApplicationContext("Resources/base-context.xml", "Resources/appsensor-client-config.xml");
            //IApplicationContext context = ContextRegistry.GetContext();

            //AppSensorServer appSensorServer = (AppSensorServer)context.GetObject("AppSensorServer");
            //AppSensorClient appSensorClient = (AppSensorClient)context.GetObject("AppSensorClient");

            ServerConfiguration updatedConfiguration = appSensorServer.getConfiguration();

            updatedConfiguration.setDetectionPoints(loadMockedDetectionPoints());
            appSensorServer.setConfiguration(updatedConfiguration);

            SearchCriteria criteria = new SearchCriteria().
                                      setUser(bob).
                                      setDetectionPoint(detectionPoint1).
                                      setDetectionSystemIds(detectionSystems1);

            Assert.AreEqual(0, appSensorServer.getEventStore().findEvents(criteria).Count);
            Assert.AreEqual(0, appSensorServer.getAttackStore().findAttacks(criteria).Count);

            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));

            Assert.AreEqual(1, appSensorServer.getEventStore().findEvents(criteria).Count);
            Assert.AreEqual(0, appSensorServer.getAttackStore().findAttacks(criteria).Count);

            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));

            Assert.AreEqual(2, appSensorServer.getEventStore().findEvents(criteria).Count);
            Assert.AreEqual(0, appSensorServer.getAttackStore().findAttacks(criteria).Count);

            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));

            Assert.AreEqual(3, appSensorServer.getEventStore().findEvents(criteria).Count);
            Assert.AreEqual(1, appSensorServer.getAttackStore().findAttacks(criteria).Count);

            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));

            Assert.AreEqual(4, appSensorServer.getEventStore().findEvents(criteria).Count);
            Assert.AreEqual(1, appSensorServer.getAttackStore().findAttacks(criteria).Count);

            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));

            Assert.AreEqual(5, appSensorServer.getEventStore().findEvents(criteria).Count);
            Assert.AreEqual(1, appSensorServer.getAttackStore().findAttacks(criteria).Count);

            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));

            Assert.AreEqual(6, appSensorServer.getEventStore().findEvents(criteria).Count);
            Assert.AreEqual(2, appSensorServer.getAttackStore().findAttacks(criteria).Count);

            appSensorClient.getEventManager().addEvent(new Event(bob, detectionPoint1, "localhostme"));

            Assert.AreEqual(7, appSensorServer.getEventStore().findEvents(criteria).Count);
            Assert.AreEqual(2, appSensorServer.getAttackStore().findAttacks(criteria).Count);
        }