List of usage examples for javax.servlet.http HttpServletRequest getCookies
public Cookie[] getCookies();
Cookie
objects the client sent with this request. From source file:au.gov.dto.springframework.security.web.csrf.CookieCsrfTokenRepository.java
@Override public CsrfToken loadToken(HttpServletRequest request) { if (request.getCookies() != null) { for (Cookie cookie : request.getCookies()) { if (cookie != null && csrfCookieName.equals(cookie.getName())) { return new DefaultCsrfToken(csrfHeaderName, csrfParameterName, cookie.getValue()); }//from w w w.j a v a 2 s . co m } } return null; }
From source file:com.acme.demo.web.LogoutController.java
private void handleLogOutResponse(HttpServletRequest request, HttpServletResponse response) { Cookie[] cookies = request.getCookies(); for (Cookie cookie : cookies) { cookie.setMaxAge(0);/*from www .ja v a 2 s .co m*/ cookie.setValue(null); cookie.setPath("/"); response.addCookie(cookie); } }
From source file:de.adorsys.oauth.authdispatcher.matcher.RememberMeAuthMatcher.java
private Cookie getCookieToken(String clientId, HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if (cookies == null) { return null; }/*from w ww . jav a 2 s . c om*/ for (Cookie cookie : cookies) { if (cookie.getName().equals("REMEMBER_" + clientId) && StringUtils.isNotEmpty(cookie.getValue())) { return cookie; } } return null; }
From source file:com.jaspersoft.jasperserver.war.JSSessionLocaleResolver.java
private Locale getLocaleFromCookies(HttpServletRequest req) { Cookie[] cookies = req.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals(JasperServerConstImpl.getUserLocaleSessionAttr())) { if (cookie.getValue() != null && cookie.getValue().length() > 0) { return LocaleUtils.toLocale(cookie.getValue()); }//from w w w . j a va 2 s . co m break; } } } return null; }
From source file:com.reever.humilheme.web.CookieController.java
public String getCookie(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie iterator : cookies) { if (iterator.getName().equals(nomeCookie)) { String value = iterator.getValue(); try { return URLDecoder.decode(value, "UTF-8"); } catch (UnsupportedEncodingException e) { _logger.error("Erro no encode do cookie", e); }//from www . jav a 2s. c om break; } } } return null; }
From source file:shiver.me.timbers.spring.security.jwt.AuthenticationRequestJwtTokenParser.java
private String findCookieToken(HttpServletRequest request) { final Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (tokenName.equals(cookie.getName())) { return cookie.getValue(); }//from w ww . j av a2s . c o m } } return null; }
From source file:com.baidu.rigel.biplatform.ma.auth.resource.RandomValidateCode.java
/** * /*from w ww . j a v a 2s . c om*/ * @param request * @param response * @param cacheManagerForResource */ public static void getRandcode(HttpServletRequest request, HttpServletResponse response, CacheManagerForResource cacheManagerForResource) { // BufferedImageImage,Image???? BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); Graphics g = image.getGraphics(); // ImageGraphics,????? g.fillRect(0, 0, width, height); g.setFont(new Font("Times New Roman", Font.ROMAN_BASELINE, 18)); g.setColor(getRandColor(110, 133)); // for (int i = 0; i <= lineSize; i++) { drowLine(g); } // ? String randomString = ""; for (int i = 1; i <= stringNum; i++) { randomString = drowString(g, randomString, i); } String key = null; if (request.getCookies() != null) { for (Cookie tmp : request.getCookies()) { if (tmp.getName().equals(Constants.RANDOMCODEKEY)) { key = tmp.getName(); cacheManagerForResource.removeFromCache(key); break; } } } if (StringUtils.isEmpty(key)) { key = String.valueOf(System.nanoTime()); } cacheManagerForResource.setToCache(key, randomString); final Cookie cookie = new Cookie(Constants.RANDOMCODEKEY, key); cookie.setPath(Constants.COOKIE_PATH); response.addCookie(cookie); g.dispose(); try { ImageIO.write(image, "JPEG", response.getOutputStream()); // ?? } catch (Exception e) { LOG.info(e.getMessage()); } }
From source file:net.buffalo.service.interceptor.AllowOriginalHostOnlyInterceptor.java
public Object invoke(MethodInvocation method) throws Throwable { HttpServletRequest request = RequestContext.getContext().getHttpRequest(); Cookie[] cookies = request.getCookies(); if (cookies == null || cookies.length <= 0) { LOG.warn("Some rantankerous user invoke this service, refused. " + method.getClass()); throw new ServiceInvocationException("Permission error!"); }//from ww w . j a v a 2 s . com return method.proceed(); }
From source file:Controladores.ControladorLogin.java
private Cookie obterCookie(String nomeCookie, HttpServletRequest request) { Cookie[] lista = request.getCookies(); for (Cookie c : lista) { if (c.getName().equals(nomeCookie)) { return c; }/*from w w w . j a v a 2s .c o m*/ } return null; }
From source file:com.google.ie.web.interceptor.LoginInterceptor.java
/** * Checks if the fcauth cookie is present with a non empty value * /* w w w . j a v a2s. c om*/ * @param request * @return true if a valid fcauth cookie is present in the request, else * false */ private boolean checkAuthToken(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { Cookie cookie = cookies[i]; if (cookie != null && cookie.getName().equals(getFcauthCookieName())) { // Cookie found. Check for value String authToken = cookie.getValue(); if (authToken != null && authToken.length() > 0) { LOG.info("Auth token found. Allowing request to proceed"); return true; } } } } LOG.warn("Auth token not found. Stopping request to proceed"); return false; }