示例#1
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);
            }
        }
示例#2
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));
        }
示例#3
0
        public ActionResult Settings()
        {
            var settings = new Models.Settings();

            var email  = ModuleContext.Configuration.ModuleSettings.GetValueOrDefault(FeatureController.SETTING_EMAIL, string.Empty);
            var zoneId = ModuleContext.Configuration.ModuleSettings.GetValueOrDefault(FeatureController.SETTING_ZONEID, string.Empty);

            if (!string.IsNullOrEmpty(zoneId))
            {
                zoneId = FIPSCompliant.DecryptAES(zoneId, Config.GetDecryptionkey(), PortalSettings.GUID.ToString());
            }

            settings.Email  = email;
            settings.ZoneID = zoneId;

            return(View(settings));
        }
示例#4
0
        public static List <IUIData> GetSettings(int ModuleID)
        {
            CacheFactory.ClearCache();
            Dictionary <string, IUIData> Settings = SettingFactory.GetDictionary(ModuleID, AppFactory.Identifiers.admin_notifications_email.ToString());
            List <dynamic> ServerTypes            = new List <dynamic>
            {
                new { AuthenticationType = "Anonymous" },
                new { AuthenticationType = "NTLM" },
                new { AuthenticationType = "Basic" }
            };

            Settings["Authentication"].Options      = ServerTypes;
            Settings["Authentication"].OptionsText  = "AuthenticationType";
            Settings["Authentication"].OptionsValue = "AuthenticationType";
            Settings["Password"].Value = FIPSCompliant.DecryptAES(Settings["Password"].Value, Config.GetDecryptionkey(), Host.GUID, 1000);
            return(Settings.Values.ToList());
        }
示例#5
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());
        }
示例#6
0
        /// <summary>Handles the <see cref="IModuleViewBase.Initialize"/> event of the <see cref="Presenter{TView}.View"/>.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void View_Initialize(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.Username) || string.IsNullOrEmpty(this.Password) || string.IsNullOrEmpty(this.IAmKey) ||
                    string.IsNullOrEmpty(this.DiscussionKey))
                {
                    this.View.Model.AdminMessage = this.LocalizeString("ModuleNeedsToBeConfigured.Text");
                    return;
                }

                var decryptedPassword = FIPSCompliant.DecryptAES(this.Password, Config.GetDecryptionkey(), Host.GUID, 1200);

                var authenticationToken = HigherLogicService.GetAuthenticationToken(this.Username, decryptedPassword, this.IAmKey);
                var postTask            = HigherLogicService.GetDiscussionPosts(
                    this.DiscussionKey,
                    this.MaxDiscussionsToRetrieve,
                    this.MaxSubjectLength,
                    this.MaxContentLength,
                    this.IncludeStaff,
                    this.IAmKey,
                    authenticationToken);

                postTask.Wait();

                var discussionPosts = postTask.Result.ToArray();

                var tokenReplace = new TokenReplace();

                this.View.Model.FooterTemplate = tokenReplace.ReplaceEnvironmentTokens(
                    this.FooterTemplate,
                    new Dictionary <string, string>(),
                    "HL").AsRawHtml();

                this.View.Model.HeaderTemplate = tokenReplace.ReplaceEnvironmentTokens(
                    this.HeaderTemplate,
                    new Dictionary <string, string>(),
                    "HL").AsRawHtml();

                if (!discussionPosts.Any())
                {
                    this.View.Model.NoRecordsTemplate = tokenReplace.ReplaceEnvironmentTokens(
                        this.NoRecordsTemplate,
                        new Dictionary <string, string>(),
                        "HL").AsRawHtml();

                    return;
                }

                this.View.Model.HasRecords = true;
                var renderAttachemnts = this.ItemTemplate.Contains("[HL:Discussion:Attachments]");

                this.View.Model.ItemTemplate = (from post in discussionPosts
                                                select tokenReplace.ReplaceEnvironmentTokens(
                                                    this.ItemTemplate,
                                                    this.BuildTokenDictionary(post, renderAttachemnts),
                                                    "HL"))
                                               .Aggregate((template, itemTemplate) => $"{template}{itemTemplate}")
                                               .AsRawHtml();
            }
            catch (AggregateException exc)
            {
                this.ProcessModuleLoadException(exc);
                this.View.Model.AdminMessage = exc.Message;
            }
        }
示例#7
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);
        }
