Java Code Examples for javax.servlet.http.HttpServletRequestWrapper

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project pluto, under directory /pluto-container/src/main/java/org/apache/pluto/container/impl/.

Source file: HttpServletPortletRequestWrapper.java

  23 
vote

/** 
 * Determine if the web container modified the current HttpServletRequestWrapper stack. <p> The current HttpServletRequestWrapper hierachy (stack) size is determined and compared against the previous size. </p> <p> If the size is different the web container "injected" (or removed) a request wrapper of its own to manage request dispatcher logic like merging additional dispatcher query string parameters. </p> <p> This DispatchDetection solution only works on web containers like Tomcat. </p>
 * @return true if the request wrapper stack (size) changed.
 */
protected boolean isRequestWrapperStackChanged(){
  HttpServletRequestWrapper currentRequest=this;
  int currentRequestWrapperStackSize=0;
  while ((currentRequest.getRequest()) instanceof HttpServletRequestWrapper) {
    currentRequestWrapperStackSize++;
    currentRequest=(HttpServletRequestWrapper)currentRequest.getRequest();
  }
  if (currentRequestWrapperStackSize != requestWrapperStackSize) {
    requestWrapperStackSize=currentRequestWrapperStackSize;
    return true;
  }
  return false;
}
 

Example 2

From project resty-gwt, under directory /restygwt/src/it/restygwt-jersey-jaxb-example/src/main/java/org/fusesource/restygwt/examples/server/.

Source file: JerseyServlet.java

  22 
vote

@Override public void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  HttpServletRequestWrapper wrapper=new HttpServletRequestWrapper(request){
    @Override public String getServletPath(){
      if (getPathInfo().startsWith("/org.fusesource.restygwt.examples.JERSEY_JAXB.JUnit/rest")) {
        return "/org.fusesource.restygwt.examples.JERSEY_JAXB.JUnit/rest";
      }
      return super.getServletPath();
    }
  }
;
  super.service(wrapper,response);
}
 

Example 3

From project spark_1, under directory /src/main/java/spark/servlet/.

Source file: SparkFilter.java

  22 
vote

@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpRequest=(HttpServletRequest)request;
  final String relativePath=FilterTools.getRelativePath(httpRequest,filterPath);
  System.out.println(relativePath);
  HttpServletRequestWrapper requestWrapper=new HttpServletRequestWrapper(httpRequest){
    @Override public String getRequestURI(){
      return relativePath;
    }
  }
;
  matcherFilter.doFilter(requestWrapper,response,chain);
}
 

Example 4

From project candlepin, under directory /src/main/java/org/candlepin/servlet/filter/.

Source file: ContentTypeHackFilter.java

  21 
vote

@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest httpRequest=(HttpServletRequest)request;
  if (httpRequest.getContentType() == null) {
    httpRequest=new HttpServletRequestWrapper(httpRequest){
      @Override public String getContentType(){
        return "application/json";
      }
    }
;
  }
  chain.doFilter(httpRequest,response);
}
 

Example 5

From project Carolina-Digital-Repository, under directory /sword-server/src/main/java/edu/unc/lib/dl/cdr/sword/server/.

Source file: SwordHeaderRewriteFilter.java

  21 
vote

@Override public void doFilterInternal(HttpServletRequest request,HttpServletResponse response,FilterChain chain) throws IOException, ServletException {
  final String packaging=request.getHeader("X-Packaging");
  final String onBehalfOf=request.getHeader("X-On-Behalf-Of");
  if (packaging != null || onBehalfOf != null) {
    final HttpServletRequest httpRequest=(HttpServletRequest)request;
    HttpServletRequestWrapper wrapper=new HttpServletRequestWrapper(httpRequest){
      @Override public String getHeader(      String name){
        if (PACKAGING.equals(name) && packaging != null) {
          return packaging;
        }
        if (ON_BEHALF_OF.equals(name) && onBehalfOf != null) {
          return onBehalfOf;
        }
        return super.getHeader(name);
      }
    }
;
    chain.doFilter(wrapper,response);
    return;
  }
  chain.doFilter(request,response);
}
 

Example 6

From project dev-examples, under directory /misc-demo/src/main/java/org/richfaces/demo/.

Source file: TestIdentityFilter.java

  21 
vote

