private void SetDatabaseConfig(XmlElement databaseConfigRootNode, DatabaseConfig dbConfig) { GetOrCreateElement(databaseConfigRootNode, "name").InnerText = dbConfig.name; if (dbConfig.DBType.Equals(WebUtils.DBTypeEmun.MSSQL)) { HROne.CommonLib.Crypto crypto = new HROne.CommonLib.Crypto(HROne.CommonLib.Crypto.SymmProvEnum.Rijndael); GetOrCreateElement(databaseConfigRootNode, "dbtype").InnerText = "MSSQL"; System.Data.SqlClient.SqlConnectionStringBuilder connStringBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder(dbConfig.ConnectionString); connStringBuilder.Password = crypto.Encrypting(connStringBuilder.Password, keyString); GetOrCreateElement(databaseConfigRootNode, "ConnectionString").InnerText = connStringBuilder.ConnectionString; } }
private void SetDatabaseConfig(XmlElement databaseConfigRootNode, DatabaseConfig dbConfig) { XmlDocument config = databaseConfigRootNode.OwnerDocument; databaseConfigRootNode.AppendChild(config.CreateElement("name")); databaseConfigRootNode["name"].InnerText = dbConfig.name; databaseConfigRootNode.AppendChild(config.CreateElement("dbtype")); if (dbConfig.DBType.Equals(WebUtils.DBTypeEmun.MSSQL)) { HROne.CommonLib.Crypto crypto = new HROne.CommonLib.Crypto(HROne.CommonLib.Crypto.SymmProvEnum.Rijndael); databaseConfigRootNode["dbtype"].InnerText = "MSSQL"; databaseConfigRootNode.AppendChild(config.CreateElement("ConnectionString")); System.Data.SqlClient.SqlConnectionStringBuilder connStringBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder(dbConfig.ConnectionString); connStringBuilder.Password = crypto.Encrypting(connStringBuilder.Password, keyString); databaseConfigRootNode["ConnectionString"].InnerText = connStringBuilder.ConnectionString; } }
private DatabaseConfig LoadDatabaseConfig(XmlElement node) { HROne.CommonLib.Crypto crypto = new HROne.CommonLib.Crypto(HROne.CommonLib.Crypto.SymmProvEnum.Rijndael); string strDBType = string.Empty; string strConnectionString = string.Empty; string strName = string.Empty; if (node["dbtype"] != null) { strDBType = node["dbtype"].InnerText; } if (node["name"] != null) { strName = node["name"].InnerText; } if (node["ConnectionString"] != null) { strConnectionString = node["ConnectionString"].InnerText; } if (strDBType.Equals("MSSQL")) { DatabaseConfig config = new DatabaseConfig(); config.DBType = WebUtils.DBTypeEmun.MSSQL; config.name = strName; System.Data.SqlClient.SqlConnectionStringBuilder connStringBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder(strConnectionString); try { connStringBuilder.Password = crypto.Decrypting(connStringBuilder.Password, keyString); connStringBuilder.ApplicationName = "HROneWeb"; config.ConnectionString = connStringBuilder.ConnectionString; } catch { } return(config); } else { return(null); } }
private DateTime getDateFromKey(string trialKey) { HROne.CommonLib.Crypto crypto = new HROne.CommonLib.Crypto(HROne.CommonLib.Crypto.SymmProvEnum.DES); try { trialKey = base32.ConvertBase32ToBase64(trialKey); string realTrialKey = crypto.Decrypting(trialKey, "HROne"); string strYear = realTrialKey.Substring(0, 4); string strMonth = realTrialKey.Substring(4, 2); string strDay = realTrialKey.Substring(6, 2); return(new DateTime(int.Parse(strYear), int.Parse(strMonth), int.Parse(strDay))); } catch { return(new DateTime()); } }
protected void btnSubmit_Click(object sender, EventArgs e) { PageErrors pageErrors = PageErrors.getErrors(null, this.Page); if (!IsValidPassCode(txtPassCode.Text)) { pageErrors.addError("Incorrect Pass Code!"); return; } HROne.CommonLib.Crypto crypto = new HROne.CommonLib.Crypto(HROne.CommonLib.Crypto.SymmProvEnum.Rijndael); Session["LoginID"] = crypto.Encrypting("EM", Session.SessionID); //EUser user = new EUser(); //user.UserID = -1; //user.LoginID = "EM"; //Session["User"] = user; Session["IgnoreEM"] = false; Session.Remove("User"); HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/Default.aspx"); }
public static HROne.SaaS.Entities.EUser GetCurUser(HttpSessionState Session) { DatabaseConnection dbConn = HROne.Common.WebUtility.GetDatabaseConnection(Session); HROne.SaaS.Entities.EUser CurrentUser = null; if (Session["User"] == null) { if (Session["LoginID"] != null) { HROne.CommonLib.Crypto crypto = new HROne.CommonLib.Crypto(HROne.CommonLib.Crypto.SymmProvEnum.Rijndael); if (Session["LoginID"].ToString().Equals(crypto.Encrypting("EM", Session.SessionID))) { CurrentUser = new HROne.SaaS.Entities.EUser(); CurrentUser.LoginID = "EM"; CurrentUser.UserID = -1; } if (Session["PasswordEncrypted"] != null) { HROne.SaaS.Entities.EUser user = null; if (ValidateUser(dbConn, Session["LoginID"].ToString(), Session["PasswordEncrypted"].ToString(), false, false, out user)) { CurrentUser = user; } else { Session.Remove("LoginID"); Session.Remove("PasswordEncrypted"); } } } if (CurrentUser != null) { Session["User"] = CurrentUser; } } else { CurrentUser = (HROne.SaaS.Entities.EUser)Session["User"]; } return(CurrentUser); }