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: 1
NCLOC: 48   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LoggerListener.java 75% 87.5% 100% 81.8%
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.event.authorization;
 17   
 18    import org.apache.commons.logging.Log;
 19    import org.apache.commons.logging.LogFactory;
 20   
 21    import org.springframework.context.ApplicationEvent;
 22    import org.springframework.context.ApplicationListener;
 23   
 24   
 25    /**
 26    * Outputs interceptor-related application events to Commons Logging.
 27    *
 28    * <P>
 29    * All failures are logged at the warning level, with success events logged at
 30    * the information level, and public invocation events logged at the debug
 31    * level.
 32    * </p>
 33    *
 34    * @author Ben Alex
 35    * @version $Id: LoggerListener.java,v 1.2 2005/11/17 00:56:09 benalex Exp $
 36    */
 37    public class LoggerListener implements ApplicationListener {
 38    //~ Static fields/initializers =============================================
 39   
 40    private static final Log logger = LogFactory.getLog(LoggerListener.class);
 41   
 42    //~ Methods ================================================================
 43   
 44  43 public void onApplicationEvent(ApplicationEvent event) {
 45  43 if (event instanceof AuthenticationCredentialsNotFoundEvent) {
 46  1 AuthenticationCredentialsNotFoundEvent authEvent = (AuthenticationCredentialsNotFoundEvent) event;
 47   
 48  1 if (logger.isWarnEnabled()) {
 49  1 logger.warn("Security interception failed due to: "
 50    + authEvent.getCredentialsNotFoundException()
 51    + "; secure object: " + authEvent.getSource()
 52    + "; configuration attributes: "
 53    + authEvent.getConfigAttributeDefinition());
 54    }
 55    }
 56   
 57  43 if (event instanceof AuthorizationFailureEvent) {
 58  2 AuthorizationFailureEvent authEvent = (AuthorizationFailureEvent) event;
 59   
 60  2 if (logger.isWarnEnabled()) {
 61  2 logger.warn("Security authorization failed due to: "
 62    + authEvent.getAccessDeniedException()
 63    + "; authenticated principal: "
 64    + authEvent.getAuthentication() + "; secure object: "
 65    + authEvent.getSource() + "; configuration attributes: "
 66    + authEvent.getConfigAttributeDefinition());
 67    }
 68    }
 69   
 70  43 if (event instanceof AuthorizedEvent) {
 71  7 AuthorizedEvent authEvent = (AuthorizedEvent) event;
 72   
 73  7 if (logger.isInfoEnabled()) {
 74  0 logger.info("Security authorized for authenticated principal: "
 75    + authEvent.getAuthentication() + "; secure object: "
 76    + authEvent.getSource() + "; configuration attributes: "
 77    + authEvent.getConfigAttributeDefinition());
 78    }
 79    }
 80   
 81  43 if (event instanceof PublicInvocationEvent) {
 82  2 PublicInvocationEvent authEvent = (PublicInvocationEvent) event;
 83   
 84  2 if (logger.isInfoEnabled()) {
 85  0 logger.info(
 86    "Security interception not required for public secure object: "
 87    + authEvent.getSource());
 88    }
 89    }
 90    }
 91    }