public HttpServerExchange getExchange() { return httpServletRequest.getExchange(); }
public HttpServerExchange getExchange() { return originalRequest.getExchange(); }
public HttpServerExchange getExchange() { return httpServletRequest.getExchange(); }
@Override public boolean isRequestedSessionIdValid() { HttpSession session = servletContext.getSession(originalServletContext, httpServletRequest.getExchange(), false); return session != null; }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequestImpl) { HttpServerExchange exchange = ((HttpServletRequestImpl) request).getExchange(); String name = exchange.getAttachment(LISTEN_ADDRESS_NAME_ATTACHMENT); if (name != null) { request.setAttribute(GuiceRsServerRuntimeInfo.LISTEN_ADDRESS_NAME_ATTRIBUTE, name); } chain.doFilter(request, response); } }
@Override public boolean isRequestedSessionIdValid() { HttpSession session = servletContext.getSession(originalServletContext, httpServletRequest.getExchange(), false); return session != null; }
@Override public HttpSession getSession(final boolean create) { return servletContext.getSession(originalServletContext, httpServletRequest.getExchange(), create); }
@Override public HttpSession getSession(final boolean create) { return servletContext.getSession(originalServletContext, httpServletRequest.getExchange(), create); }
public ServletInputStreamImpl(final HttpServletRequestImpl request) { this.request = request; if (request.getExchange().isRequestChannelAvailable()) { this.channel = request.getExchange().getRequestChannel(); } else { this.channel = new EmptyStreamSourceChannel(request.getExchange().getIoThread()); } this.bufferPool = request.getExchange().getConnection().getByteBufferPool(); }
@Override public void prelogin(HttpSession session, Object request, String servletName) { if (session == null) // Cannot prelogin() without a session return; if (session.getAttribute(AuthenticationContext.class.getName()) instanceof UndertowAuthenticationContext) return; HttpServerExchange exchange = null; if (request instanceof HttpServletRequestImpl) exchange = ((HttpServletRequestImpl)request).getExchange(); else if (request.getClass().getSimpleName().equals("ExchangeHandshakeRequest")) { // Websocket Field f = null; try { f = request.getClass().getDeclaredField("exchange"); f.setAccessible(true); Object wsExchange = f.get(request); f = wsExchange.getClass().getDeclaredField("exchange"); f.setAccessible(true); exchange = (HttpServerExchange)f.get(wsExchange); } catch (Exception e) { throw new RuntimeException("Could not get internal undertow exchange", e); } } SecurityContext securityContext = exchange.getSecurityContext(); UndertowAuthenticationContext authenticationContext = new UndertowAuthenticationContext(securityContext); session.setAttribute(AuthenticationContext.class.getName(), authenticationContext); }
public ServletWebSocketHttpExchange(final HttpServletRequest request, final HttpServletResponse response, Set<WebSocketChannel> peerConnections) { this.request = request; this.response = response; this.peerConnections = peerConnections; this.exchange = SecurityActions.requireCurrentServletRequestContext().getOriginalRequest().getExchange(); }
HttpServerExchange exchange = SecurityActions.requireCurrentServletRequestContext().getOriginalRequest().getExchange(); final Resource resource;
public void logout() throws SecurityServiceException { ServletGraniteContext graniteContext = (ServletGraniteContext)GraniteContext.getCurrentInstance(); if (graniteContext instanceof HttpGraniteContext) { HttpServletRequest httpRequest = graniteContext.getRequest(); HttpServerExchange exchange = ((HttpServletRequestImpl)httpRequest).getExchange(); SecurityContext securityContext = exchange.getSecurityContext(); securityContext.logout(); } HttpSession session = graniteContext.getSession(false); if (session != null) { endLogout(); session.invalidate(); } }
final HttpServerExchange exchange = requestImpl.getExchange(); requestImpl.getExchange().setRelativePath(newServletPath); requestImpl.getExchange().setQueryString(newQueryString); requestImpl.getExchange().setRequestPath(newRequestUri); requestImpl.getExchange().setRequestURI(newRequestUri); requestImpl.setServletContext((ServletContextImpl) context); responseImpl.setServletContext((ServletContextImpl) context); requestImpl.getExchange().getAttachment(ServletRequestContext.ATTACHMENT_KEY).setServletPathMatch(info);
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) {
@Override public void invalidate() { invalid = true; if (servletRequestContext == null) { session.invalidate(null); } else { if(servletRequestContext.getOriginalRequest().getServletContext() == servletContext) { session.invalidate(servletRequestContext.getOriginalRequest().getExchange()); } else { session.invalidate(null); } } }
public Principal login(Object credentials, String charset) throws SecurityServiceException { String[] decoded = decodeBase64Credentials(credentials, charset); ServletGraniteContext graniteContext = (ServletGraniteContext)GraniteContext.getCurrentInstance(); Principal principal = null; if (graniteContext instanceof HttpGraniteContext) { HttpServletRequest httpRequest = graniteContext.getRequest(); HttpServerExchange exchange = ((HttpServletRequestImpl)httpRequest).getExchange(); SecurityContext securityContext = exchange.getSecurityContext(); UndertowAuthenticationContext authenticationContext = new UndertowAuthenticationContext(securityContext); principal = authenticationContext.authenticate(decoded[0], decoded[1]); if (principal != null) graniteContext.getSession().setAttribute(AuthenticationContext.class.getName(), authenticationContext); } else { AuthenticationContext authenticationContext = (AuthenticationContext)graniteContext.getSession().getAttribute(AuthenticationContext.class.getName()); if (authenticationContext != null) principal = authenticationContext.authenticate(decoded[0], decoded[1]); else return null; } if (principal == null) throw SecurityServiceException.newInvalidCredentialsException("Wrong username or password"); graniteContext.setPrincipal(principal); endLogin(credentials, charset); return principal; }
throw UndertowServletMessages.MESSAGES.pathWasNotSet(); ServerConnection con = servletRequest.getExchange().getConnection(); if (con.isPushSupported()) { HeaderMap newHeaders = new HeaderMap();
setFlags(FLAG_BEING_INVOKED_IN_IO_THREAD); try { request.getServletContext().invokeOnDataAvailable(request.getExchange(), listener); } finally { clearFlags(FLAG_BEING_INVOKED_IN_IO_THREAD); request.getServletContext().invokeOnAllDataRead(request.getExchange(), listener); if (allAreClear(state, FLAG_ON_DATA_READ_CALLED)) { setFlags(FLAG_ON_DATA_READ_CALLED); request.getServletContext().invokeOnAllDataRead(request.getExchange(), listener); request.getServletContext().invokeRunnable(request.getExchange(), new Runnable() { @Override public void run() {
@Override public boolean isReady() { boolean finished = anyAreSet(state, FLAG_FINISHED); if(finished) { if (anyAreClear(state, FLAG_ON_DATA_READ_CALLED)) { if(allAreClear(state, FLAG_BEING_INVOKED_IN_IO_THREAD)) { setFlags(FLAG_ON_DATA_READ_CALLED); request.getServletContext().invokeOnAllDataRead(request.getExchange(), listener); } else { setFlags(FLAG_CALL_ON_ALL_DATA_READ); } } } boolean ready = anyAreSet(state, FLAG_READY) && !finished; if(!ready && listener != null && !finished) { channel.resumeReads(); } if(ready) { setFlags(FLAG_IS_READY_CALLED); } return ready; }