示例#1
0
 public static String getToken(
     HttpServletRequest request, HttpServletResponse response, String name) {
   String value = CookieUtil.getValue(request, name);
   try {
     if (StringUtil.isNotBlank(value)) {
       value = URLDecoder.decode(value, CharsetConstant.UTF_8);
       return AESUtil.decryptBase64(secKey, value);
     }
   } catch (Exception e) {
     logger.error("Read cookie failured!", e);
   }
   return null;
 }
示例#2
0
 public static void saveToken(
     HttpServletRequest request, HttpServletResponse response, String name, String token) {
   if (StringUtil.isBlank(token)) {
     return;
   }
   try {
     token = AESUtil.encryptBase64(secKey, token);
     token = URLEncoder.encode(token, CharsetConstant.UTF_8);
     Cookie secCookie = new Cookie(name, token);
     secCookie.setPath(SymbolConstant.SLASH);
     CookieUtil.addCookie(response, secCookie);
   } catch (Exception e) {
     logger.error("Save Cookie failure!", e);
   }
 }