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(); } } }
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; } }
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; }
void OnCheckingSettings(SprocketSettings.SettingsErrors errors) { }
public static void Process(Exception e) { bool sendEmail = SprocketSettings.GetBooleanValue("SendErrorEmail"); HttpRequest Request = HttpContext.Current.Request; string strauth = ""; string form = ""; string headers = ""; string fulltext = ""; string path = ""; string divider = "----------------------------------------------------------" + Environment.NewLine; string cookies = ""; bool isAjax = false; try { isAjax = AjaxRequestHandler.IsAjaxRequest; } catch { } try { if (WebAuthentication.IsLoggedIn) { strauth = "Username: "******"[null]") + Environment.NewLine; } else { strauth = "The user was not signed in at the time." + Environment.NewLine; } strauth += "Host address/IP: " + Request.UserHostAddress + " / " + Request.UserHostName + Environment.NewLine; } catch (Exception ex) { strauth = "ERROR EVALUATING AUTHENTICATION STATE: " + ex + "\r\n\r\n"; } try { foreach (string key in HttpContext.Current.Request.Headers) { if (key == "Cookie") { cookies = "Cookie Data:" + Environment.NewLine; foreach (string k in Request.Headers[key].Split(';')) { string[] arr = k.Split('='); string val = arr.Length > 0 ? k.Substring(arr[0].Length + 1) : ""; cookies += "[ " + arr[0] + " ]" + Environment.NewLine + val + Environment.NewLine; } } else { headers += key + ": " + HttpContext.Current.Request.Headers[key] + Environment.NewLine; } } } catch (Exception ex) { headers = "ERROR EVALUATING HEADERS: " + ex + "\r\n\r\n"; } try { if (Request.Form.Count > 0) { form += Environment.NewLine + "FORM POST DATA:" + Environment.NewLine; foreach (string key in Request.Form.AllKeys) { form += key + ": " + Request.Form[key] + Environment.NewLine; } } else { form = "There was no form POST data (i.e. this was not a submitted form)." + Environment.NewLine; } } catch (Exception ex) { headers = "ERROR EVALUATING FORM POST DATA: " + ex + "\r\n\r\n"; } try { path = "The SprocketPath for the request was: " + SprocketPath.Value + Environment.NewLine; path += "The full URL was: " + Request.RawUrl + Environment.NewLine; } catch (Exception ex) { path = "ERROR EVALUATING SPROCKET PATH: " + ex + "\r\n\r\n"; } fulltext = "An exception was thrown by the application." + Environment.NewLine + strauth + divider + path + divider + form + divider + cookies + divider + "The HTTP Headers were:" + Environment.NewLine + headers + divider + "Program flow log:" + Environment.NewLine + ProgramFlowLog.Value + divider + "The exception thrown was:" + Environment.NewLine + e.ToString(); if (e.InnerException != null) { fulltext += Environment.NewLine + divider + "INNER EXCEPTION:" + Environment.NewLine + e.InnerException; } if (sendEmail) { try { EmailHandler.Send(EmailHandler.AdminEmailAddress, EmailHandler.NullEmailAddress, "APPLICATION ERROR", fulltext, false); } catch (Exception ex) { fulltext += "ERROR SENDING EMAIL: " + ex.ToString(); } } try { LogFile.Append(string.Format("error-{0:yyyy-MM-dd-HH-mm-ss-fff}.txt", DateTime.UtcNow), fulltext); } catch { } }
public SprocketSettings() { inst = this; }
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(); } }