public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequestWrapper wrapper=new HttpServletRequestWrapper((HttpServletRequest)request){
    private UserBean getUserBean(){
      HttpSession session=getSession(false);
      if (session != null) {
        return (UserBean)session.getAttribute("userBean");
      }
      return null;
    }
    @Override public boolean isUserInRole(    String role){
      UserBean userBean=getUserBean();
      if (userBean != null) {
        return userBean.isUserInRole(role);
      }
      return false;
    }
    @Override public Principal getUserPrincipal(){
      UserBean userBean=getUserBean();
      if (userBean != null) {
        return userBean.getPrincipal();
      }
      return null;
    }
    @Override public String getRemoteUser(){
      UserBean userBean=getUserBean();
      if (userBean != null) {
        return userBean.getRolename();
      }
      return null;
    }
  }
;
  chain.doFilter(wrapper,response);
}
 

Example 7

From project guice-jit-providers, under directory /extensions/servlet/src/com/google/inject/servlet/.

Source file: ManagedFilterPipeline.java

  21 
vote

/** 
 * Used to create an proxy that dispatches either to the guice-servlet pipeline or the regular pipeline based on uri-path match. This proxy also provides minimal forwarding support. We cannot forward from a web.xml Servlet/JSP to a guice-servlet (because the filter pipeline is not called again). However, we can wrap requests with our own dispatcher to forward the *other* way. web.xml Servlets/JSPs can forward to themselves as per normal. This is not a problem cuz we intend for people to migrate from web.xml to guice-servlet, incrementally, but not the other way around (which, we should actively discourage).
 */
@SuppressWarnings({"JavaDoc","deprecation"}) private ServletRequest withDispatcher(ServletRequest servletRequest,final ManagedServletPipeline servletPipeline){
  if (!servletPipeline.hasServletsMapped()) {
    return servletRequest;
  }
  HttpServletRequest request=(HttpServletRequest)servletRequest;
  return new HttpServletRequestWrapper(request){
    @Override public RequestDispatcher getRequestDispatcher(    String path){
      final RequestDispatcher dispatcher=servletPipeline.getRequestDispatcher(path);
      return (null != dispatcher) ? dispatcher : super.getRequestDispatcher(path);
    }
  }
;
}
 

Example 8

From project jboss-as-quickstart, under directory /servlet-filterlistener/src/main/java/org/jboss/as/quickstarts/servlet/filterlistener/.

Source file: VowelRemoverFilter.java

  21 
vote

@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  final Map<String,String[]> filteredParams=Collections.unmodifiableMap(removeVowels(request.getParameterMap()));
  HttpServletRequestWrapper wrappedRequest=new HttpServletRequestWrapper((HttpServletRequest)request){
    @Override public Map<String,String[]> getParameterMap(){
      return filteredParams;
    }
    @Override public String getParameter(    String name){
      return filteredParams.get(name) == null ? null : filteredParams.get(name)[0];
    }
    @Override public Enumeration<String> getParameterNames(){
      return Collections.enumeration(filteredParams.keySet());
    }
    @Override public String[] getParameterValues(    String name){
      return filteredParams.get(name);
    }
  }
;
  try {
    servletContext.log("VowelRemoverFilter invoking filter chain...");
    chain.doFilter(wrappedRequest,response);
  }
  finally {
    servletContext.log("VowelRemoverFilter done filtering request");
  }
}
 

Example 9

From project jira-hudson-integration, under directory /hudson-apiv2-plugin/src/main/java/com/marvelution/hudson/plugins/apiv2/servlet/filter/.

Source file: HudsonAPIV2ServletFilter.java

  21 
vote

/** 
 * {@inheritDoc}
 */
@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain filterChain) throws IOException, ServletException {
  if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
    final HttpServletRequestWrapper servletRequest=new HttpServletRequestWrapper((HttpServletRequest)request);
    String requestUri=servletRequest.getPathInfo();
    if (StringUtils.isNotBlank(requestUri) && requestUri.startsWith("/")) {
      requestUri=requestUri.substring(1);
    }
    LOGGER.log(Level.FINE,"Got a request from URI: " + requestUri + " with Accept Header: "+ servletRequest.getHeader("Accept"));
    if (StringUtils.isNotBlank(requestUri) && requestUri.startsWith(BaseRestResource.BASE_REST_URI)) {
      validateRuntimeDelegate();
      LOGGER.log(Level.FINE,"Got a REST request, forwarding it to the Wink RestFilter");
      FilteredHttpServletResponse servletResponse=new FilteredHttpServletResponse((HttpServletResponse)response);
      restServlet.service(servletRequest,servletResponse);
      if ((!(servletResponse.isCommitted())) && (servletResponse.getStatusCode() == 404)) {
        LOGGER.log(Level.FINE,"Filter " + this.getClass().getName() + " did not match a resource so letting request continue on FilterChain");
        servletResponse.setStatus(200);
        filterChain.doFilter(request,response);
      }
    }
 else {
      LOGGER.log(Level.FINE,"No REST request, forwarding request to the next ServletFilter");
      filterChain.doFilter(request,response);
    }
  }
 else {
    LOGGER.log(Level.FINE,"No HttpServletRequest and HttpServletResponse, forwarding request to the next ServletFilter");
    filterChain.doFilter(request,response);
  }
}
 

