Esempio n. 1
0
 public XElement SetResultForJavaTrader(LoginInfo loginInfo)
 {
     Session session = loginInfo.Parameter.Request.ClientInfo.Session;
     Token token = SessionManager.Default.GetToken(session);
     var companyLogo = this.GetLogoForJava(loginInfo.CompanyName);
     var colorSettings = this.GetColorSettingsForJava(loginInfo.CompanyName);
     var systemParameter = this.GetParameterForJava(session, loginInfo.CompanyName, token.Language);
     var settings = this.GetSettings(loginInfo.CompanyName);
     var tradingAccountData = Application.Default.TradingConsoleServer.GetTradingAccountData(loginInfo.UserID);
     var recoverPasswordData = Application.Default.TradingConsoleServer.GetRecoverPasswordData(token.Language, loginInfo.UserID);
     var dict = new Dictionary<string, string>()
             {
                 {"companyName", loginInfo.CompanyName},
                 {"disallowLogin", loginInfo.DisallowLogin.ToString()},
                 {"isActivateAccount", loginInfo.IsActivateAccount.ToString()},
                 {"isDisableJava30", loginInfo.IsDisableJava30.ToString()},
                 {"companyLogo",Convert.ToBase64String(companyLogo)},
                 {"colorSettings",colorSettings.OuterXml},
                 {"parameter",systemParameter.OuterXml},
                 {"settings",settings.OuterXml},
                 {"recoverPasswordData",recoverPasswordData.ToXml()},
                 {"tradingAccountData", tradingAccountData.ToXml()},
                 {"userId", loginInfo.UserID.ToString()},
                 {"session", session.ToString()}
             };
     return XmlResultHelper.NewResult(dict);
 }
Esempio n. 2
0
 private void AsyncLoginCompletedCallback(ILoginProvider provider,LoginInfo loginInfo)
 {
     provider.Completed -= AsyncLoginCompletedCallback;
     bool success = false;
     switch (loginInfo.Status)
     {
         case LoginStatus.None:
             break;
         case LoginStatus.ExceedMaxRetryCount:
             var loginId = loginInfo.Parameter.LoginId;
             var password = loginInfo.Parameter.Password;
             var ip = loginInfo.Parameter.Request.ClientInfo.RemoteIp;
             _Logger.WarnFormat("{0} login failed: exceed max login retry times", loginId);
             AuditHelper.AddIllegalLogin(AppType.TradingConsole, loginId, password, ip);
             Application.Default.TradingConsoleServer.SaveLoginFail(loginId, password, ip);
             break;
         case LoginStatus.LoginIdIsEmpty:
             _Logger.Warn("LoginId is empty");
             break;
         case LoginStatus.ParticipantServiceLoginFailed:
             break;
         case LoginStatus.UserIdIsEmpty:
             _Logger.WarnFormat("{0} is not a valid user", loginInfo.Parameter.LoginId);
             break;
         case LoginStatus.CheckPermissionFailed:
             break;
         case LoginStatus.NotAuthrized:
             _Logger.WarnFormat("{0} doesn't have the right to login trader", loginInfo.Parameter.LoginId);
             break;
         case LoginStatus.StateServerLoginFailed:
             break;
         case LoginStatus.StateServerNotLogined:
             break;
         case LoginStatus.Success:
             success = true;
             break;
     }
     if (!success)
     {
         LoginRetryTimeHelper.IncreaseFailedCount(loginInfo.Parameter.LoginId, ParticipantType.Customer, SettingManager.Default.ConnectionString);
         OnError(loginInfo.Parameter.Request, loginInfo.Parameter.AppType);
     }
     else
     {
         LoginRetryTimeHelper.ClearFailedCount(loginInfo.UserID, ParticipantType.Customer, SettingManager.Default.ConnectionString);
         ProcessPostAsyncLoginSuccess(loginInfo);
     }
 }
Esempio n. 3
0
 public LoginService(LoginInfo loginInfo)
 {
     this._LoginInfo = loginInfo;
 }
Esempio n. 4
0
 private bool SetLoginInfo(LoginInfo loginInfo)
 {
     var ds = Application.Default.TradingConsoleServer.GetLoginParameters(loginInfo.UserID, string.Empty);
     var row = ds.Tables[0].Rows[0];
     bool isPathPassed = (Boolean)row["IsPathPassed"];
     loginInfo.DisallowLogin = (Boolean)row["DisallowLogin"];
     loginInfo.IsActivateAccount = (Boolean)row["IsActivateAccount"];
     loginInfo.IsDisableJava30 = (Boolean)row["IsDisableJava30"];
     if (!loginInfo.CompanyName.HasValue())
     {
         var companyName2 = (String)row["Path"];
         if (companyName2 == string.Empty)
             companyName2 = "MHL";
         if (Directory.Exists(LoginHelper.GetOrginazationDir(companyName2)))
         {
             isPathPassed = true;
             loginInfo.CompanyName = companyName2;
         }
     }
     return isPathPassed && !loginInfo.DisallowLogin;
 }
