/// <summary>
        /// ReadConfigurationForCache method implementation
        /// </summary>
        private byte[] ReadConfigurationForCache()
        {
            MFAConfig           config        = CFGUtilities.ReadConfiguration();
            XmlConfigSerializer xmlserializer = new XmlConfigSerializer(typeof(MFAConfig));
            MemoryStream        stm           = new MemoryStream();

            using (StreamReader reader = new StreamReader(stm))
            {
                xmlserializer.Serialize(stm, config);
                stm.Position = 0;
                return(XORUtilities.XOREncryptOrDecrypt(stm.ToArray(), XORUtilities.XORKey));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// WriteToCache method implementation
        /// </summary>
        private static void WriteToCache(SIDsParametersRecord config)
        {
            XmlConfigSerializer xmlserializer = new XmlConfigSerializer(typeof(SIDsParametersRecord));
            MemoryStream        stm           = new MemoryStream();

            using (StreamReader reader = new StreamReader(stm))
            {
                xmlserializer.Serialize(stm, config);
                stm.Position = 0;
                byte[] byt = null;
                using (AESSystemEncryption aes = new AESSystemEncryption())
                {
                    byt = aes.Encrypt(stm.ToArray());
                }
                using (FileStream fs = new FileStream(SystemUtilities.SystemCacheFile, FileMode.Create, FileAccess.ReadWrite))
                {
                    fs.Write(byt, 0, byt.Length);
                    fs.Close();
                }
                return;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// GetConfig method implementation
        /// </summary>
        private static byte[] GetConfig(MFAConfig config)
        {
            using (AESSystemEncryption MSIS = new AESSystemEncryption())
            {
                config.KeysConfig.XORSecret = MSIS.Encrypt(config.KeysConfig.XORSecret);
                config.Hosts.ActiveDirectoryHost.Password = MSIS.Encrypt(config.Hosts.ActiveDirectoryHost.Password);
                config.MailProvider.Password = MSIS.Encrypt(config.MailProvider.Password);
            };
            XmlConfigSerializer xmlserializer = new XmlConfigSerializer(typeof(MFAConfig));
            MemoryStream        stm           = new MemoryStream();

            using (StreamReader reader = new StreamReader(stm))
            {
                xmlserializer.Serialize(stm, config);
                stm.Position = 0;
                byte[] bytes = null;
                using (AESSystemEncryption aes = new AESSystemEncryption())
                {
                    bytes = aes.Encrypt(stm.ToArray());
                }
                return(bytes);
            }
        }
 /// <summary>
 /// WriteConfigurationToCache method implementation
 /// </summary>
 internal void WriteConfigurationToCache(byte[] config)
 {
     try
     {
         using (FileStream fs = new FileStream(CFGUtilities.ConfigCacheFile, FileMode.Create, FileAccess.ReadWrite))
         {
             fs.Write(config, 0, config.Length);
             fs.Close();
         }
         if (SIDs.Loaded)
         {
             XmlConfigSerializer xmlserializer = new XmlConfigSerializer(typeof(SIDsParametersRecord));
             MemoryStream        stm           = new MemoryStream();
             byte[] bytes = null;
             using (StreamReader reader = new StreamReader(stm))
             {
                 xmlserializer.Serialize(stm, SIDs.GetSIDs());
                 stm.Position = 0;
                 using (AESSystemEncryption aes = new AESSystemEncryption())
                 {
                     bytes = aes.Encrypt(stm.ToArray());
                 }
             }
             using (FileStream fs = new FileStream(SystemUtilities.SystemCacheFile, FileMode.Create, FileAccess.ReadWrite))
             {
                 fs.Write(bytes, 0, bytes.Length);
                 fs.Close();
             }
         }
     }
     catch (Exception e)
     {
         _log.WriteEntry(string.Format("Error on WebAdminService Service WriteConfigurationToCache method : {0}.", e.Message), EventLogEntryType.Error, 2010);
         throw e;
     }
 }