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: 91   Methods: 5
NCLOC: 47   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
NamedCasProxyDecider.java 83.3% 83.3% 80% 82.6%
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.providers.cas.proxy;
 17   
 18    import java.util.List;
 19   
 20    import org.acegisecurity.AcegiMessageSource;
 21    import org.acegisecurity.providers.cas.CasProxyDecider;
 22    import org.acegisecurity.providers.cas.ProxyUntrustedException;
 23    import org.apache.commons.logging.Log;
 24    import org.apache.commons.logging.LogFactory;
 25    import org.springframework.beans.factory.InitializingBean;
 26    import org.springframework.context.MessageSource;
 27    import org.springframework.context.MessageSourceAware;
 28    import org.springframework.context.support.MessageSourceAccessor;
 29    import org.springframework.util.Assert;
 30   
 31   
 32    /**
 33    * Accepts proxied requests if the closest proxy is named in the
 34    * <code>validProxies</code> list.
 35    *
 36    * <P>
 37    * Also accepts the request if there was no proxy (ie the user directly
 38    * authenticated against this service).
 39    * </p>
 40    */
 41    public class NamedCasProxyDecider implements CasProxyDecider, InitializingBean,
 42    MessageSourceAware {
 43    //~ Static fields/initializers =============================================
 44   
 45    private static final Log logger = LogFactory.getLog(NamedCasProxyDecider.class);
 46   
 47    //~ Instance fields ========================================================
 48   
 49    private List validProxies;
 50    protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor();
 51   
 52    //~ Methods ================================================================
 53   
 54  3 public void afterPropertiesSet() throws Exception {
 55  3 Assert.notNull(this.validProxies, "A validProxies list must be set");
 56  2 Assert.notNull(this.messages, "A message source must be set");
 57    }
 58   
 59  4 public void confirmProxyListTrusted(List proxyList)
 60    throws ProxyUntrustedException {
 61  4 Assert.notNull(proxyList, "proxyList cannot be null");
 62   
 63  3 if (logger.isDebugEnabled()) {
 64  0 logger.debug("Proxy list: " + proxyList.toString());
 65    }
 66   
 67  3 if (proxyList.size() == 0) {
 68    // A Service Ticket (not a Proxy Ticket)
 69  1 return;
 70    }
 71   
 72  2 if (!validProxies.contains(proxyList.get(0))) {
 73  1 throw new ProxyUntrustedException(messages.getMessage(
 74    "NamedCasProxyDecider.untrusted",
 75    new Object[] {proxyList.get(0)},
 76    "Nearest proxy {0} is untrusted"));
 77    }
 78    }
 79   
 80  1 public List getValidProxies() {
 81  1 return validProxies;
 82    }
 83   
 84  0 public void setMessageSource(MessageSource messageSource) {
 85  0 this.messages = new MessageSourceAccessor(messageSource);
 86    }
 87   
 88  3 public void setValidProxies(List validProxies) {
 89  3 this.validProxies = validProxies;
 90    }
 91    }