public static void createAndStoreCryptographicallyStrongTokenInSession(HttpSession session) { ByteArrayGuardAESCTR guard = new ByteArrayGuardAESCTR(); String clearText = "" + System.currentTimeMillis(); String result = guard.encrypt(clearText); try { result = URLEncoder.encode(result, "UTF-8"); } catch (UnsupportedEncodingException e) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, "Unable to URL encode cryptographically strong token, storing clear text in session instead.", e); } result = clearText; } session.setAttribute(TOKEN_NAME, result); }
public static void createAndStoreCryptographicallyStrongTokenInSession(HttpSession session) { ByteArrayGuardAESCTR guard = new ByteArrayGuardAESCTR(); String clearText = "" + System.currentTimeMillis(); String result = guard.encrypt(clearText); try { result = URLEncoder.encode(result, "UTF-8"); } catch (UnsupportedEncodingException e) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, "Unable to URL encode cryptographically strong token, storing clear text in session instead.", e); } result = clearText; } session.setAttribute(TOKEN_NAME, result); }
public static void createAndStoreCryptographicallyStrongTokenInSession(HttpSession session) { ByteArrayGuardAESCTR guard = new ByteArrayGuardAESCTR(); String clearText = "" + System.currentTimeMillis(); String result = guard.encrypt(clearText); try { result = URLEncoder.encode(result, "UTF-8"); } catch (UnsupportedEncodingException e) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, "Unable to URL encode cryptographically strong token, storing clear text in session instead.", e); } result = clearText; } session.setAttribute(TOKEN_NAME, result); }
public static void createAndStoreCryptographicallyStrongTokenInSession(HttpSession session) { ByteArrayGuardAESCTR guard = new ByteArrayGuardAESCTR(); String clearText = "" + System.currentTimeMillis(); String result = guard.encrypt(clearText); try { result = URLEncoder.encode(result, "UTF-8"); } catch (UnsupportedEncodingException e) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, "Unable to URL encode cryptographically strong token, storing clear text in session instead.", e); } result = clearText; } session.setAttribute(TOKEN_NAME, result); }
/** * <p>Encode the current state of the * PreviousNextFlashInfoManager to the cookie.</p> */ Cookie encode() { Cookie result = null; String value = ((null != previousRequestFlashInfo) ? previousRequestFlashInfo.encode() : "") + "_" + ((null != nextRequestFlashInfo) ? nextRequestFlashInfo.encode() : ""); String encryptedValue = guard.encrypt(value); try { result = new Cookie(FLASH_COOKIE_NAME, URLEncoder.encode(encryptedValue, "UTF-8")); } catch (UnsupportedEncodingException uee) { result = new Cookie(FLASH_COOKIE_NAME, encryptedValue); } if (1 == value.length()) { result.setMaxAge(0); } String requestContextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); if (requestContextPath.isEmpty()) { requestContextPath = "/"; } result.setPath(requestContextPath); return result; }
/** * <p>Encode the current state of the * PreviousNextFlashInfoManager to the cookie.</p> */ Cookie encode() { Cookie result = null; String value = ((null != previousRequestFlashInfo) ? previousRequestFlashInfo.encode() : "") + "_" + ((null != nextRequestFlashInfo) ? nextRequestFlashInfo.encode() : ""); String encryptedValue = guard.encrypt(value); try { result = new Cookie(FLASH_COOKIE_NAME, URLEncoder.encode(encryptedValue, "UTF-8")); } catch (UnsupportedEncodingException uee) { result = new Cookie(FLASH_COOKIE_NAME, encryptedValue); } if (1 == value.length()) { result.setMaxAge(0); } String requestContextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); if (requestContextPath.isEmpty()) { requestContextPath = "/"; } result.setPath(requestContextPath); return result; }
/** * <p>Encode the current state of the * PreviousNextFlashInfoManager to the cookie.</p> */ Cookie encode() { Cookie result = null; String value = ((null != previousRequestFlashInfo) ? previousRequestFlashInfo.encode() : "") + "_" + ((null != nextRequestFlashInfo) ? nextRequestFlashInfo.encode() : ""); String encryptedValue = guard.encrypt(value); try { result = new Cookie(FLASH_COOKIE_NAME, URLEncoder.encode(encryptedValue, "UTF-8")); } catch (UnsupportedEncodingException uee) { result = new Cookie(FLASH_COOKIE_NAME, encryptedValue); } if (1 == value.length()) { result.setMaxAge(0); } String requestContextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); if (requestContextPath.isEmpty()) { requestContextPath = "/"; } result.setPath(requestContextPath); return result; }
/** * <p>Encode the current state of the * PreviousNextFlashInfoManager to the cookie.</p> */ Cookie encode() { Cookie result = null; String value = ((null != previousRequestFlashInfo) ? previousRequestFlashInfo.encode() : "") + "_" + ((null != nextRequestFlashInfo) ? nextRequestFlashInfo.encode() : ""); String encryptedValue = guard.encrypt(value); try { result = new Cookie(FLASH_COOKIE_NAME, URLEncoder.encode(encryptedValue, "UTF-8")); } catch (UnsupportedEncodingException uee) { result = new Cookie(FLASH_COOKIE_NAME, encryptedValue); } if (1 == value.length()) { result.setMaxAge(0); } String requestContextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); if (requestContextPath.isEmpty()) { requestContextPath = "/"; } result.setPath(requestContextPath); return result; }