Exemple #1
0
        public Authenticator() : base(null, null)
        {
            UserRepository = new UserRepository();
            RoleRepository = new RoleRepository();

            RoleRepository.Add(new Role()
            {
                Name = "login", Active = true
            });
            RoleRepository.Add(new Role()
            {
                Name = "admin", Active = true
            });
            User user = new User()
            {
                Active = true, Login = "******", Password = "******"
            };

            user.Roles.Add(RoleRepository.FirstOrDefault(p => p.Name == "admin"));
            UserRepository.Add(user);

            ServiceFinder.GetInstance <IEventAggregator>().GetEvent <AuthenticationNeeded>().Subscribe((auser) =>
            {
                lock (authLock)
                {
                    IAuthenticator <IUser, IRole> authenticator = ServiceFinder.GetInstance <IAuthenticator <IUser, IRole> >();
                    if ((authenticator != null) && (authenticator.CurrentUser == null))
                    {
                        authenticator.Authenticate(null, null);
                    }
                }
            });
        }
        private void InitMenu()
        {
            MenuBuilder builder = new MenuBuilder(ServiceFinder.GetInstance <ICommandContainer>().Commands);

            foreach (MenuItem item in builder.Menu)
            {
                Items.Add(item);
            }
        }
 public MainMenu()
 {
     InitializeComponent();
     InitMenu();
     ServiceFinder.GetInstance <ICommandContainer>().Commands.CollectionChanged += (o, e) => {
         Items.Clear();
         InitMenu();
     };
 }
Exemple #4
0
        private void OnExit(object sender, ExitEventArgs e)
        {
            ILogger logger = ServiceFinder.GetInstance <ILogger>();

            if (logger != null)
            {
                logger.InfoFormat("Application exited with code {0}", e.ApplicationExitCode);
            }
        }
        protected override void InitializeModule()
        {
            EventCommand command = new EventCommand(null, "Súgó");

            command.Children.Add(new AboutCommand("Névjegy", "2014"));
            RegisterCommand(command);
            RegisterView <ModuleButton>("ButtonRegion");
            ServiceFinder.GetInstance <IEventAggregator>().GetEvent <AboutEvent>().Subscribe((sender) => {
                MessageBox.Show("Névjegy", "Névjegy");
            });
        }
        public ModuleButton()
        {
            InitializeComponent();

            ServiceFinder.GetInstance <IEventAggregator>().GetEvent <StringEvent>().Subscribe((str) =>
            {
                msg.Text = str;
            });

            send.Click += (o, e) => {
                ServiceFinder.GetInstance <IEventAggregator>().GetEvent <StringEvent>().Publish(msg.Text);
            };
        }
        private bool CheckUser()
        {
            ISession session = GetInstance <ISession>();

            if (session == null)
            {
                Log.Warn("No Session registered!");
            }
            IAuthenticator <IUser, IRole> authenticator = ServiceFinder.GetInstance <IAuthenticator <IUser, IRole> >();

            return((authenticator != null) && authenticator.CurrentUser != null);
            // session != null && session.User != null;
        }
        private void OnUserAuthenticated(IUser user)
        {
            Log.InfoFormat("{0} logged in", user.Login);

            foreach (string role in RequiredRoles)
            {
                if ((user.Roles == null) || user.Roles.Count(p => p.Name == role) == 0)
                {
                    Log.InfoFormat("{0} hasn't {1} role, aborting module {2}", user.Login, role, Name);
                    return;
                }
            }

            ServiceFinder.GetInstance <IEventAggregator>().GetEvent <CurrentUserChanged <IUser> >().Unsubscribe(OnUserAuthenticated);

            InitializeModule();
        }
Exemple #9
0
        public StateButton()
        {
            InitializeComponent();

            btn.IsEnabled = false;

            btn.IsEnabledChanged += (o, e) => {
                btn.Content = btn.IsEnabled ? "Üzenet érkezett" : "Várakozás üzenetre";
            };

            ServiceFinder.GetInstance <IEventAggregator>().GetEvent <StringEvent>().Subscribe((str) =>
            {
                _content      = str;
                btn.IsEnabled = !String.IsNullOrEmpty(_content);
            });

            btn.Click += (o, e) => { MessageBox.Show(_content, "Üzenet a másik modultól"); };
        }
Exemple #10
0
        public override IUser Authenticate(string login, string password)
        {
            string username, pass;
            IUser  user = null;

            ServiceFinder.GetInstance <ILogger>().DebugFormat("User authentication with {0}", GetType().Name);

            do
            {
                if (LoginWindow.Login(out username, out pass))
                {
                    user = base.Authenticate(username, pass);
                    if (user == null)
                    {
                        ServiceFinder.GetInstance <ILogger>().WarnFormat("Authentication failed {0}", username);
                    }
                }
                else
                {
                    break;
                }
            } while (user == null);
            return(user);
        }
