1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.shiro.web.filter.mgt;
20
21 import javax.servlet.FilterChain;
22 import javax.servlet.ServletRequest;
23 import javax.servlet.ServletResponse;
24
25 /**
26 * A {@code FilterChainResolver} can resolve an appropriate {@link FilterChain} to execute during a
27 * {@code ServletRequest}. It allows resolution of arbitrary filter chains which can be executed for any given
28 * request or URI/URL.
29 * <p/>
30 * This mechanism allows for a much more flexible FilterChain resolution than normal {@code web.xml} servlet filter
31 * definitions: it allows arbitrary filter chains to be defined per URL in a much more concise and easy to read manner,
32 * and even allows filter chains to be dynamically resolved or constructed at runtime if the underlying implementation
33 * supports it.
34 *
35 * @since 1.0
36 */
37 public interface FilterChainResolver {
38
39 /**
40 * Returns the filter chain that should be executed for the given request, or {@code null} if the
41 * original chain should be used.
42 * <p/>
43 * This method allows a implementation to define arbitrary security {@link javax.servlet.Filter Filter}
44 * chains for any given request or URL pattern.
45 *
46 * @param request the incoming ServletRequest
47 * @param response the outgoing ServletResponse
48 * @param originalChain the original {@code FilterChain} intercepted by the ShiroFilter implementation.
49 * @return the filter chain that should be executed for the given request, or {@code null} if the
50 * original chain should be used.
51 */
52 FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain originalChain);
53
54 }