Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    * 
    *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  package org.apache.catalina.connector;
  
  import static org.jboss.web.CatalinaMessages.MESSAGES;
  
  import java.util.Locale;
  import java.util.Map;
  
  
Facade class that wraps a Coyote request object. All methods are delegated to the wrapped request.

Author(s):
Craig R. McClanahan
Remy Maucherat
Jean-Francois Arcand
Version:
$Revision: 1781 $ $Date: 2011-07-13 18:31:38 +0200 (Wed, 13 Jul 2011) $
  
  
  @SuppressWarnings("deprecation")
  public class RequestFacade implements HttpServletRequest {
          
          
      // ----------------------------------------------------------- DoPrivileged
      
      private final class GetAttributePrivilegedAction
              implements PrivilegedAction {
          
          public Object run() {
              return .getAttributeNames();
          }            
      }
       
      
      private final class GetParameterMapPrivilegedAction
              implements PrivilegedAction {
          
          public Object run() {
              return .getParameterMap();
          }        
      }    
      
      
      private final class GetRequestDispatcherPrivilegedAction
              implements PrivilegedAction {
  
          private String path;
  
          public GetRequestDispatcherPrivilegedAction(String path){
              this. = path;
          }
          
          public Object run() {   
              return .getRequestDispatcher();
          }           
      }    
      
      
     private final class GetParameterPrivilegedAction
             implements PrivilegedAction {
 
         public String name;
 
         public GetParameterPrivilegedAction(String name){
             this. = name;
         }
 
         public Object run() {       
             return .getParameter();
         }           
     }    
     
      
     private final class GetParameterNamesPrivilegedAction
             implements PrivilegedAction {
         
         public Object run() {          
             return .getParameterNames();
         }           
     } 
     
     
     private final class GetParameterValuePrivilegedAction
             implements PrivilegedAction {
 
         public String name;
 
         public GetParameterValuePrivilegedAction(String name){
             this. = name;
         }
 
         public Object run() {       
             return .getParameterValues();
         }           
     }    
   
     
     private final class GetCookiesPrivilegedAction
             implements PrivilegedAction {
         
         public Object run() {       
             return .getCookies();
         }           
     }      
     
     
     private final class GetCharacterEncodingPrivilegedAction
             implements PrivilegedAction {
         
         public Object run() {       
             return .getCharacterEncoding();
         }           
     }   
         
     
     private final class GetHeadersPrivilegedAction
             implements PrivilegedAction {
 
         private String name;
 
         public GetHeadersPrivilegedAction(String name){
             this. = name;
         }
         
         public Object run() {       
             return .getHeaders();
         }           
     }    
         
     
     private final class GetHeaderNamesPrivilegedAction
             implements PrivilegedAction {
 
         public Object run() {       
             return .getHeaderNames();
         }           
     }  
             
     
     private final class GetLocalePrivilegedAction
             implements PrivilegedAction {
 
         public Object run() {       
             return .getLocale();
         }           
     }    
             
     
     private final class GetLocalesPrivilegedAction
             implements PrivilegedAction {
 
         public Object run() {       
             return .getLocales();
         }           
     }    
     
     private final class GetSessionPrivilegedAction
             implements PrivilegedAction {
 
         private boolean create;
         
         public GetSessionPrivilegedAction(boolean create){
             this. = create;
         }
                 
         public Object run() {  
             return .getSession();
         }           
     }
 
     // ----------------------------------------------------------- Constructors
 

    
Construct a wrapper for the specified request.

Parameters:
request The request to be wrapped
 
     public RequestFacade(Request request) {
 
         this. = request;
 
     }
 
 
     // ----------------------------------------------------- Instance Variables
 

    
The wrapped request.
 
     protected Request request = null;
 
 
     // --------------------------------------------------------- Public Methods
 

    
Clear facade.
 
     public void clear() {
          = null;
     }

    
    
Prevent cloning the facade.
 
     protected Object clone()
         throws CloneNotSupportedException {
         throw new CloneNotSupportedException();
     }
 
 
     // ------------------------------------------------- ServletRequest Methods
 
 
     public Object getAttribute(String name) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getAttribute(name);
     }
 
 
     public Enumeration getAttributeNames() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (Enumeration)AccessController.doPrivileged(
                 new GetAttributePrivilegedAction());        
         } else {
             return .getAttributeNames();
         }
     }
 
 
     public String getCharacterEncoding() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (String)AccessController.doPrivileged(
                 new GetCharacterEncodingPrivilegedAction());
         } else {
             return .getCharacterEncoding();
         }         
     }
 
 
     public void setCharacterEncoding(String env)
             throws java.io.UnsupportedEncodingException {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         .setCharacterEncoding(env);
     }
 
 
     public int getContentLength() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getContentLength();
     }
 
 
     public String getContentType() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getContentType();
     }
 
 
     public ServletInputStream getInputStream() throws IOException {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getInputStream();
     }
 
 
     public String getParameter(String name) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (String)AccessController.doPrivileged(
                 new GetParameterPrivilegedAction(name));
         } else {
             return .getParameter(name);
         }
     }
 
 
     public Enumeration getParameterNames() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (Enumeration)AccessController.doPrivileged(
                 new GetParameterNamesPrivilegedAction());
         } else {
             return .getParameterNames();
         }
     }
 
 
     public String[] getParameterValues(String name) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         String[] ret = null;
 
         /*
          * Clone the returned array only if there is a security manager
          * in place, so that performance won't suffer in the nonsecure case
          */
         if (SecurityUtil.isPackageProtectionEnabled()){
             ret = (String[]) AccessController.doPrivileged(
                 new GetParameterValuePrivilegedAction(name));
             if (ret != null) {
                 ret = (String[]) ret.clone();
             }
         } else {
             ret = .getParameterValues(name);
         }
 
         return ret;
     }
 
 
     public Map getParameterMap() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (Map)AccessController.doPrivileged(
                 new GetParameterMapPrivilegedAction());        
         } else {
             return .getParameterMap();
         }
     }
 
 
     public String getProtocol() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getProtocol();
     }
 
 
     public String getScheme() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getScheme();
     }
 
 
     public String getServerName() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getServerName();
     }
 
 
     public int getServerPort() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getServerPort();
     }
 
 
     public BufferedReader getReader() throws IOException {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getReader();
     }
 
 
     public String getRemoteAddr() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getRemoteAddr();
     }
 
 
     public String getRemoteHost() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getRemoteHost();
     }
 
 
     public void setAttribute(String nameObject o) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         .setAttribute(nameo);
     }
 
 
     public void removeAttribute(String name) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         .removeAttribute(name);
     }
 
 
     public Locale getLocale() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (Locale)AccessController.doPrivileged(
                 new GetLocalePrivilegedAction());
         } else {
             return .getLocale();
         }        
     }
 
 
     public Enumeration getLocales() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (Enumeration)AccessController.doPrivileged(
                 new GetLocalesPrivilegedAction());
         } else {
             return .getLocales();
         }        
     }
 
 
     public boolean isSecure() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .isSecure();
     }
 
 
     public RequestDispatcher getRequestDispatcher(String path) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (RequestDispatcher)AccessController.doPrivileged(
                 new GetRequestDispatcherPrivilegedAction(path));
         } else {
             return .getRequestDispatcher(path);
         }
     }
 
     public String getRealPath(String path) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getRealPath(path);
     }
 
 
     public String getAuthType() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getAuthType();
     }
 
 
     public Cookie[] getCookies() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         Cookie[] ret = null;
 
         /*
          * Clone the returned array only if there is a security manager
          * in place, so that performance won't suffer in the nonsecure case
          */
         if (SecurityUtil.isPackageProtectionEnabled()){
             ret = (Cookie[])AccessController.doPrivileged(
                 new GetCookiesPrivilegedAction());
             if (ret != null) {
                 ret = (Cookie[]) ret.clone();
             }
         } else {
             ret = .getCookies();
         }
 
         return ret;
     }
 
 
     public long getDateHeader(String name) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getDateHeader(name);
     }
 
 
     public String getHeader(String name) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getHeader(name);
     }
 
 
     public Enumeration getHeaders(String name) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (Enumeration)AccessController.doPrivileged(
                 new GetHeadersPrivilegedAction(name));
         } else {
             return .getHeaders(name);
         }         
     }
 
 
     public Enumeration getHeaderNames() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (.){
             return (Enumeration)AccessController.doPrivileged(
                 new GetHeaderNamesPrivilegedAction());
         } else {
             return .getHeaderNames();
         }             
     }
 
 
     public int getIntHeader(String name) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getIntHeader(name);
     }
 
 
     public String getMethod() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getMethod();
     }
 
 
     public String getPathInfo() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getPathInfo();
     }
 
 
     public String getPathTranslated() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getPathTranslated();
     }
 
 
     public String getContextPath() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getContextPath();
     }
 
 
     public String getQueryString() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getQueryString();
     }
 
 
     public String getRemoteUser() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getRemoteUser();
     }
 
 
     public boolean isUserInRole(String role) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .isUserInRole(role);
     }
 
 
     public java.security.Principal getUserPrincipal() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getUserPrincipal();
     }
 
 
     public String getRequestedSessionId() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getRequestedSessionId();
     }
 
 
     public String getRequestURI() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getRequestURI();
     }
 
 
     public StringBuffer getRequestURL() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getRequestURL();
     }
 
 
     public String getServletPath() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getServletPath();
     }
 
 
     public HttpSession getSession(boolean create) {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         if (SecurityUtil.isPackageProtectionEnabled()){
             return (HttpSession)AccessController.
                 doPrivileged(new GetSessionPrivilegedAction(create));
         } else {
             return .getSession(create);
         }
     }
 
     public HttpSession getSession() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return getSession(true);
     }
 
 
     public boolean isRequestedSessionIdValid() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .isRequestedSessionIdValid();
     }
 
 
     public boolean isRequestedSessionIdFromCookie() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .isRequestedSessionIdFromCookie();
     }
 
 
     public boolean isRequestedSessionIdFromURL() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .isRequestedSessionIdFromURL();
     }
 
 
     public boolean isRequestedSessionIdFromUrl() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .isRequestedSessionIdFromURL();
     }
 
 
     public String getLocalAddr() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getLocalAddr();
     }
 
 
     public String getLocalName() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getLocalName();
     }
 
 
     public int getLocalPort() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getLocalPort();
     }
 
 
     public int getRemotePort() {
 
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getRemotePort();
     }
 
 
     public AsyncContext getAsyncContext() {
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getAsyncContext();
     }
 
 
     public ServletContext getServletContext() {
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getServletContext();
     }
 
 
     public boolean isAsyncStarted() {
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .isAsyncStarted();
     }
 
 
     public boolean isAsyncSupported() {
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .isAsyncSupported();
     }
 
 
     public AsyncContext startAsync() throws IllegalStateException {
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .startAsync();
     }
 
 
     public AsyncContext startAsync(ServletRequest servletRequest,
             ServletResponse servletResponsethrows IllegalStateException {
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .startAsync(servletRequestservletResponse);
     }
 
 
     public DispatcherType getDispatcherType() {
         if ( == null) {
             throw .nullRequestFacade();
         }
 
         return .getDispatcherType();
     }


    
Get filter chain associated with the request.
 
         if ( == null) {
             throw .nullRequestFacade();
         }
         return .getFilterChain();
     }


    