Esempio n. 5
0
 private void ProcessPostAsyncLoginSuccess(LoginInfo loginInfo)
 {
     Session session = loginInfo.Parameter.Request.ClientInfo.Session;
     if (SetLoginInfo(loginInfo))
     {
         SessionManager.Default.AddSession(loginInfo.UserID, session);
         string version = loginInfo.Parameter.Version;
         var language = string.IsNullOrEmpty(version) ? "ENG" : version.Substring(version.Length - 3);
         var token = SessionManager.Default.GetToken(session);
         if (token == null)
         {
             var tokenType = loginInfo.Parameter.AppType;
             token = new Token(loginInfo.UserID, UserType.Customer, tokenType);
             SessionManager.Default.AddToken(session, token);
         }
         token.Language = language;
         Application.Default.SessionMonitor.Add(session);
         switch (loginInfo.Parameter.AppType)
         {
             case AppType.TradingConsole:
                 JavaLoginService service = new JavaLoginService(loginInfo);
                 service.AsyncGetLoginData();
                 break;
             case AppType.Mobile:
                 OnStateLoadingComplete(AppType.Mobile);
                 break;
             case AppType.CppTrader:
                 OnStateLoadingComplete(AppType.CppTrader);
                 break;
             default:
                 throw new ArgumentException(string.Format("{0} is not recogized", loginInfo.Parameter.AppType), "AppType");
         }
     }
     else
     {
         SessionManager.Default.RemoveToken(session);
     }
 }
Esempio n. 6
0
        public IEnumerator<int> AsyncLogin(LoginParameter parameter,AsyncEnumerator ae)
        {
            string connectionString = SettingManager.Default.ConnectionString;
            LoginInfo loginInfo = new LoginInfo() { Parameter=parameter};
            if (LoginRetryTimeHelper.IsFailedCountExceeded(parameter.LoginId, ParticipantType.Customer, connectionString))
            {
                loginInfo.Status = LoginStatus.ExceedMaxRetryCount;
                OnCompleted(loginInfo);
                yield break;
            }
            if (!parameter.LoginId.HasValue())
            {
                loginInfo.Status = LoginStatus.LoginIdIsEmpty;
                OnCompleted(loginInfo);
                yield break;
            }

            Application.Default.ParticipantService.BeginLogin(parameter.LoginId, parameter.Password,ae.End(), null);
            yield return 1;
            try
            {
                loginInfo.UserID = Application.Default.ParticipantService.EndLogin(ae.DequeueAsyncResult());
            }
            catch (Exception ex)
            {
                _Logger.Error(ex);
                loginInfo.Status = LoginStatus.ParticipantServiceLoginFailed;
                OnCompleted(loginInfo);
                yield break;
            }

            if (loginInfo.UserID == Guid.Empty)
            {
                loginInfo.Status = LoginStatus.UserIdIsEmpty;
                OnCompleted(loginInfo);
                yield break;
            }

            Guid programID = new Guid(SettingManager.Default.GetJavaTraderSettings("TradingConsole"));
            Guid permissionID = new Guid(SettingManager.Default.GetJavaTraderSettings("Run"));
            Application.Default.SecurityService.BeginCheckPermission(loginInfo.UserID, programID, permissionID, "", "", loginInfo.UserID, ae.End(), null);
            yield return 1;
            bool isAuthrized = false;
            try
            {
                string message;
                isAuthrized = Application.Default.SecurityService.EndCheckPermission(ae.DequeueAsyncResult(), out message);
            }
            catch (Exception ex)
            {
                _Logger.Error(ex);
                loginInfo.Status = LoginStatus.CheckPermissionFailed;
                OnCompleted(loginInfo);
                yield break;
            }

            if (!isAuthrized)
            {
                loginInfo.Status = LoginStatus.NotAuthrized;
                OnCompleted(loginInfo);
                yield break;
            }

            var token = new Token(Guid.Empty, UserType.Customer, parameter.AppType);
            token.UserID = loginInfo.UserID;
            token.SessionID = parameter.Request.ClientInfo.Session.ToString();
            SessionManager.Default.AddToken(parameter.Request.ClientInfo.Session, token);

            var stateServerCallToken = new Token
            {
                UserID = token.UserID,
                AppType = AppType.TradingConsole,
                SessionID = token.SessionID,
                UserType=token.UserType
            };

            Application.Default.StateServer.BeginLogin(stateServerCallToken, ae.End(), null);
            yield return 1;
            bool isStateServerLogined = false;
            try
            {
                isStateServerLogined = Application.Default.StateServer.EndLogin(ae.DequeueAsyncResult());
            }
            catch (Exception ex)
            {
                _Logger.Error(ex);
                loginInfo.Status = LoginStatus.StateServerLoginFailed;
                OnCompleted(loginInfo);
                yield break;
            }

            if (!isStateServerLogined)
            {
                loginInfo.Status = LoginStatus.StateServerNotLogined;
                OnCompleted(loginInfo);
                yield break;
            }
            loginInfo.Status = LoginStatus.Success;
            OnCompleted(loginInfo);
        }
Esempio n. 7
0
 private void OnCompleted(LoginInfo info)
 {
     var handle = Completed;
     if (handle != null)
         handle(this, info);
 }