I had implemented AuthenticationFailureListener
for fail login by using ApplicationListener<AuthenticationFailureBadCredentialsEvent>
and all my Bad Credentials event are handeled in the same class, very convenient, I have tried to add a Listener to ExpiredJwtException
or SignatureException
but I could not figure which event is triggered, I have tried -
@Component
public class ApplicationEventListener implements ApplicationListener<ApplicationEvent>{
@Override
public void onApplicationEvent(ApplicationEvent event) {
System.out.println(event.toString()); //not printed when ExpiredJwtException thrown
}
}
to catch all ApplicationEvent
but when one of this exception happens the method onApplicationEvent
does not fired.
I can catch this Exceptions but I want to handle them globally like BadCredentialsException
is handled by AuthenticationFailureBadCredentialsEvent
.
Tried AuthenticationFailureExpiredEvent
-
@Component
public class ApplicationEventListener implements ApplicationListener<AuthenticationFailureExpiredEvent>{
@Override
public void onApplicationEvent(AuthenticationFailureExpiredEvent event) {
System.out.println("Expired!!"); //same result
}
}
but still not working.