Package javax.ws.rs.core

Examples of javax.ws.rs.core.Cookie


  @Override
  public boolean authenticate(Request request, Subject subject) throws LoginException, HandlerException {
    String[] cookieValues = request.getHeaderValues(HeaderName.COOKIE);
    if (cookieValues != null && cookieValues.length > 0) {
      Map<String, Cookie> cookies = parseCookies(cookieValues[0]);   
      Cookie authCookie = cookies.get(CookieLogin.AUTH_COOKIE_NAME);
      if (authCookie == null) {
        return false;
      }

      String authBase64 = authCookie.getValue();
      String[] credentials = new String(Base64.decode(authBase64)).split(":");
      String userName = credentials[0];
      String password;
      if (credentials.length > 1) {
        password = credentials[1];
View Full Code Here


      this.name = name;
      this.value = value;
    }

    public Cookie getImmutableCookie() {
      return new Cookie(name, value, path, domain, version);
    }
View Full Code Here

  private Cookie validateAndBuildCookie(ModifiableCookie firstCookie, String cookie) {
    if (firstCookie.name == null || firstCookie.value == null) {
      throw new IllegalArgumentException("Failed to parse Cookie " + cookie);
    }
    return new Cookie(firstCookie.name, firstCookie.value, firstCookie.path,
        firstCookie.domain, firstCookie.version);

  }
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

    }

    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

       
    }

    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

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.