Example 10

From project nuxeo-webengine, under directory /nuxeo-webengine-jaxrs/src/main/java/org/nuxeo/ecm/webengine/jaxrs/login/.

Source file: AuthenticationFilter.java

  21 
vote

protected HttpServletRequest wrapRequest(HttpServletRequest request,LoginContext lc){
  Set<Principal> set=lc.getSubject().getPrincipals();
  if (!set.isEmpty()) {
    final Principal principal=set.iterator().next();
    return new HttpServletRequestWrapper(request){
      @Override public Principal getUserPrincipal(){
        return principal;
      }
    }
;
  }
  return request;
}
 

Example 11

From project saiku, under directory /saiku-bi-platform-plugin/src/main/java/org/saiku/plugin/.

Source file: EnunciateJerseyPluginServlet.java

  21 
vote

@Override public void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  logger.debug("servicing request for resource " + request.getPathInfo());
  HttpServletRequestWrapper wrapper=new HttpServletRequestWrapper(request){
    @Override public String getRequestURI(){
      String uri=super.getRequestURI().replace("content/","");
      return uri;
    }
    @Override public StringBuffer getRequestURL(){
      String url=super.getRequestURL().toString();
      return new StringBuffer(url.replace("content/",""));
    }
  }
;
  super.service(wrapper,response);
}
 

Example 12

From project saiku-adhoc, under directory /saiku-adhoc-core/src/main/java/org/saiku/adhoc/service/.

Source file: EnunciateJerseyPluginServlet.java

  21 
vote

@Override public void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  logger.debug("servicing request for resource " + request.getPathInfo());
  HttpServletRequestWrapper wrapper=new HttpServletRequestWrapper(request){
    @Override public String getRequestURI(){
      String uri=super.getRequestURI().replace("content/","");
      return uri;
    }
    @Override public StringBuffer getRequestURL(){
      String url=super.getRequestURL().toString();
      return new StringBuffer(url.replace("content/",""));
    }
  }
;
  super.service(wrapper,response);
}
 

Example 13

From project security_2, under directory /web-nutsNbolts/src/main/java/org/intalio/tempo/web/controller/.

Source file: SecuredController.java

  21 
vote

public static String getCurrentUserName(HttpServletRequest request){
  ApplicationState state=ApplicationState.getCurrentInstance(new HttpServletRequestWrapper(request));
  if (state == null || state.getCurrentUser() == null) {
    return "UnknownUser";
  }
  return state.getCurrentUser().getName();
}
 

Example 14

From project sisu-guice, under directory /extensions/servlet/src/com/google/inject/servlet/.

Source file: ManagedFilterPipeline.java

  21 
vote

/** 
 * Used to create an proxy that dispatches either to the guice-servlet pipeline or the regular pipeline based on uri-path match. This proxy also provides minimal forwarding support. We cannot forward from a web.xml Servlet/JSP to a guice-servlet (because the filter pipeline is not called again). However, we can wrap requests with our own dispatcher to forward the *other* way. web.xml Servlets/JSPs can forward to themselves as per normal. This is not a problem cuz we intend for people to migrate from web.xml to guice-servlet, incrementally, but not the other way around (which, we should actively discourage).
 */
@SuppressWarnings({"JavaDoc","deprecation"}) private ServletRequest withDispatcher(ServletRequest servletRequest,final ManagedServletPipeline servletPipeline){
  if (!servletPipeline.hasServletsMapped()) {
    return servletRequest;
  }
  HttpServletRequest request=(HttpServletRequest)servletRequest;
  return new HttpServletRequestWrapper(request){
    @Override public RequestDispatcher getRequestDispatcher(    String path){
      final RequestDispatcher dispatcher=servletPipeline.getRequestDispatcher(path);
      return (null != dispatcher) ? dispatcher : super.getRequestDispatcher(path);
    }
  }
;
}
 

