|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
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 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| public class LoggerListener implements ApplicationListener { |
|
38 |
| |
|
39 |
| |
|
40 |
| private static final Log logger = LogFactory.getLog(LoggerListener.class); |
|
41 |
| |
|
42 |
| |
|
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 |
| } |