2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.application;
19
20 import org.apache.shale.application.faces.ShaleWebContext;
21
22 /***
23 * <p>Command that filters incoming requests based on matching the remote
24 * host name (or the remote address, if no remote host name is available)
25 * against regular expression patterns that are configured on
26 * this instance. See {@link AbstractRegExpFilter} for details of the
27 * matching algorithm.</p>
28 *
29 * <p><strong>USAGE NOTE:</strong> - This command will only be effective if
30 * used before the regular filter chain is processed. In other words, you
31 * should invoke it as part of a <code>preprocess</code> chain in the
32 * <code>shale</code> catalog.</p>
33 *
34 * $Id: RemoteHostFilter.java 464373 2006-10-16 04:21:54Z rahul $
35 *
36 * @see AbstractRegExpFilter
37 */
38 public class RemoteHostFilter extends AbstractRegExpFilter {
39
40
41
42
43
44 /***
45 * <p>Return the value to be tested against exclude and include patterns.
46 * This will be the value of the <code>remoteHost</code> property (if any);
47 * otherwise the value of the <code>remoteAddr</code> property.</p>
48 *
49 * @param context <code>Context</code> for the current request
50 */
51 protected String value(ShaleWebContext context) {
52
53 String value = context.getRequest().getRemoteHost();
54 if (value == null) {
55 value = context.getRequest().getRemoteAddr();
56 }
57 return value;
58
59 }
60
61
62 }