01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.catalina.valves;
19:
20: import java.io.IOException;
21: import javax.servlet.ServletException;
22: import org.apache.catalina.connector.Request;
23: import org.apache.catalina.connector.Response;
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: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
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: *
64: * @exception IOException if an input/output error occurs
65: * @exception ServletException if a servlet error occurs
66: */
67: public void invoke(Request request, Response response)
68: throws IOException, ServletException {
69:
70: process(request.getRequest().getRemoteAddr(), request, response);
71:
72: }
73:
74: }
|