コード例 #1
0
        public IActionResult IssueToken([FromBody] AuthenticateUserParams authenticateUserParams)
        {
            var command = new AuthenticateUserCommand
            {
                Login     = authenticateUserParams.Login,
                Password  = authenticateUserParams.Password,
                Pin       = authenticateUserParams.Pin,
                IpAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString()
            };

            return(_commandHandler.ExecuteCommand(command, -1));
        }
コード例 #2
0
        private static void ValidateUser(ValidateUserNamePasswordParams parameters)
        {
            AuthenticationProvider provider = new AuthenticationProvider();

            provider.Initialize(parameters.Password);

            AuthenticateUserAction aua = new AuthenticateUserAction();
            AuthenticateUserParams p   = new AuthenticateUserParams();

            p.UserName         = parameters.UserName;
            p.Salt             = provider.Salt;
            p.Data             = provider.SessionData;
            p.Product          = productName;
            p.NodeIdentity     = ""; //TODO loose this
            p.TerminalIdentity = ""; //TODO loose this

            // Authenticate
            AuthenticateUserResultParams r = aua.Execute(p);

            if (!String.IsNullOrEmpty(r.Almid))
            {
                throw new AlarmException(r.Almid, r.AlarmText1, null);
            }

            AuthenticationSession authenticationSession = provider.DecryptSession(r.SessionData);

            // Logon application
            LogonUserParams lp = new LogonUserParams();

            lp.TerminalIdentity = "";  //TODO loose this
            lp.UserName         = parameters.UserName;
            lp.SessionIdentity  = authenticationSession.SessionId;

            LogonUserAction       lua = new LogonUserAction();
            LogonUserResultParams lr  = lua.Execute(lp);

            if (!String.IsNullOrEmpty(lr.Almid))
            {
                throw new AlarmException(lr.Almid, lr.AlarmText1, null);
            }
        }