Example 15

From project spring-security, under directory /config/src/test/java/org/springframework/security/config/debug/.

Source file: DebugFilterTest.java

  21 
vote

@Test public void doFilterDoesNotWrapWithDebugRequestWrapperAgain() throws Exception {
  when(request.getAttribute(requestAttr)).thenReturn(Boolean.TRUE);
  HttpServletRequest fireWalledRequest=new HttpServletRequestWrapper(new DebugRequestWrapper(this.request));
  filter.doFilter(fireWalledRequest,response,filterChain);
  verify(fcp).doFilter(fireWalledRequest,response,filterChain);
}
 

Example 16

From project spring-test-mvc, under directory /src/test/java/org/springframework/test/web/server/samples/standalone/.

Source file: FilterTests.java

  21 
vote

@Override protected void doFilterInternal(HttpServletRequest request,HttpServletResponse response,FilterChain filterChain) throws ServletException, IOException {
  filterChain.doFilter(new HttpServletRequestWrapper(request){
    @Override public Principal getUserPrincipal(){
      return new Principal(){
        public String getName(){
          return PRINCIPAL_NAME;
        }
      }
;
    }
  }
,new HttpServletResponseWrapper(response));
}
 

Example 17

From project tempo, under directory /ui-fw/src/main/java/org/intalio/tempo/portlet/.

Source file: SecuredController.java

  21 
vote

@Override protected final ModelAndView showForm(RenderRequest request,RenderResponse response,BindException errors) throws Exception {
  ModelAndView mav=null;
  Method getHttpServletRequest=request.getClass().getMethod("getHttpServletRequest");
  HttpServletRequest hsr=(HttpServletRequest)getHttpServletRequest.invoke(request);
  HttpServletRequestWrapper wrapper=new HttpServletRequestWrapper(hsr);
  String proxyTicket=(String)request.getAttribute(TokenService.CAS_PROXY_TICKET);
  if (proxyTicket == null) {
    proxyTicket=(String)request.getAttribute(PROXY_TICKET);
    if (proxyTicket == null) {
      String pgtIou=null;
      try {
        CASReceipt casReceipt=(CASReceipt)hsr.getSession().getAttribute(CASFilter.CAS_FILTER_RECEIPT);
        if (casReceipt != null)         pgtIou=casReceipt.getPgtIou();
        if (pgtIou != null)         proxyTicket=ProxyTicketReceptor.getProxyTicket(pgtIou,_serviceURL);
      }
 catch (      IOException e) {
        throw new RuntimeException("Could not get the proxy ticket",e);
      }
    }
  }
  ApplicationState state=getApplicationState(wrapper);
  if (state.getCurrentUser() == null) {
    String token=_tokenService.getTokenFromTicket(proxyTicket,_serviceURL);
    String[] grantedRoles=new String[0];
    User currentUser=authenticate(token,grantedRoles);
    state.setCurrentUser(currentUser);
    ApplicationState.setCurrentInstance(wrapper,state);
  }
  mav=new ModelAndView("portlet");
  fillAuthorization(wrapper,mav);
  return mav;
}
 

Example 18

From project winstone, under directory /src/java/winstone/auth/.

Source file: BasicAuthenticationHandler.java

  21 
vote

/** 
 * Handling the (possible) response
 */
protected boolean validatePossibleAuthenticationResponse(HttpServletRequest request,HttpServletResponse response,String pathRequested) throws IOException {
  String authorization=request.getHeader("Authorization");
  if ((authorization != null) && authorization.toLowerCase().startsWith("basic")) {
    char[] inBytes=authorization.substring(5).trim().toCharArray();
    byte[] outBytes=new byte[(int)(inBytes.length * 0.75f)];
    int length=decodeBase64(inBytes,outBytes,0,inBytes.length,0);
    String decoded=new String(outBytes,0,length);
    int delimPos=decoded.indexOf(':');
    if (delimPos != -1) {
      AuthenticationPrincipal principal=this.realm.authenticateByUsernamePassword(decoded.substring(0,delimPos).trim(),decoded.substring(delimPos + 1).trim());
      if (principal != null) {
        principal.setAuthType(HttpServletRequest.BASIC_AUTH);
        if (request instanceof WinstoneRequest)         ((WinstoneRequest)request).setRemoteUser(principal);
 else         if (request instanceof HttpServletRequestWrapper) {
          HttpServletRequestWrapper wrapper=(HttpServletRequestWrapper)request;
          if (wrapper.getRequest() instanceof WinstoneRequest)           ((WinstoneRequest)wrapper.getRequest()).setRemoteUser(principal);
 else           Logger.log(Logger.WARNING,AUTH_RESOURCES,"BasicAuthenticationHandler.CantSetUser",wrapper.getRequest().getClass().getName());
        }
 else         Logger.log(Logger.WARNING,AUTH_RESOURCES,"BasicAuthenticationHandler.CantSetUser",request.getClass().getName());
      }
    }
  }
  return true;
}
 

