Package javax.ws.rs.core

Examples of javax.ws.rs.core.Cookie


     * @throws HttpException
     */
    public void testCookiesOneGiven() throws HttpException, IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/context/httpheaders/cookies")
                .cookie(new Cookie("foo", "bar")).post(null);
        assertEquals(200, response.getStatusCode());
        String responseBody = response.getEntity(String.class);
        assertEquals("cookies:foo=bar:", responseBody);

        response =
View Full Code Here


     * @throws HttpException
     */
    public void testCookiesManyGiven() throws HttpException, IOException {
        ClientResponse response =
            client.resource(getBaseURI() + "/context/httpheaders/cookies")
                .cookie(new Cookie("foo", "bar")).cookie(new Cookie("foo2", "bar2")).post(null);
        assertEquals(200, response.getStatusCode());
        String responseBody = response.getEntity(String.class);
        assertEquals("cookies:foo=bar:foo2=bar2:", responseBody);

        response =
View Full Code Here

         if (name.indexOf('$') == -1)
         {

            // first save previous cookie
            if (temp != null)
               l.add(new Cookie(temp.name, temp.value, temp.path, temp.domain, temp.version));

            temp = new TempCookie(name, value);
            // version was kept before
            // @see http://www.ietf.org/rfc/rfc2109.txt section 4.4
            temp.version = version;
         }
         else if (name.equalsIgnoreCase("$Version"))
         {
            // keep version number
            version = Integer.valueOf(value);
         }
         else if (name.equalsIgnoreCase("$Path") && temp != null)
         {
            // Temporary cookie must exists, otherwise this parameter will be lost
            temp.path = value;
         }
         else if (name.equalsIgnoreCase("$Domain") && temp != null)
         {
            // Temporary cookie must exists, otherwise this parameter will be lost.
            temp.domain = value;
         }

         p = n + 1;
      }

      if (temp != null)
         l.add(new Cookie(temp.name, temp.value, temp.path, temp.domain, temp.version));

      return l;
   }
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

    }

    private static Object processCookieParam(Message m, String cookieName,
                              Class<?> pClass, Type genericType,
                              Annotation[] paramAnns, 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(), false, pClass, paramAnns,
                                              ParameterType.COOKIE, m);
    }
View Full Code Here

    }

    private static Object processCookieParam(Message m, String cookieName,
                              Class<?> pClass, Type genericType,
                              Annotation[] paramAnns, 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(), false, pClass, paramAnns,
                                              ParameterType.COOKIE, m);
    }
View Full Code Here

   
    protected boolean checkSecurityContext(Message m) {
        HttpHeaders headers = new HttpHeadersImpl(m);
        Map<String, Cookie> cookies = headers.getCookies();
       
        Cookie securityContextCookie = cookies.get(SSOConstants.SECURITY_CONTEXT_TOKEN);
       
        ResponseState responseState = getValidResponseState(securityContextCookie, m);
        if (responseState == null) {
            return false;   
        }
       
        Cookie relayStateCookie = cookies.get(SSOConstants.RELAY_STATE);
        if (relayStateCookie == null) {
            reportError("MISSING_RELAY_COOKIE");
            return false;
        }
        String originalRelayState = responseState.getRelayState();
        if (!originalRelayState.equals(relayStateCookie.getValue())) {
            // perhaps the response state should also be removed
            reportError("INVALID_RELAY_STATE");
            return false;
        }
        try {
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

        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

        }
        if (theValue == null) {
            return null;
        }
       
        Cookie c = Cookie.valueOf(theValue);
        if (pClass.isAssignableFrom(Cookie.class)) {
            return c;
        }
       
        return InjectionUtils.handleParameter(c.getValue(), pClass, ParameterType.COOKIE, m);
    }
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.