Ejemplo n.º 1
0
        public ConfigUpdater(Configuration config, VLogger log, int frequency, Delegate method, Platform platform)
        {
            this.config = config;
            this.logger = log;
            this.frequency = frequency;
            this.methodToInvoke = method;
            this.platform = platform;

            tcb = ConfigSync;
            timer = new Timer(tcb, null, 500, frequency);

            if (System.IO.Directory.Exists(temporaryZipLocation)) // creating temporary directory location for downloading and holding zips
                Utils.CleanDirectory(logger, temporaryZipLocation);
            Utils.CreateDirectory(logger, temporaryZipLocation);

            this.status = new UpdateStatus(this.frequency);

            ConfigUpdaterWebService webService = new ConfigUpdaterWebService(logger, this);

            string homeIdPart = "";
            if (!string.IsNullOrWhiteSpace(Settings.HomeId))
                homeIdPart = "/" + Settings.HomeId;

            string url = Constants.InfoServiceAddress + homeIdPart + "/config";
            serviceHost = ConfigUpdaterWebService.CreateServiceHost(webService, new Uri(url));
            serviceHost.Open();
            Utils.structuredLog(logger, "I", "ConfigUpdaterWebService initiated at " + url);

        }
Ejemplo n.º 2
0
        public GuiService(Platform platform, Configuration config, HomeStoreInfo hsInfo, VLogger logger)
        {
            this.platform = platform;
            this.config = config;
            this.homeStoreInfo = hsInfo;
            this.logger = logger;

            string svcBase = Common.Constants.InfoServiceAddress + "/" ;

            //let us start serving the files
            string webBase = svcBase + Common.Constants.GuiServiceSuffixWeb;
            webFileServer = new WebFileServer(Common.Constants.DashboardRoot, webBase, logger);

            serviceHostWeb = OpenUnsafeServiceWeb(webBase + Common.Constants.AjaxSuffix);
        }
Ejemplo n.º 3
0
        private void AddSystemHighRules(Configuration config)
        {
            AccessRule systemHighaccessRule;
            foreach (string moduleName in config.allModules.Keys)
            {
                systemHighaccessRule = new AccessRule();
                systemHighaccessRule.ModuleName = moduleName;
                systemHighaccessRule.RuleName = Constants.SystemHigh;
                systemHighaccessRule.UserGroup = Constants.SystemHigh;
                systemHighaccessRule.AccessMode = AccessMode.Allow;
                systemHighaccessRule.DeviceList = new List<string> { "*" };
                systemHighaccessRule.TimeList = new List<TimeOfWeek> { new TimeOfWeek(-1, 0, 2400) };
                systemHighaccessRule.Priority = 0;
                AddAccessRule(systemHighaccessRule);
            }

            // Adding systemhigh access rules for "platform-based" modules GuiWeb and GuiWebSec
            systemHighaccessRule = new AccessRule();
            systemHighaccessRule.RuleName = Constants.SystemHigh;
            systemHighaccessRule.UserGroup = Constants.SystemHigh;
            systemHighaccessRule.AccessMode = AccessMode.Allow;
            systemHighaccessRule.DeviceList = new List<string> { "*" };
            systemHighaccessRule.TimeList = new List<TimeOfWeek> { new TimeOfWeek(-1, 0, 2400) };
            systemHighaccessRule.Priority = 0;
            systemHighaccessRule.ModuleName = Constants.GuiServiceSuffixWeb;
            AddAccessRule(systemHighaccessRule);

            systemHighaccessRule.ModuleName = Constants.GuiServiceSuffixWebSec;
            AddAccessRule(systemHighaccessRule);

            // Adding systemhigh access rules for scouts
            systemHighaccessRule = new AccessRule();
            systemHighaccessRule.RuleName = Constants.SystemHigh;
            systemHighaccessRule.UserGroup = Constants.SystemHigh;
            systemHighaccessRule.AccessMode = AccessMode.Allow;
            systemHighaccessRule.DeviceList = new List<string> { "*" };
            systemHighaccessRule.TimeList = new List<TimeOfWeek> { new TimeOfWeek(-1, 0, 2400) };
            systemHighaccessRule.Priority = 0;
            systemHighaccessRule.ModuleName = Constants.ScoutsSuffixWeb;
            AddAccessRule(systemHighaccessRule);

            

        }
Ejemplo n.º 4
0
        internal void Init(Configuration config)
        {
            groupMembershipFacts = new List<UserGroupMembershipFact>();
            resourceAccessFacts = new List<ResourceAccessFact>();
            policyAssertions = new List<Assertion>();

            //add the user system to group everyone
            UserGroupMembershipFact fact = new UserGroupMembershipFact(new StringPrincipal("usr:"******"grp:" + "everyone"));


            groupMembershipFacts.Add(fact);
            policyAssertions.Add(new Assertion(localAuthority, new Claim(fact)));

            // Adding AccessRules to allow SystemHigh to access all modules at all times with all devices
            AddSystemHighRules(config);

            //add group membership for other users
            foreach (UserInfo userInfo in config.GetAllUsers())
                AddUser(userInfo);

            //now add the access control rules
            foreach (var rule in config.GetAllPolicies())
                AddAccessRule(rule);

            // ..... now print these policies
            //PrintPolicies();
        }
