/// <summary>
        /// UpgradeServersConfig method implementation (Client)
        /// </summary>
        private void UpgradeServersConfig(NamedPipeRegistryRecord reg)
        {
            NamedPipeRegistryRecord rec = FarmUtilities.InitServerNodeConfiguration(reg);

            MFAConfig      cfg = CFGUtilities.ReadConfiguration(null);
            ADFSServerHost svr = null;

            if (cfg.Hosts.ADFSFarm.Servers.Exists(s => s.FQDN.ToLower().Equals(rec.FQDN.ToLower())))
            {
                svr = cfg.Hosts.ADFSFarm.Servers.Find(s => s.FQDN.ToLower().Equals(rec.FQDN.ToLower()));
                cfg.Hosts.ADFSFarm.Servers.Remove(svr);
            }
            svr                           = new ADFSServerHost();
            svr.FQDN                      = rec.FQDN;
            svr.CurrentVersion            = rec.CurrentVersion;
            svr.CurrentBuild              = rec.CurrentBuild;
            svr.CurrentMajorVersionNumber = rec.CurrentMajorVersionNumber;
            svr.CurrentMinorVersionNumber = rec.CurrentMinorVersionNumber;
            svr.InstallationType          = rec.InstallationType;
            svr.ProductName               = rec.ProductName;
            svr.NodeType                  = rec.NodeType;
            svr.BehaviorLevel             = rec.BehaviorLevel;
            svr.HeartbeatTmeStamp         = rec.HeartbeatTimestamp;
            cfg.Hosts.ADFSFarm.Servers.Add(svr);
            CFGUtilities.WriteConfiguration(null, cfg);

            using (MailSlotClient mailslot = new MailSlotClient())
            {
                mailslot.Text = Environment.MachineName;
                mailslot.SendNotification(NotificationsKind.ConfigurationReload);
            }
        }
        /// <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));
            }
        }
        /// <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);
            }
        }
예제 #4
0
        /// <summary>
        /// ReloadData method implementation
        /// </summary>
        internal void ReloadData()
        {
            this.SuspendLayout();
            this.Cursor   = Cursors.WaitCursor;
            _notifenabled = false;
            try
            {
                ComponentResourceManager resources = new ComponentResourceManager(typeof(ServiceViewControl));
                this.label1.Text = resources.GetString("label1.Text");
                this.label2.Text = resources.GetString("label2.Text");
                this.label3.Text = resources.GetString("label3.Text");
                this.label4.Text = resources.GetString("label4.Text");

                ((IMMCRefreshData)ControlInstance).DoRefreshData();
                bool isconfigured = ManagementService.ADFSManager.IsFarmConfigured();
                if (isconfigured)
                {
                    foreach (ADFSServerControl srv in _lst)
                    {
                        this.tableLayoutPanel.Controls.Remove(srv);
                    }
                    _lst.Clear();

                    int       i   = 3;
                    MFAConfig cfg = CFGUtilities.ReadConfiguration(null);
                    foreach (ADFSServerHost srv in cfg.Hosts.ADFSFarm.Servers)
                    {
                        bool isok             = ManagementService.ADFSManager.IsRunning(srv.FQDN);
                        ADFSServerControl crt = new ADFSServerControl(this, srv, isok);
                        _lst.Add(crt);
                        this.tableLayoutPanel.Invoke((MethodInvoker) delegate { this.tableLayoutPanel.Controls.Add(crt, 0, i); });
                        i++;
                    }
                }
            }
            finally
            {
                _notifenabled = true;
                this.Cursor   = Cursors.Default;
                this.ResumeLayout();
            }
        }
        /// <summary>
        /// ResetWebThemesList method implementation
        /// </summary>
        internal static void ResetWebThemesList(PSHost host)
        {
            MFAConfig config = CFGUtilities.ReadConfiguration(host);

            WebThemeManagerClient.ResetThemesList(config);
        }
        /// <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);
        }