@Test public void paserEncrpytCookieValue() { CookieNameConfig cookieNameConfig = new CookieNameConfig(CookieNameEnum.msun_cookie_forever, encryptedCookieNamePolicy); cookieNameConfig.appendKey(CookieKeyEnum.cookie_id); cookieNameConfig.appendKey(CookieKeyEnum.last_access_time); cookieNameConfig.appendKey(CookieKeyEnum.member_id); String cookieValue = "c_id=1&l_t=2&y_m_id=3"; cookieValue = CookieUtils.encrypt(cookieValue); System.out.println("encypted:" + cookieValue); CookieNameHelper cookieNameHelper = CookieParser.paserCookieValue(cookieNameConfig, cookieValue); Assert.assertNotNull(cookieNameHelper); Assert.assertTrue(cookieNameHelper.getAllKeys().size() == 2); Assert.assertTrue(cookieNameHelper.getValue(CookieKeyEnum.cookie_id).equals("1")); Assert.assertTrue(cookieNameHelper.getValue(CookieKeyEnum.member_id).equals("3")); }
static CookieNameHelper paserCookieValue(CookieNameConfig cookieNameConfig, String cookieValue) { String value = StringUtils.trimToNull(cookieValue); if (value == null || StringUtils.equalsIgnoreCase("null", value)) return null; if (cookieNameConfig.isEncrypt()) { value = CookieUtils.decrypt(value); } CookieNameHelper cookieNameHelper = new CookieNameHelper(cookieNameConfig.getCookieName(), cookieNameConfig); if (cookieNameConfig.isSimpleValue()) { cookieNameHelper.parserValue(value); } else { Map<CookieKeyEnum, String> kv = CookieUtils.strToKVMap(value, cookieNameConfig); if (kv != null && !kv.isEmpty()) cookieNameHelper.parserAllValues(kv); } return cookieNameHelper; }
CookieParser { static CookieNameHelper paserCookieValue(CookieNameConfig cookieNameConfig, String cookieValue) { String value = StringUtils.trimToNull(cookieValue); if (value == null || StringUtils.equalsIgnoreCase("null", value)) return null; if (cookieNameConfig.isEncrypt()) { value = CookieUtils.decrypt(value); } CookieNameHelper cookieNameHelper = new CookieNameHelper(cookieNameConfig.getCookieName(), cookieNameConfig); if (cookieNameConfig.isSimpleValue()) { cookieNameHelper.parserValue(value); } else { Map<CookieKeyEnum, String> kv = CookieUtils.strToKVMap(value, cookieNameConfig); if (kv != null && !kv.isEmpty()) cookieNameHelper.parserAllValues(kv); } return cookieNameHelper; } }
CookieParser { static CookieNameHelper paserCookieValue(CookieNameConfig cookieNameConfig, String cookieValue) { String value = StringUtils.trimToNull(cookieValue); if (value == null || StringUtils.equalsIgnoreCase("null", value)) return null; if (cookieNameConfig.isEncrypt()) { value = CookieUtils.decrypt(value); } CookieNameHelper cookieNameHelper = new CookieNameHelper(cookieNameConfig.getCookieName(), cookieNameConfig); if (cookieNameConfig.isSimpleValue()) { cookieNameHelper.parserValue(value); } else { Map<CookieKeyEnum, String> kv = CookieUtils.strToKVMap(value, cookieNameConfig); if (kv != null && !kv.isEmpty()) cookieNameHelper.parserAllValues(kv); } return cookieNameHelper; }  }
CookieParser { static CookieNameHelper paserCookieValue(CookieNameConfig cookieNameConfig, String cookieValue) { String value = StringUtils.trimToNull(cookieValue); if (value == null || StringUtils.equalsIgnoreCase("null", value)) return null; if (cookieNameConfig.isEncrypt()) { value = CookieUtils.decrypt(value); } CookieNameHelper cookieNameHelper = new CookieNameHelper(cookieNameConfig.getCookieName(), cookieNameConfig); if (cookieNameConfig.isSimpleValue()) { cookieNameHelper.parserValue(value); } else { Map<CookieKeyEnum, String> kv = CookieUtils.strToKVMap(value, cookieNameConfig); if (kv != null && !kv.isEmpty()) cookieNameHelper.parserAllValues(kv); } return cookieNameHelper; }  static Map<CookieNameEnum, CookieNameHelper> loadCookie(HttpServletRequest request); }
CookieParser { static CookieNameHelper paserCookieValue(CookieNameConfig cookieNameConfig, String cookieValue) { String value = StringUtils.trimToNull(cookieValue); if (value == null || StringUtils.equalsIgnoreCase("null", value)) return null; if (cookieNameConfig.isEncrypt()) { value = CookieUtils.decrypt(value); } CookieNameHelper cookieNameHelper = new CookieNameHelper(cookieNameConfig.getCookieName(), cookieNameConfig); if (cookieNameConfig.isSimpleValue()) { cookieNameHelper.parserValue(value); } else { Map<CookieKeyEnum, String> kv = CookieUtils.strToKVMap(value, cookieNameConfig); if (kv != null && !kv.isEmpty()) cookieNameHelper.parserAllValues(kv); } return cookieNameHelper; }  static Map<CookieNameEnum, CookieNameHelper> loadCookie(HttpServletRequest request);  }