| 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 |
34 |
public class LoggerListener implements ApplicationListener { |
| 36 |
|
|
| 37 |
|
|
| 38 |
2 |
private static final Log logger = LogFactory.getLog(LoggerListener.class); |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
public void onApplicationEvent(ApplicationEvent event) { |
| 43 |
46 |
if (event instanceof AuthenticationCredentialsNotFoundEvent) { |
| 44 |
1 |
AuthenticationCredentialsNotFoundEvent authEvent = (AuthenticationCredentialsNotFoundEvent) event; |
| 45 |
|
|
| 46 |
1 |
if (logger.isWarnEnabled()) { |
| 47 |
1 |
logger.warn("Security interception failed due to: " + authEvent.getCredentialsNotFoundException() |
| 48 |
|
+ "; secure object: " + authEvent.getSource() + "; configuration attributes: " |
| 49 |
|
+ authEvent.getConfigAttributeDefinition()); |
| 50 |
|
} |
| 51 |
|
} |
| 52 |
|
|
| 53 |
46 |
if (event instanceof AuthorizationFailureEvent) { |
| 54 |
2 |
AuthorizationFailureEvent authEvent = (AuthorizationFailureEvent) event; |
| 55 |
|
|
| 56 |
2 |
if (logger.isWarnEnabled()) { |
| 57 |
2 |
logger.warn("Security authorization failed due to: " + authEvent.getAccessDeniedException() |
| 58 |
|
+ "; authenticated principal: " + authEvent.getAuthentication() |
| 59 |
|
+ "; secure object: " + authEvent.getSource() |
| 60 |
|
+ "; configuration attributes: " + authEvent.getConfigAttributeDefinition()); |
| 61 |
|
} |
| 62 |
|
} |
| 63 |
|
|
| 64 |
46 |
if (event instanceof AuthorizedEvent) { |
| 65 |
7 |
AuthorizedEvent authEvent = (AuthorizedEvent) event; |
| 66 |
|
|
| 67 |
7 |
if (logger.isInfoEnabled()) { |
| 68 |
0 |
logger.info("Security authorized for authenticated principal: " + authEvent.getAuthentication() |
| 69 |
|
+ "; secure object: " + authEvent.getSource() + "; configuration attributes: " |
| 70 |
|
+ authEvent.getConfigAttributeDefinition()); |
| 71 |
|
} |
| 72 |
|
} |
| 73 |
|
|
| 74 |
46 |
if (event instanceof PublicInvocationEvent) { |
| 75 |
2 |
PublicInvocationEvent authEvent = (PublicInvocationEvent) event; |
| 76 |
|
|
| 77 |
2 |
if (logger.isInfoEnabled()) { |
| 78 |
0 |
logger.info("Security interception not required for public secure object: " + authEvent.getSource()); |
| 79 |
|
} |
| 80 |
|
} |
| 81 |
46 |
} |
| 82 |
|
} |