[1240] | 1 | package gov.va.med.edp.springframework.security.ui.vistalink;
|
---|
| 2 |
|
---|
| 3 | import org.springframework.security.ui.logout.LogoutHandler;
|
---|
| 4 | import org.springframework.security.Authentication;
|
---|
| 5 | import org.springframework.beans.factory.InitializingBean;
|
---|
| 6 | import org.springframework.util.Assert;
|
---|
| 7 |
|
---|
| 8 | import javax.servlet.http.HttpServletRequest;
|
---|
| 9 | import javax.servlet.http.HttpServletResponse;
|
---|
| 10 |
|
---|
| 11 | import gov.va.med.edp.springframework.security.userdetails.VistaUserDetailsService;
|
---|
| 12 | import gov.va.med.edp.springframework.security.providers.vistalink.VistaAuthenticationToken;
|
---|
| 13 |
|
---|
| 14 | public class VistaLogoutHandler implements LogoutHandler, InitializingBean {
|
---|
| 15 |
|
---|
| 16 | private VistaUserDetailsService userDetailsService;
|
---|
| 17 |
|
---|
| 18 | public void afterPropertiesSet() throws Exception {
|
---|
| 19 | Assert.notNull(userDetailsService, "userDetailsService must be set.");
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
---|
| 23 | if (!(authentication instanceof VistaAuthenticationToken)) return;
|
---|
| 24 | VistaAuthenticationToken auth = (VistaAuthenticationToken) authentication;
|
---|
| 25 | userDetailsService.logout(auth.getVistaUserDetails());
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | public VistaUserDetailsService getUserDetailsService() {
|
---|
| 29 | return userDetailsService;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | public void setUserDetailsService(VistaUserDetailsService userDetailsService) {
|
---|
| 33 | this.userDetailsService = userDetailsService;
|
---|
| 34 | }
|
---|
| 35 | }
|
---|