示例#8
0
        /// <summary>Handles the <see cref="IModuleViewBase.Initialize"/> 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="EventArgs"/> instance containing the event data.</param>
        private void View_Initialize(object sender, EventArgs e)
        {
            try
            {
                this.View.Model.HigherLogicUserName =
                    HigherLogicFeedSettings.HigherLogicUsername.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.HigherLogicUsername.DefaultValue);

                var encryptedPassword =
                    HigherLogicFeedSettings.HigherLogicPassword.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.HigherLogicPassword.DefaultValue);

                this.View.Model.HigherLogicPassword = FIPSCompliant.DecryptAES(encryptedPassword, Config.GetDecryptionkey(), Host.GUID, 1200);

                this.View.Model.HigherLogicIAMKey =
                    HigherLogicFeedSettings.HigherLogicIAMKey.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.HigherLogicIAMKey.DefaultValue);

                this.View.Model.HigherLogicDiscussionKey =
                    HigherLogicFeedSettings.HigherLogicDiscussionKey.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.HigherLogicDiscussionKey.DefaultValue);

                this.View.Model.MaxDiscussionsToRetrieve =
                    HigherLogicFeedSettings.MaxDiscussionsToRetrieve.GetValueAsInt32For(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.MaxDiscussionsToRetrieve.DefaultValue);

                this.View.Model.MaxContentLength =
                    HigherLogicFeedSettings.MaxContentLength.GetValueAsInt32For(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.MaxContentLength.DefaultValue);

                this.View.Model.MaxSubjectLength =
                    HigherLogicFeedSettings.MaxSubjectLength.GetValueAsInt32For(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.MaxSubjectLength.DefaultValue);

                this.View.Model.IncludeStaff =
                    HigherLogicFeedSettings.IncludeStaff.GetValueAsBooleanFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.IncludeStaff.DefaultValue);

                this.View.Model.DateFormat =
                    HigherLogicFeedSettings.DateFormat.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.DateFormat.DefaultValue);

                if (string.IsNullOrEmpty(this.View.Model.HigherLogicUserName) || string.IsNullOrEmpty(this.View.Model.HigherLogicPassword) ||
                    string.IsNullOrEmpty(this.View.Model.HigherLogicIAMKey) || string.IsNullOrEmpty(this.View.Model.HigherLogicDiscussionKey))
                {
                    this.View.Model.HeaderTemplate         = Localization.GetString("HeaderTemplate.Text", $"/DesktopModules/Engage/{Localization.LocalResourceDirectory}/{Localization.LocalSharedResourceFile}");
                    this.View.Model.ItemTemplate           = Localization.GetString("ItemTemplate.Text", $"/DesktopModules/Engage/{Localization.LocalResourceDirectory}/{Localization.LocalSharedResourceFile}");
                    this.View.Model.FooterTemplate         = Localization.GetString("FooterTemplate.Text", $"/DesktopModules/Engage/{Localization.LocalResourceDirectory}/{Localization.LocalSharedResourceFile}");
                    this.View.Model.NoRecordsTemplate      = Localization.GetString("NoRecordsTemplate.Text", $"/DesktopModules/Engage/{Localization.LocalResourceDirectory}/{Localization.LocalSharedResourceFile}");
                    this.View.Model.AttachmentItemTemplate = Localization.GetString("AttachmentItemTemplate.Text", $"/DesktopModules/Engage/{Localization.LocalResourceDirectory}/{Localization.LocalSharedResourceFile}");

                    return;
                }

                this.View.Model.HeaderTemplate =
                    HigherLogicFeedSettings.HeaderTemplate.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.HeaderTemplate.DefaultValue);

                this.View.Model.ItemTemplate =
                    HigherLogicFeedSettings.ItemTemplate.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.ItemTemplate.DefaultValue);

                this.View.Model.FooterTemplate =
                    HigherLogicFeedSettings.FooterTemplate.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.FooterTemplate.DefaultValue);

                this.View.Model.NoRecordsTemplate =
                    HigherLogicFeedSettings.NoRecordsTemplate.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.NoRecordsTemplate.DefaultValue);

                this.View.Model.AttachmentItemTemplate =
                    HigherLogicFeedSettings.AttachmentItemTemplate.GetValueAsStringFor(
                        FeaturesController.SettingsPrefix,
                        this.ModuleContext.Configuration,
                        HigherLogicFeedSettings.AttachmentItemTemplate.DefaultValue);
            }
            catch (Exception exc)
            {
                this.ProcessModuleLoadException(exc);
            }
        }
示例#9
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();
            }
        }