Advertisement
duc-phan

Untitled

Nov 30th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public class UserValidator {
  2.     private Cryptographer cryptographer;
  3.     public boolean checkPassword(String userName, String password) {
  4.         User user = UserGateway.findByName(userName);
  5.         if (user != User.NULL) {
  6.             String codedPhrase = user.getPhraseEncodedByPassword();
  7.             String phrase = cryptographer.decrypt(codedPhrase, password);
  8.             if ("Valid Password".equals(phrase)) {
  9.                 Session.initialize();
  10.                 return true;
  11.             }
  12.         }
  13.         return false;
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement