Package javax.ws.rs.core

Examples of javax.ws.rs.core.Cookie


        headers.putSingle(HttpHeaders.COOKIE, "$Version=1;a=b");
        m.put(Message.PROTOCOL_HEADERS, headers);
        HttpHeaders h = new HttpHeadersImpl(m);
        Map<String, Cookie> cookies = h.getCookies();
        assertEquals(1, cookies.size());
        Cookie cookie = cookies.get("a");
        assertEquals("b", cookie.getValue());
        assertEquals(1, cookie.getVersion());
    }
View Full Code Here


            }
            List<String> cs = value.contains("$")
                ? Collections.singletonList(value)
                : getHeaderValues(HttpHeaders.COOKIE, value, getCookieSeparator());
            for (String c : cs) {
                Cookie cookie = Cookie.valueOf(c);
                cl.put(cookie.getName(), cookie);
            }
        }
        return cl;
    }
View Full Code Here

    if (httpHeaders.getCookies() == null) {
      // This is a cold user
      return sessionToken;
    }

    Cookie cookie = httpHeaders.getCookies().get(SiteConfiguration.SESSION_TOKEN_NAME);
    if (cookie == null) {
      // This is a cold user
      return sessionToken;
    }
    String value = cookie.getValue();
    if (value == null) {
      // This is a broken cookie
      // Rather than throw an error we can force a fresh login to fix it up
      return sessionToken;
    }
View Full Code Here

       
    }

    private static Object processCookieParam(Message m, String cookieName,
                              Class<?> pClass, Type genericType, String defaultValue) {
        Cookie c = new HttpHeadersImpl(m).getCookies().get(cookieName);
       
        if (c == null && defaultValue != null) {
            c = Cookie.valueOf(cookieName + '=' + defaultValue);
        }
        if (c == null) {
            return null;
        }
       
        if (pClass.isAssignableFrom(Cookie.class)) {
            return c;
        }
       
        return InjectionUtils.handleParameter(c.getValue(), pClass, ParameterType.COOKIE, m);
    }
View Full Code Here

        for (Map.Entry<String, Object> p : headerParams.entrySet()) {
            resource.header(p.getKey(), String.valueOf(p.getValue()));
        }

        for (Map.Entry<String, Object> p : cookieParams.entrySet()) {
            Cookie cookie = new Cookie(p.getKey(), String.valueOf(p.getValue()));
            resource.cookie(cookie);
        }

        resource.contentType(getContentType());
        resource.accept(getAccepts());
View Full Code Here

            }
            String value = null;
            HttpHeaders httpHeaders = runtimeContext.getHttpHeaders();
            Map<String, Cookie> values = httpHeaders.getCookies();

            Cookie cookie = null;
            if (values.size() > 0) {
                cookie = values.get(getName());
            }

            if (cookie == null && hasDefaultValue()) {
                cookie = new Cookie(getName(), getDefaultValue());
            }

            if (cookie != null) {
                // special handling for List<Cookie>
                if (isTypeCollectionOf(Cookie.class)) {
                    return elementAsTypeCollection(cookie, new CookieComparator());
                }

                // special handling for Cookie
                if (isTypeOf(Cookie.class)) {
                    return cookie;
                }

                // for all other types
                value = cookie.getValue();
            }

            try {
                return getConvertor().convert(value);
            } catch (ConversionException e) {
View Full Code Here

            if (value == null) {
                continue;
            }
            List<String> cs = getHeaderValues(HttpHeaders.COOKIE, value, getCookieSeparator());
            for (String c : cs) {
                Cookie cookie = Cookie.valueOf(c);
                cl.put(cookie.getName(), cookie);
            }
        }
        return cl;
    }
View Full Code Here

        if (cookies == null) {
            cookies = new HashMap<String, Cookie>();
            List<String> cookiesHeaders = headers.get(HttpHeaders.COOKIE);
            if (cookiesHeaders != null) {
                for (String cookieHeader : cookiesHeaders) {
                    Cookie cookie = Cookie.valueOf(cookieHeader);
                    cookies.put(cookie.getName(), cookie);
                }
            }
        }
        return cookies;
    }
View Full Code Here

            }
            String value = null;
            HttpHeaders httpHeaders = runtimeContext.getHttpHeaders();
            Map<String, Cookie> values = httpHeaders.getCookies();

            Cookie cookie = null;
            if (values.size() > 0) {
                cookie = values.get(getName());
            }

            if (cookie == null && hasDefaultValue()) {
                cookie = new Cookie(getName(), getDefaultValue());
            }

            if (cookie != null) {
                // special handling for List<Cookie>
                if (isTypeCollectionOf(Cookie.class)) {
                    return elementAsTypeCollection(cookie, new CookieComparator());
                }

                // special handling for Cookie
                if (isTypeOf(Cookie.class)) {
                    return cookie;
                }

                // for all other types
                value = cookie.getValue();
            }

            try {
                return getConvertor().convert(value);
            } catch (ConversionException e) {
View Full Code Here

        if (cookies == null) {
            cookies = new HashMap<String, Cookie>();
            List<String> cookiesHeaders = getRequestHeaderInternal(HttpHeaders.COOKIE);
            if (cookiesHeaders != null) {
                for (String cookieHeader : cookiesHeaders) {
                    Cookie cookie = Cookie.valueOf(cookieHeader);
                    cookies.put(cookie.getName(), cookie);
                }
            }
        }
        logger.debug("Cookies are: {}", cookies);
        return cookies;
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Cookie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.