List of usage examples for io.netty.handler.codec.http Cookie value
String value();
From source file:com.chiorichan.http.HttpCookie.java
License:Mozilla Public License
public HttpCookie(Cookie cookie) { this(cookie.name(), cookie.value()); setDomain(cookie.domain());/*from w w w . jav a2 s .c o m*/ setExpiration(cookie.maxAge()); setPath(cookie.path()); needsUpdating = false; }
From source file:com.soho.framework.server.servlet.interceptor.HttpSessionInterceptor.java
License:Apache License
@Override public void onRequestReceived(ChannelHandlerContext ctx, HttpRequest request) { HttpSessionThreadLocal.unset();/* w w w .j av a2 s. c o m*/ Collection<Cookie> cookies = Utils.getCookies(HttpSessionImpl.SESSION_ID_KEY, request); if (cookies != null) { for (Cookie cookie : cookies) { String jsessionId = cookie.value(); HttpSession s = HttpSessionThreadLocal.getSessionStore().findSession(jsessionId); if (s != null) { HttpSessionThreadLocal.set(s); this.sessionRequestedByCookie = true; break; } } } }
From source file:com.vmware.dcp.common.http.netty.CookieJar.java
License:Open Source License
/** * List cookies that apply for the given request URI. * * @param uri request URI/*w ww . j a v a 2 s . co m*/ */ public Map<String, String> list(URI uri) { Map<String, String> result = new HashMap<>(); // Find cookies by the request URI String origin = buildOrigin(uri); Set<Cookie> byOrigin = this.cookiesByOrigin.get(origin); if (byOrigin != null) { for (Cookie cookie : byOrigin) { // Only add "secure" cookies if request URI has https scheme if (cookie.isSecure() && !uri.getScheme().equals(URI_SCHEME_HTTPS)) { continue; } result.put(cookie.name(), cookie.value()); } } return result; }
From source file:ratpack.http.internal.DefaultRequest.java
License:Apache License
public String oneCookie(String name) { Cookie found = null; List<Cookie> allFound = null; for (Cookie cookie : getCookies()) { if (cookie.name().equals(name)) { if (found == null) { found = cookie;//from w w w. j a v a2 s . c o m } else if (allFound == null) { allFound = new ArrayList<>(2); allFound.add(found); } else { allFound.add(cookie); } } } if (found == null) { return null; } else if (allFound != null) { StringBuilder s = new StringBuilder("Multiple cookies with name '").append(name).append("': "); int i = 0; for (Cookie cookie : allFound) { s.append(cookie.toString()); if (++i < allFound.size()) { s.append(", "); } } throw new IllegalStateException(s.toString()); } else { return found.value(); } }
From source file:ratpack.session.clientside.internal.DefaultClientSessionService.java
License:Apache License
@Override public ConcurrentMap<String, Object> deserializeSession(Cookie cookie) { ConcurrentMap<String, Object> sessionStorage = new ConcurrentHashMap<>(); String encodedPairs = cookie == null ? null : cookie.value(); if (encodedPairs != null) { String[] parts = encodedPairs.split(SESSION_SEPARATOR); if (parts.length == 2) { byte[] urlEncoded = DECODER.decode(parts[0]); byte[] digest = DECODER.decode(parts[1]); try { byte[] expectedDigest = signer.sign(Unpooled.wrappedBuffer(urlEncoded)); if (Arrays.equals(digest, expectedDigest)) { byte[] message; if (crypto == null) { message = urlEncoded; } else { message = crypto.decrypt(Unpooled.wrappedBuffer(urlEncoded)); }//from ww w.j av a2 s . com String payload = new String(message, CharsetUtil.UTF_8); QueryStringDecoder queryStringDecoder = new QueryStringDecoder(payload, CharsetUtil.UTF_8, false); Map<String, List<String>> decoded = queryStringDecoder.parameters(); for (Map.Entry<String, List<String>> entry : decoded.entrySet()) { String value = entry.getValue().isEmpty() ? null : entry.getValue().get(0); sessionStorage.put(entry.getKey(), value); } } } catch (Exception e) { throw Exceptions.uncheck(e); } } } return sessionStorage; }
From source file:ratpack.session.internal.RequestSessionManager.java
License:Apache License
private String getCookieSessionId() { if (cookieSessionId == null) { Cookie match = null; for (Cookie cookie : context.getRequest().getCookies()) { if (cookie.name().equals(COOKIE_NAME)) { match = cookie;/*from ww w. ja va 2 s . co m*/ break; } } if (match != null) { cookieSessionId = match.value(); } else { cookieSessionId = ""; } } return cookieSessionId.equals("") ? null : cookieSessionId; }