Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1.  
  2. package com.oblivionsoftware.raid.security;
  3.  
  4. /**
  5. * Imports
  6. */
  7. import com.oblivionsoftware.raid.entity.User;
  8. import com.oblivionsoftware.raid.entity.UserServiceBean;
  9. import javax.ejb.EJB;
  10. import javax.ejb.Stateless;
  11.  
  12. /**
  13. * SecurityServiceBean.
  14. *
  15. * @author Dustin Dobervich <ddobervich@gmail.com>
  16. */
  17. @Stateless
  18. public class SecurityServiceBean
  19. {
  20. /**
  21. * Private Data
  22. */
  23. @EJB
  24. private UserServiceBean userService;
  25.  
  26. @EJB
  27. private PasswordEncoderServiceBean encoder;
  28.  
  29. /**
  30. * Validates a users credentials.
  31. *
  32. * @param username The username
  33. * @param password The password
  34. * @return True if valid, false otherwise
  35. */
  36. public boolean validateCredentials(String username, String password)
  37. {
  38. User user = this.userService.findUserByUsername(username);
  39.  
  40. String encodedPassword = this.encoder.encodePassword(password, user.getSalt());
  41.  
  42. return encodedPassword.equals(password);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement