Exemple #1
0
        public ResultDTO wfkLoginForDebug(LogonInfo logonInfo)
        {
            ResultDTO result = new ResultDTO();

            SSOTicket ssoTicket = GetSSOTicketFromCookie();

            logonInfo.IsSSOTicketAleadyExisted = true;

            try
            {
                string url = new SSOAuthentication().LogonWithPortalUrl(logonInfo);
                if (url == null)
                {
                    result.success = false;
                    result.message = "user name or password error!";//MessageUserPasswordError;
                }
                else
                {
                    result.success = true;
                    result.data    = url;
                }
            }
            catch (Exception ex)
            {
                result.success = false;
                result.message = ex.Message;
            }

            return(result);
        }
Exemple #2
0
        private bool resetPassword(LogonInfo logonInfo)
        {
            ASNA.Monarch.DynamicDisplayFile wfSignon = new ASNA.Monarch.DynamicDisplayFile("~/Monarch/SignOn.aspx");

            char[] myIndicators = new string('0', 100).ToCharArray();
            string currentPass  = "";
            string newPass      = "";
            string message      = "";

            wfSignon.Open();
            do
            {
                wfSignon.Write("RNEWPASS", myIndicators, populatePassBuffer, message);
                wfSignon.Read();
                if (wfSignon.FeedbackAID == (byte)ASNA.Monarch.WebDspF.AidKeyIBM.F3)
                {
                    return(false);
                }

                System.Data.DataRow row = wfSignon.DataSet.Tables["RNEWPASS"].Rows[0];
                currentPass = row["PASSWORD"].ToString().Trim();
                newPass     = row["NEWPASS"].ToString().Trim();
                if (newPass == row["CONFIRM"].ToString().Trim())
                {
                    break;
                }
                message = "Confirmation Password is not identical to New Password";
            } while (true);
            wfSignon.Close();

            logonInfo.Message  = setNewPassword(logonInfo.User, currentPass, newPass);
            logonInfo.Password = newPass;
            return(true);
        }
Exemple #3
0
        public bool LogIn(string userName, string password, bool rememberMe)
        {
            var user = _userRepository.GetByEmail(userName);

            if (user != null)
            {
                string truePassword = Cryptography.Decrypt(user.Password, AppConstants.SECRET_CODE);
                if (truePassword == password)
                {
                    FormsAuthentication.SetAuthCookie(userName, rememberMe);

                    var logoninfo = new LogonInfo()
                    {
                        DateLogin = DateTime.Now,
                        Email     = user.Email,
                        Id        = user.UID,
                        FullName  = user.Name
                    };

                    var principal = new SitePrincipal(logoninfo);
                    HttpContext.Current.User = principal;
                    return(true);
                }
            }
            return(false);
        }
        public LogonInfo Login(UserInfo userInfo)
        {
            var logonResult
                = gateway.ExecuteAPICommand <LogonInfo>("accounts/login",
                                                        Method.POST, userInfo, HttpStatusCode.OK);

            this.logonInfo = logonResult;
            return(logonResult);
        }
Exemple #5
0
        public void LogonConstructorTest()
        {
            LogonInfo logonInfo = new LogonInfo(_userId, _password);

            Assert.AreEqual<string>(_userId, logonInfo.UserId,
               "The UserId was not correctly initialized.");
            Assert.AreEqual<string>(_password, logonInfo.Password,
               "The Password was not correctly initialized.");
        }
Exemple #6
0
        public void IgnoreTest()
        {
            string newPassword = "******";

            LogonInfo logonInfo = new LogonInfo(_userId, _password);
            logonInfo.UpdatePassword(newPassword);

            Assert.AreEqual<string>(newPassword, logonInfo.Password);
        }
Exemple #7
0
        private void populateSignonBuffer(string formatName, System.Data.DataRow newRow, object cookie)
        {
            LogonInfo logonInfo = cookie as LogonInfo;

            newRow["SYSTEM"]   = logonInfo.Server;
            newRow["PORT"]     = logonInfo.Port;
            newRow["USER"]     = logonInfo.User;
            newRow["PASSWORD"] = logonInfo.Password;
            newRow["MESSAGE"]  = logonInfo.Message;
        }