Exemple #11
0
        public static void Main(params string[] args)
        {
            XmlConfigurator.Configure();
            ILog log = LogManager.GetLogger(typeof(Program));

            new Application(new ApplicationOptions <CmdLineOptions>()
            {
                CommandLineOptionsFactory = (Func <CmdLineOptions>)(() => new CmdLineOptions("CSIdentificationServer")),
                InitializeAction          = (Action <string[]>)(a =>
                {
                    BcDevices.MaxFrameCount = Settings.Default.MaxFrameCount;
                    Program.PrepareDirectories("CSIdentificationServer", log);
                    Program.InitializeBiometricEngines();
                    SetupUtils.SetupService <BcIdentificationServer, IdentificationServer>(a, "CSIdentificationServer", log, (Func <IPEndPoint, BcIdentificationServer>)(addressParts => ServiceFinder.GetInstance <BcIdentificationServer>(new Func <IEnumerable <BcIdentificationServer> >(BcIdentificationServer.LoadAll), (Func <BcIdentificationServer, bool>)(ds => ds.Ip == addressParts.Address.ToString() && ds.Port == addressParts.Port))));
                }),
                MainWorkerAction = new Action(IdentificationServer.WorkerThread),
                StopAction       = new Action(Program.OnStop),
                ServiceName      = "CSIdentificationServer"
            }, IdentificationServer.Logger).Run(args);
        }
Exemple #12
0
        public static void Main(params string[] args)
        {
            XmlConfigurator.Configure();
            ILog log = LogManager.GetLogger(typeof(DetectorServer));

            new Application(new ApplicationOptions <CmdLineOptions>()
            {
                CommandLineOptionsFactory = (Func <CmdLineOptions>)(() => new CmdLineOptions("CSDetectorServer")),
                InitializeAction          = (Action <string[]>)(stg =>
                {
                    Engine.Initialize(0U);
                    log.Debug((object)"Engine initialized");
                    BcDevices.MaxFrameCount = Settings.Default.MaxFrameCount;
                    Program.PrepareDirectories("CSDetectorServer", log);
                    SetupUtils.SetupService <BcDetectorServer, DetectorServer>(stg, "CSDetectorServer", log, (Func <IPEndPoint, BcDetectorServer>)(addressParts => ServiceFinder.GetInstance <BcDetectorServer>(new Func <IEnumerable <BcDetectorServer> >(BcDetectorServer.LoadAll), (Func <BcDetectorServer, bool>)(ds => ds.Ip == addressParts.Address.ToString() && ds.Port == addressParts.Port))));
                }),
                MainWorkerAction = new Action(DetectorServer.RefreshDevicesLoop),
                StopAction       = new Action(Program.OnStop),
                ServiceName      = "CSDetectorServer"
            }, DetectorServer.Logger).Run(args);
        }
Exemple #13
0
        public static void Main(params string[] args)
        {
            XmlConfigurator.Configure();
            ILog log = LogManager.GetLogger(typeof(Program));

            new Application(new ApplicationOptions <CmdLineOptions>()
            {
                CommandLineOptionsFactory = (Func <CmdLineOptions>)(() => new CmdLineOptions("CSVideoServer")),
                InitializeAction          = (Action <string[]>)(a =>
                {
                    BcDevices.MaxFrameCount = Settings.Default.MaxframeCount;
                    BcDevices.VideoWidth    = Convert.ToInt32(ConfigurationManager.AppSettings["VideoWidth"]);
                    BcDevices.VideoHeight   = Convert.ToInt32(ConfigurationManager.AppSettings["VideoHeight"]);
                    Program.PrepareDirectories("CSVideoServer");
                    SetupUtils.SetupService <BcVideoServer, VideoServerContractImpl>(a, "CSVideoServer", log, (Func <IPEndPoint, BcVideoServer>)(addressParts => ServiceFinder.GetInstance <BcVideoServer>(new Func <IEnumerable <BcVideoServer> >(BcVideoServer.LoadAll), (Func <BcVideoServer, bool>)(ds => ds.Ip == addressParts.Address.ToString() && ds.Port == addressParts.Port))));
                }),
                MainWorkerAction = (Action)null,
                StopAction       = new Action(Program.OnStop),
                ServiceName      = "CSVideoServer"
            }, VideoServerContractImpl.Instance.Logger).Run(args);
        }
 protected TService GetInstance <TService>()
 {
     return(ServiceFinder.GetInstance <TService>());
 }