List of usage examples for javax.servlet.http Cookie getValue
public String getValue()
From source file:es.logongas.ix3.web.security.impl.WebSessionSidStorageImplAbstractJws.java
private String getJwsCompactInCookie(HttpServletRequest httpServletRequest) { Cookie[] cookies = httpServletRequest.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (jwsCookieName.equals(cookie.getName())) { return cookie.getValue(); }/* w ww.ja v a 2 s .co m*/ } } return null; }
From source file:io.github.jhipster.config.locale.AngularCookieLocaleResolver.java
private void parseLocaleCookieIfNecessary(HttpServletRequest request) { if (request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME) == null) { // Retrieve and parse cookie value. Cookie cookie = WebUtils.getCookie(request, getCookieName()); Locale locale = null;//from w ww . j av a2 s . co m TimeZone timeZone = null; if (cookie != null) { String value = cookie.getValue(); // Remove the double quote value = StringUtils.replace(value, "%22", ""); String localePart = value; String timeZonePart = null; int spaceIndex = localePart.indexOf(' '); if (spaceIndex != -1) { localePart = value.substring(0, spaceIndex); timeZonePart = value.substring(spaceIndex + 1); } locale = !"-".equals(localePart) ? StringUtils.parseLocaleString(localePart.replace('-', '_')) : null; if (timeZonePart != null) { timeZone = StringUtils.parseTimeZoneString(timeZonePart); } if (logger.isTraceEnabled()) { logger.trace("Parsed cookie value [" + cookie.getValue() + "] into locale '" + locale + "'" + (timeZone != null ? " and time zone '" + timeZone.getID() + "'" : "")); } } request.setAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME, locale != null ? locale : determineDefaultLocale(request)); request.setAttribute(TIME_ZONE_REQUEST_ATTRIBUTE_NAME, timeZone != null ? timeZone : determineDefaultTimeZone(request)); } }
From source file:au.gov.dto.dibp.appointments.security.csrf.CookieBasedCsrfTokenRepository.java
@Override public CsrfToken loadToken(HttpServletRequest request) { if (request.getCookies() != null) { for (Cookie cookie : request.getCookies()) { if (cookie != null && CSRF_COOKIE_AND_PARAMETER_NAME.equals(cookie.getName())) { return new DefaultCsrfToken(CSRF_HEADER_NAME, CSRF_COOKIE_AND_PARAMETER_NAME, cookie.getValue()); }/* w ww .j a v a2 s . c om*/ } } return null; }
From source file:org.craftercms.engine.view.freemarker.CrafterFreeMarkerView.java
protected Map<String, String> createCookieMap(HttpServletRequest request) { Map<String, String> cookieMap = new HashMap<String, String>(); Cookie[] cookies = request.getCookies(); if (ArrayUtils.isNotEmpty(cookies)) { for (Cookie cookie : cookies) { cookieMap.put(cookie.getName(), cookie.getValue()); }// w w w . ja va 2 s.c o m } return cookieMap; }
From source file:de.voolk.marbles.web.app.IdentSession.java
private boolean hasCookie() { Cookie identCookie = ((WebRequest) RequestCycle.get().getRequest()).getCookie(IDENT_COOKIE); if (identCookie != null) { User user = getAuthentificationService().findUserByIdentKey(identCookie.getValue()); if (user != null) { login = user.getName();/*from w w w. j a va 2 s . c om*/ signIn(true); return true; } } return false; }
From source file:com.mobileman.projecth.web.util.PersistentCookieHelper.java
public User getUser(UserService userService, HttpServletRequest request, HttpServletResponse response) { Cookie[] cookies = request.getCookies(); boolean removeCookie = false; if (cookies != null) { for (Cookie c : cookies) { if (COOKIE_NAME.equals(c.getName())) { removeCookie = true;/* w w w . j av a 2s. c om*/ String hash = c.getValue(); //extract id, salt, hash if (StringUtils.isNotBlank(hash)) { //if not found remove cookie!!! String[] split = hash.split(SEPARATOR); if (split.length == 3) { try { Long id = Long.parseLong(split[0]); //find user User user = userService.findById(id); if (user != null) { //check hash String h2 = createHash(split[1], user); if (hash.equals(h2)) { return user; } } } catch (Exception ex) { } } } } } } if (removeCookie && response != null) { removeUser(request, response); } return null; }
From source file:hudson.plugins.codeviation.JavaFileIterableView.java
public ChartConf getChartConf(StaplerRequest req) { String chartTypePar = req.getParameter(CHART_TYPE_PARAM); if (chartTypePar == null) { Cookie cookies[] = req.getCookies(); // cookies are null if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals(CHART_TYPE_PARAM)) { chartTypePar = cookie.getValue(); break; }/* ww w. java2 s . co m*/ } } } for (ChartConf conf : getChartConfs()) { if (conf.getName().equals(chartTypePar)) { selectedChartConf = conf; return conf; } } selectedChartConf = null; return null; }
From source file:edu.ucmerced.cas.web.support.CasShibCookieRetrievingCookieGenerator.java
public String retrieveCookieValue(final HttpServletRequest request) { String appName = CasShibUtil.getAppNameFromRequestURI(request, shibServiceRegistrar); if (appName == null) { // can't determine appName so can't determine cookie to retrieve return null; }// w w w. jav a 2 s . c om final Cookie cookie = org.springframework.web.util.WebUtils.getCookie(request, getFullCookieName(appName)); return cookie == null ? null : cookie.getValue(); }
From source file:com.atlassian.jira.security.xsrf.SimpleXsrfTokenGenerator.java
@Override public String getToken(HttpServletRequest request) { final Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (TOKEN_HTTP_SESSION_KEY.equalsIgnoreCase(cookie.getName())) { return htmlEncode(cookie.getValue()); }/*from w w w.j a v a 2 s .co m*/ } } return null; }
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 ww. ja v a 2s . c o m } } } filterChain.doFilter(request, response); }