コード例 #1
0
        private bool InnerLoginAndAuthenticate(string userName, string password, ExchangeSystem exchangeSystem, bool authenticateOnly, out Guid userID, out string errorMsg)
        {
            try
            {
                ParticipantServices.ParticipantServices participantServices = (ParticipantServices.ParticipantServices)Application["ParticipantServices"];
                userID = participantServices.Login(userName, password);
                if (userID == Guid.Empty)
                {
                    errorMsg = "User name not exists or password is invalid.";
                    return(false);
                }

                SecurityServices.SecurityServices securityServices = (SecurityServices.SecurityServices)Application["SecurityServices"];
                Guid programID    = new Guid(ConfigurationSettings.AppSettings["DealingConsole"]);
                Guid permissionID = new Guid(ConfigurationSettings.AppSettings["Run"]);
                bool isAuthrized  = securityServices.CheckPermission(userID, programID, permissionID, "", "", userID, out errorMsg);
                if (isAuthrized == false)
                {
                    userID = Guid.Empty;
                    return(false);
                }

                Token token = new Token(userID, UserType.System, AppType.DealingConsole);
                token.SessionID       = this.Context.Session.SessionID;
                token.ExchangeSystem  = exchangeSystem;
                this.Session["Token"] = token;
                bool success = this.StateServer.Login(token);
                if (success == false)
                {
                    userID   = Guid.Empty;
                    errorMsg = "Login to stateServer failure.";
                    return(false);
                }

                if (!authenticateOnly)
                {
                    FormsAuthentication.SetAuthCookie(userID.ToString(), false);

                    //Prevent be kickout
                    Hashtable sessionIDs = (Hashtable)this.Context.Application["SessionIDs"];
                    sessionIDs         = Hashtable.Synchronized(sessionIDs);
                    sessionIDs[userID] = this.Context.Session.SessionID;
                }

                return(true);
            }
            catch (Exception exception)
            {
                AppDebug.LogEvent("DealingConsole", exception.ToString(), EventLogEntryType.Error);
                throw;
            }
        }
コード例 #2
0
        public bool UpdatePassword(string loginId, string oldPassword, string newPassword, out string message)
        {
            message = "";
            ParticipantServices.ParticipantServices ParticipantServices = (ParticipantServices.ParticipantServices)Application["ParticipantServices"];
            Guid userId = ParticipantServices.Login(loginId, oldPassword);

            if (userId != Guid.Empty)
            {
                Token token = (Token)Session["Token"];
                return(ParticipantServices.UpdatePassword(userId, newPassword, userId, out message));
            }
            return(false);
        }