NOJIRA
removed unnecessary cast and use StringBuilder rather than non-final String and concatenation.
This commit is contained in:
parent
ed92d5ea71
commit
dada789814
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue