public static void UpdateFeatureSettings()

in src/Microsoft.IIS.Administration.WebServer.Handlers/HandlersHelper.cs [52:142]


        public static void UpdateFeatureSettings(dynamic model, HandlersSection section)
        {
            if (model == null) {
                throw new ApiArgumentException("model");
            }
            if (section == null) {
                throw new ArgumentNullException("section");
            }
            
            try {
                if (model.allowed_access != null) {

                    Dictionary<string, bool> accessPolicyDictionary = null;
                    
                    try {
                        accessPolicyDictionary = JsonConvert.DeserializeObject<Dictionary<string, bool>>(model.allowed_access.ToString());
                    }
                    catch (JsonSerializationException e) {
                        throw new ApiArgumentException("allowed_access", e);
                    }

                    if (accessPolicyDictionary == null) {
                        throw new ApiArgumentException("allowed_access");
                    }

                    Dictionary<string, HandlerAccessPolicy> accessPolicyMap = new Dictionary<string, HandlerAccessPolicy>() {
                        { "read", HandlerAccessPolicy.Read },
                        { "write", HandlerAccessPolicy.Write },
                        { "execute", HandlerAccessPolicy.Execute },
                        { "source", HandlerAccessPolicy.Source },
                        { "script", HandlerAccessPolicy.Script }
                    };
                    
                    foreach (var key in accessPolicyMap.Keys) {
                        if (accessPolicyDictionary.ContainsKey(key)) {
                            if (accessPolicyDictionary[key]) {
                                section.AccessPolicy |= accessPolicyMap[key];
                            }
                            else {
                                section.AccessPolicy &= ~accessPolicyMap[key];
                            }
                        }
                    }
                }

                if (model.remote_access_prevention != null) {

                    Dictionary<string, bool> remoteAccessDictionary = null;

                    try {
                        remoteAccessDictionary = JsonConvert.DeserializeObject<Dictionary<string, bool>>(model.remote_access_prevention.ToString());
                    }
                    catch (JsonSerializationException e) {
                        throw new ApiArgumentException("remote_access_prevention", e);
                    }

                    if (remoteAccessDictionary == null) {
                        throw new ApiArgumentException("remote_access_prevention");
                    }

                    Dictionary<string, HandlerAccessPolicy> remoteAccessMap = new Dictionary<string, HandlerAccessPolicy>() {
                        { "read", HandlerAccessPolicy.NoRemoteRead },
                        { "write", HandlerAccessPolicy.NoRemoteWrite },
                        { "execute", HandlerAccessPolicy.NoRemoteExecute },
                        { "script", HandlerAccessPolicy.NoRemoteScript }
                    };
                    
                    foreach (var key in remoteAccessMap.Keys) {
                        if (remoteAccessDictionary.ContainsKey(key)) {
                            if (remoteAccessDictionary[key]) {
                                section.AccessPolicy |= remoteAccessMap[key];
                            }
                            else {
                                section.AccessPolicy &= ~remoteAccessMap[key];
                            }
                        }
                    }
                }

                if (model.metadata != null) {
                    DynamicHelper.If<OverrideMode>((object)model.metadata.override_mode, v => section.OverrideMode = v);
                }

            }
            catch (FileLoadException e) {
                throw new LockedException(section.SectionPath, e);
            }
            catch (DirectoryNotFoundException e) {
                throw new ConfigScopeNotFoundException(e);
            }
        }