public virtual string DecryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection) { if (protectedSection == null) throw new ArgumentNullException ("protectedSection"); return protectedSection.EncryptSection (encryptedXml, protectionProvider); }
/////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// #if CACHE_PROVIDERS_IN_STATIC private static void InstantiateProviders() { if (_Providers != null) { return; } lock (_Lock) { if (_Providers != null) { return; } ProtectedConfigurationProviderCollection providers = new ProtectedConfigurationProviderCollection(); ProtectedConfigurationSection config = PrivilegedConfigurationManager.GetSection(BaseConfigurationRecord.RESERVED_SECTION_PROTECTED_CONFIGURATION) as ProtectedConfigurationSection; if (config != null) { foreach (DictionaryEntry de in config.ProviderNodes) { ProviderNode pn = de.Value as ProviderNode; if (pn == null) { continue; } providers.Add(pn.Provider); } } _Providers = providers; } }
private string CallEncryptOrDecrypt(bool doEncrypt, string xmlString, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { string str = null; WindowsImpersonationContext context = null; string assemblyQualifiedName = protectionProvider.GetType().AssemblyQualifiedName; ProviderSettings settings = protectedConfigSection.Providers[protectionProvider.Name]; if (settings == null) { throw System.Web.Util.ExceptionUtil.ParameterInvalid("protectionProvider"); } NameValueCollection parameters = settings.Parameters; if (parameters == null) { parameters = new NameValueCollection(); } string[] allKeys = parameters.AllKeys; string[] parameterValues = new string[allKeys.Length]; for (int i = 0; i < allKeys.Length; i++) { parameterValues[i] = parameters[allKeys[i]]; } if (this._Identity != null) { context = this._Identity.Impersonate(); } try { try { IRemoteWebConfigurationHostServer o = CreateRemoteObject(this._Server, this._Username, this._Domain, this._Password); try { str = o.DoEncryptOrDecrypt(doEncrypt, xmlString, protectionProvider.Name, assemblyQualifiedName, allKeys, parameterValues); } finally { while (Marshal.ReleaseComObject(o) > 0) { } } return str; } finally { if (context != null) { context.Undo(); } } } catch { } return str; }
public virtual string EncryptSection(string clearTextXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { return Host.EncryptSection(clearTextXml, protectionProvider, protectedConfigSection); }
public virtual string DecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { return Host.DecryptSection(encryptedXml, protectionProvider, protectedConfigSection); }
public override string EncryptSection(string clearTextXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { return base.EncryptSection(clearTextXml, protectionProvider, protectedConfigSection); }
private string CallEncryptOrDecrypt(bool doEncrypt, string xmlString, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { #if !FEATURE_PAL // FEATURE_PAL has no COM objects => no encryption // ROTORTODO: COM Objects are not implemented. // CORIOLISTODO: COM Objects are not implemented. ProviderSettings ps; NameValueCollection nvc; string [] paramKeys; string [] paramValues; string returnString = null; string typeName; WindowsImpersonationContext wiContext = null; //////////////////////////////////////////////////////////// // Step 1: Create list of parameters for the protection provider typeName = protectionProvider.GetType().AssemblyQualifiedName; ps = protectedConfigSection.Providers[protectionProvider.Name]; if (ps == null) throw ExceptionUtil.ParameterInvalid("protectionProvider"); nvc = ps.Parameters; if (nvc == null) nvc = new NameValueCollection(); paramKeys = nvc.AllKeys; paramValues = new string[paramKeys.Length]; for(int iter = 0; iter<paramKeys.Length; iter++) paramValues[iter] = nvc[paramKeys[iter]]; //////////////////////////////////////////////////////////// // Step 2: Set the impersonation if required if (_Identity != null) wiContext = _Identity.Impersonate(); try { try { ////////////////////////////////////////////////////////////////// // Step 3: Get the type and create the object on the remote server IRemoteWebConfigurationHostServer remoteSrv = CreateRemoteObject(_Server, _Username, _Domain, _Password); try { ////////////////////////////////////////////////////////////////// // Step 4: Call the API returnString = remoteSrv.DoEncryptOrDecrypt(doEncrypt, xmlString, protectionProvider.Name, typeName, paramKeys, paramValues); } finally { while (Marshal.ReleaseComObject(remoteSrv) > 0) { } // release the COM object } } finally { if (wiContext != null) wiContext.Undo(); // revert impersonation } } catch { } return returnString; #else // !FEATURE_PAL throw new NotImplementedException("ROTORTODO"); #endif // !FEATURE_PAL }
string IInternalConfigHost.EncryptSection (string clearXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection) { return protectedSection.EncryptSection (clearXml, protectionProvider); }
string IInternalConfigHost.EncryptSection(string clearXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection) { return(protectedSection.EncryptSection(clearXml, protectionProvider)); }
protected virtual string CallHostDecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfig) { return Host.DecryptSection(encryptedXml, protectionProvider, protectedConfig); }
internal void InitProtectedConfigurationSection() { if (!_flags[ProtectedDataInitialized]) { _protectedConfig = GetSection(BaseConfigurationRecord.RESERVED_SECTION_PROTECTED_CONFIGURATION, false, false) as ProtectedConfigurationSection; Debug.Assert(_protectedConfig != null, "<configProtectedData> section should always be available because it's a built-in section"); _flags[ProtectedDataInitialized] = true; } }
protected override string CallHostDecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfig) { return(base.CallHostDecryptSection(encryptedXml, protectionProvider, protectedConfig)); }
public override string EncryptSection(string clearTextXmlString, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { return this.CallEncryptOrDecrypt(true, clearTextXmlString, protectionProvider, protectedConfigSection); }
public override string DecryptSection(string encryptedXmlString, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { return this.CallEncryptOrDecrypt(false, encryptedXmlString, protectionProvider, protectedConfigSection); }
/// <summary> /// Gets or creates protected provider section /// </summary> /// <param name="config">The configuration</param> private static void CreateProtectProvider(Configuration config) { var protectedConfigurationSection = config.GetSection(ProtectionProviderSectionName) as ProtectedConfigurationSection; bool found = false; if (protectedConfigurationSection != null) { foreach (ProviderSettings provider in protectedConfigurationSection.Providers) { if (provider.Name.Equals(ProtectionProvider)) { found = true; break; } } } else { protectedConfigurationSection = new ProtectedConfigurationSection(); config.Sections.Add(ProtectionProviderSectionName, protectedConfigurationSection); } if (!found) { protectedConfigurationSection.Providers.Add( new ProviderSettings(ProtectionProvider, typeof(DpapiProtectedConfigurationProvider).AssemblyQualifiedName)); } }
protected override string CallHostDecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfig) { // Decrypt should always succeed in runtime. (VSWhidbey 429996) // Need to override in order to Assert before calling the base class method. return base.CallHostDecryptSection(encryptedXml, protectionProvider, protectedConfig); }
string IInternalConfigHost.DecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection) { return(protectedSection.DecryptSection(encryptedXml, protectionProvider)); }
protected override string CallHostDecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfig) { return base.CallHostDecryptSection(encryptedXml, protectionProvider, protectedConfig); }
string IInternalConfigHost.DecryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection) { return protectedSection.DecryptSection (encryptedXml, protectionProvider); }
protected override string CallHostDecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfig) { // Decrypt should always succeed in runtime. (VSWhidbey 429996) // Need to override in order to Assert before calling the base class method. return(base.CallHostDecryptSection(encryptedXml, protectionProvider, protectedConfig)); }
public override string DecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { return base.DecryptSection(encryptedXml, protectionProvider, protectedConfigSection); }
string IInternalConfigHost.EncryptSection(string clearTextXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) { throw new NotImplementedException(); }