Exemple #8
0
        public ResultDTO wfkLogin(string userName, string password, string productId, string productName, string orgId, string orgName, string domain, bool isInternal, string language)
        {
            ResultDTO result = new ResultDTO();

            SSOTicket ssoTicket = GetSSOTicketFromCookie();

            LogonInfo logonInfo = new LogonInfo();

            logonInfo.SSORequest  = _SSORequest;
            logonInfo.IsNT        = isInternal;
            logonInfo.OrgID       = Guid.Parse(orgId);
            logonInfo.OrgName     = orgName;
            logonInfo.ProductID   = Guid.Parse(productId);
            logonInfo.ProductName = productName;

            logonInfo.UserName = userName;

            if (ssoTicket == null &&
                _SSORequest.LoginType != LoginTypeEnum.AdminSimulate &&
                _SSORequest.LoginType != LoginTypeEnum.Debug)
            {
                logonInfo.Password = password;
                if (logonInfo.IsNT)
                {
                    logonInfo.Domain = domain;
                }
            }
            else
            {
                logonInfo.IsSSOTicketAleadyExisted = true;
            }
            logonInfo.Language = language;

            try
            {
                string url = new SSOAuthentication().LogonWithPortalUrl(logonInfo);
                if (url == null)
                {
                    result.success = false;
                    result.message = "user name or password error!";//MessageUserPasswordError;
                }
                else
                {
                    result.success = true;
                    result.data    = url;
                }
            }
            catch (Exception ex)
            {
                result.success = false;
                result.message = ex.Message;
            }

            return(result);
        }
