Coverage Report - org.acegisecurity.providers.cas.proxy.RejectProxyTickets
 
Classes in this File Line Coverage Branch Coverage Complexity
RejectProxyTickets
62% 
100% 
2.333
 
 1  
 /* Copyright 2004, 2005, 2006 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 org.acegisecurity.AcegiMessageSource;
 19  
 
 20  
 import org.acegisecurity.providers.cas.CasProxyDecider;
 21  
 import org.acegisecurity.providers.cas.ProxyUntrustedException;
 22  
 
 23  
 import org.apache.commons.logging.Log;
 24  
 import org.apache.commons.logging.LogFactory;
 25  
 
 26  
 import org.springframework.beans.factory.InitializingBean;
 27  
 
 28  
 import org.springframework.context.MessageSource;
 29  
 import org.springframework.context.MessageSourceAware;
 30  
 import org.springframework.context.support.MessageSourceAccessor;
 31  
 
 32  
 import org.springframework.util.Assert;
 33  
 
 34  
 import java.util.List;
 35  
 
 36  
 
 37  
 /**
 38  
  * Accepts no proxied requests.<P>This class should be used if only service tickets wish to be accepted (ie no
 39  
  * proxy tickets at all).</p>
 40  
  */
 41  3
 public class RejectProxyTickets implements CasProxyDecider, MessageSourceAware, InitializingBean {
 42  
     //~ Static fields/initializers =====================================================================================
 43  
 
 44  2
     private static final Log logger = LogFactory.getLog(RejectProxyTickets.class);
 45  
 
 46  
     //~ Instance fields ================================================================================================
 47  
 
 48  3
     protected MessageSourceAccessor messages = AcegiMessageSource.getAccessor();
 49  
 
 50  
     //~ Methods ========================================================================================================
 51  
 
 52  
     public void afterPropertiesSet() throws Exception {
 53  0
         Assert.notNull(this.messages, "A message source must be set");
 54  0
     }
 55  
 
 56  
     public void confirmProxyListTrusted(List proxyList)
 57  
         throws ProxyUntrustedException {
 58  3
         Assert.notNull(proxyList, "proxyList cannot be null");
 59  
 
 60  2
         if (proxyList.size() == 0) {
 61  
             // A Service Ticket (not a Proxy Ticket)
 62  1
             return;
 63  
         }
 64  
 
 65  1
         if (logger.isDebugEnabled()) {
 66  0
             logger.debug("Proxies are unacceptable; proxy list provided: " + proxyList.toString());
 67  
         }
 68  
 
 69  1
         throw new ProxyUntrustedException(
 70  
                 messages.getMessage("RejectProxyTickets.reject", "Proxy tickets are rejected"));
 71  
     }
 72  
 
 73  
     public void setMessageSource(MessageSource messageSource) {
 74  0
         this.messages = new MessageSourceAccessor(messageSource);
 75  0
     }
 76  
 }