Coverage Report - org.acegisecurity.acls.domain.ConsoleAuditLogger
 
Classes in this File Line Coverage Branch Coverage Complexity
ConsoleAuditLogger
78% 
100% 
4
 
 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  
 package org.acegisecurity.acls.domain;
 16  
 
 17  
 import org.acegisecurity.acls.AccessControlEntry;
 18  
 import org.acegisecurity.acls.AuditableAccessControlEntry;
 19  
 
 20  
 import org.springframework.util.Assert;
 21  
 
 22  
 
 23  
 /**
 24  
  * A bsaic implementation of {@link AuditLogger}.
 25  
  *
 26  
  * @author Ben Alex
 27  
  * @version $Id: ConsoleAuditLogger.java 1784 2007-02-24 21:00:24Z luke_t $
 28  
  */
 29  1
 public class ConsoleAuditLogger implements AuditLogger {
 30  
     //~ Methods ========================================================================================================
 31  
 
 32  
     public void logIfNeeded(boolean granted, AccessControlEntry ace) {
 33  8
         Assert.notNull(ace, "AccessControlEntry required");
 34  
 
 35  8
         if (ace instanceof AuditableAccessControlEntry) {
 36  8
             AuditableAccessControlEntry auditableAce = (AuditableAccessControlEntry) ace;
 37  
 
 38  8
             if (granted && auditableAce.isAuditSuccess()) {
 39  0
                 System.out.println("GRANTED due to ACE: " + ace);
 40  8
             } else if (!granted && auditableAce.isAuditFailure()) {
 41  0
                 System.out.println("DENIED due to ACE: " + ace);
 42  
             }
 43  
         }
 44  8
     }
 45  
 }