Source code: org/acegisecurity/event/authorization/AuthorizationFailureEvent.java
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.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 * @author Ben Alex
28 * @version $Id: AuthorizationFailureEvent.java,v 1.3 2005/11/17 00:56:09 benalex Exp $
29 */
30 public class AuthorizationFailureEvent extends AbstractAuthorizationEvent {
31 //~ Instance fields ========================================================
32
33 private AccessDeniedException accessDeniedException;
34 private Authentication authentication;
35 private ConfigAttributeDefinition configAttributeDefinition;
36
37 //~ Constructors ===========================================================
38
39 /**
40 * Construct the event.
41 *
42 * @param secureObject the secure object
43 * @param configAttribs that apply to the secure object
44 * @param authentication that was found in the <code>SecurityContextHolder</code>
45 * @param accessDeniedException that was returned by the
46 * <code>AccessDecisionManager</code>
47 *
48 * @throws IllegalArgumentException if any null arguments are presented.
49 */
50 public AuthorizationFailureEvent(Object secureObject,
51 ConfigAttributeDefinition configAttribs, Authentication authentication,
52 AccessDeniedException accessDeniedException) {
53 super(secureObject);
54
55 if ((configAttribs == null) || (authentication == null)
56 || (accessDeniedException == null)) {
57 throw new IllegalArgumentException(
58 "All parameters are required and cannot be null");
59 }
60
61 this.configAttributeDefinition = configAttribs;
62 this.authentication = authentication;
63 this.accessDeniedException = accessDeniedException;
64 }
65
66 //~ Methods ================================================================
67
68 public AccessDeniedException getAccessDeniedException() {
69 return accessDeniedException;
70 }
71
72 public Authentication getAuthentication() {
73 return authentication;
74 }
75
76 public ConfigAttributeDefinition getConfigAttributeDefinition() {
77 return configAttributeDefinition;
78 }
79 }