01: /*
02: * Copyright 1999-2001,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.catalina.valves;
18:
19: import java.io.IOException;
20: import javax.servlet.ServletException;
21: import org.apache.catalina.Request;
22: import org.apache.catalina.Response;
23: import org.apache.catalina.ValveContext;
24:
25: /**
26: * Concrete implementation of <code>RequestFilterValve</code> that filters
27: * based on the string representation of the remote client's IP address.
28: *
29: * @author Craig R. McClanahan
30: * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:52 $
31: */
32:
33: public final class RemoteAddrValve extends RequestFilterValve {
34:
35: // ----------------------------------------------------- Instance Variables
36:
37: /**
38: * The descriptive information related to this implementation.
39: */
40: private static final String info = "org.apache.catalina.valves.RemoteAddrValve/1.0";
41:
42: // ------------------------------------------------------------- Properties
43:
44: /**
45: * Return descriptive information about this Valve implementation.
46: */
47: public String getInfo() {
48:
49: return (info);
50:
51: }
52:
53: // --------------------------------------------------------- Public Methods
54:
55: /**
56: * Extract the desired request property, and pass it (along with the
57: * specified request and response objects) to the protected
58: * <code>process()</code> method to perform the actual filtering.
59: * This method must be implemented by a concrete subclass.
60: *
61: * @param request The servlet request to be processed
62: * @param response The servlet response to be created
63: * @param context The valve context used to invoke the next valve
64: * in the current processing pipeline
65: *
66: * @exception IOException if an input/output error occurs
67: * @exception ServletException if a servlet error occurs
68: */
69: public void invoke(Request request, Response response,
70: ValveContext context) throws IOException, ServletException {
71:
72: process(request.getRequest().getRemoteAddr(), request,
73: response, context);
74:
75: }
76:
77: }
|