@Override public User findUserByUsername(String username) { try { return userManager.findUserByUsername(username); } catch (Exception e) { throw new ManagerDataAccessException("Error while retrieving user", e); } }
@Override public User findUserById(Long userId) { try { return userManager.findUser(userId); } catch (Exception e) { throw new ManagerDataAccessException("Error while rtrieving user", e); } }
@Override public List<User> getAllUsers() { try { return userManager.findAllUsers(); } catch (Exception e) { throw new ManagerDataAccessException("Error while rtrieving users", e); } }
@Override public void registerUser(User user, String unencryptedPassword) { user.setPassword(createHash(unencryptedPassword)); try { user.setId(userManager.addUser(user)); } catch (Exception e) { throw new ManagerDataAccessException("Error while registering user", e); } }
@Override public void changePassword(User user, String password, String newUnencryptedPassword) { if (authenticate(user, password)) { user.setPassword(createHash(newUnencryptedPassword)); try { userManager.updateUser(user); } catch (Exception e) { throw new ManagerDataAccessException("Error while rtrieving users", e); } } }