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

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;
if (!logInteractiveAuthenticationSuccessEvents && authEvent instanceof InteractiveAuthenticationSuccessEvent) {
return; return;
} }
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
String message = "Authentication event " + ClassUtils.getShortName(authEvent.getClass()) + ": " final StringBuilder builder = new StringBuilder();
+ authEvent.getAuthentication().getName() + "; details: " builder.append("Authentication event ");
+ authEvent.getAuthentication().getDetails(); 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) { if (event instanceof AbstractAuthenticationFailureEvent) {
message = message + "; exception: " builder.append("; exception: ");
+ ((AbstractAuthenticationFailureEvent) event).getException().getMessage(); builder.append(((AbstractAuthenticationFailureEvent) event).getException().getMessage());
} }
logger.warn(message); logger.warn(builder.toString());
}
} }
} }