removed unnecessary cast and use StringBuilder rather than non-final String and concatenation.
This commit is contained in:
Scott Battaglia 2009-12-01 15:19:56 +00:00
parent ed92d5ea71
commit dada789814
1 changed files with 16 additions and 16 deletions

View File

@ -40,25 +40,25 @@ public class LoggerListener implements ApplicationListener<AbstractAuthenticatio
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
public void onApplicationEvent(AbstractAuthenticationEvent event) { public void onApplicationEvent(AbstractAuthenticationEvent event) {
if (event instanceof AbstractAuthenticationEvent) { if (!logInteractiveAuthenticationSuccessEvents && event instanceof InteractiveAuthenticationSuccessEvent) {
AbstractAuthenticationEvent authEvent = (AbstractAuthenticationEvent) event; return;
}
if (!logInteractiveAuthenticationSuccessEvents && authEvent instanceof InteractiveAuthenticationSuccessEvent) { if (logger.isWarnEnabled()) {
return; final StringBuilder builder = new StringBuilder();
builder.append("Authentication event ");
builder.append(ClassUtils.getShortName(event.getClass()));
builder.append(": ");
builder.append(event.getAuthentication().getName());
builder.append("; details: ");
builder.append(event.getAuthentication().getDetails());
if (event instanceof AbstractAuthenticationFailureEvent) {
builder.append("; exception: ");
builder.append(((AbstractAuthenticationFailureEvent) event).getException().getMessage());
} }
if (logger.isWarnEnabled()) { logger.warn(builder.toString());
String message = "Authentication event " + ClassUtils.getShortName(authEvent.getClass()) + ": "
+ authEvent.getAuthentication().getName() + "; details: "
+ authEvent.getAuthentication().getDetails();
if (event instanceof AbstractAuthenticationFailureEvent) {
message = message + "; exception: "
+ ((AbstractAuthenticationFailureEvent) event).getException().getMessage();
}
logger.warn(message);
}
} }
} }