Set filter chain associated with the request.

Parameters:
filterChain new filter chain
 
     public void setFilterChain(ApplicationFilterChain filterChain) {
         if ( == null) {
             throw .nullRequestFacade();
         }
         .setFilterChain(filterChain);
     }


    
Next filter chain.
 
     public void nextFilterChain() {
         if ( == null) {
             throw .nullRequestFacade();
         }
         .nextFilterChain();
     }


    
Release the current filter chain.
 
     public void releaseFilterChain() {
         if ( == null) {
             throw .nullRequestFacade();
         }
         .releaseFilterChain();
     }
 
 
     public boolean authenticate(HttpServletResponse responsethrows IOException,
             ServletException {
         if ( == null) {
             throw .nullRequestFacade();
         }
        return .authenticate(response);
    }
    public void login(String usernameString passwordthrows ServletException {
        if ( == null) {
            throw .nullRequestFacade();
        }
        .login(usernamepassword);
    }
    public void logout() throws ServletException {
        if ( == null) {
            throw .nullRequestFacade();
        }
        .logout();
    }
    public Part getPart(String namethrows IOExceptionServletException {
        if ( == null) {
            throw .nullRequestFacade();
        }
        return .getPart(name);
    }
    public Collection<PartgetParts() throws IOExceptionServletException {
        if ( == null) {
            throw .nullRequestFacade();
        }
        return .getParts();
    }
    public boolean hasSendfile() {
        if ( == null) {
            throw .nullRequestFacade();
        }
        return .hasSendfile();
    }
    public long getContentLengthLong() {
        if ( == null) {
            throw .nullRequestFacade();
        }
        return .getContentLengthLong();
    }
    public <T extends HttpUpgradeHandler> T upgrade(Class<T> upgradeHandler)
            throws IOException {
        if ( == null) {
            throw .nullRequestFacade();
        }
        return .upgrade(upgradeHandler);
    }