Esempio n. 1
0
        private static void InitializePolicyHierarchy()
        {
            string machinePolicyPath = Path.GetDirectoryName(Environment.GetMachineConfigPath());
            // note: use InternalGetFolderPath to avoid recursive policy initialization
            string userPolicyPath = Path.Combine(Environment.UnixGetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create), "mono");

            PolicyLevel enterprise = new PolicyLevel("Enterprise", PolicyLevelType.Enterprise);

            _level = enterprise;
            enterprise.LoadFromFile(Path.Combine(machinePolicyPath, "enterprisesec.config"));

            PolicyLevel machine = new PolicyLevel("Machine", PolicyLevelType.Machine);

            _level = machine;
            machine.LoadFromFile(Path.Combine(machinePolicyPath, "security.config"));

            PolicyLevel user = new PolicyLevel("User", PolicyLevelType.User);

            _level = user;
            user.LoadFromFile(Path.Combine(userPolicyPath, "security.config"));

            ArrayList al = new ArrayList();

            al.Add(enterprise);
            al.Add(machine);
            al.Add(user);

            _hierarchy = ArrayList.Synchronized(al);
            _level     = null;
        }
Esempio n. 2
0
        public static PolicyLevel LoadPolicyLevelFromFile(string path, PolicyLevelType type)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            PolicyLevel pl = null;

            try {
                pl = new PolicyLevel(type.ToString(), type);
                pl.LoadFromFile(path);
            }
            catch (Exception e) {
                throw new ArgumentException(Locale.GetText("Invalid policy XML"), e);
            }
            return(pl);
        }
Esempio n. 3
0
        private static void InitializePolicyHierarchy()
        {
            string      directoryName = Path.GetDirectoryName(Environment.GetMachineConfigPath());
            string      path          = Path.Combine(Environment.InternalGetFolderPath(Environment.SpecialFolder.ApplicationData), "mono");
            PolicyLevel policyLevel   = new PolicyLevel("Enterprise", PolicyLevelType.Enterprise);

            SecurityManager._level = policyLevel;
            policyLevel.LoadFromFile(Path.Combine(directoryName, "enterprisesec.config"));
            PolicyLevel policyLevel2 = new PolicyLevel("Machine", PolicyLevelType.Machine);

            SecurityManager._level = policyLevel2;
            policyLevel2.LoadFromFile(Path.Combine(directoryName, "security.config"));
            PolicyLevel policyLevel3 = new PolicyLevel("User", PolicyLevelType.User);

            SecurityManager._level = policyLevel3;
            policyLevel3.LoadFromFile(Path.Combine(path, "security.config"));
            SecurityManager._hierarchy = ArrayList.Synchronized(new ArrayList
            {
                policyLevel,
                policyLevel2,
                policyLevel3
            });
            SecurityManager._level = null;
        }