Esempio n. 1
0
        /// <summary>
        /// Removes the client info.
        /// </summary>
        /// <param name="clientSessionInfo">The client session info.</param>
        private void RemoveClientInfo(ClientSessionInfo clientSessionInfo)
        {
            this.lvClientInfo.BeginUpdate();

            string       sessionId = clientSessionInfo.ClientSessionId.ToString();
            ListViewItem lvi       = this.lvClientInfo.FindItemWithText(sessionId);

            if (lvi != null)
            {
                lvi.Remove();
            }

            this.lvClientInfo.EndUpdate();
        }
Esempio n. 2
0
        /// <summary>
        /// Adds the client info.
        /// </summary>
        /// <param name="clientSessionInfo">The client session info.</param>
        private void AddClientInfo(ClientSessionInfo clientSessionInfo)
        {
            this.lvClientInfo.BeginUpdate();

            ListViewItem lvi = new ListViewItem(clientSessionInfo.ClientSessionId.ToString());

            lvi.SubItems.Add(clientSessionInfo.ClientSessionIP);
            lvi.SubItems.Add(clientSessionInfo.ClientSessionPort.ToString());
            lvi.SubItems.Add(clientSessionInfo.SessionConnectTime.ToString());
            lvi.SubItems.Add(clientSessionInfo.SessionState);
            lvi.SubItems.Add(clientSessionInfo.StreamName);

            this.lvClientInfo.Items.Add(lvi);

            this.lvClientInfo.EndUpdate();
        }
