package ch.uzh.csg.reimbursement.security;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

@Component
public class HttpLogoutSuccessHandler implements LogoutSuccessHandler {
	private static final Logger LOGGER = LoggerFactory.getLogger(HttpLogoutSuccessHandler.class);

	@Override
	public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
			throws IOException {
		response.setStatus(HttpServletResponse.SC_OK);
		LOGGER.info("onLogoutSuccess for user: " + authentication.getName());
	}
}

@@ -789,16 +789,48 @@
 SC_OK);%0A
+%09%09if(authentication != null) %7B%0A%09
 %09%09LOGGER
@@ -893,13 +893,97 @@
 ame());%0A
+%09%09%7D%0A%09%09else %7B%0A%09%09%09LOGGER.info(%22onLogoutSuccess: User was not logged in before.%22);%0A%09%09%7D%0A
 %09%7D%0A%7D%0A

fix nullpointer if logout is called and user already logged out (e.g. session time out)