Example 19

From project amber, under directory /oauth-2.0/resourceserver-filter/src/main/java/org/apache/amber/oauth2/rsfilter/.

Source file: OAuthFilter.java

  20 
vote

@Override public void doFilter(ServletRequest request,ServletResponse response,FilterChain chain) throws IOException, ServletException {
  HttpServletRequest req=(HttpServletRequest)request;
  HttpServletResponse res=(HttpServletResponse)response;
  try {
    OAuthAccessResourceRequest oauthRequest=new OAuthAccessResourceRequest(req,parameterStyles);
    String accessToken=oauthRequest.getAccessToken();
    final OAuthDecision decision=provider.validateRequest(realm,accessToken,req);
    final Principal principal=decision.getPrincipal();
    request=new HttpServletRequestWrapper((HttpServletRequest)request){
      @Override public String getRemoteUser(){
        return principal != null ? principal.getName() : null;
      }
      @Override public Principal getUserPrincipal(){
        return principal;
      }
    }
;
    request.setAttribute(OAuth.OAUTH_CLIENT_ID,decision.getOAuthClient().getClientId());
    chain.doFilter(request,response);
    return;
  }
 catch (  OAuthSystemException e1) {
    throw new ServletException(e1);
  }
catch (  OAuthProblemException e) {
    respondWithError(res,e);
    return;
  }
}
 

Example 20

From project EasySOA, under directory /easysoa-proxy/easysoa-proxy-core/easysoa-proxy-core-httpdiscoveryproxy-test/src/test/java/org/easysoa/test/mock/nuxeo/.

Source file: EasySoaRestApiMock.java

  20 
vote

@Override public void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  final String reqContent=IOUtils.toString(request.getInputStream());
  request=new HttpServletRequestWrapper(request){
    public ServletInputStream getInputStream(){
      return new ServletInputStream(){
        private ByteArrayInputStream bis=new ByteArrayInputStream(reqContent.getBytes());
        @Override public int read() throws IOException {
          return bis.read();
        }
      }
;
    }
    public BufferedReader getReader(){
      return new BufferedReader(new StringReader(reqContent));
    }
  }
;
  this.recordExchange(request);
  this.handleExchange(request,response);
}
 

Example 21

From project IOCipherServer, under directory /src/Acme/Serve/.

Source file: Serve.java

  20 
vote

public void forward(ServletRequest _request,ServletResponse _response) throws ServletException, java.io.IOException {
  _request.removeAttribute("javax.servlet.forward.request_uri");
  _response.reset();
  servlet.service(new HttpServletRequestWrapper((HttpServletRequest)_request){
    public java.lang.String getPathInfo(){
      return dispatchLen >= dispatchPath.length() ? null : dispatchPath.substring(dispatchLen);
    }
    public String getRequestURI(){
      return dispatchPath;
    }
    public String getQueryString(){
      return dispatchQuery;
    }
    public String getPathTranslated(){
      return getRequest().getRealPath(getPathInfo());
    }
    public String getServletPath(){
      return dispatchLen <= 0 ? "" : dispatchPath.substring(0,dispatchLen);
    }
    public synchronized java.util.Enumeration getAttributeNames(){
      if (super.getAttribute("javax.servlet.forward.request_uri") == null) {
        setAttribute("javax.servlet.forward.request_uri",super.getRequestURI());
        setAttribute("javax.servlet.forward.context_path",this.getContextPath());
        setAttribute("javax.servlet.forward.servlet_path",super.getServletPath());
        setAttribute("javax.servlet.forward.path_info",super.getPathInfo());
        setAttribute("javax.servlet.forward.query_string",super.getQueryString());
      }
      return super.getAttributeNames();
    }
    public Object getAttribute(    String name){
      getAttributeNames();
      return super.getAttribute(name);
    }
  }
,_response);
}
 

