Esempio n. 1
0
        internal static string GetDecryptionKey()
        {
            var machineKey = Config.GetDecryptionkey();
            var key        = $"{machineKey ?? string.Empty}{Host.GUID.Replace("-", string.Empty)}";

            return(FIPSCompliant.EncryptAES(key, key, Host.GUID));
        }
Esempio n. 2
0
        /// <summary>Handles the <see cref="ISettingsView.UpdatingSettings"/> event of the <see cref="Presenter{TView}.View"/> control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="UpdatingSettingsEventArgs"/> instance containing the event data.</param>
        private void View_UpdatingSettings(object sender, UpdatingSettingsEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(e.HigherLogicPassword))
                {
                    var encryptedPassword = FIPSCompliant.EncryptAES(e.HigherLogicPassword, Config.GetDecryptionkey(), Host.GUID, 1200);
                    HigherLogicFeedSettings.HigherLogicPassword.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, encryptedPassword);
                }

                HigherLogicFeedSettings.HigherLogicUsername.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.HigherLogicUserName);
                HigherLogicFeedSettings.HigherLogicIAMKey.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.HigherLogicIAMKey);
                HigherLogicFeedSettings.HigherLogicDiscussionKey.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.HigherLogicDiscussionKey);
                HigherLogicFeedSettings.MaxDiscussionsToRetrieve.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.MaxDiscussionsToRetrieve < 0 ? 0 : e.MaxDiscussionsToRetrieve);
                HigherLogicFeedSettings.IncludeStaff.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.IncludeStaff);
                HigherLogicFeedSettings.MaxContentLength.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.MaxContentLength < 0 ? 0 : e.MaxContentLength);
                HigherLogicFeedSettings.MaxSubjectLength.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.MaxSubjectLength < 0 ? 0 : e.MaxSubjectLength);
                HigherLogicFeedSettings.DateFormat.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.DateFormat);
                HigherLogicFeedSettings.HeaderTemplate.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.HeaderTemplate);
                HigherLogicFeedSettings.ItemTemplate.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.ItemTemplate);
                HigherLogicFeedSettings.FooterTemplate.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.FooterTemplate);
                HigherLogicFeedSettings.NoRecordsTemplate.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.NoRecordsTemplate);
                HigherLogicFeedSettings.AttachmentItemTemplate.Set(FeaturesController.SettingsPrefix, this.ModuleContext.Configuration, e.AttachmentItemTemplate);
            }
            catch (Exception exc)
            {
                this.ProcessModuleLoadException(exc);
            }
        }
Esempio n. 3
0
        public ActionResult Settings(Models.Settings settings)
        {
            var security = new PortalSecurity();

            if (!string.IsNullOrEmpty(settings.ZoneID))
            {
                settings.ZoneID = security.InputFilter(settings.ZoneID.Trim(), PortalSecurity.FilterFlag.NoMarkup);
                settings.ZoneID = FIPSCompliant.EncryptAES(settings.ZoneID, Config.GetDecryptionkey(), PortalSettings.GUID.ToString());
                ModuleContext.Configuration.ModuleSettings[FeatureController.SETTING_ZONEID] = settings.ZoneID;
            }
            else
            {
                ModuleContext.Configuration.ModuleSettings[FeatureController.SETTING_ZONEID] = string.Empty;
            }

            if (string.Equals(settings.ApiToken, "clear", StringComparison.OrdinalIgnoreCase))
            {
                ModuleContext.Configuration.ModuleSettings[FeatureController.SETTING_APITOKEN] = string.Empty;
            }
            else if (!string.IsNullOrEmpty(settings.ApiToken))
            {
                settings.ApiToken = security.InputFilter(settings.ApiToken.Trim(), PortalSecurity.FilterFlag.NoMarkup);
                settings.ApiToken = FIPSCompliant.EncryptAES(settings.ApiToken, Config.GetDecryptionkey(), PortalSettings.GUID.ToString());
                ModuleContext.Configuration.ModuleSettings[FeatureController.SETTING_APITOKEN] = settings.ApiToken;
            }

            if (!string.IsNullOrEmpty(settings.Email))
            {
                settings.Email = security.InputFilter(settings.Email.Trim(), PortalSecurity.FilterFlag.NoMarkup);
                ModuleContext.Configuration.ModuleSettings[FeatureController.SETTING_EMAIL] = settings.Email;
            }
            else
            {
                ModuleContext.Configuration.ModuleSettings[FeatureController.SETTING_EMAIL] = string.Empty;
            }

            return(RedirectToDefaultRoute());
        }
