public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		if ( request instanceof HttpServletRequest ) {
			HttpServletRequest req = ((HttpServletRequest)request);
			try {
				// get what we want from the request
				Principal p = req.getUserPrincipal();
				
				if ( p != null ) {
					AccountModel account = accountService.getAccountByUsername(p.getName());
					// store it in the ThreadLocal bean
					CurrentUser.setUser(account);
				}
				
				// proceed with the request
				chain.doFilter(request, response);
			} finally { 
				// remove user from the ThreadLocal bean so that this
				// thread is ready for the next request
				CurrentUser.setUser(null);
			}
		} else {
			// this almost never happens, but we have it here for completeness
			chain.doFilter(request, response);
		}
	}