Example 22

From project springfaces, under directory /springfaces-mvc/src/main/java/org/springframework/springfaces/mvc/servlet/.

Source file: FacesPostbackHandler.java

  20 
vote

/** 
 * Return the handler that would have processed the request if it were not a postback.
 * @param request The current request
 * @return the original handler
 */
private Object getOriginalHandler(HttpServletRequest request){
  request.setAttribute(DISABLE_ATTRIBUTE,Boolean.TRUE);
  try {
    request=new HttpServletRequestWrapper(request){
      @Override public String getMethod(){
        return METHOD_GET;
      }
    }
;
    HandlerExecutionChain chain=this.dispatcher.getHandler(request);
    return chain.getHandler();
  }
 catch (  Exception e) {
    throw new IllegalStateException(e);
  }
 finally {
    request.removeAttribute(DISABLE_ATTRIBUTE);
  }
}
 

Example 23

From project SpringSecurityDemo, under directory /src/main/java/com/github/peholmst/springsecuritydemo/servlet/.

Source file: SpringApplicationServlet.java

  20 
vote

@Override protected void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  final Locale locale=localeResolver.resolveLocale(request);
  if (logger.isDebugEnabled()) {
    logger.debug("Resolved locale [" + locale + "]");
  }
  LocaleContextHolder.setLocale(locale);
  ServletRequestAttributes requestAttributes=new ServletRequestAttributes(request);
  RequestContextHolder.setRequestAttributes(requestAttributes);
  try {
    super.service(new HttpServletRequestWrapper(request){
      @Override public Locale getLocale(){
        return locale;
      }
    }
,response);
  }
  finally {
    if (!locale.equals(LocaleContextHolder.getLocale())) {
      if (logger.isDebugEnabled()) {
        logger.debug("Locale changed, updating locale resolver");
      }
      localeResolver.setLocale(request,response,LocaleContextHolder.getLocale());
    }
    LocaleContextHolder.resetLocaleContext();
    RequestContextHolder.resetRequestAttributes();
  }
}
 

Example 24

From project subsonic, under directory /subsonic-main/src/main/java/net/sourceforge/subsonic/controller/.

Source file: RESTController.java

  20 
vote

private HttpServletRequest wrapRequest(final HttpServletRequest request,boolean jukebox){
  final String playerId=createPlayerIfNecessary(request,jukebox);
  return new HttpServletRequestWrapper(request){
    @Override public String getParameter(    String name){
      if ("player".equals(name)) {
        return playerId;
      }
      if ("id".equals(name)) {
        return mapId(request.getParameter("id"));
      }
      return super.getParameter(name);
    }
  }
;
}
 

Example 25

From project subsonic_1, under directory /subsonic-main/src/main/java/net/sourceforge/subsonic/controller/.

Source file: RESTController.java

  20 
vote

private HttpServletRequest wrapRequest(final HttpServletRequest request,boolean jukebox){
  final String playerId=createPlayerIfNecessary(request,jukebox);
  return new HttpServletRequestWrapper(request){
    @Override public String getParameter(    String name){
      if ("player".equals(name)) {
        return playerId;
      }
      if ("id".equals(name)) {
        return mapId(request.getParameter("id"));
      }
      return super.getParameter(name);
    }
  }
;
}
 

Example 26

From project subsonic_2, under directory /subsonic-main/src/main/java/net/sourceforge/subsonic/controller/.

Source file: RESTController.java

  20 
vote

private HttpServletRequest wrapRequest(final HttpServletRequest request,boolean jukebox){
  final String playerId=createPlayerIfNecessary(request,jukebox);
  return new HttpServletRequestWrapper(request){
    @Override public String getParameter(    String name){
      if ("path".equals(name)) {
        try {
          return StringUtil.utf8HexDecode(request.getParameter("id"));
        }
 catch (        Exception e) {
          return null;
        }
      }
 else       if ("player".equals(name)) {
        return playerId;
      }
      return super.getParameter(name);
    }
  }
;
}
 

Example 27

From project Supersonic, under directory /subsonic-main/src/main/java/net/sourceforge/subsonic/controller/.

Source file: RESTController.java

  20 
vote

