コード例 #1
0
        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);
        }
コード例 #2
0
        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;
                    }
                }
            }
        }
コード例 #3
0
 public override void TestCleanup()
 {
     if (Security != null)
     {
         Security.LogOut();
     }
     base.TestCleanup();
 }
コード例 #4
0
        public static void Logout()
        {
            var manager = new EidssSecurityManager();

            manager.LogOut();

            m_Trace.Trace(TraceTitle, "EIDSS logout successfully.");
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public void LogInByTicketTest()
        {
            EidssSecurityManager target = new EidssSecurityManager();

            if (target.AccessGranted)
            {
                target.LogOut();
            }
            int res = target.LogIn(Organizaton, Admin, AdminPassword);

            Assert.AreEqual(0, res);
            string ticket = target.CreateTicket((long)EidssUserContext.User.ID);

            Assert.IsNotNull(ticket);
            target.LogOut();
            res = target.LogIn(ticket);
            Assert.AreEqual(0, res);
            Assert.IsTrue(target.AccessGranted);
            target.LogOut();
            res = target.LogIn(ticket);
            Assert.AreEqual(2, res);
            Assert.IsFalse(target.AccessGranted);
        }
コード例 #7
0
        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"]);
            }
        }
コード例 #8
0
        private bool Login()
        {
            if (!BaseFormManager.CloseAll(true))
            {
                return(true);
            }
            if (m_ActivityMonitor != null)
            {
                m_ActivityMonitor.Enabled = false;
            }
            var manager = new EidssSecurityManager();

            manager.LogOut();
            Visible = false;
            if (!LoginForm.DefaultLogin())
            {
                ExitApp(true);
                return(false);
            }

            //reset connection
            UpdateMessenger.SetConnection((SqlConnection)ConnectionManager.CreateNew().Connection);

            //check for can run application
            if (!UpdateMessenger.CanRunApplication(ModelUserContext.ClientID, AppCode))
            {
                ErrorForm.ShowMessageDirect(EidssMessages.Get("ApplicationMustBeClosed"));
                ExitApp(true);
                return(false);
            }

            if (m_Server == null)
            {
                try
                {
                    RemotingServer.Init();
                    RemoteEventManager.Singleton.MainForm = this;
                    m_Server = RemoteEventManager.Singleton;
                }
                catch (Exception)
                {
                    ErrorForm.ShowMessageDirect(EidssMessages.Get("errRemotingSockeError",
                                                                  "Unable to start server for communication with EIDSS Client Agent. Please check that no EIDSS application is started in other Windows session or ask adminisrtators to correct TCP port used by EIDSS. If you see this message, you will be not able to open EIDSS form directly from EIDSS Client Agent. Other EIDSS functionality is not changed."));
                }
            }
            CommonResourcesCache.Reset();
            EIDSS_LookupCacheHelper.Init();
            BaseForm.ReplicationNeeded         = EidssSiteContext.Instance.RealSiteType != SiteType.CDR;
            CustomCultureHelper.CurrentCountry = EidssSiteContext.Instance.CountryID;
            if (EidssSiteContext.Instance.IsAzerbaijanCustomization)
            {
                panel1.BackgroundImage = Properties.Resources.EIDSS_AZ_Background;
                Appearance.BackColor   = Color.White;
            }
            else if (EidssSiteContext.Instance.IsIraqCustomization)
            {
                panel1.BackgroundImage = Properties.Resources.EIDSS_IQ_Background;
                Appearance.BackColor   = Color.White;
                //Appearance.BackColor =Color.FromArgb(96,199,242);
            }
            else if (EidssSiteContext.Instance.IsThaiCustomization)
            {
                panel1.BackgroundImage = Properties.Resources.EIDSS_TH_Logo;
                Appearance.BackColor   = Color.White;
                //Appearance.BackColor =Color.FromArgb(96,199,242);
            }
            else
            {
                panel1.BackgroundImage = Properties.Resources.EIdss_background;
                Appearance.BackColor   = Color.FromArgb(184, 199, 230);
            }
            //eidss.model.Core.EidssSiteContext.Instance.CountryID = EIDSS.model.Core.EidssSiteContext.Instance.CountryID;
            Splash.ShowSplash();
            if (!ReloadMenu())
            {
                return(false);
            }
            Visible = true;
            InitAutoLogoutMonitor();

            if (BaseSettings.ScanFormsMode)
            {
                MessageBox.Show("Change config setting 'ScanFormsMode' to false!!", "ScanFormsMode = true!!");
            }

            return(true);
        }
コード例 #9
0
        public void UpdateLayoutDetailSettingsTest()
        {
            lock (m_LayoutDB.Connection)
            {
                OpenConnection();
                // create layout under admin
                var securityManager = new EidssSecurityManager();
                int result          = securityManager.LogIn(BaseReportTests.Organizaton, BaseReportTests.Admin, BaseReportTests.AdminPassword);
                Assert.AreEqual(0, result);

                long layoutId = CreateLayout();

                var layoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);
                var row          = (LayoutDetailDataSet.LayoutRow)layoutDetail.Layout.Rows[0];

                Assert.AreEqual(EidssUserContext.User.EmployeeID, row.idfPerson);

                row.strDefaultLayoutName = "English name";
                row.strLayoutName        = "russian";

                UpdateLayout(layoutDetail);

                var newLayoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);
                var newRow          = (LayoutDetailDataSet.LayoutRow)newLayoutDetail.Layout.Rows[0];

                Assert.AreEqual(EidssUserContext.User.EmployeeID, newRow.idfPerson);

                securityManager.LogOut();
                CloseConnection();

                // check that layout under user has the same chart options
                OpenConnection();
                result = securityManager.LogIn(BaseReportTests.Organizaton, BaseReportTests.User, BaseReportTests.UserPassword);
                Assert.AreEqual(0, result);

                layoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);

                Assert.AreNotEqual(EidssUserContext.User.EmployeeID, newRow.idfPerson);

                UpdateLayout(layoutDetail);

                newLayoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);
                newRow          = (LayoutDetailDataSet.LayoutRow)newLayoutDetail.Layout.Rows[0];

                Assert.AreEqual(EidssUserContext.User.EmployeeID, newRow.idfPerson);
                securityManager.LogOut();
                CloseConnection();

                // check that layout under admin has original options
                OpenConnection();

                result = securityManager.LogIn(BaseReportTests.Organizaton, BaseReportTests.Admin, BaseReportTests.AdminPassword);
                Assert.AreEqual(0, result);

                layoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);
                Assert.AreEqual(1, layoutDetail.Layout.Rows.Count);
                //row = (LayoutDetailDataSet.LayoutRow) layoutDetail.Layout.Rows[0];

                DeleteLayout(layoutId);
                securityManager.LogOut();
                CloseConnection();
            }
        }