List of usage examples for javax.servlet.http HttpServletRequest setAttribute
public void setAttribute(String name, Object o);
From source file:com.jsmartframework.web.manager.CsrfEncrypter.java
private static Cipher getEncryptCipher(HttpServletRequest request, String key) throws Exception { Cipher encryptCipher = (Cipher) request.getAttribute(REQUEST_CSRF_ENCRYPT_CIPHER); if (encryptCipher == null) { encryptCipher = Cipher.getInstance("AES"); SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF8"), "AES"); encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey); request.setAttribute(REQUEST_CSRF_ENCRYPT_CIPHER, encryptCipher); }/* w w w . j av a 2s .c o m*/ return encryptCipher; }
From source file:com.jsmartframework.web.manager.CsrfEncrypter.java
private static Cipher getDecryptCipher(HttpServletRequest request, String key) throws Exception { Cipher decryptCipher = (Cipher) request.getAttribute(REQUEST_CSRF_DECRYPT_CIPHER); if (decryptCipher == null) { decryptCipher = Cipher.getInstance("AES"); SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF8"), "AES"); decryptCipher.init(Cipher.DECRYPT_MODE, secretKey); request.setAttribute(REQUEST_CSRF_DECRYPT_CIPHER, decryptCipher); }//from w ww . ja v a 2 s . c o m return decryptCipher; }
From source file:com.jsmartframework.web.manager.AuthEncrypter.java
private static Cipher getEncryptCipher(HttpServletRequest request, String key) throws Exception { Cipher encryptCipher = (Cipher) request.getAttribute(REQUEST_AUTH_ENCRYPT_CIPHER); if (encryptCipher == null) { encryptCipher = Cipher.getInstance("AES"); SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF8"), "AES"); encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey); request.setAttribute(REQUEST_AUTH_ENCRYPT_CIPHER, encryptCipher); }// w w w . j av a 2 s . c om return encryptCipher; }
From source file:com.jsmartframework.web.manager.AuthEncrypter.java
private static Cipher getDecryptCipher(HttpServletRequest request, String key) throws Exception { Cipher decryptCipher = (Cipher) request.getAttribute(REQUEST_AUTH_DECRYPT_CIPHER); if (decryptCipher == null) { decryptCipher = Cipher.getInstance("AES"); SecretKey secretKey = new SecretKeySpec(key.getBytes("UTF8"), "AES"); decryptCipher.init(Cipher.DECRYPT_MODE, secretKey); request.setAttribute(REQUEST_AUTH_DECRYPT_CIPHER, decryptCipher); }//from w ww . ja v a 2 s. c o m return decryptCipher; }
From source file:edu.ucsb.nceas.metacat.util.RequestUtil.java
/** * Add a list of errors to the request. The pages will pick up the errors * and display them where appropriate./*from www . j a v a2 s . c o m*/ * * @param request * the request that will get forwarded * @param errorVector * a list of error strings */ public static void setRequestErrors(HttpServletRequest request, Vector<String> errorVector) { request.setAttribute("formErrors", "true"); request.setAttribute("processingErrors", errorVector); }
From source file:edu.ucsb.nceas.metacat.util.RequestUtil.java
/** * Add a list of form errors to the request. The pages will pick up the * errors and display them where appropriate. * /* w w w . ja v a2 s .co m*/ * @param request * the request that will get forwarded * @param errorVector * a list of form error strings */ public static void setRequestFormErrors(HttpServletRequest request, Vector<String> errorVector) { request.setAttribute("formErrors", "true"); request.setAttribute("formFieldErrors", errorVector); }
From source file:edu.ucsb.nceas.metacat.util.RequestUtil.java
/** * Add a list of success messages to the request. The pages will pick up the * messages and display them where appropriate. * //w w w . j a v a 2 s .c o m * @param request * the request that will get forwarded * @param errorVector * a list of success message strings */ public static void setRequestSuccess(HttpServletRequest request, Vector<String> successVector) { request.setAttribute("formSuccess", "true"); request.setAttribute("processingSuccess", successVector); }
From source file:edu.ucsb.nceas.metacat.util.RequestUtil.java
/** * Add a list of general messages to the request. The pages will pick up the * messages and display them where appropriate. * // www . j a va 2 s .c o m * @param request * the request that will get forwarded * @param errorVector * a list of general message strings */ public static void setRequestMessage(HttpServletRequest request, Vector<String> messageVector) { request.setAttribute("formMessage", "true"); request.setAttribute("processingMessage", messageVector); }
From source file:com.aoindustries.website.signup.SignupBusinessActionHelper.java
public static void setRequestAttributes(ServletContext servletContext, HttpServletRequest request) throws IOException, SQLException { AOServConnector rootConn = SiteSettings.getInstance(servletContext).getRootAOServConnector(); // Build the list of countries List<CountryOption> countryOptions = getCountryOptions(rootConn); // Store to the request request.setAttribute("countryOptions", countryOptions); }
From source file:ru.org.linux.csrf.CSRFProtectionService.java
public static void generateCSRFCookie(HttpServletRequest request, HttpServletResponse response) { SecureRandom random = new SecureRandom(); byte[] value = new byte[16]; random.nextBytes(value);/*from w w w .j a v a 2 s. c o m*/ String token = new String(Base64.encodeBase64(value)); Cookie cookie = new Cookie(CSRF_COOKIE, token); cookie.setMaxAge(TWO_YEARS); cookie.setPath("/"); response.addCookie(cookie); request.setAttribute(CSRF_ATTRIBUTE, token); }