+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.IOException;\r
-import java.io.UnsupportedEncodingException;\r
-import java.security.Principal;\r
-import java.util.Collection;\r
-import java.util.Enumeration;\r
-import java.util.Locale;\r
-import java.util.Map;\r
-\r
-import javax.servlet.AsyncContext;\r
-import javax.servlet.DispatcherType;\r
-import javax.servlet.RequestDispatcher;\r
-import javax.servlet.ServletContext;\r
-import javax.servlet.ServletException;\r
-import javax.servlet.ServletInputStream;\r
-import javax.servlet.ServletRequest;\r
-import javax.servlet.ServletResponse;\r
-import javax.servlet.http.Cookie;\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-import javax.servlet.http.HttpSession;\r
-import javax.servlet.http.Part;\r
-\r
-/**\r
- * ServletRequestWrapper is a pass-through/delegate wrapper class for a servlet\r
- * request. This class is used in conjunction with ServletFilters, such as the\r
- * AccessRestrictionFilter.\r
- * \r
- * The original request is wrapped by instances of this class and this class is\r
- * set as the servlet request in the filter. This allows for specialized\r
- * implementations of request methods, like getUserPrincipal() with delegation\r
- * to the original request for any method not overridden.\r
- * \r
- * This class, by itself, is not altogether interesting. Subclasses of this\r
- * class, however, are of interest.\r
- * \r
- * @author James Moger\r
- * \r
- */\r
-public abstract class ServletRequestWrapper implements HttpServletRequest {\r
-\r
- protected final HttpServletRequest req;\r
-\r
- public ServletRequestWrapper(HttpServletRequest req) {\r
- this.req = req;\r
- }\r
-\r
- @Override\r
- public Object getAttribute(String name) {\r
- return req.getAttribute(name);\r
- }\r
-\r
- @Override\r
- public Enumeration getAttributeNames() {\r
- return req.getAttributeNames();\r
- }\r
-\r
- @Override\r
- public String getCharacterEncoding() {\r
- return req.getCharacterEncoding();\r
- }\r
-\r
- @Override\r
- public void setCharacterEncoding(String env) throws UnsupportedEncodingException {\r
- req.setCharacterEncoding(env);\r
- }\r
-\r
- @Override\r
- public int getContentLength() {\r
- return req.getContentLength();\r
- }\r
-\r
- @Override\r
- public String getContentType() {\r
- return req.getContentType();\r
- }\r
-\r
- @Override\r
- public ServletInputStream getInputStream() throws IOException {\r
- return req.getInputStream();\r
- }\r
-\r
- @Override\r
- public String getParameter(String name) {\r
- return req.getParameter(name);\r
- }\r
-\r
- @Override\r
- public Enumeration getParameterNames() {\r
- return req.getParameterNames();\r
- }\r
-\r
- @Override\r
- public String[] getParameterValues(String name) {\r
- return req.getParameterValues(name);\r
- }\r
-\r
- @Override\r
- public Map getParameterMap() {\r
- return req.getParameterMap();\r
- }\r
-\r
- @Override\r
- public String getProtocol() {\r
- return req.getProtocol();\r
- }\r
-\r
- @Override\r
- public String getScheme() {\r
- return req.getScheme();\r
- }\r
-\r
- @Override\r
- public String getServerName() {\r
- return req.getServerName();\r
- }\r
-\r
- @Override\r
- public int getServerPort() {\r
- return req.getServerPort();\r
- }\r
-\r
- @Override\r
- public BufferedReader getReader() throws IOException {\r
- return req.getReader();\r
- }\r
-\r
- @Override\r
- public String getRemoteAddr() {\r
- return req.getRemoteAddr();\r
- }\r
-\r
- @Override\r
- public String getRemoteHost() {\r
- return req.getRemoteHost();\r
- }\r
-\r
- @Override\r
- public void setAttribute(String name, Object o) {\r
- req.setAttribute(name, o);\r
- }\r
-\r
- @Override\r
- public void removeAttribute(String name) {\r
- req.removeAttribute(name);\r
- }\r
-\r
- @Override\r
- public Locale getLocale() {\r
- return req.getLocale();\r
- }\r
-\r
- @Override\r
- public Enumeration getLocales() {\r
- return req.getLocales();\r
- }\r
-\r
- @Override\r
- public boolean isSecure() {\r
- return req.isSecure();\r
- }\r
-\r
- @Override\r
- public RequestDispatcher getRequestDispatcher(String path) {\r
- return req.getRequestDispatcher(path);\r
- }\r
-\r
- @Override\r
- @Deprecated\r
- public String getRealPath(String path) {\r
- return req.getRealPath(path);\r
- }\r
-\r
- @Override\r
- public int getRemotePort() {\r
- return req.getRemotePort();\r
- }\r
-\r
- @Override\r
- public String getLocalName() {\r
- return req.getLocalName();\r
- }\r
-\r
- @Override\r
- public String getLocalAddr() {\r
- return req.getLocalAddr();\r
- }\r
-\r
- @Override\r
- public int getLocalPort() {\r
- return req.getLocalPort();\r
- }\r
-\r
- @Override\r
- public String getAuthType() {\r
- return req.getAuthType();\r
- }\r
-\r
- @Override\r
- public Cookie[] getCookies() {\r
- return req.getCookies();\r
- }\r
-\r
- @Override\r
- public long getDateHeader(String name) {\r
- return req.getDateHeader(name);\r
- }\r
-\r
- @Override\r
- public String getHeader(String name) {\r
- return req.getHeader(name);\r
- }\r
-\r
- @Override\r
- public Enumeration getHeaders(String name) {\r
- return req.getHeaders(name);\r
- }\r
-\r
- @Override\r
- public Enumeration getHeaderNames() {\r
- return req.getHeaderNames();\r
- }\r
-\r
- @Override\r
- public int getIntHeader(String name) {\r
- return req.getIntHeader(name);\r
- }\r
-\r
- @Override\r
- public String getMethod() {\r
- return req.getMethod();\r
- }\r
-\r
- @Override\r
- public String getPathInfo() {\r
- return req.getPathInfo();\r
- }\r
-\r
- @Override\r
- public String getPathTranslated() {\r
- return req.getPathTranslated();\r
- }\r
-\r
- @Override\r
- public String getContextPath() {\r
- return req.getContextPath();\r
- }\r
-\r
- @Override\r
- public String getQueryString() {\r
- return req.getQueryString();\r
- }\r
-\r
- @Override\r
- public String getRemoteUser() {\r
- return req.getRemoteUser();\r
- }\r
-\r
- @Override\r
- public boolean isUserInRole(String role) {\r
- return req.isUserInRole(role);\r
- }\r
-\r
- @Override\r
- public Principal getUserPrincipal() {\r
- return req.getUserPrincipal();\r
- }\r
-\r
- @Override\r
- public String getRequestedSessionId() {\r
- return req.getRequestedSessionId();\r
- }\r
-\r
- @Override\r
- public String getRequestURI() {\r
- return req.getRequestURI();\r
- }\r
-\r
- @Override\r
- public StringBuffer getRequestURL() {\r
- return req.getRequestURL();\r
- }\r
-\r
- @Override\r
- public String getServletPath() {\r
- return req.getServletPath();\r
- }\r
-\r
- @Override\r
- public HttpSession getSession(boolean create) {\r
- return req.getSession(create);\r
- }\r
-\r
- @Override\r
- public HttpSession getSession() {\r
- return req.getSession();\r
- }\r
-\r
- @Override\r
- public boolean isRequestedSessionIdValid() {\r
- return req.isRequestedSessionIdValid();\r
- }\r
-\r
- @Override\r
- public boolean isRequestedSessionIdFromCookie() {\r
- return req.isRequestedSessionIdFromCookie();\r
- }\r
-\r
- @Override\r
- public boolean isRequestedSessionIdFromURL() {\r
- return req.isRequestedSessionIdFromURL();\r
- }\r
-\r
- @Override\r
- @Deprecated\r
- public boolean isRequestedSessionIdFromUrl() {\r
- return req.isRequestedSessionIdFromUrl();\r
- }\r
- \r
- /*\r
- * Servlet 3.0 Methods \r
- */\r
- \r
- @Override\r
- public boolean authenticate(HttpServletResponse response) throws IOException, ServletException {\r
- return false;\r
- }\r
- \r
- @Override\r
- public void login(String username, String password) throws ServletException {\r
- }\r
-\r
- @Override\r
- public void logout() throws ServletException {\r
- }\r
-\r
- \r
- @Override\r
- public Part getPart(String arg0) throws IOException, ServletException {\r
- return req.getPart(arg0);\r
- }\r
-\r
- @Override\r
- public Collection<Part> getParts() throws IOException, ServletException {\r
- return req.getParts();\r
- }\r
-\r
- @Override\r
- public AsyncContext getAsyncContext() {\r
- return req.getAsyncContext();\r
- }\r
-\r
- @Override\r
- public DispatcherType getDispatcherType() {\r
- return req.getDispatcherType();\r
- }\r
-\r
- @Override\r
- public ServletContext getServletContext() {\r
- return req.getServletContext();\r
- }\r
-\r
- @Override\r
- public boolean isAsyncStarted() {\r
- return req.isAsyncStarted();\r
- }\r
-\r
- @Override\r
- public boolean isAsyncSupported() {\r
- return req.isAsyncStarted();\r
- }\r
-\r
- @Override\r
- public AsyncContext startAsync() throws IllegalStateException {\r
- return req.startAsync();\r
- }\r
-\r
- @Override\r
- public AsyncContext startAsync(ServletRequest arg0, ServletResponse arg1)\r
- throws IllegalStateException {\r
- return req.startAsync(arg0, arg1);\r
- }\r
-}
\ No newline at end of file