@Override
 public void save(User user) throws UserExistedException {
   if (userDao.get(user.getLoginName()) != null) {
     throw new UserExistedException();
   }
   user.setPassword(SecurityUtils.encryptPassword(user.getLoginName(), user.getPassword()));
   user.setRegTime(new Date());
   userDao.save(user);
 }
 @Override
 public User getUser(String encryptedId) {
   try {
     int id = Integer.valueOf(SecurityUtils.volatileDecrypt(encryptedId));
     return userDao.get(id);
   } catch (Exception e) {
     return null;
   }
 }
 @Override
 public User getUser(String loginName, String password) {
   User user = userDao.get(loginName);
   if ((user != null)
       && user.getPassword().equals(SecurityUtils.encryptPassword(loginName, password))) {
     return user;
   } else {
     return null;
   }
 }