Esempio n. 3
0
        public void Securesession_StartSessionShouldCreateSecureSessionEntry()
        {
            SecureChannel server = new SecureChannel();

            server.HttpContext         = A.Fake <IHttpContext>();
            server.HttpContext.Request = new ServiceProxyTestHelpers.FormUrlEncodedTestRequest();

            SecureChannelMessage <ClientSessionInfo> message = server.InitSession(new Instant());
            ClientSessionInfo sessionInfo = message.Data;

            SecureSession created = SecureSession.OneWhere(c => c.Id == sessionInfo.SessionId);

            Expect.IsNotNull(created);
            Expect.IsNotNullOrEmpty(created.Identifier, "Identifier was null or empty");
            Expect.AreEqual(created.Identifier, sessionInfo.ClientIdentifier, "ClientIdentifiers didn't match");
            Expect.AreEqual(sessionInfo.PublicKey, created.PublicKey);
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the client info.
        /// </summary>
        /// <param name="clientSessionInfo">The client session info.</param>
        private void UpdateClientInfo(ClientSessionInfo clientSessionInfo)
        {
            this.lvClientInfo.BeginUpdate();

            string       sessionId = clientSessionInfo.ClientSessionId.ToString();
            ListViewItem lvi       = this.lvClientInfo.FindItemWithText(sessionId);

            if (lvi != null && lvi.SubItems.Count > 0)
            {
                lvi.SubItems[1].Text = clientSessionInfo.ClientSessionIP;
                lvi.SubItems[2].Text = clientSessionInfo.ClientSessionPort.ToString();
                lvi.SubItems[3].Text = clientSessionInfo.SessionConnectTime.ToString();
                lvi.SubItems[4].Text = clientSessionInfo.SessionState;
                lvi.SubItems[5].Text = clientSessionInfo.StreamName;
            }

            this.lvClientInfo.EndUpdate();
        }
Esempio n. 5
0
        private IdentityPair GetUserIdentityPair()
        {
            IdentityPair      result = default(IdentityPair);
            ClientSessionInfo remoteClientSessionInfo = this.MailboxSession.RemoteClientSessionInfo;

            if (remoteClientSessionInfo != null)
            {
                result.LogonUserSid         = remoteClientSessionInfo.LogonUserSid;
                result.LogonUserDisplayName = remoteClientSessionInfo.LogonUserDisplayName;
            }
            else
            {
                result = IdentityHelper.GetIdentityPair(this.MailboxSession);
                if (result.LogonUserDisplayName == null && this.LogonType == LogonType.Owner && this.MailboxSession.MailboxOwner.MailboxInfo.IsArchive)
                {
                    result.LogonUserDisplayName = AuditEvent.ResolveMailboxOwnerName(this.MailboxSession.MailboxOwner);
                }
            }
            return(result);
        }
        private static IdentityPair GetUserIdentityPair(MailboxSession session, LogonType logonType)
        {
            IdentityPair      result = default(IdentityPair);
            ClientSessionInfo remoteClientSessionInfo = session.RemoteClientSessionInfo;

            if (remoteClientSessionInfo != null)
            {
                result.LogonUserSid         = remoteClientSessionInfo.LogonUserSid;
                result.LogonUserDisplayName = remoteClientSessionInfo.LogonUserDisplayName;
            }
            else
            {
                result = IdentityHelper.GetIdentityPair(session);
                if (result.LogonUserDisplayName == null && logonType == LogonType.Owner && session.MailboxOwner.MailboxInfo.IsArchive)
                {
                    result.LogonUserDisplayName = AuditRecordFactory.ResolveMailboxOwnerName(session.MailboxOwner);
                }
            }
            return(result);
        }
Esempio n. 7
0
        public ActionResult Logout()
        {
            #region [ Add data into language combo box ]
            if (TempData.Keys.Contains(StaticContent.LanguageKey))
            {
                LanguageKey temp = (LanguageKey)(TempData[StaticContent.LanguageKey]);

                initLanguageComboBox(temp.ToString());
            }
            else
            {
                initLanguageComboBox();
            }
            #endregion

            string str_IpAddr   = this.HttpContext.Request.UserHostAddress;
            string str_HostName = this.HttpContext.Request.UserHostName;

            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource("LoginScreentTitle");

            string strError = MultilingualHelper.GetStringFromResource("I003");

            string str_SaveAuthorizedHistory_Error = "";

            if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
            {
                ClientSessionInfo entity_ClientSessionInfo = null;
                if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
                {
                    entity_ClientSessionInfo = (ClientSessionInfo)ViewData[Bootstrapper.UserClientSessionKey.ToString()];
                }

                if (entity_ClientSessionInfo != null)
                {
                    BaseSession entity_BaseSession = entity_SessionWUserInfo;

                    if (entity_BaseSession != null)
                    {
                        WebCommonHelper webCommonHelper = new WebCommonHelper();

                        webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
                        {
                            WCFReturnResult entity = loginUserMgtHelper.Value.Logout(entity_WCFAuthInfoVM);

                            if (!entity.IsSuccess)
                            {
                                str_SaveAuthorizedHistory_Error = string.Join("<br/>", entity.StrList_Error.ToArray());
                            }
                            else
                            {
                                MVCSessionMgt.RemoveServerSideSession(entity_BaseSession);
                            }
                        });
                    }

                    if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
                    {
                        ViewData.Remove(Bootstrapper.UserClientSessionKey.ToString());
                    }

                    if (TempData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
                    {
                        TempData.Remove(Bootstrapper.UserClientSessionKey.ToString());
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(str_SaveAuthorizedHistory_Error))
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc       = str_SaveAuthorizedHistory_Error;
                errorMsgInfo.MsgType       = MessageType.ValidationError;
                ViewBag.ActionMessage      = errorMsgInfo;
                TempData[ActionMessageKey] = errorMsgInfo;
            }
            else
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc       = strError;
                errorMsgInfo.MsgType       = MessageType.Success;
                ViewBag.ActionMessage      = errorMsgInfo;
                TempData[ActionMessageKey] = errorMsgInfo;
            }
            return(View("Index"));
        }
Esempio n. 8
0
        public ActionResult Index(LoginUserVM loginUserVM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource("LoginScreentTitle");

            ClearSelectionCriteriaFromViewData();

            #region [ Add data into language combo box ]
            if (TempData.Keys.Contains(StaticContent.LanguageKey))
            {
                LanguageKey temp = (LanguageKey)(TempData[StaticContent.LanguageKey]);

                initLanguageComboBox(temp.ToString());
            }
            else
            {
                initLanguageComboBox();
            }
            #endregion

            LUSerLoginResult entity_LUSerLoginResult = new LUSerLoginResult();
            //Define and Create channel factory in order to call the service
            entity_LUSerLoginResult = loginUserMgtHelper.Value.Login(loginUserVM, TempData[StaticContent.LanguageKey].ToString(), UserHostAddress, UserHostName);

            if (entity_LUSerLoginResult != null && entity_LUSerLoginResult.StrList_Error.Count == 0)
            {
                //Clear the cache.
                TempData[ActionMessageKey] = ViewBag.ActionMessage = null;

                //Save login user's authorized info to the cache.
                MVCSessionMgt.SaveServerSideSession(entity_LUSerLoginResult.Entity_SessionWUserInfo, StaticContent.SystemInfoInst.GetSessionTimeOutSeconds());

                //Save service authorized key and client side session key.
                ClientSessionInfo entity_ClientSessionInfo = new ClientSessionInfo();
                if (entity_LUSerLoginResult.Entity_SessionWUserInfo != null)
                {
                    entity_ClientSessionInfo.MVCSessionKey        = entity_LUSerLoginResult.Entity_SessionWUserInfo.SessionKey;
                    entity_ClientSessionInfo.ServiceAuthorizedKey = entity_LUSerLoginResult.Str_ServerToken;

                    Entity_ClientSessionInfo = entity_ClientSessionInfo;

                    TempData[Bootstrapper.UserClientSessionKey.ToString()]     =
                        ViewData[Bootstrapper.UserClientSessionKey.ToString()] = entity_ClientSessionInfo;
                }

                //Check the password is expire or not.
                if (entity_LUSerLoginResult.IsPWDExpire)
                {
                    return(Redirect("/AccessControl/Login/Reset"));
                }
                else
                {
                    return(Redirect("/Home/Index"));
                }
            }

            //Output error.
            MsgInfo errorMsgInfo = new MsgInfo();
            errorMsgInfo.MsgTitle = str_MsgBoxTitle;
            //Retrieve all error message.
            errorMsgInfo.MsgDesc       = string.Join("<br/>", entity_LUSerLoginResult.StrList_Error.ToArray());
            errorMsgInfo.MsgType       = MessageType.ValidationError;
            ViewBag.ActionMessage      = errorMsgInfo;
            TempData[ActionMessageKey] = errorMsgInfo;
            return(View(loginUserVM));
        }
Esempio n. 9
0
        public ActionResult Reset(FormCollection collection)
        {
            string str_Error       = "";
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource("Login_Reset");

            List <string> strList_Error = new List <string>();

            if (UserGuid.HasValue)
            {
                LoginUserVM entity_LUVM = new LoginUserVM();
                entity_LUVM.ID = this.UserGuid.Value;

                WebCommonHelper webCommonHelper = new WebCommonHelper();

                LUSerEditResult entity_LUSerEditResult = new LUSerEditResult();

                webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
                {
                    entity_LUSerEditResult = loginUserMgtHelper.Value.GetEntityByID(entity_WCFAuthInfoVM, entity_LUVM.ID.ToString());
                });

                if (entity_LUSerEditResult.StrList_Error.Count > 0)
                {
                    foreach (var item in entity_LUSerEditResult.StrList_Error)
                    {
                        strList_Error.Add(item);
                    }
                }

                if (strList_Error.Count > 0)
                {
                    str_Error = string.Join("<br/>", strList_Error.ToArray());
                }
                else
                {
                    entity_LUVM = entity_LUSerEditResult.Entity_LoginUserVM;

                    typeof(LoginUserVM).GetProperties(BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance).ToList().ForEach(current =>
                    {
                        if (collection.AllKeys.Contains(current.Name))
                        {
                            current.SetValue(entity_LUVM, collection[current.Name], null);
                        }
                    });

                    ClientSessionInfo entity_ClientSessionInfo = null;
                    if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
                    {
                        entity_ClientSessionInfo = (ClientSessionInfo)ViewData[Bootstrapper.UserClientSessionKey.ToString()];
                    }

                    WCFReturnResult entity_Return = new WCFReturnResult();

                    //webCommonHelper.CallWCFHelper<ILoginUserMgtSer>(this, this.HttpContext, postOffice.LoginUserMgtSerPath, (entity_ILoginUserMgtSer, entity_WCFAuthInfoVM) =>
                    //{
                    //    entity_Return = entity_ILoginUserMgtSer.ResetPwd(entity_WCFAuthInfoVM, entity_LUVM);
                    //});

                    webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
                    {
                        entity_Return = loginUserMgtHelper.Value.ResetPwd(entity_WCFAuthInfoVM, entity_LUVM);
                    });

                    if (entity_Return.StrList_Error.Count > 0)
                    {
                        foreach (var item in entity_Return.StrList_Error)
                        {
                            strList_Error.Add(item);
                        }
                        str_Error = string.Join("<br/>", entity_Return.StrList_Error.ToArray());
                    }
                    else
                    if (entity_Return.IsSuccess)
                    {
                        return(Redirect("/AccessControl/FManage"));
                    }
                }
            }

            string str_E011 = MultilingualHelper.GetStringFromResource("E011");

            MsgInfo errorMsgInfo = new MsgInfo();

            errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
            errorMsgInfo.MsgDesc       = str_E011;
            errorMsgInfo.MsgType       = MessageType.ValidationError;
            ViewBag.ActionMessage      = errorMsgInfo;
            TempData[ActionMessageKey] = errorMsgInfo;
            return(View());
        }