List of usage examples for javax.servlet.http Cookie getName
public String getName()
From source file:com.wikipy.security.AuthenticationFilter.java
public String getCookieTicket(HttpServletRequest httpReq) { Cookie[] cookies = httpReq.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals(ARG_TICKET)) { return cookie.getValue(); }/* w w w . j a v a 2 s.co m*/ } } return httpReq.getParameter(ARG_TICKET); }
From source file:com.haulmont.cuba.web.sys.AppCookies.java
public void updateCookies() { if (isCookiesEnabled()) { requestedCookies.clear();/*from w ww . j a v a2 s. c o m*/ Cookie[] cookies = RequestContext.get().getRequest().getCookies(); if (cookies != null) { for (final Cookie cookie : cookies) { requestedCookies.put(cookie.getName(), cookie); } } lastRequestTimestamp = RequestContext.get().getRequestTimestamp(); } }
From source file:com.ctc.storefront.filters.CustomerLocationRestorationFilter.java
protected void setUserLocationDataFromCookies(final Cookie[] cookies) { for (final Cookie cookie : cookies) { if (getCustomerLocationCookieGenerator().getCookieName().equals(cookie.getName())) { final UserLocationData cookieUserLocationData = decipherUserLocationData( StringUtils.remove(cookie.getValue(), "\"")); getCustomerLocationFacade().setUserLocationData(cookieUserLocationData); break; }/*from ww w .java 2 s.c o m*/ } }
From source file:com.persistent.cloudninja.utils.RoleBasedAccessControlInterceptor.java
/** * Returns the cookie based on name otherwise null object * @param request/* ww w. j a v a 2 s .c o m*/ * @param cookieName * @return Auth cookie */ protected Cookie getCookie(HttpServletRequest request, String cookieName) { Cookie reqCookie = null; Cookie[] cookies = request.getCookies(); if (cookies != null) for (Cookie cookie : cookies) if (cookie.getName().equals(cookieName)) { reqCookie = cookie; break; } return reqCookie; }
From source file:org.tonguetied.web.CookieUtilsTest.java
/** * Test method for {@link org.tonguetied.web.CookieUtils#createCookie(HttpServletRequest, String, String)}. *///w ww. j ava 2s . c o m @Test public final void testCreateCookie() { Cookie cookie = CookieUtils.createCookie(request, "name", "value"); assertEquals("name", cookie.getName()); assertEquals("value", cookie.getValue()); assertEquals("/test", cookie.getPath()); assertEquals(-1, cookie.getMaxAge()); }
From source file:com.ms.commons.summer.security.web.DefaultSecurityFormResolver.java
/** * @param request// www . j a v a2 s.com * @param response * @throws InvalidTokenException */ public void validCSRFToken(final HttpServletRequest request, final HttpServletResponse response) throws InvalidTokenException { Cookie[] cookies = request.getCookies(); String ctoken = null; if (cookies != null) { for (Cookie cookie : cookies) { if (SESSION_TOKEN.equals(cookie.getName())) { ctoken = cookie.getValue(); break; } } } String rtoken = request.getParameter(SESSION_TOKEN); if (rtoken == null || rtoken.length() == 0) { throw new InvalidTokenException("can't find csrf token in request"); } if (ctoken == null || ctoken.length() == 0) { throw new InvalidTokenException("can't find csrf token in cookie"); } if (!ctoken.equals(rtoken)) { throw new InvalidTokenException("failed to check for csrf token in request"); } }
From source file:net.duckling.ddl.web.controller.LynxHomeController.java
@SuppressWarnings("unchecked") private JSONObject userStatus(HttpServletRequest request) { VWBSession session = VWBSession.findSession(request); JSONObject obj = new JSONObject(); obj.put("haveUmtId", false); if (session != null && session.isAuthenticated()) { obj.put("status", true); obj.put("userEmail", ((UserPrincipal) session.getCurrentUser()).getFullName()); } else {/*from w ww .j a v a 2s . co m*/ Cookie[] cookies = request.getCookies(); if (cookies != null && cookies.length > 0) { obj.put("status", false); Integer i = (Integer) request.getSession().getAttribute("redirect_uri_count"); if (i != null && i > 2) { request.getSession().setAttribute("redirect_uri_count", 0); } else { for (Cookie cookie : cookies) { if ("UMTID".equals(cookie.getName())) { obj.put("haveUmtId", true); break; } } } } else { obj.put("status", false); } } return obj; }
From source file:com.acc.storefront.filters.CustomerLocationRestorationFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { if (getCustomerLocationFacade().getUserLocationData() == null) { final Cookie[] cookies = request.getCookies(); if (cookies != null) { for (final Cookie cookie : cookies) { if (getCustomerLocationCookieGenerator().getCookieName().equals(cookie.getName())) { final UserLocationData cookieUserLocationData = decipherUserLocationData(cookie.getValue()); getCustomerLocationFacade().setUserLocationData(cookieUserLocationData); break; }//from w w w.jav a 2 s .c om } } } filterChain.doFilter(request, response); }
From source file:com.ctc.storefront.security.evaluator.impl.RequireHardLoginEvaluator.java
protected boolean isGuidStoredinCookies(final HttpServletRequest request, final HttpServletResponse response, final String guid, final String guidCookieName) { for (final Cookie cookie : request.getCookies()) { if (guidCookieName.equals(cookie.getName())) { if (guid.equals(cookie.getValue())) { return true; } else { LOG.info("Found secure cookie with invalid value. expected [" + guid + "] actual [" + cookie.getValue() + "]. removing."); getCookieGenerator().removeCookie(response); }/* w ww. j av a 2s .c o m*/ } } return false; }
From source file:cec.easyshop.storefront.filters.CustomerLocationRestorationFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { if (getCustomerLocationFacade().getUserLocationData() == null) { final Cookie[] cookies = request.getCookies(); if (cookies != null) { for (final Cookie cookie : cookies) { if (getCustomerLocationCookieGenerator().getCookieName().equals(cookie.getName())) { final UserLocationData cookieUserLocationData = decipherUserLocationData( StringUtils.remove(cookie.getValue(), "\"")); getCustomerLocationFacade().setUserLocationData(cookieUserLocationData); break; }//w ww . jav a 2s . c o m } } } filterChain.doFilter(request, response); }