//============================================================================================= Static API

        public static SecuritySystem StartSecurity(ISecurityDataProvider securityDataProvider,
                                                   IMessageProvider messageProvider,
                                                   IMissingEntityHandler missingEntityHandler,
                                                   MessagingOptions messagingOptions)
        {
            var securityConfig = new SecurityConfiguration
            {
                SystemUserId    = Identifiers.SystemUserId,
                VisitorUserId   = Identifiers.VisitorUserId,
                EveryoneGroupId = Identifiers.EveryoneGroupId,
                OwnerGroupId    = Identifiers.OwnersGroupId
            };

            var securitySystem = new SecuritySystem(securityDataProvider, messageProvider, missingEntityHandler,
                                                    securityConfig, messagingOptions);

            securitySystem.Start();

            SnLog.WriteInformation("Security subsystem started in Search service", EventId.RepositoryLifecycle,
                                   properties: new Dictionary <string, object> {
                { "DataProvider", securityDataProvider.GetType().FullName },
                { "MessageProvider", messageProvider.GetType().FullName }
            });

            return(securitySystem);
        }
Exemple #2
0
        internal static SecuritySystem StartTheSystem(ISecurityDataProvider securityDataProvider)
        {
            var messageSenderManager = new MessageSenderManager("asdf");
            // Call SecurityContext starter method.
            //var securitySystem = SecurityContextForConcurrencyTests.StartTheSystem(new SecurityConfiguration
            //{
            //    SecurityDataProvider = securityDataProvider,
            //    MessageProvider = new DefaultMessageProvider(messageSenderManager),
            //    CommunicationMonitorRunningPeriodInSeconds = 31
            //});
            var config           = new SecurityConfiguration();
            var messagingOptions = new MessagingOptions {
                CommunicationMonitorRunningPeriodInSeconds = 31
            };
            var securitySystem = new SecuritySystem(securityDataProvider,
                                                    new DefaultMessageProvider(messageSenderManager),
                                                    new MissingEntityHandler(), config, messagingOptions);

            securitySystem.Start();

            // legacy logic
            // original line: MessageSender.Initialize("asdf");
            //securitySystem.MessageSenderManager = messageSenderManager;

            return(securitySystem);
        }
Exemple #3
0
        // Called by tests. The messageProvider must be initialized.
        internal static SecuritySystem StartTheSystem(ISecurityDataProvider securityDataProvider, IMessageProvider messageProvider, TextWriter traceChannel = null)
        {
            var securitySystem = new SecuritySystem(securityDataProvider, messageProvider,
                                                    new MissingEntityHandler(),
                                                    new SecurityConfiguration(),
                                                    new MessagingOptions {
                CommunicationMonitorRunningPeriodInSeconds = 31
            });

            securitySystem.Start();

            return(securitySystem);
        }
Exemple #4
0
        private SecuritySystem CreateSecuritySystem(string instanceName, Queue <byte[]> messageQueue, bool isReceiver)
        {
            var entities    = SystemStartTests.CreateTestEntities();
            var groups      = SystemStartTests.CreateTestGroups();
            var memberships = Tools.CreateInMemoryMembershipTable(groups);
            var aces        = SystemStartTests.CreateTestAces();
            var storage     = new DatabaseStorage {
                Aces = aces, Memberships = memberships, Entities = entities, Messages = new List <Tuple <int, DateTime, byte[]> >()
            };

            var messageSenderManager = new MessageSenderManager(null, instanceName);
            var securitySystem       = new SecuritySystem(
                new MemoryDataProvider(storage),
                new TestMessageProvider(messageSenderManager, messageQueue, isReceiver),
                new MissingEntityHandler(),
                new SecurityConfiguration(),
                new MessagingOptions());

            securitySystem.Start();

            return(securitySystem);
        }