Refine search
@Override public String toString(Cookie cookie) { throwIllegalArgumentExceptionIfNull(cookie, LocalizationMessages.COOKIE_IS_NULL()); StringBuilder b = new StringBuilder(); b.append("$Version=").append(cookie.getVersion()).append(';'); b.append(cookie.getName()).append('='); StringBuilderUtils.appendQuotedIfWhitespace(b, cookie.getValue()); if (cookie.getDomain() != null) { b.append(";$Domain="); StringBuilderUtils.appendQuotedIfWhitespace(b, cookie.getDomain()); } if (cookie.getPath() != null) { b.append(";$Path="); StringBuilderUtils.appendQuotedIfWhitespace(b, cookie.getPath()); } return b.toString(); }
for (final Object v : ((Collection) value)) { if (!(v instanceof Cookie)) { c = new Cookie(name, v.toString()); } else { c = (Cookie) v; if (!name.equals(((Cookie) v).getName())) { c = new Cookie(name, c.getValue(), c.getPath(), c.getDomain(), c.getVersion()); cookies.add(new Cookie(name, value.toString())); } else { c = (Cookie) value; if (!name.equals(((Cookie) value).getName())) { cookies.add(new Cookie(name, c.getValue(), c.getPath(), c.getDomain(), c.getVersion())); if (entity == null && !form.asMap().isEmpty()) { entity = form; contentType = MediaType.APPLICATION_FORM_URLENCODED; contentType = MediaType.APPLICATION_OCTET_STREAM; if (!form.asMap().isEmpty()) { if (entity instanceof Form) { ((Form) entity).asMap().putAll(form.asMap());
buf.append("<html><head><title>Form results</title></head><body>"); buf.append("<p>Hello, you entered the following information: </p><table border='1'>"); for (String key : formData.keySet()) { if (key.equals("submit")) { continue; buf.append(key); buf.append("</td><td>"); buf.append(formData.getFirst(key)); buf.append("</td></tr>"); for (Cookie c : headers.getCookies().values()) { buf.append("<tr><td>Cookie: "); buf.append(c.getName()); buf.append("</td><td>"); buf.append(c.getValue()); buf.append("</td></tr>");
static Map<String, Cookie> extractCookies(MultivaluedMap<String, String> headers) { Map<String, Cookie> cookies = new HashMap<String, Cookie>(); List<String> cookieHeaders = headers.get("Cookie"); if (cookieHeaders == null) return cookies; for (String cookieHeader : cookieHeaders) { for (Cookie cookie : CookieParser.parseCookies(cookieHeader)) { cookies.put(cookie.getName(), cookie); } } return cookies; }
@Override public MultivaluedMap<String, String> getCookieNameValueMap() { if (cookieNames == null || headersModCount != headers.getModCount()) { cookieNames = new MultivaluedMapImpl(); for (Map.Entry<String, Cookie> e : getCookies().entrySet()) { cookieNames.putSingle(e.getKey(), e.getValue().getValue()); } } return cookieNames; }
public void checkStateCookie(UriInfo uriInfo, HttpHeaders headers) { Cookie stateCookie = headers.getCookies().get(stateCookieName); if (stateCookie == null) throw new BadRequestException("state cookie not set"); String state = uriInfo.getQueryParameters().getFirst(OAuth2Constants.STATE); if (state == null) throw new BadRequestException("state parameter was null"); if (!state.equals(stateCookie.getValue())) { throw new BadRequestException("state parameter invalid"); } } }
private static Map<String, String> getCookies(HttpHeaders headers) { Map<String, String> output = new HashMap<String, String>(); if (headers != null) { for (String key : headers.getCookies().keySet()) { Cookie cookie = headers.getCookies().get(key); output.put(key, cookie.getValue()); } } return output; }
static Map<String, Cookie> extractCookies(MultivaluedMap<String, String> headers) { Map<String, Cookie> cookies = new HashMap<String, Cookie>(); List<String> cookieHeaders = headers.get("Cookie"); if (cookieHeaders == null) return cookies; for (String cookieVal : cookieHeaders) { Cookie cookie = Cookie.valueOf(cookieVal); cookies.put(cookie.getName(), cookie); } return cookies; }
@Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = cookieParam.value(); if (Cookie.class.isAssignableFrom(parameter.getParameterClass())) { Cookie cookie = context.getHttpHeaders().getCookies().get(param); if (cookie == null && parameter.getDefaultValue() != null) { cookie = Cookie.valueOf(parameter.getDefaultValue()); } return cookie; } else { TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); MultivaluedMap<String, String> cookieValues = new MultivaluedMapImpl(); for (Map.Entry<String, Cookie> entry : context.getHttpHeaders().getCookies().entrySet()) { cookieValues.putSingle(entry.getKey(), entry.getValue().getValue()); } return typeProducer.createValue(param, cookieValues, parameter.getDefaultValue()); } } }
public Cookie getImmutableCookie() { return new Cookie(name, value, path, domain, version); } }
Map<String, Cookie> values = httpHeaders.getCookies(); cookie = new Cookie(getName(), getDefaultValue()); value = cookie.getValue();
@Override public ClientResponse handle(ClientRequest request) throws ClientHandlerException { Cookie cookie = new Cookie(TokenBasedSecurityFilter.COOKIE_NAME, authToken); List<Object> cookieList = new ArrayList<Object>(); cookieList.add(cookie); if (authToken != null) { request.getHeaders().put("Cookie", cookieList); } ClientResponse response = getNext().handle(request); if (response.getCookies() != null) { cookieList.addAll(response.getCookies()); } return response; }
/** * Generate a hashcode by hashing all of the properties * @return the hashcode */ @Override public int hashCode() { int hash = super.hashCode(); hash = 59 * hash + (this.comment != null ? this.comment.hashCode() : 0); hash = 59 * hash + this.maxAge; hash = 59 * hash + (this.secure ? 1 : 0); return hash; }
public Map<String, Cookie> getCookies() { Map<String, Cookie> cookies = new HashMap<String, Cookie>(); List list = headers.get(HttpHeaders.COOKIE); if (list == null) return cookies; for (Object obj : list) { if (obj instanceof Cookie) { Cookie cookie = (Cookie)obj; cookies.put(cookie.getName(), cookie); } else { String str = configuration.toHeaderString(obj); Cookie cookie = Cookie.valueOf(str); cookies.put(cookie.getName(), cookie); } } return cookies; } }
static Map<String, Cookie> extractCookies(MultivaluedMap<String, String> headers) { Map<String, Cookie> cookies = new HashMap<String, Cookie>(); List<String> cookieHeaders = headers.get("Cookie"); if (cookieHeaders == null) return cookies; for (String cookieHeader : cookieHeaders) { for (Cookie cookie : CookieParser.parseCookies(cookieHeader)) { cookies.put(cookie.getName(), cookie); } } return cookies; }
@Override public Object apply(ContainerRequest containerRequest) { // TODO: cache? MultivaluedMap<String, String> cookies = new MultivaluedStringMap(); for (Map.Entry<String, Cookie> e : containerRequest.getCookies().entrySet()) { cookies.putSingle(e.getKey(), e.getValue().getValue()); } try { return extractor.extract(cookies); } catch (ExtractorException ex) { throw new ParamException.CookieParamException(ex.getCause(), extractor.getName(), extractor.getDefaultValueString()); } } }
public String getBearerToken(UriInfo uriInfo, HttpHeaders headers) throws BadRequestException, InternalServerErrorException { String error = uriInfo.getQueryParameters().getFirst("error"); if (error != null) throw new BadRequestException(new Exception(Messages.MESSAGES.oAuthError(error))); Cookie stateCookie = headers.getCookies().get(stateCookieName); if (stateCookie == null) throw new BadRequestException(new Exception(Messages.MESSAGES.stateCookieNotSet())); String state = uriInfo.getQueryParameters().getFirst("state"); if (state == null) throw new BadRequestException(new Exception(Messages.MESSAGES.stateParameterWasNull())); if (!state.equals(stateCookie.getValue())) { throw new BadRequestException(new Exception(Messages.MESSAGES.stateParameterInvalid())); } String code = uriInfo.getQueryParameters().getFirst("code"); if (code == null) throw new BadRequestException(new Exception(Messages.MESSAGES.codeParameterWasNull())); return resolveBearerToken(uriInfo.getRequestUri().toString(), code); } }
@Override public CompletionStage<Object> inject(HttpRequest request, HttpResponse response, boolean unwrapAsync) { Cookie cookie = request.getHttpHeaders().getCookies().get(paramName); if (type.equals(Cookie.class)) return CompletableFuture.completedFuture(cookie); if (cookie == null) return CompletableFuture.completedFuture(extractValues(null)); List<String> values = new ArrayList<String>(); values.add(cookie.getValue()); return CompletableFuture.completedFuture(extractValues(values)); }
public Cookie getImmutableCookie() { return new Cookie(name, value, path, domain, version); } }