Exemple #9
0
        private bool connect(string message)
        {
            LogonInfo logonInfo = new LogonInfo();

            logonInfo.Message = message;

            var    webConfig = ConfigurationManager.AppSettings;
            var    dbName    = webConfig["MobileRPGDatabaseName"] ?? "";
            var    hasDbName = !string.IsNullOrWhiteSpace(dbName);
            string resetExpiredPasswordStr = webConfig["ResetExpiredPassword"] ?? "false";
            bool   resetExpiredPassword    = resetExpiredPasswordStr.Equals("true", StringComparison.InvariantCultureIgnoreCase);


            myDatabase = new AVRRuntime.Database(dbName, AVRRuntime.VirtualTerminal.None, AVRRuntime.OpenAccessDspF.MobileRPG);
            while (true)
            {
                if (!hasDbName && !promptLogon(logonInfo))
                {
                    return(false);
                }
                if (!hasDbName)
                {
                    myDatabase.Server   = logonInfo.Server;
                    myDatabase.Port     = logonInfo.Port;
                    myDatabase.User     = logonInfo.User;
                    myDatabase.Password = logonInfo.Password;
                }
                try
                {
                    myDatabase.Open();
                    break;
                }
                catch (dgException dgEx)
                {
                    logonInfo.Message = dgEx.Message;
                    hasDbName         = false;
                    if (dgEx.Error == dgErrorNumber.dgEsAS400ERROR && dgEx.ErrorClass == dgErrorClass.dgEC_AS400CPF && dgEx.SystemError == 0x22E4)
                    {
                        if (resetExpiredPassword)
                        {
                            if (!resetPassword(logonInfo))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            PsdsJobUser = myDatabase.User;
            return(true);
        }
Exemple #10
0
        void populateSignonBuffer(string formatName, System.Data.DataRow newRow, object cookie)
        {
            LogonInfo logonInfo = cookie as LogonInfo;

            newRow["SYSTEM"]   = logonInfo.Server;
            newRow["USER"]     = logonInfo.User;
            newRow["PASSWORD"] = logonInfo.Password;
            newRow["PORT"]     = logonInfo.Port;
            newRow["PROGRAM"]  = logonInfo.Program;
            newRow["MENU"]     = logonInfo.Menu;
            newRow["LIBRARY"]  = logonInfo.Library;
            newRow["MESSAGE"]  = logonInfo.Message;
        }
        LogonResult Logon(LogonInfo logonInfo)
        {
            LogonResult logonResult = null;

            try
            {
                new TServiceFactory().Create().Using(service =>
                {
                    logonResult = service.Logon(logonInfo);
                }, () => new TServiceFactory().Create());
            }
            catch (Exception e) //(FaultException<AuthenticationCrmServiceError> e)
            {
                //    XtraMessageBox.Show("Произошел сбой авторизации пользователя. \r\nПопробуйте повторить вызов тек. операции", "PKI.CRM", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                new TServiceFactory().ShowErrorMessage(null, true, exception: e);
            }

            return(logonResult);
        }
Exemple #12
0
        public void MakeGuesLogin()
        {
            var guest = _userRepository.GetByGuidID(new Guid(AppConstants.GUEST_GUID));

            if (guest != null)
            {
                var logoninfo = new LogonInfo()
                {
                    DateLogin = DateTime.Now,
                    Email     = guest.Email,
                    Id        = guest.UID,
                    FullName  = guest.Name,
                    IsGuest   = true
                };

                var principal = new SitePrincipal(logoninfo);
                HttpContext.Current.User = principal;
            }
        }
Exemple #13
0
        public void AutoLogin()
        {
            var cookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];

            if (cookie != null)
            {
                var ticket = FormsAuthentication.Decrypt(cookie.Value);
                var email  = ticket.Name;
                if (!String.IsNullOrEmpty(email))
                {
                    var user = _userRepository.GetByEmail(email);
                    if (user != null)
                    {
                        var logoninfo = new LogonInfo()
                        {
                            DateLogin = DateTime.Now,
                            Email     = user.Email,
                            Id        = user.UID,
                            FullName  = user.Name,
                            IsGuest   = false
                        };

                        var principal = new SitePrincipal(logoninfo);
                        HttpContext.Current.User = principal;
                    }
                    else
                    {
                        MakeGuesLogin();
                    }
                }
                else
                {
                    MakeGuesLogin();
                }
            }
            else
            {
                MakeGuesLogin();
            }
        }
Exemple #14
0
        public LogonResult Logon(LogonInfo info)
        {
            LogonResult result = new LogonResult()
            {
                Success = false
            };

            try
            {
                var process = Configuration.Configure();
                process.Logon(info?.LicenseGuid, new LicenseDAL.Models.LogonHistory()
                {
                    MachineName        = info?.History?.MachineName,
                    Login              = info?.History?.UserName,
                    UserDomainName     = info?.History?.UserDomainName,
                    HardwareId         = info?.History?.HardwareId,
                    ApplicationVersion = info?.History?.CurrentVersion,
                    ApplicationName    = info?.History?.ApplicationName,
                    ProductName        = info?.History?.ProductName,
                    ProductId          = info?.History?.ProductId,
                    CSDBuildNumber     = info?.History?.CSDBuildNumber,
                    CSDVersion         = info?.History?.CSDVersion,
                    CurrentBuild       = info?.History?.CurrentBuild,
                    RegisteredOwner    = info?.History?.RegisteredOwner,
                    ServerUrl          = info?.History?.ServerUrl
                });

                return(new LogonResult()
                {
                    Success = process.IsValid, Message = process.ErrorMessage
                });
            }
            catch (Exception e)
            {
                _logger.Error(e.ToString());
                result.Message = "Произошла ошибка на сервере. Попробуйте позже";
            }

            return(result);
        }
Exemple #15
0
        private void logon(bool parmsHaveValues, ref string libraryName, ref string programName, ref string menuName, string message)
        {
            LogonInfo logonInfo = new LogonInfo();

            if (parmsHaveValues)
            {
                logonInfo.Message = message;
                logonInfo.Server  = myDatabase.Server;
                logonInfo.User    = myDatabase.User;
                logonInfo.Port    = myDatabase.Port;
                logonInfo.Library = libraryName;
                logonInfo.Program = programName;
                logonInfo.Menu    = menuName;
            }
            myDatabase = new AVRRuntime.Database("", AVRRuntime.VirtualTerminal.MonarchWeb, AVRRuntime.OpenAccessDspF.Wings);

            while (true)
            {
                promptLogon(logonInfo);

                myDatabase.Server   = logonInfo.Server;
                myDatabase.User     = logonInfo.User;
                myDatabase.Password = logonInfo.Password;
                myDatabase.Port     = logonInfo.Port;

                try
                {
                    myDatabase.Open();
                    break;
                }
                catch (dgException dgEx)
                {
                    logonInfo.Message = dgEx.Message;
                }
            }
            libraryName = logonInfo.Library;
            programName = logonInfo.Program;
            menuName    = logonInfo.Menu;
        }
Exemple #16
0
        private bool connect(string message)
        {
            LogonInfo logonInfo = new LogonInfo();

            logonInfo.Message = message;

            var webConfig = ConfigurationManager.AppSettings;
            var dbName    = webConfig["MobileRPGDatabaseName"] ?? "";
            var hasDbName = !string.IsNullOrWhiteSpace(dbName);

            myDatabase = new AVRRuntime.Database(dbName, AVRRuntime.VirtualTerminal.MonarchWeb, AVRRuntime.OpenAccessDspF.Wings);
            while (true)
            {
                if (!hasDbName && !promptLogon(logonInfo))
                {
                    return(false);
                }
                if (!hasDbName)
                {
                    myDatabase.Server   = logonInfo.Server;
                    myDatabase.Port     = logonInfo.Port;
                    myDatabase.User     = logonInfo.User;
                    myDatabase.Password = logonInfo.Password;
                }
                try
                {
                    myDatabase.Open();
                    break;
                }
                catch (dgException dgEx)
                {
                    logonInfo.Message = dgEx.Message;
                    hasDbName         = false;
                }
            }

            PsdsJobUser = myDatabase.User;
            return(true);
        }
Exemple #17
0
        private bool promptLogon(LogonInfo logonInfo)
        {
            ASNA.Monarch.DynamicDisplayFile wfSignon = new ASNA.Monarch.DynamicDisplayFile("~/Monarch/SignOn.aspx");
            wfSignon.Open();

            char[] myIndicators = new char[100];
            for (int i = 1; i < 100; i++)
            {
                myIndicators[i] = '1';
            }
            if (logonInfo.PromptServer)
            {
                myIndicators[30] = '0';
            }

            logonInfo.Password = "";
            wfSignon.Write("RSIGNON", myIndicators, populateSignonBuffer, logonInfo);
            wfSignon.Read();
            if (wfSignon.FeedbackAID == (byte)ASNA.Monarch.WebDspF.AidKeyIBM.F3)
            {
                return(false);
            }

            System.Data.DataRow row = wfSignon.DataSet.Tables["RSIGNON"].Rows[0];

            if (logonInfo.PromptServer)
            {
                logonInfo.Server = row["SYSTEM"].ToString().Trim();
                logonInfo.Port   = (int)decimal.Parse(row["PORT"].ToString());
            }
            logonInfo.User     = row["USER"].ToString().Trim();
            logonInfo.Password = row["PASSWORD"].ToString().Trim();
            logonInfo.Message  = "";

            wfSignon.Close();

            return(true);
        }
Exemple #18
0
        private void promptLogon(LogonInfo logonInfo)
        {
            ASNA.Monarch.DynamicDisplayFile wfSignon = new ASNA.Monarch.DynamicDisplayFile("~/Monarch/SignOn.aspx");
            wfSignon.Open();

            char[] myIndicators = new string('0', 100).ToCharArray();

            logonInfo.Password = "";
            wfSignon.Write("RSIGNON", myIndicators, populateSignonBuffer, logonInfo);
            wfSignon.Read();
            System.Data.DataRow row = wfSignon.DataSet.Tables["RSIGNON"].Rows[0];

            logonInfo.Server   = row["SYSTEM"].ToString().Trim();
            logonInfo.User     = row["USER"].ToString().Trim();
            logonInfo.Password = row["PASSWORD"].ToString().Trim();
            logonInfo.Port     = ( int )decimal.Parse(row["PORT"].ToString());
            logonInfo.Program  = row["PROGRAM"].ToString().Trim();
            logonInfo.Menu     = row["MENU"].ToString().Trim();
            logonInfo.Library  = row["LIBRARY"].ToString().Trim();
            logonInfo.Message  = "";

            wfSignon.Close();
        }
        public bool Logon(Guid guid, out string errorMessage)
        {
            Guard.AssertNotEmpty(_appName, "Не определено название приложения");
            Guard.AssertNotEmpty(_version, "Не определена версия");
            Guard.AssertNotEmpty(_serverUrl, "не определен Url");
            Guard.Against <ArgumentException>(_key == Guid.Empty, "Не определен ключ");
            //Guard.AssertNotNull(_getResult, "Не определен прокси сервис");

            var info = new LogonInfo()
            {
                LicenseGuid = guid
            };
            var reg = RegistryHelper.Create();

            info.History = new LogonHistory()
            {
                RegisteredOwner = reg?.RegisteredOwner,
                CurrentBuild    = reg?.CurrentBuild,
                CSDVersion      = reg?.CSDVersion,
                CSDBuildNumber  = reg?.CSDBuildNumber,
                ProductName     = reg?.ProductName,
                ProductId       = reg?.ProductId,
                MachineName     = Environment.MachineName,
                UserName        = Environment.UserName,
                UserDomainName  = Environment.UserDomainName,
                HardwareId      = HardwareHelper.GetId(),
                ServerUrl       = _serverUrl,
                ApplicationName = _appName,
                CurrentVersion  = _version
            };

            var res = Logon(info);

            errorMessage = res?.Message;
            return(res?.Success ?? false);
        }
Exemple #20
0
 public void NullUserIdPassedTest()
 {
     LogonInfo logonInfo = new LogonInfo(null, "P@ss0word");
 }
Exemple #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (CubeConfig.SystemMode == Base.Enums.CubeSystemModeEnum.Single)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "SwitchToSingleMode", @"SystemMode = 'S'; $('#ddlProduct').parents('tr').hide();
$('#ddlOrg').parents('tr').hide();", true);
//$('#ddlDomain').parents('tr').hide();", true);

                    string            systemId          = CubeConfig.CubeSystemId;
                    PermissionService permissionService = new PermissionService();
                    permissionService.Url = Config.Global.PermissionServiceUrl;
                    SystemDTO systemInfo = permissionService.GetSystemInfo(Guid.Parse(systemId));
                    DomainDTO domain     = permissionService.GetDomainInfo(systemInfo.Domain_Id);
                    Page.ClientScript.RegisterStartupScript(GetType(), "SetSingleModeInfo", @"SingleModeProductId = '" + systemInfo.Product_Id
                                                            + "'; SingleModeOrgId = '" + systemInfo.Org_Id + "'; SingleModeDomain = '" + domain.Name + "';", true);
                }

                InitializeSSORequest();

                if (_SSORequest != null)
                {
                    if (_SSORequest.LoginType == LoginTypeEnum.Debug)
                    {
                        string[] datas = _SSORequest.Data.Split(',');
                        if (datas.Length >= 5)
                        {
                            if (!string.IsNullOrWhiteSpace(datas[2]) && !string.IsNullOrWhiteSpace(datas[3]))
                            {
                                string       productName = datas[2];
                                string       orgName     = datas[3];
                                string       userName    = datas[4];
                                LoginService service     = new LoginService();

                                List <SimpleProductOrgDTO> productOrgList = (List <SimpleProductOrgDTO>)service.getProductOrgList().data;
                                SimpleProductOrgDTO        product        = productOrgList.FirstOrDefault(p => p.Name.Equals(productName, StringComparison.CurrentCultureIgnoreCase));
                                if (product != null)
                                {
                                    OrgDTO org = product.OrgList.FirstOrDefault(o => o.Name.Equals(orgName, StringComparison.CurrentCultureIgnoreCase));
                                    if (org != null)
                                    {
                                        LogonInfo logonInfo = new LogonInfo();
                                        logonInfo.SSORequest  = _SSORequest;
                                        logonInfo.IsNT        = true;
                                        logonInfo.OrgID       = org.Id;
                                        logonInfo.OrgName     = orgName;
                                        logonInfo.ProductID   = product.Id;
                                        logonInfo.ProductName = productName;
                                        logonInfo.UserName    = userName;
                                        logonInfo.Language    = "zh-CN";
                                        service.wfkLoginForDebug(logonInfo);
                                    }
                                }
                            }
                        }
                    }
                    else if (_SSORequest.LoginType == LoginTypeEnum.AdminSimulate)
                    {
                        Page.ClientScript.RegisterStartupScript(GetType(), "HidePassword", @"$('#tbxPassword').parents('tr').hide();
$('#ddlProduct').parents('tr').hide();
$('#ddlOrg').parents('tr').hide();
$('#ddlDomain').parents('tr').hide();", true);
                    }
                }

                if (CubeConfig.SystemMode == Base.Enums.CubeSystemModeEnum.Single)
                {
                    lblSystemName.Text = CubeConfig.CubeSystemName;
                    lblSystemName.Attributes["lang"] = "";
                }

                if (CubeConfig.CubeEnvironmentVisible)
                {
                    this.textEnvironmentInfo.Text = "(" + CubeConfig.CubeEnvironment + ")";
                }
            }
        }
Exemple #22
0
 public void EmptyUserPassedTest()
 {
     LogonInfo logonInfo = new LogonInfo(null, "P@ss0word");
 }