internal static object ToJsonModel(Site site, string path)
        {
            HandlersSection section = GetHandlersSection(site, path);

            HandlersId id = new HandlersId(site?.Id, path, section.IsLocallyStored);

            // Access Policy
            HandlerAccessPolicy accessPolicy = section.AccessPolicy;

            Dictionary <string, bool> allowedAccess = new Dictionary <string, bool>();

            allowedAccess.Add("read", accessPolicy.HasFlag(HandlerAccessPolicy.Read));
            allowedAccess.Add("write", accessPolicy.HasFlag(HandlerAccessPolicy.Write));
            allowedAccess.Add("execute", accessPolicy.HasFlag(HandlerAccessPolicy.Execute));
            allowedAccess.Add("source", accessPolicy.HasFlag(HandlerAccessPolicy.Source));
            allowedAccess.Add("script", accessPolicy.HasFlag(HandlerAccessPolicy.Script));

            Dictionary <string, bool> remoteAccessPrevention = new Dictionary <string, bool>();

            remoteAccessPrevention.Add("write", accessPolicy.HasFlag(HandlerAccessPolicy.NoRemoteWrite));
            remoteAccessPrevention.Add("read", accessPolicy.HasFlag(HandlerAccessPolicy.NoRemoteRead));
            remoteAccessPrevention.Add("execute", accessPolicy.HasFlag(HandlerAccessPolicy.NoRemoteExecute));
            remoteAccessPrevention.Add("script", accessPolicy.HasFlag(HandlerAccessPolicy.NoRemoteScript));

            var obj = new {
                id                       = id.Uuid,
                scope                    = site == null ? string.Empty : site.Name + path,
                metadata                 = ConfigurationUtility.MetadataToJson(section.IsLocallyStored, section.IsLocked, section.OverrideMode, section.OverrideModeEffective),
                allowed_access           = allowedAccess,
                remote_access_prevention = remoteAccessPrevention,
                website                  = SiteHelper.ToJsonModelRef(site)
            };

            return(Core.Environment.Hal.Apply(Defines.Resource.Guid, obj));
        }
示例#2
0
        public void SetHandlersAccessPolicy(ServerManager srvman, string fqPath, HandlerAccessPolicy policy)
        {
            var config = srvman.GetWebConfiguration(fqPath);
            //
            HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));

            //
            section.AccessPolicy = policy;
        }
 public void SetHandlersAccessPolicy(string fqPath, HandlerAccessPolicy policy)
 {
     //
     using (var srvman = GetServerManager())
     {
         var config = srvman.GetWebConfiguration(fqPath);
         //
         HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
         //
         section.AccessPolicy = policy;
         //
         srvman.CommitChanges();
     }
 }
		public void SetHandlersAccessPolicy(ServerManager srvman, string fqPath, HandlerAccessPolicy policy)
		{
			var config = srvman.GetWebConfiguration(fqPath);
			//
			HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
			//
			section.AccessPolicy = policy;
		}
		public void SetHandlersAccessPolicy(string fqPath, HandlerAccessPolicy policy)
		{
			//
			using (var srvman = GetServerManager())
			{
				var config = srvman.GetWebConfiguration(fqPath);
				//
				HandlersSection section = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection));
				//
				section.AccessPolicy = policy;
				//
				srvman.CommitChanges();
			}
		}