Ejemplo n.º 5
0
        private void Shutdown()
        {
            this.StopAllModules();
            this.DisposeAllScouts();
            this.Dispose();
            if(homeService!=null) 
                homeService.Stop();


            this.runningScouts = null;
            this.runningModules = null;
            this.runningModulesStates = null;
            this.registeredPorts = null;
            this.registeredPorts = null;
            this.config = null;
            this.allAddinTokens = null;
            this.policyEngine = null;
            //this.gadgetListener = null;
            this.guiService = null;
            this.homeService = null;
            this.infoService = null;
            this.discoveryHelperService = null;
            this.heartbeatService = null;
            this.random = null;

            GC.Collect();

            //finally close the logger object
            if (logger != null)
                logger.Close();
        }
Ejemplo n.º 6
0
 public static List<ScoutInfo> GetConfigScouts(string configDir)
 {
     Settings.Initialize();
     Configuration config = new Configuration(configDir);
     config.ParseSettings();
     config.ReadConfiguration();
     return config.GetAllScouts();
 }
Ejemplo n.º 7
0
 public static Dictionary<string, ModuleInfo> GetConfigModules(string configDir)
 {
     Settings.Initialize();            
     Configuration config = new Configuration(configDir);
     config.ParseSettings();
     config.ReadConfiguration();
     return config.allModules;
 }
Ejemplo n.º 8
0
        private void Initialize(string[] arguments)
        {
            safeToGoOnline = false;
            guiService = null;
            homeService = null; 

            //initialize various data structures
            random = new Random();
            runningModules = new Dictionary<VModule, ModuleInfo>();
            runningScouts = new Dictionary<string, Tuple<ScoutInfo, IScout>>();
            runningModulesStates = new Dictionary<VModule, VModuleState>();
            registeredPorts = new Dictionary<VPort, VModule>();

            //this initializes the settings to what was default (in the code)
            Settings.Initialize();

            ArgumentsDictionary argsDict = ProcessArguments(arguments);

            //were we supplied a non-default configuration directory?
            if (!DEFAULT_COMMAND_LINE_ARG_VAL.Equals((string)argsDict["ConfigDir"]))
                Settings.SetParameter("ConfigDir", (string) argsDict["ConfigDir"]);
           
            //this overwrites the settings to what was in the configuration file
            config = new Configuration(Settings.ConfigDir);
            config.ParseSettings();

            //now, overwrite the settings with those on the command line
            foreach (var parameter in argsDict.Keys)
            {
                if (parameter.Equals("Help"))
                    continue;

                if (!DEFAULT_COMMAND_LINE_ARG_VAL.Equals((string)argsDict[parameter]))
                    config.UpdateConfSetting(parameter, argsDict[parameter]);
            }


            //initialize the logger
            logger = InitLogger(Settings.LogFile);
            logger.Log("Platform initialized");

            //set the logger for config and read remaining config fines
            config.SetLogger(logger);
            config.ReadConfiguration();

            //initialize the policy enginer
            policyEngine = new PolicyEngine(logger);
            policyEngine.Init(config);

            //rebuild the addin tokens
            this.rebuildAddInTokens();

            homeStoreInfo = new HomeStoreInfo(logger);
            _consoleHandler = new PlatformConsoleCtrlHandlerDelegate(ConsoleEventHandler);
            SetConsoleCtrlHandler(_consoleHandler, true);
        }
Ejemplo n.º 9
0
 public void setConfig(Configuration config)
 {
     this.config = config;
 }
Ejemplo n.º 10
0
        public void Reset(Configuration config, VLogger log, int freq, Delegate method)
        {
            lock (this)
            {
                this.config = config;
                this.logger = log;
                this.frequency = freq;
                this.timer.Change(this.frequency, this.frequency);
                this.methodToInvoke = method;

                this.serviceHost.Close();

                string homeIdPart = "";
                if (!string.IsNullOrWhiteSpace(Settings.HomeId))
                    homeIdPart = "/" + Settings.HomeId;
                ConfigUpdaterWebService webService = new ConfigUpdaterWebService(logger, this);
                string url = Constants.InfoServiceAddress + homeIdPart + "/config";
                serviceHost = ConfigUpdaterWebService.CreateServiceHost(webService, new Uri(url));
                serviceHost.Open();
                Utils.structuredLog(logger, "I", "ConfigUpdaterWebService initiated at " + url);
            }
        }