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); }
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); }
IntegratorUser IServiceAuthenticationManager.AuthenticateRequest(string userName, string password, IntegratorPermissions permissions) { return(AuthenticateRequest(userName, password, permissions)); }
IntegratorUser IServiceAuthenticationManager.AuthenticateRequest(HttpContextBase context, IntegratorPermissions permissions) { return(AuthenticateRequest(GetUserName(context.Request), GetPassword(context.Request), permissions)); }
IntegratorUser IServiceAuthenticationManager.AuthenticateRequest(HttpContext context, IntegratorPermissions permissions) { var request = new HttpRequestWrapper(context.Request); return(AuthenticateRequest(GetUserName(request), GetPassword(request), permissions)); }
protected IntegratorUser CreateIntegratorUser(int index, IntegratorPermissions permissions) { return(_integrationCommand.CreateTestIntegratorUser("IntegratorUser" + index, "password", permissions)); }