static internal IInternalConfigRecord Create( InternalConfigRoot configRoot, IInternalConfigRecord parent, string configPath) { RuntimeConfigurationRecord configRecord = new RuntimeConfigurationRecord(); configRecord.Init(configRoot, (BaseConfigurationRecord) parent, configPath, null); return configRecord; }
private HybridDictionary _streamInfoUpdates; // List of StreamInfo, including the main config file, the configSource this record uses, and // new configSource stream added thru API static internal MgmtConfigurationRecord Create( IInternalConfigRoot configRoot, IInternalConfigRecord parent, string configPath, string locationSubPath) { MgmtConfigurationRecord configRecord = new MgmtConfigurationRecord(); configRecord.Init(configRoot, parent, configPath, locationSubPath); return configRecord; }
protected RuntimeConfig(IInternalConfigRecord configRecord, bool permitNull) { this._configRecord = configRecord; this._permitNull = permitNull; this._results = new object[0x18]; for (int i = 0; i < this._results.Length; i++) { this._results[i] = s_unevaluatedResult; } }
private void Init( IInternalConfigRoot configRoot, IInternalConfigRecord parent, string configPath, string locationSubPath) { base.Init(configRoot, (BaseConfigurationRecord) parent, configPath, locationSubPath); if ( IsLocationConfig && (MgmtParent._locationTags == null || !MgmtParent._locationTags.Contains(_locationSubPath))) { // By instantiating a "new" LocationSubPath class, we have implicitly // asked for one to be created _flags[ForceLocationWritten] = true; } // Copy all stream information so that we can model changes to ConfigSource InitStreamInfoUpdates(); }
public override void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { string streamName; bool flag = this.IsFile(configRecord.StreamName); if (flag) { streamName = UrlPath.ConvertFileNameToUrl(configRecord.StreamName); } else { streamName = configRecord.StreamName; } Evidence evidence = new Evidence(); evidence.AddHostEvidence<Url>(new Url(streamName)); evidence.AddHostEvidence<Zone>(Zone.CreateFromUrl(streamName)); if (!flag) { evidence.AddHostEvidence<Site>(Site.CreateFromUrl(streamName)); } permissionSet = SecurityManager.GetStandardSandbox(evidence); isHostReady = true; }
public virtual bool IsInitDelayed(IInternalConfigRecord configRecord) { return(Host.IsInitDelayed(configRecord)); }
public virtual void RequireCompleteInit(IInternalConfigRecord configRecord) {}
// Ensure that initialization has completed, while handling re-entrancy issues // for certain sections that may be used during initialization itself. private void EnsureInit(string configKey) { bool doInit = false; lock (this) { // If the user config is not initialized, then we must either: // a. Perform the initialization ourselves if no other thread is doing it, or // b. Wait for the initialization to complete if we know the section is not used during initialization itself, or // c. Ignore initialization if the section can be used during initialization. Note that GetSection() // returns null is initialization has not completed. if (!_isUserConfigInited) { if (!_isInitInProgress) { _isInitInProgress = true; doInit = true; } else { if (!IsSectionUsedInInit(configKey)) { // Wait for initialization to complete. Monitor.Wait(this); } } } } if (!doInit) { return; } try { try { // Initialize machine configuration. _machineConfigRecord = _configRoot.GetConfigRecord( ClientConfigurationHost.MachineConfigPath); _machineConfigRecord.ThrowIfInitErrors(); // Make machine configuration available to system.net sections // when application configuration is downloaded via http. _isMachineConfigInited = true; // If we add System.Net.Configuration we'll need to kick the initialization here // to prevent deadlocks in the networking classes by loading networking config // before making any networking requests. // // Any requests for sections used in initialization during the call to // EnsureConfigLoaded() will be served by _machine.config or will return null. //if (_isAppConfigHttp) //{ //} // Now load the rest of configuration var configHostPaths = (IInternalConfigHostPaths)_configHost; configHostPaths.RefreshConfigPaths(); string configPath; if (configHostPaths.HasLocalConfig) { configPath = ClientConfigurationHost.LocalUserConfigPath; } else { configPath = configHostPaths.HasRoamingConfig ? ClientConfigurationHost.RoamingUserConfigPath : ClientConfigurationHost.ExeConfigPath; } _completeConfigRecord = _configRoot.GetConfigRecord(configPath); _completeConfigRecord.ThrowIfInitErrors(); _isUserConfigInited = true; } catch (Exception e) { _initError = new ConfigurationErrorsException(SR.Config_client_config_init_error, e); throw _initError; } } catch { ConfigurationManager.SetInitError(_initError); _isMachineConfigInited = true; _isUserConfigInited = true; throw; } finally { lock (this) { try { // Notify ConfigurationSettings that initialization has fully completed, // even if unsuccessful. ConfigurationManager.CompleteConfigInit(); _isInitInProgress = false; } finally { // Wake up all threads waiting for initialization to complete. Monitor.PulseAll(this); } } } }
public virtual bool IsInitDelayed (IInternalConfigRecord configRecord) { throw new NotImplementedException (); }
public virtual bool IsInitDelayed(IInternalConfigRecord configRecord) { throw new NotImplementedException(); }
public object GetSection(string section, string configPath) { IInternalConfigRecord rec = GetConfigRecord(configPath); return(rec.GetSection(section)); }
public void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { permissionSet = new PermissionSet(null); isHostReady = true; }
// Delay init if we have not been asked to complete init, and it is a user.config file. public override bool IsInitDelayed(IInternalConfigRecord configRecord) { return !_initComplete && IsUserConfig(configRecord.ConfigPath); }
// Default implementation: ensure that the caller has full trust. bool IInternalConfigHost.IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) { return(TypeUtil.IsCallerFullTrust); }
public override void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { StaticGetRestrictedPermissions(configRecord, out permissionSet, out isHostReady); }
// Get the nearest ancestor path (including self) which contains unique configuration information. public string GetUniqueConfigPath(string configPath) { IInternalConfigRecord configRecord = GetUniqueConfigRecord(configPath); return(configRecord?.ConfigPath); }
public INConfiguration CreateConfigRecordConfiguration(IInternalConfigRecord configRecord, IList <string> fileNames) { return(new NConfigRecordConfiguration(configRecord, ConfigurationRepository, MergerRegistry, fileNames)); }
// security support void IInternalConfigHost.GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { permissionSet = null; isHostReady = true; }
private void OnConfigRemoved(object sender, InternalConfigEventArgs e) { try { IInternalConfigRecord configRecord = this._configRoot.GetConfigRecord(this._completeConfigRecord.ConfigPath); this._completeConfigRecord = configRecord; this._completeConfigRecord.ThrowIfInitErrors(); } catch (Exception exception) { this._initError = new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_client_config_init_error"), exception); ConfigurationManager.SetInitError(this._initError); throw this._initError; } }
public virtual bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) { }
// Delay init if we have not been asked to complete init, and it is a user.config file. public override bool IsInitDelayed(IInternalConfigRecord configRecord) { return(!_initComplete && IsUserConfig(configRecord.ConfigPath)); }
public virtual void GetRestrictedPermissions(IInternalConfigRecord configRecordout, System.Security.PermissionSet& permissionSetout, System.Boolean& isHostReady) { }
public virtual void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { throw new NotImplementedException(); }
// Methods public virtual bool IsInitDelayed(IInternalConfigRecord configRecord) { }
// // If config has been removed because initialization was not complete, // fetch a new configuration record. The record will be created and // completely initialized as RequireCompleteInit() will have been called // on the ClientConfigurationHost before we receive this event. // private void OnConfigRemoved(object sender, InternalConfigEventArgs e) { try { IInternalConfigRecord newConfigRecord = _configRoot.GetConfigRecord(_completeConfigRecord.ConfigPath); _completeConfigRecord = newConfigRecord; _completeConfigRecord.ThrowIfInitErrors(); } catch (Exception ex) { _initError = new ConfigurationErrorsException(SR.GetString(SR.Config_client_config_init_error), ex); ConfigurationManager.SetInitError(_initError); throw _initError; } }
bool IInternalConfigHost.IsInitDelayed(IInternalConfigRecord configRecord) { throw new NotImplementedException(); }
public bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) => true;
void IInternalConfigHost.RequireCompleteInit(IInternalConfigRecord configRecord) { throw new NotImplementedException(); }
public virtual void GetRestrictedPermissions (IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { throw new NotImplementedException (); }
// Default implementation: ensure that the caller has full trust. bool IInternalConfigHost.IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) { return TypeUtil.IsCallerFullTrust; }
// Methods public virtual bool IsInitDelayed(IInternalConfigRecord configRecord) {}
public override bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) { return(true); }
bool IInternalConfigHost.IsInitDelayed(IInternalConfigRecord configRecord) { return false; }
public virtual void RequireCompleteInit(IInternalConfigRecord configRecord) { Host.RequireCompleteInit(configRecord); }
void IInternalConfigHost.RequireCompleteInit(IInternalConfigRecord configRecord) { }
internal RuntimeConfig(IInternalConfigRecord configRecord) : this(configRecord, false) { }
public virtual bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) { return(host.IsFullTrustSectionWithoutAptcaAllowed(configRecord)); }
private void EnsureInit(string configKey) { bool flag = false; lock (this) { if (!this._isUserConfigInited) { if (!this._isInitInProgress) { this._isInitInProgress = true; flag = true; } else if (!this.IsSectionUsedInInit(configKey)) { Monitor.Wait(this); } } } if (flag) { try { try { string str; this._machineConfigRecord = this._configRoot.GetConfigRecord("MACHINE"); this._machineConfigRecord.ThrowIfInitErrors(); this._isMachineConfigInited = true; if (this._isAppConfigHttp) { ConfigurationManagerHelperFactory.Instance.EnsureNetConfigLoaded(); } this._configHost.RefreshConfigPaths(); if (this._configHost.HasLocalConfig) { str = "MACHINE/EXE/ROAMING_USER/LOCAL_USER"; } else if (this._configHost.HasRoamingConfig) { str = "MACHINE/EXE/ROAMING_USER"; } else { str = "MACHINE/EXE"; } this._completeConfigRecord = this._configRoot.GetConfigRecord(str); this._completeConfigRecord.ThrowIfInitErrors(); this._isUserConfigInited = true; } catch (Exception exception) { this._initError = new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_client_config_init_error"), exception); throw this._initError; } } catch { ConfigurationManager.SetInitError(this._initError); this._isMachineConfigInited = true; this._isUserConfigInited = true; throw; } finally { lock (this) { try { ConfigurationManager.CompleteConfigInit(); this._isInitInProgress = false; } finally { Monitor.PulseAll(this); } } } } }
public virtual void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { host.GetRestrictedPermissions(configRecord, out permissionSet, out isHostReady); }
public override void RequireCompleteInit(IInternalConfigRecord record) { // Loading information about user.config files is expensive, // so do it just once by locking. lock (this) { if (!_initComplete) { // Note that all future requests for config must be complete. _initComplete = true; // Throw out the ConfigPath for this exe. ClientConfigPaths.RefreshCurrent(); // Throw out our cached copy. _configPaths = null; // Force loading of user.config file information under lock. ClientConfigPaths configPaths = ConfigPaths; } } }
public NConfigRecordConfiguration(IInternalConfigRecord configRecord, IConfigurationRepository repository, INSectionMergerRegistry mergerRegistry, IList <string> fileNames) : base(repository, mergerRegistry, fileNames) { this.configRecord = configRecord; }
public virtual bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) { throw new NotImplementedException(); }
internal static void StaticGetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { isHostReady = HttpRuntime.IsTrustLevelInitialized; permissionSet = null; if (isHostReady && IsVirtualPathConfigPath(configRecord.ConfigPath)) { permissionSet = HttpRuntime.NamedPermissionSet; } }
public virtual void RequireCompleteInit(IInternalConfigRecord configRecord) { throw new NotImplementedException(); }
public override bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) { if (HostingEnvironment.IsHosted) { return HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted); } else { return Host.IsFullTrustSectionWithoutAptcaAllowed(configRecord); } }
public override void SubstituteSystemConfiguration(IConfigurationFactory factory, IList <string> fileNames) { if (OriginalConfiguration != null) { throw new InvalidOperationException("Web system default configuration already substituted."); } IInternalConfigSystem originalConfigSystem = SubstituteConfigurationSystem(factory, fileNames); // Web Part (10 level black magic starts here) var httpConfigurationSystem = new ReflectionAccessor(originalConfigSystem.GetType()); // Get original values. var configSystem = httpConfigurationSystem.GetField <IConfigSystem>("s_configSystem"); var replacingSystem = new NConfigSystemReplacement(configSystem, factory, fileNames); // Substitute to decorated instances. httpConfigurationSystem.SetField("s_configSystem", replacingSystem); httpConfigurationSystem.SetField("s_configRoot", replacingSystem.Root); // Refill system cache with new decorated records. var systemWebAss = httpConfigurationSystem.AccessedType.Assembly; var hostingEnviroment = new ReflectionAccessor(systemWebAss.GetType("System.Web.Hosting.HostingEnvironment")); string siteId = hostingEnviroment.GetProperty <string>("SiteID"); string configPath = "dmachine/webroot/" + siteId; var httpRuntime = new ReflectionAccessor(systemWebAss.GetType("System.Web.HttpRuntime")); var internalCache = new ReflectionAccessor(httpRuntime.GetProperty("CacheInternal")); var caches = internalCache.GetField("_caches") as IEnumerable ?? Enumerable.Empty <object>(); // Get all site specific configuration records keys for internal cache. var rootReplacement = replacingSystem.Root as NConfigRootReplacement; foreach (var cache in caches) { // Caches stored in array ala hash, so there is could be gaps. if (cache == null) { continue; } var cacheAcessor = new ReflectionAccessor(cache); lock (cacheAcessor.GetField("_lock")) { var entries = cacheAcessor.GetField("_entries") as IEnumerable ?? Enumerable.Empty <object>(); // entries is HashTable, so just iterate through foreach (DictionaryEntry entry in entries) { var keyAccessor = new ReflectionAccessor(entry.Key); // Only configuration cache entries replaced. if (!keyAccessor.GetProperty("Key").ToString().StartsWith(configPath)) { continue; } // Key and Value is the same object in the configuration cache entry. var entryValueAccesor = new ReflectionAccessor(keyAccessor.GetField("_value")); var runtimeConfigAccessor = new ReflectionAccessor(entryValueAccesor.GetField("_runtimeConfig")); IInternalConfigRecord replacingRecord = rootReplacement.CreateConfigRecord(runtimeConfigAccessor.GetField <IInternalConfigRecord>("_configRecord")); runtimeConfigAccessor.SetField("_configRecord", replacingRecord); runtimeConfigAccessor.SetField("_runtimeConfigLKG", null); } } } OriginalConfiguration = originalConfigSystem; }
internal RuntimeConfigLKG(IInternalConfigRecord configRecord) : base(configRecord, true) { }
// Ensure that initialization has completed, while handling re-entrancy issues // for certain sections that may be used during initialization itself. void EnsureInit(string configKey) { bool doInit = false; lock (this) { // If the user config is not initialized, then we must either: // a. Perform the initialization ourselves if no other thread is doing it, or // b. Wait for the initialization to complete if we know the section is not used during initialization itself, or // c. Ignore initialization if the section can be used during initialization. Note that GetSection() // returns null is initialization has not completed. if (!_isUserConfigInited) { if (!_isInitInProgress) { _isInitInProgress = true; doInit = true; } else if (!IsSectionUsedInInit(configKey)) { // Wait for initialization to complete. Monitor.Wait(this); } } } if (doInit) { try { try { try { // Initialize machine configuration. _machineConfigRecord = _configRoot.GetConfigRecord( ClientConfigurationHost.MachineConfigPath); _machineConfigRecord.ThrowIfInitErrors(); // Make machine configuration available to system.net sections // when application configuration is downloaded via http. _isMachineConfigInited = true; // // Prevent deadlocks in the networking classes by loading // networking config before making a networking request. // Any requests for sections used in initialization during // the call to EnsureConfigLoaded() will be served by // _machine.config or will return null. // if (_isAppConfigHttp) { ConfigurationManagerHelperFactory.Instance.EnsureNetConfigLoaded(); } // // Now load the rest of configuration // _configHost.RefreshConfigPaths(); string configPath; if (_configHost.HasLocalConfig) { configPath = ClientConfigurationHost.LocalUserConfigPath; } else if (_configHost.HasRoamingConfig) { configPath = ClientConfigurationHost.RoamingUserConfigPath; } else { configPath = ClientConfigurationHost.ExeConfigPath; } _completeConfigRecord = _configRoot.GetConfigRecord(configPath); _completeConfigRecord.ThrowIfInitErrors(); _isUserConfigInited = true; } catch (Exception e) { _initError = new ConfigurationErrorsException(SR.GetString(SR.Config_client_config_init_error), e); throw _initError; } } catch { ConfigurationManager.SetInitError(_initError); _isMachineConfigInited = true; _isUserConfigInited = true; throw; } } finally { lock (this) { try { // Notify ConfigurationSettings that initialization has fully completed, // even if unsuccessful. ConfigurationManager.CompleteConfigInit(); _isInitInProgress = false; } finally { // Wake up all threads waiting for initialization to complete. Monitor.PulseAll(this); } } } } }
public virtual void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) { Host.GetRestrictedPermissions(configRecord, out permissionSet, out isHostReady); }
bool IInternalConfigHost.IsInitDelayed(IInternalConfigRecord configRecord) { return(false); }
public virtual bool IsInitDelayed(IInternalConfigRecord configRecord) { return Host.IsInitDelayed(configRecord); }
public virtual bool IsFullTrustSectionWithoutAptcaAllowed (IInternalConfigRecord configRecord) { throw new NotImplementedException (); }
// // Note that if configRecord is null, we are the LKG for the ClientRuntimeConfig. // internal RuntimeConfigLKG(IInternalConfigRecord configRecord) : base(configRecord, true) {}
public virtual void RequireCompleteInit (IInternalConfigRecord configRecord) { throw new NotImplementedException (); }
public virtual bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) {}
public NConfigRecordReplacement(IInternalConfigRecord originalRecord, INConfiguration configuration) { this.originalRecord = originalRecord; this.configuration = configuration; }
public virtual void GetRestrictedPermissions(IInternalConfigRecord configRecordout , System.Security.PermissionSet& permissionSetout , System.Boolean& isHostReady) {}