try {
chain.doFilter(requestWrapper, response);
} finally {
if (this.impersonate && ctx != null) {
LOGGER.debug("terminating impersonation");
ctx.revertToSelf();
}
}
} else {
LOGGER.debug("previously authenticated user: {}", principal.getName());
chain.doFilter(request, response);