Beispiel #1
0
        virtual public void LoadValuesFromJson(JToken jsonConfig, bool useProtectionService = false)
        {
            IProtectionService ps = null;

            if (useProtectionService)
            {
                ps = protectionService;
            }
            configData.LoadValuesFromJson(jsonConfig, ps);
            if (string.IsNullOrWhiteSpace(configData.SiteLink.Value))
            {
                configData.SiteLink.Value = DefaultSiteLink;
            }

            if (!configData.SiteLink.Value.EndsWith("/", StringComparison.Ordinal))
            {
                configData.SiteLink.Value += "/";
            }

            // reset site link to default if it's a legacy (defunc link)
            if (LegacySiteLinks != null && LegacySiteLinks.Contains(configData.SiteLink.Value))
            {
                logger.Debug(string.Format("changing legacy site link from {0} to {1}", configData.SiteLink.Value, DefaultSiteLink));
                configData.SiteLink.Value = DefaultSiteLink;
            }

            // check whether the site link is well-formatted
            var siteUri = new Uri(configData.SiteLink.Value);

            SiteLink = configData.SiteLink.Value;
        }
Beispiel #2
0
        virtual public void LoadValuesFromJson(JToken jsonConfig, bool useProtectionService = false)
        {
            IProtectionService ps = null;

            if (useProtectionService)
            {
                ps = protectionService;
            }
            configData.LoadValuesFromJson(jsonConfig, ps);
            if (string.IsNullOrWhiteSpace(configData.SiteLink.Value))
            {
                configData.SiteLink.Value = DefaultSiteLink;
            }
            if (!configData.SiteLink.Value.EndsWith("/"))
            {
                configData.SiteLink.Value += "/";
            }

            var match = Regex.Match(configData.SiteLink.Value, "^https?:\\/\\/[\\w\\-\\/\\.]+$");

            if (!match.Success)
            {
                throw new Exception(string.Format("\"{0}\" is not a valid URL.", configData.SiteLink.Value));
            }

            SiteLink = configData.SiteLink.Value;
        }
Beispiel #3
0
 public virtual void LoadFromSavedConfiguration(JToken jsonConfig)
 {
     if (jsonConfig is JArray)
     {
         configData.LoadValuesFromJson(jsonConfig, protectionService);
         IsConfigured = true;
     }
     // read and upgrade old settings file format
     else if (jsonConfig is Object)
     {
         LoadLegacyCookieConfig(jsonConfig);
         SaveConfig();
         IsConfigured = true;
     }
 }
Beispiel #4
0
        virtual public void LoadValuesFromJson(JToken jsonConfig, bool useProtectionService = false)
        {
            IProtectionService ps = null;

            if (useProtectionService)
            {
                ps = protectionService;
            }
            configData.LoadValuesFromJson(jsonConfig, ps);
            if (string.IsNullOrWhiteSpace(configData.SiteLink.Value))
            {
                configData.SiteLink.Value = DefaultSiteLink;
            }
            if (!configData.SiteLink.Value.EndsWith("/", StringComparison.Ordinal))
            {
                configData.SiteLink.Value += "/";
            }

            // check whether the site link is well-formatted
            var siteUri = new Uri(configData.SiteLink.Value);

            SiteLink = configData.SiteLink.Value;
        }