Exemple #1
0
        private IntegratorUser AuthenticateRequest(string userName, string password, IntegratorPermissions permissions)
        {
            if (string.IsNullOrEmpty(userName))
            {
                throw new UserException(NoUserNameError);
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new UserException(NoPasswordError);
            }

            var user = _integrationQuery.GetIntegratorUser(userName);

            if (user == null)
            {
                throw new UserException(string.Format(UnknownUserError, userName));
            }

            var passwordHash = LoginCredentials.HashToString(password);

            if (passwordHash != user.PasswordHash)
            {
                throw new UserException(string.Format(IncorrectPasswordError, userName));
            }

            if (!user.Permissions.IsFlagSet(permissions))
            {
                throw new UserException(string.Format(PermissionDeniedError, user.LoginId));
            }

            return(user);
        }
Exemple #2
0
        public static IntegratorUser CreateTestIntegratorUser(this IIntegrationCommand integrationCommand, string loginId, string password, IntegratorPermissions permissions)
        {
            var system = new Ats {
                Name = loginId + " Integration System"
            };

            integrationCommand.CreateIntegrationSystem(system);

            var user = new IntegratorUser {
                LoginId = loginId, PasswordHash = HashToString(password), Permissions = permissions, IntegrationSystemId = system.Id
            };

            integrationCommand.CreateIntegratorUser(user);

            return(user);
        }
Exemple #3
0
 IntegratorUser IServiceAuthenticationManager.AuthenticateRequest(string userName, string password, IntegratorPermissions permissions)
 {
     return(AuthenticateRequest(userName, password, permissions));
 }
Exemple #4
0
 IntegratorUser IServiceAuthenticationManager.AuthenticateRequest(HttpContextBase context, IntegratorPermissions permissions)
 {
     return(AuthenticateRequest(GetUserName(context.Request), GetPassword(context.Request), permissions));
 }
Exemple #5
0
        IntegratorUser IServiceAuthenticationManager.AuthenticateRequest(HttpContext context, IntegratorPermissions permissions)
        {
            var request = new HttpRequestWrapper(context.Request);

            return(AuthenticateRequest(GetUserName(request), GetPassword(request), permissions));
        }
Exemple #6
0
 protected IntegratorUser CreateIntegratorUser(int index, IntegratorPermissions permissions)
 {
     return(_integrationCommand.CreateTestIntegratorUser("IntegratorUser" + index, "password", permissions));
 }