Esempio n. 4
0
        internal static SmtpServer GetDNNHostSettingsSmtpServer(int ModuleId)
        {
            SmtpServer smInfo = new SmtpServer();

            try
            {
                ModuleInfo mod = new ModuleController().GetModule(ModuleId, Null.NullInteger, false);
                if (mod != null)
                {
                    Dictionary <string, string> portalsettings = PortalController.Instance.GetPortalSettings(mod.PortalID);
                    //NS Fix for DNN v922 case: when server mode type 'My Website'
                    if (portalsettings.ContainsKey("SMTPmode") && portalsettings["SMTPmode"].ToLower() == "p")
                    {
                        string Server = portalsettings["SMTPServer"].ToString();
                        int    Port   = 25;
                        if (!string.IsNullOrEmpty(Server) && Server.Contains(":"))
                        {
                            try
                            {
                                Port   = int.Parse(Server.Split(':')[1]);
                                Server = Server.Split(':')[0];
                            }
                            catch { }
                        }
                        smInfo.Server   = Server;
                        smInfo.Port     = Port;
                        smInfo.Username = portalsettings["SMTPUsername"].ToString();
                        smInfo.Password = portalsettings["SMTPPassword"].ToString();
                        smInfo.SSL      = portalsettings["SMTPEnableSSL"].ToString().ToUpper() == "Y" ? true : false;
                        int Authentication = 0;
                        try
                        {
                            Authentication = int.Parse(portalsettings["SMTPAuthentication"].ToString());
                        }
                        catch { }

                        if (smInfo.SSL && smInfo.Port == 25)//SSL is Enable or true then assign Port number 465 else 25
                        {
                            smInfo.Port = 465;
                        }

                        if (Authentication == 0)
                        {
                            smInfo.Authentication = "Anonymous";
                        }
                        else if (Authentication == 1)
                        {
                            smInfo.Authentication = "Basic";
                        }
                        else
                        {
                            smInfo.Authentication = "NTLM";
                        }
                    }
                    //get dnn host and map it to smtpinfo and return the object
                    else
                    {
                        string Server = Host.SMTPServer;
                        int    Port   = 25;
                        if (!string.IsNullOrEmpty(Server) && Server.Contains(":"))
                        {
                            try
                            {
                                Port   = int.Parse(Server.Split(':')[1]);
                                Server = Server.Split(':')[0];
                            }
                            catch { }
                        }
                        smInfo.Server   = Server;
                        smInfo.Port     = Port;
                        smInfo.Username = Host.SMTPUsername;
                        smInfo.Password = FIPSCompliant.EncryptAES(Host.SMTPPassword, Config.GetDecryptionkey(), Host.GUID, 1000);
                        smInfo.SSL      = Host.EnableSMTPSSL;
                        int Authentication = 0;
                        try
                        {
                            Authentication = int.Parse(Host.SMTPAuthentication);
                        }
                        catch { }

                        if (smInfo.SSL && smInfo.Port == 25)//SSL is Enable or true then assign Port number 465 else 25
                        {
                            smInfo.Port = 465;
                        }

                        if (Authentication == 0)
                        {
                            smInfo.Authentication = "Anonymous";
                        }
                        else if (Authentication == 1)
                        {
                            smInfo.Authentication = "Basic";
                        }
                        else
                        {
                            smInfo.Authentication = "NTLM";
                        }
                    }
                    //smInfo.SmtpUniqueId = -1;
                }
            }
            catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); }
            return(smInfo);
        }
Esempio n. 5
0
        public static void UpdateSettings(int ModuleID, List <IUIData> Settings)
        {
            if (Settings != null && Settings.Count > 0)
            {
                SettingFactory.Update(Settings.Cast <Setting>().ToList());
                if (Settings.Where(a => a.Name == "Password").FirstOrDefault() != null)
                {
                    SettingFactory.UpdateValue(ModuleID, AppFactory.Identifiers.admin_notifications_email.ToString(), "Password", FIPSCompliant.EncryptAES(Settings.Where(a => a.Name == "Password").Select(a => new { a.Value }).FirstOrDefault().Value, Config.GetDecryptionkey(), Host.GUID, 1000));
                }

                CacheFactory.ClearCache();
            }
        }