List of usage examples for javax.servlet.http HttpServletRequestWrapper HttpServletRequestWrapper
public HttpServletRequestWrapper(HttpServletRequest request)
From source file:org.intalio.tempo.uiframework.actions.OneTaskAction.java
protected void fillModel(Map model) { final UIFWApplicationState state = ApplicationState .getCurrentInstance(new HttpServletRequestWrapper(_request)); final String token = state.getCurrentUser().getToken(); final String user = state.getCurrentUser().getName(); try {//ww w .ja va 2 s. co m TasksCollector collector = new TasksCollector(new HttpServletRequestWrapper(_request), user, token); model.put("taskform", collector.retrieveOneTask(_request.getParameter("id")).getFormManagerURL()); } catch (Exception ex) { _errors.add(new ActionError(-1, null, "com_intalio_bpms_workflow_tasks_retrieve_error", null, ActionError.getStackTrace(ex), null, null)); _log.error("Error while retrieving task list", ex); } model.put("participantToken", token); model.put("currentUser", user); model.put("refreshTime", Configuration.getInstance().getRefreshTime()); model.put("sessionTimeout", Configuration.getInstance().getSessionTimeout()); }
From source file:dk.dma.msinm.user.security.SecurityUtils.java
/** * Attempts to log-in the user./*from ww w .j a va 2 s. c o m*/ * <p> * The web-app is using a custom login-module, {@linkplain JbossLoginModule}, and the * natural solution would be that this module set the {@code User} as the user principal * upon successful authentication. * <br> * However, this tends to cause ClassCastException's when the web-app has been reloaded, * because a different class-loader is used for the login-modules. * <br> * Hence, the login-module sets a {@code SimplePrincipal} as the request user principal, and this * method swaps the {@code SimplePrincipal} for a {@code User} principal. * * @param userService the user service * @param request the servlet request * @param username the user name * @param password the password * @return the updated request */ public static HttpServletRequest login(UserService userService, HttpServletRequest request, String username, String password) throws ServletException { // Will throw an exception if the login fails //request.logout(); request.login(username, password); // The email is used as it is unique for the user String email = request.getUserPrincipal().getName(); final User user = userService.findByEmail(email); return new HttpServletRequestWrapper(request) { @Override public java.security.Principal getUserPrincipal() { return user; } }; }
From source file:org.intalio.tempo.uiframework.actions.TasksAction.java
protected TasksCollector getTaskCollector(String user, String token) { return new TasksCollector(new HttpServletRequestWrapper(_request), user, token); }
From source file:com.boundlessgeo.geoserver.AppDispatcher.java
@Override protected HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception { String servletPath = request.getServletPath(); if (servletPath != null && servletPath.startsWith(API_PATH)) { //JD: Hack to deal with the GeoServer "advanced dispatch", the point here is that we want to expose // the rest api directly "/api" request = new HttpServletRequestWrapper(request) { @Override/*from w w w . ja v a2 s.c om*/ public String getRequestURI() { return super.getRequestURI().replace(API_PATH, API_PATH + API_PATH); } }; } return super.getHandler(request); }
From source file:org.intalio.tempo.uiframework.actions.TasksAction.java
protected void fillModel(Map model) { final UIFWApplicationState state = ApplicationState .getCurrentInstance(new HttpServletRequestWrapper(_request)); final String token = state.getCurrentUser().getToken(); final String user = state.getCurrentUser().getName(); if (Boolean.valueOf(_request.getParameter("update")).booleanValue()) { try {//from w w w . j a va 2s.c om TasksCollector collector = getTaskCollector(user, token); model.put("tasks", collector.retrieveTasks()); } catch (Exception ex) { _errors.add(new ActionError(-1, null, "com_intalio_bpms_workflow_tasks_retrieve_error", null, ActionError.getStackTrace(ex), null, null)); _log.error("Error while retrieving task list", ex); } } model.put("participantToken", token); model.put("currentUser", user); model.put("refreshTime", Configuration.getInstance().getRefreshTime()); model.put("sessionTimeout", Configuration.getInstance().getSessionTimeout()); BPMS_DESCRIPTOR_PARSER.addBpmsBuildVersionsPropertiesToMap(model); }
From source file:by.creepid.jsf.fileupload.UploadFilter.java
private static HttpServletRequest wrapRequest(HttpServletRequest request, final Map<String, String[]> parameterMap) { /**/*from w ww .ja v a2 s. com*/ * Provides a convenient implementation of the HttpServletRequest * interface that can be subclassed by developers wishing to adapt the * request to a Servlet */ return new HttpServletRequestWrapper(request) { // inner methods passed as parameters @Override public Map<String, String[]> getParameterMap() { return parameterMap; } @Override public String[] getParameterValues(String name) { return (String[]) parameterMap.get(name); } @Override public String getParameter(String name) { String[] params = getParameterValues(name); if (params == null) { return null; } return params[0]; } @Override public Enumeration<String> getParameterNames() { return Collections.enumeration(parameterMap.keySet()); } }; }
From source file:org.intalio.tempo.web.controller.SecuredController.java
public static String getCurrentUserName(HttpServletRequest request) { ApplicationState state = ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(request)); if (state == null || state.getCurrentUser() == null) { return "UnknownUser"; }// w ww .java2 s. c o m return state.getCurrentUser().getName(); }
From source file:com.tasktop.c2c.server.web.proxy.AjpProxy.java
@Override protected void proxy(String targetUrl, HttpServletRequest request, HttpServletResponse response) throws IOException { Matcher matcher = targetUrlPattern.matcher(targetUrl); if (!matcher.matches()) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); throw new IllegalStateException(); }/*w w w .ja va 2 s . com*/ String uri = matcher.group(3); int query = uri.indexOf('?'); if (query != -1) { uri = uri.substring(0, query); } final String requestUri = uri; request = new HttpServletRequestWrapper(request) { public String getRequestURI() { return requestUri; } }; AjpProtocol ajpProtocol = new AjpProtocol(); ajpProtocol.setSocketPool(socketPool); ajpProtocol.setProxyHost(matcher.group(1)); String portPart = matcher.group(2); ajpProtocol.setProxyPort(portPart == null ? 8009 : Integer.parseInt(portPart)); ajpProtocol.setHeaderFilter(headerFilter); ajpProtocol.forward(request, response); }
From source file:com.navercorp.pinpoint.web.servlet.RewriteForV2Filter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (enable) { HttpServletRequest req = (HttpServletRequest) request; String requestURI = req.getRequestURI(); if (isRedirectTarget(requestURI)) { HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper((HttpServletRequest) request); RequestDispatcher dispatcher = wrapper.getRequestDispatcher("/v2/index.html"); dispatcher.forward(request, response); } else {// w w w. j av a2 s . c om chain.doFilter(request, response); } } else { chain.doFilter(request, response); } }
From source file:org.brutusin.rpc.websocket.WebsocketFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; if (isDisabled || httpRequest.getRequestURI() == null || !(httpRequest.getRequestURI().substring(httpRequest.getContextPath().length()) .startsWith(RpcConfig.getInstance().getPath() + "/wskt"))) { chain.doFilter(request, response); return;// ww w . ja v a 2s . c om } final Map<String, String[]> fakedParams = Collections.singletonMap("requestId", new String[] { String.valueOf(counter.getAndIncrement()) }); HttpServletRequestWrapper wrappedRequest = new HttpServletRequestWrapper(httpRequest) { @Override public Map<String, String[]> getParameterMap() { return fakedParams; } }; /* * current request is needed for getEndpointInstance(). In glassfish getEndpointInstance() is executed out this filter chain, * but inside whole request-response cycle (controlled by the overall listener that sets and removes GlobalThreadLocal) */ if (GlobalThreadLocal.get() == null) { throw new AssertionError(); } Object securityContext; if (ClassUtils.isPresent("org.springframework.security.core.context.SecurityContextHolder", RpcWebInitializer.class.getClassLoader())) { securityContext = SecurityContextHolder.getContext(); } else { securityContext = null; } GlobalThreadLocal.set(new GlobalThreadLocal(wrappedRequest, securityContext)); // override current request with the one with faked params and security context chain.doFilter(wrappedRequest, response); }