Esempio n. 1
0
 public UserStatusEnum Reg(User user) {
   // TODO Auto-generated method stub
   if (user == null) return UserStatusEnum.UNV;
   else {
     try {
       User temp = userDao.selectUserByUsername(user.getUsername());
       if (temp != null) {
         return UserStatusEnum.UE;
       }
       user.setPassword(EncodeTools.encoder(user.getPassword(), EncodeTools.giveMeSalt()));
       userDao.addUser(user);
       return UserStatusEnum.RS;
     } catch (Exception e) {
       System.out.println(e.getMessage());
       return UserStatusEnum.AUF;
     }
   }
 }
Esempio n. 2
0
 public UserStatusEnum login(String username, String password) {
   // TODO Auto-generated method stub
   if (username == null || password == null) return UserStatusEnum.UNV;
   username = username.trim();
   password = password.trim();
   if (username == "" || password == "") return UserStatusEnum.UNV;
   User user = userDao.selectUserByUsername(username);
   if (user != null
       && user.getPassword()
           .equals(EncodeTools.encoder(password, user.getPassword().substring(0, 4)))) {
     return UserStatusEnum.LS;
   } else return UserStatusEnum.PI;
 }