Refine search
@Override protected void handleInternal(HttpServerExchange exchange) throws Exception { String ct = exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE); ContentType contentType = ContentType.parse(ct); if (contentType != null) { exchange.setStatusCode(StatusCodes.BAD_REQUEST); EjbHttpClientMessages.MESSAGES.debugf("Bad content type %s", ct); return; String relativePath = exchange.getRelativePath(); if (relativePath.startsWith("/")) { relativePath = relativePath.substring(1); boolean cancelIdRunning = Boolean.parseBoolean(parts[5]); Cookie cookie = exchange.getRequestCookies().get(EjbHttpService.JSESSIONID); final String sessionAffinity = cookie != null ? cookie.getValue() : null; final InvocationIdentifier identifier; if (invocationId != null && sessionAffinity != null) {
final StringBuilder sb = new StringBuilder(); final SecurityContext sc = exchange.getSecurityContext(); sb.append("\n----------------------------REQUEST---------------------------\n"); sb.append(" URI=" + exchange.getRequestURI() + "\n"); sb.append(" characterEncoding=" + exchange.getRequestHeaders().get(Headers.CONTENT_ENCODING) + "\n"); sb.append(" contentLength=" + exchange.getRequestContentLength() + "\n"); sb.append(" contentType=" + exchange.getRequestHeaders().get(Headers.CONTENT_TYPE) + "\n"); for (Map.Entry<String, Cookie> entry : cookies.entrySet()) { Cookie cookie = entry.getValue(); sb.append(" cookie=" + cookie.getName() + "=" + cookie.getValue() + "\n");
sb.append(" contentLength=" + exchange.getResponseContentLength() + "\n"); sb.append(" contentType=" + exchange.getResponseHeaders().getFirst(Headers.CONTENT_TYPE) + "\n"); Map<String, Cookie> cookies = exchange.getResponseCookies(); if (cookies != null) { for (Cookie cookie : cookies.values()) { sb.append(" cookie=" + cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain() + "; path=" + cookie.getPath() + "\n");
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { Cookie sessionId = exchange.getRequestCookies().get(sessionCookieName); if (sessionId != null) { int part = sessionId.getValue().indexOf('.'); if (part != -1) { sessionId.setValue(sessionId.getValue().substring(0, part)); } } exchange.addResponseWrapper(wrapper); next.handleRequest(exchange); }
private static Cookie cookie(final io.undertow.server.handlers.Cookie c) { Cookie.Definition cookie = new Cookie.Definition(c.getName(), c.getValue()); Optional.ofNullable(c.getComment()).ifPresent(cookie::comment); Optional.ofNullable(c.getDomain()).ifPresent(cookie::domain); Optional.ofNullable(c.getPath()).ifPresent(cookie::path); return cookie.toCookie(); }
@Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) { Map<String, Cookie> cookies = exchange.getResponseCookiesInternal(); if (cookies != null) { Cookie sessionId = cookies.get(sessionCookieName); if (sessionId != null) { StringBuilder sb = new StringBuilder(sessionId.getValue()); sb.append('.'); sb.append(jvmRoute); sessionId.setValue(sb.toString()); } } return factory.create(); } }
sb.append(exchange.getRequestMethod()).append(" ") .append(exchange.getRequestURL()); if (exchange.getQueryString() != null && !exchange.getQueryString().isEmpty()) { sb.append("?").append(exchange.getQueryString()); if (cookies != null) { cookies.entrySet().stream().map((entry) -> entry.getValue()).forEach((cookie) -> { sb.append(" cookie=").append(cookie.getName()).append("=") .append(cookie.getValue()).append("\n"); });
.addHttpListener(port, "localhost") .setHandler(ex -> { ex.getRequestReceiver().receiveFullBytes((exchange, bytes) -> { try { DefaultRequest request = new DefaultRequest( this, exchange.getRequestPath(), exchange.getDestinationAddress().getHostString(), Method.create(exchange.getRequestMethod().toString()), exchange.getRequestURI(), request.setGet(exchange.getPathParameters()); for (Map.Entry<String, Cookie> cookie : exchange.getRequestCookies().entrySet()) { request.getCookies().put(cookie.getKey(), cookie.getValue().getValue());
logger.trace( "{} {}", exchange.getRequestMethod(), exchange.getRequestPath() ); logger.trace( "FROM: {}", exchange.getSourceAddress() ); final HeaderMap headerMap = exchange.getRequestHeaders(); final Collection<HttpString> names = headerMap.getHeaderNames(); key, cookie.getDomain(), cookie.getName(), cookie.getPath(), cookie.getValue(), cookie.getExpires(), cookie.getMaxAge(), cookie.getComment(), cookie.getVersion() );
private static String addRfc6265ResponseCookieToExchange(final Cookie cookie) { final StringBuilder header = new StringBuilder(cookie.getName()); header.append("="); if(cookie.getValue() != null) { header.append(cookie.getValue()); if (cookie.getPath() != null) { header.append("; Path="); header.append(cookie.getPath()); if (cookie.getDomain() != null) { header.append("; Domain="); header.append(cookie.getDomain()); if (cookie.isDiscard()) { header.append("; Discard"); if (cookie.isSecure()) { header.append("; Secure"); if (cookie.isHttpOnly()) { header.append("; HttpOnly"); if (cookie.getMaxAge() != null) { if (cookie.getMaxAge() >= 0) { header.append("; Max-Age="); header.append(cookie.getMaxAge()); if (cookie.getExpires() == null) { if (cookie.getMaxAge() == 0) {
public static H.Cookie undertow2osgl(Cookie uc) { H.Cookie c = new H.Cookie(uc.getName(), uc.getValue()); c.domain(uc.getDomain()).httpOnly(uc.isHttpOnly()) .path(uc.getPath()).secure(uc.isSecure()) .version(uc.getVersion()).comment(uc.getComment()); Integer maxAge = uc.getMaxAge(); if (null != maxAge) { c.maxAge(maxAge); } Date exp = uc.getExpires(); if (null != exp) { c.expires(exp); } return c; }
@Override protected MultiValueMap<String, HttpCookie> initCookies() { MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>(); for (String name : this.exchange.getRequestCookies().keySet()) { Cookie cookie = this.exchange.getRequestCookies().get(name); HttpCookie httpCookie = new HttpCookie(name, cookie.getValue()); cookies.add(name, httpCookie); } return cookies; }
/** * Sets a response cookie * * @param cookie The cookie */ public HttpServerExchange setResponseCookie(final Cookie cookie) { if(getConnection().getUndertowOptions().get(UndertowOptions.ENABLE_RFC6265_COOKIE_VALIDATION, UndertowOptions.DEFAULT_ENABLE_RFC6265_COOKIE_VALIDATION)) { if (cookie.getValue() != null && !cookie.getValue().isEmpty()) { Rfc6265CookieSupport.validateCookieValue(cookie.getValue()); } if (cookie.getPath() != null && !cookie.getPath().isEmpty()) { Rfc6265CookieSupport.validatePath(cookie.getPath()); } if (cookie.getDomain() != null && !cookie.getDomain().isEmpty()) { Rfc6265CookieSupport.validateDomain(cookie.getDomain()); } } if (responseCookies == null) { responseCookies = new TreeMap<>(); //hashmap is slow to allocate in JDK7 } responseCookies.put(cookie.getName(), cookie); return this; }
for(HeaderValues header : servletRequest.getExchange().getRequestHeaders()) { if(!IGNORE.contains(header.getHeaderName())) { headers.addAll(header.getHeaderName(), header); for(Map.Entry<String, Cookie> cookie : servletRequest.getExchange().getResponseCookies().entrySet()) { if(cookie.getValue().getMaxAge() != null && cookie.getValue().getMaxAge() <= 0) { headers.add(Headers.COOKIE, cookie.getKey() + "=" + cookie.getValue().getValue());
@Override public Cookie getCookie(String cookieName) { Map<String, io.undertow.server.handlers.Cookie> requestCookies = exchange.getRequestCookies(); if (requestCookies == null) return null; io.undertow.server.handlers.Cookie cookie = requestCookies.get(cookieName); if (cookie == null) return null; return new Cookie(cookie.getName(), cookie.getValue(), cookie.getVersion(), cookie.getDomain(), cookie.getPath()); }
@Override protected void applyCookies() { for (String name : getCookies().keySet()) { for (ResponseCookie httpCookie : getCookies().get(name)) { Cookie cookie = new CookieImpl(name, httpCookie.getValue()); if (!httpCookie.getMaxAge().isNegative()) { cookie.setMaxAge((int) httpCookie.getMaxAge().getSeconds()); } if (httpCookie.getDomain() != null) { cookie.setDomain(httpCookie.getDomain()); } if (httpCookie.getPath() != null) { cookie.setPath(httpCookie.getPath()); } cookie.setSecure(httpCookie.isSecure()); cookie.setHttpOnly(httpCookie.isHttpOnly()); this.exchange.getResponseCookies().putIfAbsent(name, cookie); } } }
int version = cookie.getVersion(); String value = cookie.getValue(); String path = cookie.getPath(); String domain = cookie.getDomain(); String comment = cookie.getComment();
final Map<String, Cookie> cookies = exchange.getRequestCookies(); if (balancer.isStickySession()) { if (cookies.containsKey(balancer.getStickySessionCookie())) { final String session = cookies.get(balancer.getStickySessionCookie()).getValue(); final String jvmRoute = getJVMRoute(session); if (jvmRoute != null) { if (exchange.getPathParameters().containsKey(balancer.getStickySessionPath())) { final String session = exchange.getPathParameters().get(balancer.getStickySessionPath()).getFirst(); final String jvmRoute = getJVMRoute(session); if (jvmRoute != null) {
private HttpHandler setupRoutes(HttpHandler handler) { final SimpleSessionIdentifierCodec codec = new SimpleSessionIdentifierCodec(new SimpleRoutingSupport(), this.host.getValue().getServer().getRoute()); return exchange -> { exchange.addResponseCommitListener(ex -> { Cookie cookie = ex.getResponseCookies().get(JSESSIONID); if(cookie != null ) { cookie.setValue(codec.encode(cookie.getValue())); } }); handler.handleRequest(exchange); }; }
@Override public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) { Cookie cookie = exchange.getRequestCookies().get(cookieName); if (cookie != null) { final String ssoId = cookie.getValue(); log.tracef("Found SSO cookie %s", ssoId); try (SingleSignOn sso = this.singleSignOnManager.findSingleSignOn(ssoId)) { exchange.addResponseWrapper(responseListener); return AuthenticationMechanismOutcome.NOT_ATTEMPTED;