Exemplo n.º 1
0
        void Settings_OnCheckingSettings(SprocketSettings.SettingsErrors errors)
        {
            if (!IntegrationEnabled)
            {
                return;
            }

            if (TestMode)
            {
                if (SprocketSettings.GetValue("PayPalTestIdentityToken") == null)
                {
                    errors.Add("PayPal", "PayPalTestMode setting has been specified, thus a value is required for PayPalTestIdentityToken. This is the PayPal-supplied identity token for use with the PayPal Sandbox development environment. See developer.paypal.com for more info.");
                    errors.SetCriticalError();
                }
                if (SprocketSettings.GetValue("PayPalTestAccountAddress") == null)
                {
                    errors.Add("PayPal", "PayPalTestMode setting has been specified, thus a value is required for PayPalTestAccountAddress. This is a test PayPal account address for use with the PayPal Sandbox development environment. See developer.paypal.com for more info.");
                    errors.SetCriticalError();
                }
            }
            else
            {
                if (SprocketSettings.GetValue("PayPalIdentityToken") == null)
                {
                    errors.Add("PayPal", "The PayPalTestMode setting is disabled and the PayPalIntegration setting is enabled, thus a value is required for PayPalIdentityToken. This is the PayPal-supplied identity token for authenticating PayPal responses. See developer.paypal.com for more info.");
                    errors.SetCriticalError();
                }
                if (SprocketSettings.GetValue("PayPalAccountAddress") == null)
                {
                    errors.Add("PayPal", "The PayPalTestMode setting is disabled and the PayPalIntegration setting is enabled, thus a value is required for PayPalAccountAddress. This is the PayPal account address that is to receive transaction payments. See developer.paypal.com for more info.");
                    errors.SetCriticalError();
                }
            }
        }
Exemplo n.º 2
0
        void OnCheckingSettings(SprocketSettings.SettingsErrors errors)
        {
            string path = HttpContext.Current.Request.PhysicalApplicationPath + @"\ClientID.config";

            if (File.Exists(path))
            {
                StreamReader sr   = new StreamReader(path);
                string       guid = sr.ReadToEnd().Trim();
                try { clientID = new Guid(guid); }
                catch
                {
                    errors.Add("WebSecurity", "The existing ClientID.config file contains an invalid unique identifier. If the file has been corrupted, someone with direct database access can retrieve the ClientID from Clients table.");
                    errors.SetCriticalError();
                    return;
                }
            }
            else
            {
                StreamWriter sw = new StreamWriter(path);
                clientID = Guid.NewGuid();
                sw.Write(clientID.ToString());
                sw.Flush();
                sw.Close();
            }
        }
Exemplo n.º 3
0
        void OnCheckSettings(SprocketSettings.SettingsErrors errors)
        {
            if (SprocketSettings.GetValue("ConnectionString") == null)
            {
                errors.Add("DatabaseManager", "The application settings (.config) file requires a valid value for \"ConnectionString\".");
                errors.SetCriticalError();
            }
            if (SprocketSettings.GetValue("DatabaseEngine") == null)
            {
                errors.Add("DatabaseManager", "The application settings (.config) file requires a valid value for \"DatabaseEngine\".");
                errors.SetCriticalError();
            }
            if (errors.HasCriticalError)
            {
                return;
            }

            DatabaseEngine engType;

            try { engType = Database.ParseEngineName(SprocketSettings.GetValue("DatabaseEngine")); }
            catch (SprocketException)
            {
                errors.Add("DatabaseManager", "The value for \"DatabaseEngine\" is not valid.");
                errors.SetCriticalError();
                return;
            }

            Database db = Database.Create(engType);

            db.ConnectionString = SprocketSettings.GetValue("ConnectionString");
            string errorMessage;

            if (!db.TestConnectionString(out errorMessage))
            {
                string msg = errorMessage;
                //if (msg.ToLower().Contains("password")
                //    || msg.ToLower().Contains("pwd")
                //    || msg.ToLower().Contains("pass")
                //    || msg.ToLower().Contains("pword"))
                //    msg = "[error message hidden because it contains password information]";
                errors.Add("DatabaseManager", "The supplied connection string didn't work. The error was: " + msg);
                errors.SetCriticalError();
                return;
            }

            defaultConnectionString = db.ConnectionString;
            defaultEngine           = db.DatabaseEngine;
        }
Exemplo n.º 4
0
        void OnCheckingSprocketSettings(SprocketSettings.SettingsErrors errors)
        {
            string psl = SprocketSettings.GetValue("PreventSimultaneousLogins");

            if (psl == null)
            {
                errors.Add(this, "The Web.config file is missing a value for \"PreventSimultaneousLogins\". The value should be \"True\" or \"False\".");
                errors.SetCriticalError();
                return;
            }
            if (psl.ToLower() != "true" && psl.ToLower() != "false")
            {
                errors.Add(this, "The Web.config file value for \"PreventSimultaneousLogins\" is invalid. The value should be \"True\" or \"False\".");
                errors.SetCriticalError();
                return;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// This is our fancy little page for displaying any errors flagged during the SprocketSettings
        /// module's settings errors checking spree at the start.
        /// </summary>
        private void ShowErrorPage()
        {
            string html = ResourceLoader.LoadTextResource("Sprocket.Web.html.errorpage.htm");

            SprocketSettings.SettingsErrors errors = SprocketSettings.Instance.ErrorList;
            string str = "";

            foreach (KeyValuePair <RegisteredModule, List <string> > error in errors.List)
            {
                str += "<h2>Module: <span class=\"ModuleName\">" + error.Key.Title + "</span></h2><ul>";
                foreach (string msg in error.Value)
                {
                    str += "<li>" + msg + "</li>";
                }
                str += "</ul>";
            }
            html = html.Replace("{body}", str);
            HttpContext.Current.Response.Write(html);
            HttpContext.Current.Response.End();
        }
Exemplo n.º 6
0
 void OnCheckingSettings(SprocketSettings.SettingsErrors errors)
 {
 }