Coverage Report - org.acegisecurity.event.authorization.AuthorizationFailureEvent
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthorizationFailureEvent
100% 
100% 
1.5
 
 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.event.authorization;
 17  
 
 18  
 import org.acegisecurity.AccessDeniedException;
 19  
 import org.acegisecurity.Authentication;
 20  
 import org.acegisecurity.ConfigAttributeDefinition;
 21  
 
 22  
 
 23  
 /**
 24  
  * Indicates a secure object invocation failed because the principal could not
 25  
  * be authorized for the request.
 26  
  *
 27  
  * <p>This event might be thrown as a result of either an
 28  
  * {@link org.acegisecurity.AccessDecisionManager AccessDecisionManager} or an
 29  
  * {@link org.acegisecurity.AfterInvocationManager AfterInvocationManager}.
 30  
  *
 31  
  * @author Ben Alex
 32  
  * @version $Id: AuthorizationFailureEvent.java 1784 2007-02-24 21:00:24Z luke_t $
 33  
  */
 34  
 public class AuthorizationFailureEvent extends AbstractAuthorizationEvent {
 35  
     //~ Instance fields ================================================================================================
 36  
 
 37  
     private AccessDeniedException accessDeniedException;
 38  
     private Authentication authentication;
 39  
     private ConfigAttributeDefinition configAttributeDefinition;
 40  
 
 41  
     //~ Constructors ===================================================================================================
 42  
 
 43  
     /**
 44  
      * Construct the event.
 45  
      *
 46  
      * @param secureObject the secure object
 47  
      * @param configAttribs that apply to the secure object
 48  
      * @param authentication that was found in the <code>SecurityContextHolder</code>
 49  
      * @param accessDeniedException that was returned by the
 50  
      *        <code>AccessDecisionManager</code>
 51  
      *
 52  
      * @throws IllegalArgumentException if any null arguments are presented.
 53  
      */
 54  
     public AuthorizationFailureEvent(Object secureObject, ConfigAttributeDefinition configAttribs,
 55  
         Authentication authentication, AccessDeniedException accessDeniedException) {
 56  12
         super(secureObject);
 57  
 
 58  11
         if ((configAttribs == null) || (authentication == null) || (accessDeniedException == null)) {
 59  3
             throw new IllegalArgumentException("All parameters are required and cannot be null");
 60  
         }
 61  
 
 62  8
         this.configAttributeDefinition = configAttribs;
 63  8
         this.authentication = authentication;
 64  8
         this.accessDeniedException = accessDeniedException;
 65  8
     }
 66  
 
 67  
     //~ Methods ========================================================================================================
 68  
 
 69  
     public AccessDeniedException getAccessDeniedException() {
 70  2
         return accessDeniedException;
 71  
     }
 72  
 
 73  
     public Authentication getAuthentication() {
 74  2
         return authentication;
 75  
     }
 76  
 
 77  
     public ConfigAttributeDefinition getConfigAttributeDefinition() {
 78  2
         return configAttributeDefinition;
 79  
     }
 80  
 }