Exemple #1
0
        public void Execute(ValidateUserNamePasswordParams parameters)
        {
            CredentialProxy credentials;


            lock (lockObject)
            {
                credentialCache.TryGetValue(parameters.UserName, out credentials);
            }

            if (credentials != null)
            {
                if (CredentialProxy.IsValid(parameters.UserName, parameters.Password, credentials))
                {
                    return;
                }
                else
                {
                    lock (lockObject)
                    {
                        credentialCache.Remove(parameters.UserName);
                    }
                }
            }

            ValidateUser(parameters);

            lock (lockObject)
            {
                credentialCache.Add(parameters.UserName, new CredentialProxy(parameters.UserName, parameters.Password));
            }
        }
Exemple #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);
            }
        }