internal void CheckEncrypted()
        {
            bool encrypted = true;

            for (int i = 0; i < Connections.Count; i++)
            {
                Connection c = Connections[i];
                if (!IsBase64String(c.Password))
                {
                    //c.Password = EncryptValue(c.Password);
                    encrypted = false;
                    break; //can jump out since the encrypt reprocesses each connection
                }
            }
            if (!encrypted)
            {
                AppDomain currentDomain         = AppDomain.CurrentDomain;
                string    configFile            = currentDomain.SetupInformation.ConfigurationFile;
                ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
                fileMap.ExeConfigFilename = configFile;
                Configuration            config  = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
                DataConfigurationSection section = (DataConfigurationSection)config.Sections["DotNetNancy.Data"];
                for (int i = 0; i < section.Connections.Count; i++)
                {
                    Connection c = Connections[i];
                    if (!IsBase64String(c.Password))
                    {
                        c.Password = EncryptValue(c.Password);
                    }
                    section.Connections[i] = c;
                }
                config.Save(ConfigurationSaveMode.Modified);
            }
        }
Exemplo n.º 2
0
 static SqlHelper()
 {
     try
     {
         _commandTimeout = 30;                //implement the default value 30 seconds
         _dbConnections  = (Config.DataConfigurationSection)System.Configuration.ConfigurationManager.GetSection("DotNetNancy.Data");
         _dbConnections.CheckEncrypted();
     }
     catch (Exception ex)
     {
         _log.Error("Unable to read Config Section DotNetNancy.Data", ex);
         _dbConnections = null;
     }
 }