01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * 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: * Indicates a secure object invocation failed because the principal could not
24: * be authorized for the request.
25: *
26: * <p>This event might be thrown as a result of either an
27: * {@link org.acegisecurity.AccessDecisionManager AccessDecisionManager} or an
28: * {@link org.acegisecurity.AfterInvocationManager AfterInvocationManager}.
29: *
30: * @author Ben Alex
31: * @version $Id: AuthorizationFailureEvent.java 1784 2007-02-24 21:00:24Z luke_t $
32: */
33: public class AuthorizationFailureEvent extends
34: 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,
55: ConfigAttributeDefinition configAttribs,
56: Authentication authentication,
57: AccessDeniedException accessDeniedException) {
58: super (secureObject);
59:
60: if ((configAttribs == null) || (authentication == null)
61: || (accessDeniedException == null)) {
62: throw new IllegalArgumentException(
63: "All parameters are required and cannot be null");
64: }
65:
66: this .configAttributeDefinition = configAttribs;
67: this .authentication = authentication;
68: this .accessDeniedException = accessDeniedException;
69: }
70:
71: //~ Methods ========================================================================================================
72:
73: public AccessDeniedException getAccessDeniedException() {
74: return accessDeniedException;
75: }
76:
77: public Authentication getAuthentication() {
78: return authentication;
79: }
80:
81: public ConfigAttributeDefinition getConfigAttributeDefinition() {
82: return configAttributeDefinition;
83: }
84: }
|