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: 100   Methods: 7
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
WebAuthenticationDetails.java 50% 60% 71.4% 62.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    package org.acegisecurity.ui;
 16   
 17    import java.io.Serializable;
 18   
 19    import javax.servlet.http.HttpServletRequest;
 20    import javax.servlet.http.HttpSession;
 21   
 22   
 23    /**
 24    * A holder of selected HTTP details related to a web authentication request.
 25    *
 26    * @author Ben Alex
 27    * @version $Id: WebAuthenticationDetails.java,v 1.4 2005/11/17 00:56:10 benalex Exp $
 28    */
 29    public class WebAuthenticationDetails implements Serializable {
 30    private String remoteAddress;
 31    private String sessionId;
 32   
 33    /**
 34    * Constructor.
 35    *
 36    * <p>
 37    * NB: This constructor will cause a <code>HttpSession</code> to be created
 38    * (this is considered reasonable as all Acegi Security authentication
 39    * requests rely on <code>HttpSession</code> to store the
 40    * <code>Authentication</code> between requests
 41    * </p>
 42    *
 43    * @param request that the authentication request was received from
 44    */
 45  21 public WebAuthenticationDetails(HttpServletRequest request) {
 46  21 this.remoteAddress = request.getRemoteAddr();
 47  21 this.sessionId = request.getSession(true).getId();
 48  21 doPopulateAdditionalInformation(request);
 49    }
 50   
 51  5 public WebAuthenticationDetails(HttpServletRequest request,
 52    boolean forceSessionCreation) {
 53  5 this.remoteAddress = request.getRemoteAddr();
 54  5 HttpSession session = request.getSession(forceSessionCreation);
 55  5 this.sessionId = session != null ? session.getId() : null;
 56   
 57  5 doPopulateAdditionalInformation(request);
 58    }
 59   
 60  0 protected WebAuthenticationDetails() {
 61  0 throw new IllegalArgumentException("Cannot use default constructor");
 62    }
 63   
 64    /**
 65    * Indicates the TCP/IP address the authentication request was received
 66    * from.
 67    *
 68    * @return the address
 69    */
 70  3 public String getRemoteAddress() {
 71  3 return remoteAddress;
 72    }
 73   
 74    /**
 75    * Indicates the <code>HttpSession</code> id the authentication request was
 76    * received from.
 77    *
 78    * @return the session ID
 79    */
 80  9 public String getSessionId() {
 81  9 return sessionId;
 82    }
 83   
 84  0 public String toString() {
 85  0 StringBuffer sb = new StringBuffer();
 86  0 sb.append(super.toString() + ": ");
 87  0 sb.append("RemoteIpAddress: " + this.getRemoteAddress() + "; ");
 88  0 sb.append("SessionId: " + this.getSessionId());
 89   
 90  0 return sb.toString();
 91    }
 92   
 93    /**
 94    * Provided so that subclasses can populate additional information.
 95    *
 96    * @param request that the authentication request was received from
 97    */
 98  26 protected void doPopulateAdditionalInformation(HttpServletRequest request) {
 99    }
 100    }