private QueryFilterControl CreateFilterControl(string lang = "en") { DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString")); ConnectionManager.DefaultInstance.SetCredentials(Config.GetSetting("EidssConnectionString")); EidssUserContext.Init(); context = ModelUserContext.Instance as EidssUserContext; Security = new EidssSecurityManager(); int result = Security.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, result); EIDSS_LookupCacheHelper.Init(); EidssUserContext.CurrentLanguage = lang; var queryDb = new Query_DB(); var querySearchObjectDb = new QuerySearchObject_DB(); var queryDs = queryDb.LoadDetailData(QueryId); DataRow row = queryDs.Tables[Query_DB.TasQueryObjectTree].Rows[0]; var searchObjectsDs = querySearchObjectDb.LoadDetailData(row["idfQuerySearchObject"]); var form = new Form(); var filter = new QueryFilterControl { Parent = form, Dock = DockStyle.Fill }; filter.Init(); filter.Bind((long)queryDs.Tables[1].Rows[0]["idfQuerySearchObject"], searchObjectsDs); return(filter); }
public void VSSessionGeneral() { using (var context = ModelUserContext.Instance as EidssUserContext) { var target = new EidssSecurityManager(); int result = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, result); using (var manager = DbManagerFactory.Factory.Create(context)) { var acc = VsSession.Accessor.Instance(null); manager.BeginTransaction(); var vs = acc.CreateNewT(manager); Assert.IsNotNull(vs); long id = vs.idfVectorSurveillanceSession; //The case could not be saved unless the diagnosis is given vs.Validation += hc_Validation_idfsTentativeDiagnosis; Assert.IsTrue(acc.Post(manager, vs)); vs.Validation -= hc_Validation_idfsTentativeDiagnosis; vs = acc.SelectByKey(manager, id); Assert.IsNotNull(vs); manager.RollbackTransaction(); } EidssUserContext.Clear(); } }
private void Init(LoginType type) { HelpTopicId = "logon"; if (BaseSettings.UseDefaultLogin) { txtOrganization.Text = BaseSettings.DefaultOrganization; txtUserName.Text = BaseSettings.DefaultUser; txtPassword.Text = BaseSettings.DefaultPassword; } else { txtOrganization.Text = Config.GetSetting("Organization"); } ControlsLastLanguage = new Dictionary <Control, string> { { txtUserName, "en" }, { txtPassword, "en" } }; Application.Idle += UpdateLangIndicators; ActiveControl = txtUserName; m_LoginType = type; m_ConnectionCredentials = new ConnectionCredentials(); m_ArchiveConnectionCredentials = new ConnectionCredentials(null, "Archive"); m_ConnectionCredentials.CredentialChange += CredentialChanged; m_Manager = new EidssSecurityManager(); m_Manager.LogOut(); m_SupportedLanguages.Clear(); foreach (var key in Localizer.SupportedLanguages.Keys) { m_SupportedLanguages.Add(key); } KeyDown += LoginForm_KeyDown; RtlHelper.SetRTL(this, true); }
public static bool DefaultLogin() { //#if !DEBUG // return Login(LoginType.Simple); //#else if (BaseSettings.UseDefaultLogin) { try { var manager = new EidssSecurityManager(); int errorCode; if (DoLogin(manager, BaseSettings.DefaultOrganization, BaseSettings.DefaultUser, BaseSettings.DefaultPassword, out errorCode)) { return(true); } } catch (Exception ex) { Dbg.Debug("auto login error: {0}", ex.ToString()); } return(Login(LoginType.Simple)); } return(Login(LoginType.Simple)); //#endif }
public void GetPermissionsTest() { EidssSecurityManager target = new EidssSecurityManager(); int result = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, result); IDictionary <string, bool> actual = EidssUserContext.User.Permissions; foreach (var value in actual) { if (value.Key == "UseSimplifiedHumanCaseReportForm.Execute") { Assert.IsFalse(value.Value); } else { Assert.IsTrue(value.Value); } } result = target.LogIn(Organizaton, User, UserPassword); Assert.AreEqual(0, result); actual = EidssUserContext.User.Permissions; foreach (string key in actual.Keys) { if (key.StartsWith("AVRReport.")) { Assert.IsFalse(actual[key]); } else if (key.StartsWith("AggregateSettings.")) { Assert.IsTrue(actual[key]); } } }
public void SetPasswordTest() { EidssSecurityManager target = new EidssSecurityManager(); int actual; actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, actual); object userID = EidssUserContext.User.ID; string password = "******"; actual = target.SetPassword(userID, password); Assert.AreEqual(0, actual); actual = target.LogIn(Organizaton, Admin, password); Assert.AreEqual(0, actual); actual = target.SetPassword(userID, AdminPassword); Assert.AreEqual(0, actual); actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, actual); actual = target.SetPassword("-1", "new password"); Assert.AreEqual(2, actual); }
public bool SaveHumanCases(string Organization, string User, string Password, string Language, HumanCaseInfo[] hc_in, out HumanCaseInfo[] hc_out) { hc_out = null; var security = new EidssSecurityManager(); var result = security.LogIn(Organization, User, Password); if (result == 0) //authorized { EidssUserContext.CurrentLanguage = Language; Thread.CurrentThread.CurrentCulture = new CultureInfo(Language); Thread.CurrentThread.CurrentUICulture = new CultureInfo(Language); Check(PermissionHelper.InsertPermission(EIDSSPermissionObject.HumanCase)); Check(PermissionHelper.UpdatePermission(EIDSSPermissionObject.HumanCase)); var list = new List <HumanCaseInfo>(); hc_in.ToList().ForEach(c => { if (c.Id == 0) { c.NotificationDate = DateTime.Today; c.NotificationSentBy.Id = EidssSiteContext.Instance.OrganizationID; c.NotificationSentBy.Name = EidssSiteContext.Instance.OrganizationName; c.NotificationSentByPerson.Id = (long)EidssUserContext.User.ID; c.NotificationSentByPerson.Name = EidssUserContext.User.FullName; } c.Save(c.Id == 0); list.Add(c); }); hc_out = list.ToArray(); return(true); } return(false); }
public static void Logout() { var manager = new EidssSecurityManager(); manager.LogOut(); m_Trace.Trace(TraceTitle, "EIDSS logout successfully."); }
public override void MyTestInitialize() { base.MyTestInitialize(); Security = new EidssSecurityManager(); int result = Security.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, result); }
private static bool DoLogin(EidssSecurityManager manager, string organization, string userName, string password, out int resultCode) { resultCode = manager.LogIn(organization, userName, password); if (resultCode == 0) { return(true); } return(false); }
public void LogInTest() { EidssSecurityManager target = new EidssSecurityManager(); int actual; actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, actual); actual = target.LogIn(Organizaton, User, UserPassword); Assert.AreEqual(0, actual); actual = target.LogIn(Organizaton + "1", Admin, AdminPassword); if (BaseSettings.UseOrganizationInLogin) { Assert.AreEqual(2, actual); } else { Assert.AreEqual(0, actual); } actual = target.LogIn(Organizaton, Admin, "invalidpassword"); Assert.AreEqual(2, actual); actual = target.LogIn(Organizaton, Admin + "1", AdminPassword); Assert.AreEqual(2, actual); int invalidLoginCount = 3; using (DbManager manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance)) { invalidLoginCount = manager.SetCommand("select top 1 intAccountTryCount from tstSecurityConfiguration").ExecuteScalar <int>(); } for (int i = 0; i < invalidLoginCount - 1; i++) { actual = target.LogIn(Organizaton, Admin, "invalidpassword"); Assert.AreEqual(2, actual); } actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(6, actual); using (DbManager manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance)) { manager.SetCommand("update tstUserTableLocal set datTryDate = null, intTry=null " + "from tstUserTable u " + "where " + "u.idfUserID = tstUserTableLocal.idfUserID " + "and u.strAccountName = @strAccountName", manager.Parameter("@strAccountName", Admin)).ExecuteNonQuery(); actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, actual); manager.SetCommand("update tstUserTable set datPasswordSet = @date where strAccountName = @strAccountName", manager.Parameter("@date", DateTime.Now.AddDays(-10000)), manager.Parameter("@strAccountName", Admin)).ExecuteNonQuery(); actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(9, actual); manager.SetCommand("update tstUserTable set datPasswordSet = @date where strAccountName = @strAccountName", manager.Parameter("@date", DateTime.Now), manager.Parameter("@strAccountName", Admin)).ExecuteNonQuery(); actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, actual); } }
public void PasswordHashTest() { EidssSecurityManager target = new EidssSecurityManager(); // TODO: Initialize to an appropriate value string password = "******"; object expected = SHA1.Create().ComputeHash(System.Text.UnicodeEncoding.Unicode.GetBytes(password)); object actual; actual = target.PasswordHash(password); CompareByteArrays(expected, actual); }
public BaseReferenceRaw[] LoadReference(string Organization, string User, string Password, long type) { var security = new EidssSecurityManager(); var result = security.LogIn(Organization, User, Password); if (result == 0) //authorized { return(BaseReferenceRaw.GetList(new[] { type })); } return(null); }
public GisBaseReferenceTranslationRaw[] LoadGisReferenceTranslation(string Organization, string User, string Password, string lang) { var security = new EidssSecurityManager(); var result = security.LogIn(Organization, User, Password); if (result == 0) //authorized { return(GisBaseReferenceTranslationRaw.GetAll(new [] { lang })); } return(null); }
public static void InitDBAndLogin() { InitSupportedLanguages(); EIDSS_LookupCacheHelper.Init(); EidssUserContext.Init(); DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString")); var target = new EidssSecurityManager(); int result = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, result); }
private void LoginByTicketAsync(long userId) { EidssSecurityManager target = new EidssSecurityManager(); string ticket = target.CreateTicket(userId); Assert.IsNotNull(ticket); var res = target.LogIn(ticket); Assert.AreEqual(0, res); Assert.IsTrue(target.AccessGranted); //target.LogOut(); }
public static void Login() { var manager = new EidssSecurityManager(); int resultCode = manager.LogIn(BaseSettings.DefaultOrganization, BaseSettings.DefaultUser, BaseSettings.DefaultPassword); if (resultCode != 0) { string err = string.Format("Could not login under user {0} from organization {1}.", BaseSettings.DefaultUser, BaseSettings.DefaultOrganization); throw new ApplicationException(err); } m_Trace.Trace(TraceTitle, "EIDSS login successfully."); }
public static void Authorize(Login login) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(Localizer.SupportedLanguages[bv.common.Core.Localizer.lngEn]); Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture; if (string.IsNullOrEmpty(login.language) || !Localizer.SupportedLanguages.ContainsKey(login.language)) { throw new AuthLanguageException(); } Thread.CurrentThread.CurrentUICulture = new CultureInfo(Localizer.SupportedLanguages[login.language]); Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture; if (!string.IsNullOrEmpty(login.externalSystem) && !SupportedExternalSystem.ContainsKey(login.externalSystem)) { throw new AuthExternalException(); } var security = new EidssSecurityManager(); var result = security.LogIn(login.organization, login.user, login.password); switch (result) { case 0: break; case 1: throw new AuthEmptyException(); case 2: throw new AuthNotFoundException(); case 3: case 4: case 5: throw new AuthVersionException(); case 6: throw new AuthLockedException(security.GetAccountLockTimeout(login.organization, login.user)); case 9: throw new AuthExpiredException(); default: throw new AuthFailedException(); } EidssUserContext.CurrentLanguage = login.language; }
public void TestInitialize() { DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString")); ConnectionManager.DefaultInstance.SetCredentials(Config.GetSetting("EidssConnectionString")); EidssUserContext.Init(); context = ModelUserContext.Instance as EidssUserContext; m_Security = new EidssSecurityManager(); int result = m_Security.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, result); EIDSS_LookupCacheHelper.Init(); //while(!LookupCache.Filled) // Thread.Sleep(500); ModelUserContext.CurrentLanguage = "en"; }
public void LogInByTicketDeadlockTest() { EidssSecurityManager target = new EidssSecurityManager(); if (target.AccessGranted) { target.LogOut(); } int res = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, res); m_Users[0] = (long)EidssUserContext.User.ID; //if (target.AccessGranted) // target.LogOut(); //res = target.LogIn(Organizaton, User, UserPassword); //Assert.AreEqual(0, res); //m_Users[1] = (long)EidssUserContext.User.ID; if (target.AccessGranted) { target.LogOut(); } var threads = new List <Thread>(); int threadCount = 100; for (int i = 0; i < threadCount; i++) { var thread = new Thread(LoginByTicket); threads.Add(thread); thread.Start(); Debug.WriteLine("login thread <{0}> is started", i); } while (true) { Thread.Sleep(100); for (int i = 0; i < threadCount; i++) { if (threads[i].IsAlive) { break; } if (i == threadCount - 1) { return; } } } }
public static string ChangePassword(string organization, string login, string oldPassword, string newPassword, string confirmPassword) { var security = new EidssSecurityManager(); var err = GetPaswordError(newPassword, confirmPassword, security); if (err != null) { return(err); } var errCode = security.ChangePassword(organization, login, oldPassword, newPassword); if (errCode != 0) { return(SecurityMessages.GetLoginErrorMessage(errCode)); } return(null); }
public void FarmPanelCollection() { EidssUserContext.Init(); DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString")); using (var context = ModelUserContext.Instance as EidssUserContext) { var target = new EidssSecurityManager(); int result = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, result); using (var manager = DbManagerFactory.Factory.Create(context)) { var acc = VetCase.Accessor.Instance(null); var vetcase = (VetCase)acc.CreateNew(manager, null, (int)HACode.Livestock); var panel = vetcase.Farm; var herdaccessor = VetFarmTree.Accessor.Instance(null); VetFarmTree farm = panel.FarmTree[0]; VetFarmTree herd = herdaccessor.CreateHerd(manager, panel, farm); VetFarmTree spec = herdaccessor.CreateSpecies(manager, panel, herd); spec.SpeciesType = spec.SpeciesTypeLookup.FirstOrDefault(c => c.idfsBaseReference == 837790000000); //spec.idfsSpeciesTypeReference = 837790000000; panel.FarmTree.Add(herd); panel.FarmTree.Add(spec); panel.Address.Region = panel.Address.RegionLookup.FirstOrDefault(); panel.Address.Rayon = panel.Address.RayonLookup.FirstOrDefault(); panel.Address.Settlement = panel.Address.SettlementLookup.FirstOrDefault(); var animal = (AnimalListItem)AnimalListItem.Accessor.Instance(null).CreateNew(manager, vetcase, (int)HACode.Livestock); animal.idfSpecies = spec.idfParty; animal.idfHerd = herd.idfParty; animal.idfCase = vetcase.idfCase; vetcase.AnimalList.Add(animal); //vetcase.Validation += new ValidationEvent(panel_Validation); //acc.Post(manager, vetcase); //vetcase.Validation -= panel_Validation; } } }
public void ChangePasswordTest() { EidssSecurityManager target = new EidssSecurityManager(); string newPassword = "******"; int expected = 0; int actual; actual = target.ChangePassword(Organizaton, Admin, AdminPassword, newPassword); Assert.AreEqual(expected, actual); actual = target.LogIn(Organizaton, Admin, newPassword); Assert.AreEqual(expected, actual); object userID = EidssUserContext.User.ID; actual = target.SetPassword(userID, AdminPassword); Assert.AreEqual(expected, actual); actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(expected, actual); }
public bool Authorize() { var security = new EidssSecurityManager(); var result = security.LogIn(Organization, UserName, Password); if (result == 0) //authorized { //set current language EidssUserContext.CurrentLanguage = Cultures.GetLanguageAbbreviation(LanguagePreference); System.Web.Security.FormsAuthentication.SetAuthCookie(this.UserName, false); HttpContext.Current.Session["UserName"] = UserName; return(true); } else { ErrorMessage = SecurityMessages.GetLoginErrorMessage(result); return(false); } }
public void MyTestInitialize() { //DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString", "")); //ClassLoader.Init("eidss*.dll", Environment.MachineName.Equals("LEONOV") ? @"c:\Projects\EIDSS4\eidss.main\bin\Debug\" : null); ClassLoader.Init("eidss*.dll", null); DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString", "")); EidssUserContext.Init(); var target = new EidssSecurityManager(); const string organizaton = "NCDC&PH"; const string admin = "test_admin"; //const string User = "******"; const string adminPassword = "******"; //const string UserPassword = "******"; int result = target.LogIn(organizaton, admin, adminPassword); Assert.AreEqual(0, result); }
public ActionResult Layout(string queryId, string layoutId, string ticket, string lang) { if (!string.IsNullOrEmpty(ticket)) { EidssSecurityManager target = new EidssSecurityManager(); int res = target.LogIn(ticket); if (res == 0) { System.Web.Security.FormsAuthentication.SetAuthCookie(EidssUserContext.User.LoginName, false); if (!string.IsNullOrEmpty(lang)) { EidssUserContext.CurrentLanguage = Cultures.GetLanguageAbbreviation(lang); } return(Redirect(String.Format("/{0}{1}?queryId={2}&layoutId={3}", lang, "/Layout/Layout", queryId, layoutId))); } } SetSelectedLanguage(); return(View("LoginLang", new eidss.avr.mweb.Models.Login())); }
public void CheckVersionTest() { EidssSecurityManager target = new EidssSecurityManager(); int expected = 0; int actual; actual = target.CheckVersion(); Assert.AreEqual(expected, actual); EidssUserContext.ApplicationName = ""; actual = target.CheckVersion(); Assert.AreEqual(5, actual); EidssUserContext.ApplicationName = "test"; using (DbManager manager = DbManagerFactory.Factory.Create()) { manager.SetCommand("update tstVersionCompare set strDatabaseVersion='0.0.0' where strModuleName='test'").ExecuteNonQuery(); actual = target.CheckVersion(); Assert.AreEqual(3, actual); object dbver = manager.SetCommand("select strDatabaseVersion from tstVersionCompare where strModuleName='MainDatabaseVersion'").ExecuteScalar(); manager.SetCommand(string.Format("update tstVersionCompare set strDatabaseVersion='{0}' where strModuleName='test'", dbver)).ExecuteNonQuery(); } }
public void LogOutTest() { EidssSecurityManager target = new EidssSecurityManager(); // TODO: Initialize to an appropriate value int actual; actual = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, actual); target.LogOut(); Assert.AreEqual(false, target.AccessGranted); using (DbManager manager = DbManagerFactory.Factory.Create()) { DataTable dt = manager.SetCommand("select * from tstLocalConnectionContext where strConnectionContext=@clientID", manager.Parameter("@clientID", EidssUserContext.ClientID)).ExecuteDataTable(); Assert.AreEqual(1, dt.Rows.Count); DataRow row = dt.Rows[0]; Assert.AreEqual(DBNull.Value, row["idfUserID"]); Assert.AreEqual(DBNull.Value, row["binChallenge"]); Assert.AreEqual(DBNull.Value, row["idfDataAuditEvent"]); Assert.AreEqual(DBNull.Value, row["idfEventID"]); } }
public void Login(string Organization, string User, string Password, string Language) { if (!Localizer.SupportedLanguages.ContainsKey(Language)) { throw new SoapException("Language is not supported", SoapException.ClientFaultCode); } Thread.CurrentThread.CurrentUICulture = new CultureInfo(Localizer.SupportedLanguages[Language]); var security = new EidssSecurityManager(); var result = security.LogIn(Organization, User, Password); if (result == 0) //authorized { //set current language EidssUserContext.CurrentLanguage = Language; } else { throw new SoapException(SecurityMessages.GetLoginErrorMessage(result), SoapException.ClientFaultCode); } }
public void AccessGrantedTest() { EidssSecurityManager target = new EidssSecurityManager(); if (target.AccessGranted) { target.LogOut(); } bool actual; actual = target.AccessGranted; Assert.IsFalse(actual); int res = target.LogIn(Organizaton, Admin, AdminPassword); Assert.AreEqual(0, res); actual = target.AccessGranted; Assert.IsTrue(actual); target.LogOut(); actual = target.AccessGranted; Assert.IsFalse(actual); }