Clover coverage report - Acegi Security System for Spring - 1.0.0-RC1
Coverage timestamp: Mon Dec 5 2005 09:05:15 EST
file stats: LOC: 135   Methods: 10
NCLOC: 67   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FilterInvocation.java 91.7% 91.7% 100% 93.5%
coverage coverage
 1    /* Copyright 2004, 2005 Acegi Technology Pty Limited
 2    *
 3    * Licensed under the Apache License, Version 2.0 (the "License");
 4    * you may not use this file except in compliance with the License.
 5    * You may obtain a copy of the License at
 6    *
 7    * http://www.apache.org/licenses/LICENSE-2.0
 8    *
 9    * Unless required by applicable law or agreed to in writing, software
 10    * distributed under the License is distributed on an "AS IS" BASIS,
 11    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    * See the License for the specific language governing permissions and
 13    * limitations under the License.
 14    */
 15   
 16    package org.acegisecurity.intercept.web;
 17   
 18    import javax.servlet.FilterChain;
 19    import javax.servlet.ServletRequest;
 20    import javax.servlet.ServletResponse;
 21    import javax.servlet.http.HttpServletRequest;
 22    import javax.servlet.http.HttpServletResponse;
 23   
 24   
 25    /**
 26    * Holds objects associated with a HTTP filter.
 27    *
 28    * <P>
 29    * Guarantees the request and response are instances of
 30    * <code>HttpServletRequest</code> and <code>HttpServletResponse</code>, and
 31    * that there are no <code>null</code> objects.
 32    * </p>
 33    *
 34    * <P>
 35    * Required so that security system classes can obtain access to the filter
 36    * environment, as well as the request and response.
 37    * </p>
 38    *
 39    * @author Ben Alex
 40    * @author colin sampaleanu
 41    * @version $Id: FilterInvocation.java,v 1.6 2005/11/17 00:55:50 benalex Exp $
 42    */
 43    public class FilterInvocation {
 44    //~ Instance fields ========================================================
 45   
 46    private FilterChain chain;
 47    private ServletRequest request;
 48    private ServletResponse response;
 49   
 50    //~ Constructors ===========================================================
 51   
 52  51 public FilterInvocation(ServletRequest request, ServletResponse response,
 53    FilterChain chain) {
 54  51 if ((request == null) || (response == null) || (chain == null)) {
 55  3 throw new IllegalArgumentException(
 56    "Cannot pass null values to constructor");
 57    }
 58   
 59  48 if (!(request instanceof HttpServletRequest)) {
 60  1 throw new IllegalArgumentException(
 61    "Can only process HttpServletRequest");
 62    }
 63   
 64  47 if (!(response instanceof HttpServletResponse)) {
 65  1 throw new IllegalArgumentException(
 66    "Can only process HttpServletResponse");
 67    }
 68   
 69  46 this.request = request;
 70  46 this.response = response;
 71  46 this.chain = chain;
 72    }
 73   
 74  1 protected FilterInvocation() {
 75  1 throw new IllegalArgumentException("Cannot use default constructor");
 76    }
 77   
 78    //~ Methods ================================================================
 79   
 80  5 public FilterChain getChain() {
 81  5 return chain;
 82    }
 83   
 84    /**
 85    * Indicates the URL that the user agent used for this request.
 86    *
 87    * <P>
 88    * The returned URL does <b>not</b> reflect the port number determined from
 89    * a {@link org.acegisecurity.util.PortResolver}.
 90    * </p>
 91    *
 92    * @return the full URL of this request
 93    */
 94  3 public String getFullRequestUrl() {
 95  3 return getHttpRequest().getScheme() + "://"
 96    + getHttpRequest().getServerName() + ":"
 97    + getHttpRequest().getServerPort() + getHttpRequest().getContextPath()
 98    + getRequestUrl();
 99    }
 100   
 101  109 public HttpServletRequest getHttpRequest() {
 102  109 return (HttpServletRequest) request;
 103    }
 104   
 105  3 public HttpServletResponse getHttpResponse() {
 106  3 return (HttpServletResponse) response;
 107    }
 108   
 109  21 public ServletRequest getRequest() {
 110  21 return request;
 111    }
 112   
 113  29 public String getRequestUrl() {
 114  29 String pathInfo = getHttpRequest().getPathInfo();
 115  29 String queryString = getHttpRequest().getQueryString();
 116   
 117  29 String uri = getHttpRequest().getServletPath();
 118   
 119  29 if (uri == null) {
 120  0 uri = getHttpRequest().getRequestURI();
 121  0 uri = uri.substring(getHttpRequest().getContextPath().length());
 122    }
 123   
 124  29 return uri + ((pathInfo == null) ? "" : pathInfo)
 125  29 + ((queryString == null) ? "" : ("?" + queryString));
 126    }
 127   
 128  24 public ServletResponse getResponse() {
 129  24 return response;
 130    }
 131   
 132  3 public String toString() {
 133  3 return "FilterInvocation: URL: " + getRequestUrl();
 134    }
 135    }