2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.application.RemoteHostFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
RemoteHostFilter
0%
0/5
0%
0/1
2
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      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.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  0
 public class RemoteHostFilter extends AbstractRegExpFilter {
 39  
     
 40  
 
 41  
     // ------------------------------------------------------- Protected Methods
 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  0
         String value = context.getRequest().getRemoteHost();
 54  0
         if (value == null) {
 55  0
             value = context.getRequest().getRemoteAddr();
 56  
         }
 57  0
         return value;
 58  
 
 59  
     }
 60  
 
 61  
 
 62  
 }