Java Code Examples for io.netty.handler.codec.http.cookie.Cookie#value()
The following examples show how to use
io.netty.handler.codec.http.cookie.Cookie#value() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuthBindClientContextHandler.java From arcusplatform with Apache License 2.0 | 6 votes |
private String extractFromCookies(String cookieHeader) { // look for auth cookie if(cookieHeader == null) { return null; } String sessionId = null; logger.trace("Found cookies: value = {}", cookieHeader); Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieHeader); for (Cookie cookie : cookies) { if (cookieConfig.getAuthCookieName().equals(cookie.name())) { logger.trace("Found {} cookie: value = {}", cookieConfig.getAuthCookieName(), cookie.value()); sessionId = cookie.value(); if (StringUtils.isNotEmpty(sessionId)) { logger.trace("Token {} found in {} cookie.", sessionId, cookieConfig.getAuthCookieName()); } else { sessionId = null; } } } return sessionId; }
Example 2
Source File: BindClientContextHandler.java From arcusplatform with Apache License 2.0 | 6 votes |
private String extractFromCookies(String cookieHeader) { // look for auth cookie if(cookieHeader == null) { return null; } String sessionId = null; logger.trace("Found cookies: value = {}", cookieHeader); Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieHeader); for (Cookie cookie : cookies) { if (cookieConfig.getAuthCookieName().equals(cookie.name())) { logger.trace("Found {} cookie: value = {}", cookieConfig.getAuthCookieName(), cookie.value()); sessionId = cookie.value(); if (StringUtils.isNotEmpty(sessionId)) { logger.trace("Token {} found in {} cookie.", sessionId, cookieConfig.getAuthCookieName()); } else { sessionId = null; } } } return sessionId; }
Example 3
Source File: UserController.java From leo-im-server with Apache License 2.0 | 6 votes |
/** * 从cookie中得到Session Id * @return */ private String getJSessionId(FullHttpRequest request) { try { String cookieStr = request.headers().get("Cookie"); if(cookieStr == null || cookieStr.trim().isEmpty()) { return null; } Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieStr); Iterator<Cookie> it = cookies.iterator(); while (it.hasNext()) { Cookie cookie = it.next(); if (cookie.name().equals(CacheKeys.JSESSIONID)) { if (CacheManagerFactory.getCacheManager().get(cookie.value()) != null) { return cookie.value(); } } } } catch (Exception e1) { return null; } return null; }
Example 4
Source File: AuthController.java From leo-im-server with Apache License 2.0 | 6 votes |
/** * 从cookie中得到Session Id * @param request * @return */ private String getJSessionId(FullHttpRequest request) { try { String cookieStr = request.headers().get("Cookie"); if(cookieStr == null || cookieStr.trim().isEmpty()) { return null; } Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieStr); Iterator<Cookie> it = cookies.iterator(); while (it.hasNext()) { Cookie cookie = it.next(); if (cookie.name().equals(CacheKeys.JSESSIONID)) { if (CacheManagerFactory.getCacheManager().get(cookie.value()) != null) { return cookie.value(); } } } } catch (Exception e1) { return null; } return null; }
Example 5
Source File: IRequestParameter.java From netty-rest with Apache License 2.0 | 6 votes |
@Override public String extract(ObjectNode node, RakamHttpRequest request) { for (Cookie cookie : request.cookies()) { if (name.equals(cookie.name())) { // TODO fixme: the value of cookie parameter always must be String. return cookie.value(); } } if (required) { throw new HttpRequestException("'" + name + "' cookie is required.", BAD_REQUEST); } return null; }
Example 6
Source File: SessionDao.java From blynk-server with GNU General Public License v3.0 | 6 votes |
public User getUserFromCookie(FullHttpRequest request) { String cookieString = request.headers().get(HttpHeaderNames.COOKIE); if (cookieString != null) { Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieString); if (!cookies.isEmpty()) { for (Cookie cookie : cookies) { if (isValid(cookie)) { String token = cookie.value(); return httpSession.get(token); } } } } return null; }
Example 7
Source File: HttpSessionInterceptor.java From cxf with Apache License 2.0 | 6 votes |
@Override public void onRequestReceived(ChannelHandlerContext ctx, HttpRequest request) { HttpSessionThreadLocal.unset(); Collection<Cookie> cookies = Utils.getCookies( NettyHttpSession.SESSION_ID_KEY, request); if (cookies != null) { for (Cookie cookie : cookies) { String jsessionId = cookie.value(); NettyHttpSession s = HttpSessionThreadLocal.getSessionStore() .findSession(jsessionId); if (s != null) { HttpSessionThreadLocal.set(s); this.sessionRequestedByCookie = true; break; } } } }
Example 8
Source File: ReactorServerHttpRequest.java From spring-analysis-note with MIT License | 5 votes |
@Override protected MultiValueMap<String, HttpCookie> initCookies() { MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>(); for (CharSequence name : this.request.cookies().keySet()) { for (Cookie cookie : this.request.cookies().get(name)) { HttpCookie httpCookie = new HttpCookie(name.toString(), cookie.value()); cookies.add(name.toString(), httpCookie); } } return cookies; }
Example 9
Source File: HttpController.java From litchi with Apache License 2.0 | 5 votes |
public String getCookie(String name, String defaultValue) { if (this.cookieMaps.containsKey(name)) { Cookie cookie = this.cookieMaps.get(name); return cookie.value(); } return defaultValue; }
Example 10
Source File: ReactorServerHttpRequest.java From java-technology-stack with MIT License | 5 votes |
@Override protected MultiValueMap<String, HttpCookie> initCookies() { MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>(); for (CharSequence name : this.request.cookies().keySet()) { for (Cookie cookie : this.request.cookies().get(name)) { HttpCookie httpCookie = new HttpCookie(name.toString(), cookie.value()); cookies.add(name.toString(), httpCookie); } } return cookies; }
Example 11
Source File: DefaultWebRes.java From krpc with Apache License 2.0 | 5 votes |
public String getCookie(String name) { if (cookies == null) return null; for (Cookie c : cookies) { if (c.name().equals(name)) return c.value(); } return null; }
Example 12
Source File: HttpUtils.java From arthas with Apache License 2.0 | 5 votes |
/** * Get cookie value by name * @param cookies request cookies * @param cookieName the cookie name */ public static String getCookieValue(Set<Cookie> cookies, String cookieName) { for (Cookie cookie : cookies) { if(cookie.name().equals(cookieName)){ return cookie.value(); } } return null; }
Example 13
Source File: HttpSessionManager.java From glowroot with Apache License 2.0 | 5 votes |
@Nullable String getSessionId(CommonRequest request) throws Exception { String cookieHeader = request.getHeader(HttpHeaderNames.COOKIE); if (cookieHeader == null) { return null; } Set<Cookie> cookies = ServerCookieDecoder.STRICT.decode(cookieHeader); for (Cookie cookie : cookies) { if (cookie.name().equals(configRepository.getWebConfig().sessionCookieName())) { return cookie.value(); } } return null; }
Example 14
Source File: DefaultCookieManager.java From redant with Apache License 2.0 | 4 votes |
@Override public String getCookieValue(String name) { Cookie cookie = getCookie(name); return cookie == null ? null : cookie.value(); }
Example 15
Source File: RequestCookie.java From styx with Apache License 2.0 | 4 votes |
private static RequestCookie convert(Cookie nettyCookie) { String name = nettyCookie.name(); String value = nettyCookie.wrap() ? quote(nettyCookie.value()) : nettyCookie.value(); return requestCookie(name, value); }