Our application has an anonymous landing page that allows one to impersonate multiple users. The first impersonation works, the second in the same session fails because of an NPE.
SwitchUserFilter tries to exit the impersonated user before doing the next impersonation. As the previous user is anonymous the originalUser will be NULL (SwitchUserFilter:284 is not executed as obj is a string with value "anonymousUser") and as such the
audit listener fails with an NPE (AuthenticationAuditListener:106).
This is using spring-boot 1.5.7 and corresponding spring-security 4.2.3 but looking at the code this is still there in the latest 1.5.18 release.
A potential workaround is to have no audit listener, or a custom one.
Note: will provide simple example later