View Javadoc
1   /* 
2    * Licensed under the Apache License, Version 2.0 (the "License");
3    * you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at
5    *
6    * http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS,
10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   * See the License for the specific language governing permissions and
12   * limitations under the License.
13   *
14   */
15  
16  package org.esigate.servlet.user;
17  
18  import java.io.IOException;
19  
20  import javax.servlet.Filter;
21  import javax.servlet.FilterChain;
22  import javax.servlet.FilterConfig;
23  import javax.servlet.ServletException;
24  import javax.servlet.ServletRequest;
25  import javax.servlet.ServletResponse;
26  import javax.servlet.http.HttpServletRequest;
27  
28  /**
29   * This handles the user name and locale passed as parameters by the driver and overrides getRemoteUser and getLocale
30   * methods from the request in order for the application to retrieve them.
31   * 
32   * @author Francois-Xavier Bonnet
33   */
34  public class ConnectorFilter implements Filter {
35      @Override
36      public void destroy() {
37          // Nothing to do
38      }
39  
40      @Override
41      public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException,
42              ServletException {
43          FilteredRequest filteredRequest = new FilteredRequest((HttpServletRequest) request);
44          filterChain.doFilter(filteredRequest, response);
45      }
46  
47      @Override
48      public void init(FilterConfig arg0) {
49          // Nothing to do
50      }
51  }