Java Code Examples for io.undertow.servlet.handlers.ServletRequestContext#getServletRequest()
The following examples show how to use
io.undertow.servlet.handlers.ServletRequestContext#getServletRequest() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServletSessionAttribute.java From quarkus-http with Apache License 2.0 | 6 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); if (req instanceof HttpServletRequest) { HttpSession session = ((HttpServletRequest) req).getSession(false); if (session != null) { Object result = session.getAttribute(attributeName); if (result != null) { return result.toString(); } } } } return null; }
Example 2
Source File: ServletSecurityRoleHandler.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletRequest request = servletRequestContext.getServletRequest(); if (request.getDispatcherType() == DispatcherType.REQUEST) { List<SingleConstraintMatch> constraints = servletRequestContext.getRequiredConstrains(); SecurityContext sc = exchange.getSecurityContext(); if (!authorizationManager.canAccessResource(constraints, sc.getAuthenticatedAccount(), servletRequestContext.getCurrentServlet().getManagedServlet().getServletInfo(), servletRequestContext.getOriginalRequest(), servletRequestContext.getDeployment())) { HttpServletResponse response = (HttpServletResponse) servletRequestContext.getServletResponse(); response.sendError(StatusCodes.FORBIDDEN); return; } } next.handleRequest(exchange); }
Example 3
Source File: ServletSessionAttribute.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); if (req instanceof HttpServletRequest) { HttpSession session = ((HttpServletRequest) req).getSession(false); if (session != null) { Object result = session.getAttribute(attributeName); if (result != null) { return result.toString(); } } } } return null; }
Example 4
Source File: ServletSecurityRoleHandler.java From quarkus-http with Apache License 2.0 | 6 votes |
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletRequest request = servletRequestContext.getServletRequest(); if (request.getDispatcherType() == DispatcherType.REQUEST) { List<SingleConstraintMatch> constraints = servletRequestContext.getRequiredConstrains(); SecurityContext sc = exchange.getSecurityContext(); if (!authorizationManager.canAccessResource(constraints, sc.getAuthenticatedAccount(), servletRequestContext.getCurrentServlet().getManagedServlet().getServletInfo(), servletRequestContext.getOriginalRequest(), servletRequestContext.getDeployment())) { HttpServletResponse response = (HttpServletResponse) servletRequestContext.getServletResponse(); response.sendError(StatusCodes.FORBIDDEN); return; } } next.handleRequest(exchange); }
Example 5
Source File: ServletRequestLocaleAttribute.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); return req.getLocale().toString(); } return null; }
Example 6
Source File: ServletRequestedSessionIdAttribute.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); if (req instanceof HttpServletRequest) { return ((HttpServletRequest) req).getRequestedSessionId(); } } return null; }
Example 7
Source File: ServletRequestedSessionIdFromCookieAttribute.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); if (req instanceof HttpServletRequest) { return Boolean.toString(((HttpServletRequest) req).isRequestedSessionIdFromCookie()); } } return null; }
Example 8
Source File: HttpServletRequestImpl.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public AsyncContext startAsync() throws IllegalStateException { if (!isAsyncSupported()) { throw UndertowServletMessages.MESSAGES.startAsyncNotAllowed(); } else if (asyncStarted) { throw UndertowServletMessages.MESSAGES.asyncAlreadyStarted(); } asyncStarted = true; final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); return asyncContext = new AsyncContextImpl(exchange, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse(), servletRequestContext, false, asyncContext); }
Example 9
Source File: ServletSessionIdAttribute.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); if (req instanceof HttpServletRequest) { HttpSession session = ((HttpServletRequest) req).getSession(false); if (session != null) { return session.getId(); } } } return null; }
Example 10
Source File: ServletRequestCharacterEncodingAttribute.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); return req.getCharacterEncoding(); } return null; }
Example 11
Source File: ServletSessionAttribute.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); if (req instanceof HttpServletRequest) { HttpSession session = ((HttpServletRequest) req).getSession(false); if (session != null) { session.setAttribute(attributeName, newValue); } } } }
Example 12
Source File: ServletSessionIdAttribute.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); if (req instanceof HttpServletRequest) { HttpSession session = ((HttpServletRequest) req).getSession(false); if (session != null) { return session.getId(); } } } return null; }
Example 13
Source File: ServletRequestLocaleAttribute.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); return req.getLocale().toString(); } return null; }
Example 14
Source File: ServletSamlSessionStore.java From keycloak with Apache License 2.0 | 5 votes |
@Override public String getRedirectUri() { final ServletRequestContext sc = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); HttpSessionImpl session = sc.getCurrentServletContext().getSession(exchange, true); String redirect = (String)session.getAttribute(SAML_REDIRECT_URI); if (redirect == null) { ServletHttpFacade facade = new ServletHttpFacade(exchange); HttpServletRequest req = (HttpServletRequest)sc.getServletRequest(); String contextPath = req.getContextPath(); String baseUri = KeycloakUriBuilder.fromUri(req.getRequestURL().toString()).replacePath(contextPath).build().toString(); return SamlUtil.getRedirectTo(facade, contextPath, baseUri); } return redirect; }
Example 15
Source File: ServletRequestAuthenticator.java From keycloak with Apache License 2.0 | 5 votes |
@Override protected void propagateKeycloakContext(KeycloakUndertowAccount account) { super.propagateKeycloakContext(account); final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); HttpServletRequest req = (HttpServletRequest) servletRequestContext.getServletRequest(); req.setAttribute(KeycloakSecurityContext.class.getName(), account.getKeycloakSecurityContext()); }
Example 16
Source File: ServletRequestCharacterEncodingAttribute.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public String readAttribute(final HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (context != null) { ServletRequest req = context.getServletRequest(); return req.getCharacterEncoding(); } return null; }
Example 17
Source File: ServletHttpFacade.java From keycloak with Apache License 2.0 | 4 votes |
public ServletHttpFacade(HttpServerExchange exchange) { super(exchange); final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); request = (HttpServletRequest)servletRequestContext.getServletRequest(); response = (HttpServletResponse)servletRequestContext.getServletResponse(); }
Example 18
Source File: ServletSamlSessionStore.java From keycloak with Apache License 2.0 | 4 votes |
private HttpServletRequest getRequest() { final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); return (HttpServletRequest) servletRequestContext.getServletRequest(); }
Example 19
Source File: ServletSessionTokenStore.java From keycloak with Apache License 2.0 | 4 votes |
protected HttpSession getSession(boolean create) { final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); HttpServletRequest req = (HttpServletRequest) servletRequestContext.getServletRequest(); return req.getSession(create); }
Example 20
Source File: UndertowLogbackAccessEvent.java From logback-access-spring-boot-starter with Apache License 2.0 | 2 votes |
/** * Extracts the HTTP servlet request from the HTTP server exchange. * * @param exchange the HTTP server exchange. * @return the HTTP servlet request. */ private static HttpServletRequest extractHttpServletRequest(HttpServerExchange exchange) { ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); return (HttpServletRequest) context.getServletRequest(); }