private static String md5Hex(String a2) {
   try {
     return DigestUtils.md5DigestAsHex(a2.getBytes("UTF-8"));
   } catch (UnsupportedEncodingException e) {
     throw new RuntimeException(e);
   }
 }
  private ModelAndView authenticateHelper(ModelAndView mav) {
    boolean authenticated = userService.isAuthenticated();
    mav.addObject("auth", authenticated);

    if (authenticated) {
      LOGGER.debug("User={} is authenticated", userService.getUser());
      mav.setViewName("settings");
      mav.addObject("template", "settings");

      mav.addObject("user", userService.getUser());
      mav.addObject(
          "gravatar", DigestUtils.md5DigestAsHex(userService.getUser().getEmail().getBytes()));
    }
    return mav;
  }
Esempio n. 3
0
 public String execute() throws Exception {
   errorInfo = "";
   if (!(Boolean) ServletActionContext.getRequest().getSession().getAttribute("isLogin"))
     return "index";
   if (number == null || password == null) return "this";
   User user = (User) ServletActionContext.getRequest().getSession().getAttribute("user");
   if (!user.getPassword().equals(DigestUtils.md5DigestAsHex(password.getBytes()))) {
     errorInfo = "ÃÜÂë´íÎó£¬ÇëÖØÊÔ";
     number = password = null;
     return "this";
   }
   int balance = Integer.parseInt(number) + user.getBalance();
   user.setBalance(balance);
   userService.update(user);
   number = password = null;
   return "success";
 }
Esempio n. 4
0
 public String encrypt(String username, String password) {
   return DigestUtils.md5DigestAsHex((username + "_._" + password).getBytes());
 }