UserFacadeEjb implements UserFacade { @Override public Set<UserRole> getValidLoginRoles(String userName, String password) { User user = userService.getByUserName(userName); if (user != null && user.isActive()) { if (DataHelper.equal(user.getPassword(), PasswordHelper.encodePassword(password, user.getSeed()))) { return new HashSet<UserRole>(user.getUserRoles()); } } return null; }  @Override List<UserReferenceDto> getUsersByRegionAndRoles(RegionReferenceDto regionRef, UserRole... assignableRoles); @Override List<UserReferenceDto> getUserRefsByDistrict(DistrictReferenceDto districtRef, boolean includeSupervisors, UserRole... userRoles); @Override List<UserReferenceDto> getAllUserRefs(); @Override List<UserDto> getUsersByAssociatedOfficer(UserReferenceDto associatedOfficerRef, UserRole... userRoles); @Override List<UserDto> getAllAfter(Date date); @Override List<UserDto> getByUuids(List<String> uuids); @Override List<String> getAllUuids(); @Override UserDto getByUuid(String uuid); @Override UserDto getByUserName(String userName); @Override UserDto saveUser(UserDto dto); @Override List<UserDto> getIndexList(UserCriteria userCriteria, int first, int max, List<SortProperty> sortProperties); @Override long count(UserCriteria userCriteria); static UserDto toDto(User source); static UserReferenceDto toReferenceDto(User entity); @Override boolean isLoginUnique(String uuid, String userName); @Override String resetPassword(String uuid); @Override UserDto getCurrentUser(); @Override UserReferenceDto getCurrentUserAsReference(); @Override Set<UserRole> getValidLoginRoles(String userName, String password); @Override void removeUserAsSurveillanceAndContactOfficer(String userUuid);  }
@Test public void testGetValidLoginRoles() { RDCF rdcf = creator.createRDCF(); UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_SUPERVISOR); String password = getUserFacade().resetPassword(user.getUuid()); Set<UserRole> validLoginRoles = getUserFacade().getValidLoginRoles(user.getUserName(), password); assertThat(validLoginRoles, containsInAnyOrder(UserRole.SURVEILLANCE_SUPERVISOR)); user.setActive(false); getUserFacade().saveUser(user); validLoginRoles = getUserFacade().getValidLoginRoles(user.getUserName(), password); assertThat(validLoginRoles, nullValue()); }