/// <summary>
        /// Import an SSO application with specified name, key and file
        /// This code is borrowed from the MMC Snap-in for SSO
        /// </summary>
        private static void ImportSSOApp()
        {
            ConsoleColor currentColor = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Red;

            bool        flag        = true;
            XmlDocument xmlDocument = new XmlDocument();
            string      text        = string.Empty;
            string      toDecrypt   = string.Empty;

            try
            {
                SSO          sSO          = new SSO(_databaseServer, _databaseName, _company);
                StreamReader streamReader = new StreamReader(_encryptedFile);
                toDecrypt = streamReader.ReadToEnd();
                streamReader.Dispose();
                text = _appName;
                string[] applications = sSO.GetApplications();
                for (int i = 0; i < applications.Length; i++)
                {
                    if (applications[i].ToUpper() == text.ToUpper())
                    {
                        flag = false;
                    }
                }
                byte[] bytes;
                try
                {
                    bytes = Encoding.ASCII.GetBytes(sSO.Decrypt(toDecrypt, _encryptedFileKey));
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Error while decrypting the file to import, probably cause is the file hasn't been encrypted with the supplied key (error: " + exception.Message + ")");
                    Console.ForegroundColor = currentColor;
                    return;
                }
                MemoryStream memoryStream = new MemoryStream(bytes);
                try
                {
                    xmlDocument.Load(memoryStream);
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Error in import process: " + exception);
                    Console.ForegroundColor = currentColor;
                    return;
                }
                finally
                {
                    memoryStream.Dispose();
                }
                XmlElement    documentElement = xmlDocument.DocumentElement;
                XmlNodeList   xmlNodeList     = documentElement.SelectNodes("applicationData/add");
                List <string> list            = new List <string>();
                List <string> list2           = new List <string>();
                if (!flag)
                {
                    list.AddRange(sSO.GetKeys(text));
                    list2.AddRange(sSO.GetValues(text));
                }
                foreach (XmlNode xmlNode in xmlNodeList)
                {
                    string value  = xmlNode.SelectSingleNode("@key").Value;
                    string value2 = xmlNode.SelectSingleNode("@value").Value;
                    if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(value2))
                    {
                        if (!list.Contains(value))
                        {
                            list.Add(value);
                            list2.Add(value2);
                        }
                    }
                }
                sSO.CreateApplicationFieldsValues(text, list.ToArray(), list2.ToArray());
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error in import process: " + exception.Message);
                Console.ForegroundColor = currentColor;
            }
        }
        /// <summary>
        /// Get an array of all SSO applications in the store
        /// </summary>
        /// <returns></returns>
        private static string[] GetSSOAppList()
        {
            SSO sSO = new SSO(_databaseServer, _databaseName, _company);

            return(sSO.GetApplications());
        }