Example #1
0
        private PermissionSet GetPermissionSetForApp(string readonlyDir, string appDir)
        {
            SecurityConfig scfg = null;

            try
            {
                //first load the config
                scfg = SecurityConfig.Load();
            }
            catch (Exception ex)
            {
                logger.Warn("Error loading security config", ex);
                //load the default permission set, and save it to file.
                scfg = new SecurityConfig(true);
                try
                {
                    scfg.Save();
                }
                catch (Exception ex1)
                {
                    logger.Warn("Error saving security config", ex1);
                }
            }

            //return scfg.GetGThreadPermissions(readonlyDir, appDir);
            PermissionSet ps = (PolicyLevel.CreateAppDomainLevel()).GetNamedPermissionSet("FullTrust");

            return(ps);
        }
Example #2
0
        public static SecurityConfig Load()
        {
            SecurityConfig scfg = new SecurityConfig();

            TextReader tr = null;

            try
            {
                tr = File.OpenText(DefaultConfigFile);
                string        xml = tr.ReadToEnd();
                PermissionSet ps  = new PermissionSet(null);
                ps.FromXml(SecurityElement.FromString(xml));
                scfg._GridThreadPermissions = ps;
            }
            finally
            {
                try
                {
                    if (tr != null)
                    {
                        tr.Close();
                    }
                }
                catch { }
            }
            return(scfg);
        }