private HttpServletRequest wrapRequest(final HttpServletRequest request,boolean jukebox){
  final String playerId=createPlayerIfNecessary(request,jukebox);
  return new HttpServletRequestWrapper(request){
    @Override public String getParameter(    String name){
      if ("player".equals(name)) {
        return playerId;
      }
      if ("id".equals(name)) {
        return mapId(request.getParameter("id"));
      }
      return super.getParameter(name);
    }
  }
;
}
 

Example 28

From project Blitz, under directory /src/com/laxser/blitz/web/impl/thread/.

Source file: ModuleEngine.java

  19 
vote

/** 
 * Clean up any resources used by the given multipart request (if any).
 * @see MultipartResolver#cleanupMultipart
 */
protected void cleanupMultipart(Invocation inv){
  HttpServletRequest src=inv.getRequest();
  while (src != null && !(src instanceof MultipartHttpServletRequest) && src instanceof HttpServletRequestWrapper) {
    src=(HttpServletRequest)((HttpServletRequestWrapper)src).getRequest();
  }
  if (src instanceof MultipartHttpServletRequest) {
    final MultipartHttpServletRequest request=(MultipartHttpServletRequest)src;
    MultipartCleanup multipartCleaner=inv.getMethod().getAnnotation(MultipartCleanup.class);
    if (multipartCleaner == null || multipartCleaner.after() == MultipartCleanup.After.CONTROLLER_INVOCATION) {
      multipartResolver.cleanupMultipart(request);
    }
 else {
      inv.addAfterCompletion(new AfterCompletion(){
        @Override public void afterCompletion(        Invocation inv,        Throwable ex) throws Exception {
          ModuleEngine.this.multipartResolver.cleanupMultipart(request);
        }
      }
);
    }
  }
}
 

Example 29

From project jspwiki, under directory /src/org/apache/wiki/ui/.

Source file: WikiServletFilter.java

  19 
vote

/** 
 * Determines whether the request has been previously wrapped with a WikiRequestWrapper.  We find the wrapper by recursively unwrapping successive request wrappers, if they have been supplied.
 * @param request the current HTTP request
 * @return <code>true</code> if the request has previously been wrapped;<code>false</code> otherwise
 */
private boolean isWrapped(ServletRequest request){
  while (!(request instanceof WikiRequestWrapper) && request != null && request instanceof HttpServletRequestWrapper) {
    request=((HttpServletRequestWrapper)request).getRequest();
  }
  return request instanceof WikiRequestWrapper ? true : false;
}
 

Example 30

From project sandbox, under directory /xwiki-portlet/src/main/java/org/xwiki/portlet/controller/.

Source file: DispatchedRequest.java

  19 
vote

/** 
 * Parses the query string of the initial request that reached the portal. The request received by the dispatch filter wraps the initial request and hides the initial query string which usually contains only portal related information. In some cases the initial query string contains parameters set through JavaScript. The reason for parsing the initial query string is to expose those parameters set from JavaScript.
 * @return the map of initial query string parameters
 * @throws ServletException if decoding the parameters fails
 */
private Map<String,List<String>> parseInitialQueryString() throws ServletException {
  HttpServletRequest initialRequest=(HttpServletRequest)getRequest();
  while (initialRequest instanceof HttpServletRequestWrapper) {
    initialRequest=(HttpServletRequest)((HttpServletRequestWrapper)initialRequest).getRequest();
  }
  if (initialRequest.getQueryString() != null) {
    try {
      return queryStringParser.parse(initialRequest.getQueryString(),initialRequest.getCharacterEncoding());
    }
 catch (    UnsupportedEncodingException e) {
      throw new ServletException("Failed to decode the initial query string parameters.",e);
    }
  }
 else {
    return Collections.emptyMap();
  }
}
 

Example 31

From project undertow, under directory /servlet/src/main/java/io/undertow/servlet/spec/.

Source file: HttpServletRequestImpl.java

  19 
vote

public static HttpServletRequestImpl getRequestImpl(final ServletRequest request){
  final HttpServletRequestImpl requestImpl;
  if (request instanceof HttpServletRequestImpl) {
    requestImpl=(HttpServletRequestImpl)request;
  }
 else   if (request instanceof HttpServletRequestWrapper) {
    requestImpl=getRequestImpl(((HttpServletRequestWrapper)request).getRequest());
  }
 else {
    throw UndertowServletMessages.MESSAGES.requestWasNotOriginalOrWrapper(request);
  }
  return requestImpl;
}