/// <summary>
        /// ExportMFAMailTemplates method implementation
        /// </summary>
        internal static void ExportMFAMailTemplates(PSHost host, int lcid)
        {
            MFAConfig config = CFGUtilities.ReadConfiguration(host);
            Dictionary <string, string> data      = new Dictionary <string, string>();
            ResourcesLocale             Resources = new ResourcesLocale(lcid);

            data.Add("MailOTPContent.html", Resources.GetString(ResourcesLocaleKind.CommonMail, "MailOTPContent"));
            data.Add("MailKeyContent.html", Resources.GetString(ResourcesLocaleKind.CommonMail, "MailKeyContent"));
            data.Add("MailAdminContent.html", Resources.GetString(ResourcesLocaleKind.CommonMail, "MailAdminContent"));
            data.Add("MailNotifications.html", Resources.GetString(ResourcesLocaleKind.CommonMail, "MailNotifications"));

            if (WebAdminManagerClient.ExportMailTemplates(config, lcid, data))
            {
                CFGUtilities.WriteConfiguration(host, config);
                CFGUtilities.BroadcastNotification(config, NotificationsKind.ConfigurationReload, Environment.MachineName, true, true);
            }
        }
        /// <summary>
        /// InstallMFASample method implementation
        /// </summary>
        internal static void InstallMFASample(PSHost host, FlatSampleKind kind, bool reset = false)
        {
            MFAConfig config = CFGUtilities.ReadConfiguration(host);

            switch (kind)
            {
            case FlatSampleKind.QuizProvider:
                if (!reset)
                {
                    config.ExternalProvider.FullQualifiedImplementation = "Neos.IdentityServer.MultiFactor.Samples.QuizProviderSample, Neos.IdentityServer.MultiFactor.Samples, Version = 3.0.0.0, Culture = neutral, " + Utilities.GetAssemblyPublicKey();
                }
                else
                {
                    config.ExternalProvider.FullQualifiedImplementation = "";
                }
                break;

            case FlatSampleKind.CaesarEnryption:
                if (!reset)
                {
                    config.KeysConfig.CustomFullyQualifiedImplementation = "Neos.IdentityServer.MultiFactor.Samples.CaesarKeyManagerActivator, Neos.IdentityServer.MultiFactor.Samples, Version=3.0.0.0, Culture=neutral, " + Utilities.GetAssemblyPublicKey();
                    config.KeysConfig.KeyFormat = SecretKeyFormat.CUSTOM;
                }
                else
                {
                    config.KeysConfig.CustomFullyQualifiedImplementation = "";
                    config.KeysConfig.KeyFormat = SecretKeyFormat.RNG;
                }
                break;

            case FlatSampleKind.InMemoryStorage:
                if (!reset)
                {
                    config.Hosts.CustomStoreHost.KeysRepositoryFullyQualifiedImplementation = "Neos.IdentityServer.MultiFactor.Samples.InMemoryKeys2RepositoryService, Neos.IdentityServer.MultiFactor.Samples, Version=3.0.0.0, Culture=neutral, " + Utilities.GetAssemblyPublicKey();
                    config.Hosts.CustomStoreHost.DataRepositoryFullyQualifiedImplementation = "Neos.IdentityServer.MultiFactor.Samples.InMemoryDataRepositoryService, Neos.IdentityServer.MultiFactor.Samples, Version=3.0.0.0, Culture=neutral, " + Utilities.GetAssemblyPublicKey();
                    config.StoreMode = DataRepositoryKind.Custom;
                }
                else
                {
                    config.Hosts.CustomStoreHost.KeysRepositoryFullyQualifiedImplementation = "";
                    config.Hosts.CustomStoreHost.DataRepositoryFullyQualifiedImplementation = "";
                    config.StoreMode = DataRepositoryKind.ADDS;
                }
                break;

            case FlatSampleKind.SMSProvider:
                if (!reset)
                {
                    config.ExternalProvider.FullQualifiedImplementation = "Neos.IdentityServer.MultiFactor.Samples.NeosSMSProvider, Neos.IdentityServer.MultiFactor.Samples, Version=3.0.0.0, Culture=neutral, " + Utilities.GetAssemblyPublicKey();
                }
                else
                {
                    config.ExternalProvider.FullQualifiedImplementation = "";
                }
                break;

            case FlatSampleKind.TOTPProvider:
                if (!reset)
                {
                    config.OTPProvider.FullQualifiedImplementation = "Neos.IdentityServer.MultiFactor.Samples.NeosOTPProvider430, Neos.IdentityServer.MultiFactor.Samples, Version=3.0.0.0, Culture=neutral, " + Utilities.GetAssemblyPublicKey();
                }
                else
                {
                    config.OTPProvider.FullQualifiedImplementation = "";
                }
                break;

            case FlatSampleKind.CustomPresentation:
                if (!reset)
                {
                    config.CustomAdapterPresentation = "Neos.IdentityServer.MultiFactor.Samples.AdapterPresentationCustom, Neos.IdentityServer.MultiFactor.PresentationSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken = 711047a08ea8edb3";
                }
                else
                {
                    config.CustomAdapterPresentation = "";
                }
                break;
            }
            CFGUtilities.WriteConfiguration(host, config);
            CFGUtilities.BroadcastNotification(config, NotificationsKind.ConfigurationReload, Environment.MachineName, true, true);
        }
        /// <summary>
        /// SetMFACredentials method implementation
        /// </summary>
        internal static void SetMFACredentials(PSHost host, byte kind, string value, bool clearvalue = false)
        {
            MFAConfig config = CFGUtilities.ReadConfigurationFromADFSStore(host);

            if (config == null)
            {
                return;
            }
            switch (kind)
            {
            case 0x00:
                using (SystemEncryption MSIS = new SystemEncryption())
                {
                    if (clearvalue)
                    {
                        config.Hosts.ActiveDirectoryHost.Password      = string.Empty;
                        config.Hosts.ActiveDirectoryHost.Account       = string.Empty;
                        config.Hosts.ActiveDirectoryHost.DomainAddress = string.Empty;
                        config.Hosts.SQLServerHost.SQLAccount          = string.Empty;
                        config.Hosts.SQLServerHost.SQLPassword         = string.Empty;
                        config.MailProvider.Password  = string.Empty;
                        config.MailProvider.UserName  = string.Empty;
                        config.MailProvider.Anonymous = true;
                        config.KeysConfig.XORSecret   = XORUtilities.DefaultKey;
                    }
                    else
                    {
                        config.KeysConfig.XORSecret = MSIS.Encrypt(config.KeysConfig.XORSecret, "Pass Phrase Encryption");
                        config.Hosts.ActiveDirectoryHost.Password = MSIS.Encrypt(config.Hosts.ActiveDirectoryHost.Password, "ADDS Super Account Password");
                        config.Hosts.SQLServerHost.SQLPassword    = MSIS.Encrypt(config.Hosts.SQLServerHost.SQLPassword, "SQL Super Account Password");
                        config.MailProvider.Password = MSIS.Encrypt(config.MailProvider.Password, "Mail Provider Account Password");
                        config.DefaultPin            = MSIS.Encrypt(config.DefaultPin, "Default Users Pin");
                        config.AdministrationPin     = MSIS.Encrypt(config.AdministrationPin, "Administration Pin");

                        if (!string.IsNullOrEmpty(value))
                        {
                            host.UI.WriteWarningLine("Block Updates not allowed, values where only encrypted !");
                        }
                    }
                }
                break;

            case 0x01:
                using (SystemEncryption MSIS = new SystemEncryption())
                {
                    if (clearvalue)
                    {
                        config.Hosts.ActiveDirectoryHost.Password      = string.Empty;
                        config.Hosts.ActiveDirectoryHost.Account       = string.Empty;
                        config.Hosts.ActiveDirectoryHost.DomainAddress = string.Empty;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(value))
                        {
                            config.Hosts.ActiveDirectoryHost.Password = MSIS.Encrypt(config.Hosts.ActiveDirectoryHost.Password, "ADDS Super Account Password");
                            host.UI.WriteWarningLine("Empty value not allowed, value was only encrypted !");
                        }
                        else
                        {
                            config.Hosts.ActiveDirectoryHost.Password = MSIS.Encrypt(value, "ADDS Super Account Password");
                        }
                    }
                }
                break;

            case 0x02:
                using (SystemEncryption MSIS = new SystemEncryption())
                {
                    if (clearvalue)
                    {
                        config.MailProvider.Password  = string.Empty;
                        config.MailProvider.UserName  = string.Empty;
                        config.MailProvider.Anonymous = true;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(value))
                        {
                            config.MailProvider.Password = MSIS.Encrypt(config.MailProvider.Password, "Mail Provider Account Password");
                            host.UI.WriteWarningLine("Empty value not allowed, value was only encrypted !");
                        }
                        else
                        {
                            config.MailProvider.Password = MSIS.Encrypt(value, "Mail Provider Account Password");
                        }
                    }
                }
                break;

            case 0x03:
                using (SystemEncryption MSIS = new SystemEncryption())
                {
                    if (clearvalue)
                    {
                        config.KeysConfig.XORSecret = XORUtilities.DefaultKey;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(value))
                        {
                            config.KeysConfig.XORSecret = MSIS.Encrypt(config.KeysConfig.XORSecret, "Pass Phrase Encryption");
                            config.DefaultPin           = MSIS.Encrypt(config.DefaultPin, "Default Users Pin");
                            config.AdministrationPin    = MSIS.Encrypt(config.AdministrationPin, "Administration Pin");
                            host.UI.WriteWarningLine("Empty value not allowed, value was only encrypted !");
                        }
                        else
                        {
                            config.KeysConfig.XORSecret = MSIS.Encrypt(value, "Pass Phrase Encryption");
                        }
                    }
                }
                break;

            case 0x04:
                using (SystemEncryption MSIS = new SystemEncryption())
                {
                    if (clearvalue)
                    {
                        config.Hosts.SQLServerHost.SQLAccount  = string.Empty;
                        config.Hosts.SQLServerHost.SQLPassword = string.Empty;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(value))
                        {
                            config.Hosts.SQLServerHost.SQLPassword = MSIS.Encrypt(config.Hosts.SQLServerHost.SQLPassword, "SQL Super Account Password");
                            host.UI.WriteWarningLine("Empty value not allowed, value was only encrypted !");
                        }
                        else
                        {
                            config.Hosts.SQLServerHost.SQLPassword = MSIS.Encrypt(value, "SQL Super Account Password");
                        }
                    }
                }
                break;
            }
            CFGUtilities.WriteConfigurationToDatabase(host, config, false);
            CFGUtilities.BroadcastNotification(config, NotificationsKind.ConfigurationCreated, Environment.MachineName, true, true);
        }
 /// <summary>
 /// BroadcastNotification method implmentation
 /// </summary>
 internal static void BroadcastNotification(MFAConfig config, NotificationsKind kind, string message, bool local = true, bool dispatch = true)
 {
     CFGUtilities.BroadcastNotification(config, kind, message, local, dispatch);
 }