@Test public void testRemoveSessionInformation() throws Exception { final String sessionId = "session-id"; final String hsaId = "hsa-id"; final String authenticationScheme = "authenticationScheme"; final String origin = "origin"; WebCertUser principal = mock(WebCertUser.class); when(principal.getHsaId()).thenReturn(hsaId); when(principal.getAuthenticationScheme()).thenReturn(authenticationScheme); when(principal.getOrigin()).thenReturn(origin); loggingSessionRegistry.registerNewSession(sessionId, principal); loggingSessionRegistry.removeSessionInformation(sessionId); verify(monitoringService).logUserLogout(hsaId, authenticationScheme); }
@Override public void removeSessionInformation(String sessionId) { LOGGER.debug("Attempting to remove session '{}'", sessionId); SessionInformation sessionInformation = getSessionInformation(sessionId); if (sessionInformation == null) { super.removeSessionInformation(sessionId); return; } Object principal = sessionInformation.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) principal; if (sessionInformation.isExpired()) { monitoringService.logUserSessionExpired(user.getHsaId(), user.getAuthenticationScheme()); } else { monitoringService.logUserLogout(user.getHsaId(), user.getAuthenticationScheme()); } } super.removeSessionInformation(sessionId); }
WebcertLoggingSessionRegistryImpl extends SessionRegistryImpl { @Override public void removeSessionInformation(String sessionId) { LOGGER.debug("Attempting to remove session '{}'", sessionId); SessionInformation sessionInformation = getSessionInformation(sessionId); if (sessionInformation == null) { super.removeSessionInformation(sessionId); return; } Object principal = sessionInformation.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) principal; if (sessionInformation.isExpired()) { monitoringService.logUserSessionExpired(user.getHsaId(), user.getAuthenticationScheme()); } else { monitoringService.logUserLogout(user.getHsaId(), user.getAuthenticationScheme()); } } super.removeSessionInformation(sessionId); } }
WebcertLoggingSessionRegistryImpl extends SessionRegistryImpl { @Override public void removeSessionInformation(String sessionId) { LOGGER.debug("Attempting to remove session '{}'", sessionId); SessionInformation sessionInformation = getSessionInformation(sessionId); if (sessionInformation == null) { super.removeSessionInformation(sessionId); return; } Object principal = sessionInformation.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) principal; if (sessionInformation.isExpired()) { monitoringService.logUserSessionExpired(user.getHsaId(), user.getAuthenticationScheme()); } else { monitoringService.logUserLogout(user.getHsaId(), user.getAuthenticationScheme()); } } super.removeSessionInformation(sessionId); }  }
WebcertLoggingSessionRegistryImpl extends SessionRegistryImpl { @Override public void removeSessionInformation(String sessionId) { LOGGER.debug("Attempting to remove session '{}'", sessionId); SessionInformation sessionInformation = getSessionInformation(sessionId); if (sessionInformation == null) { super.removeSessionInformation(sessionId); return; } Object principal = sessionInformation.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) principal; if (sessionInformation.isExpired()) { monitoringService.logUserSessionExpired(user.getHsaId(), user.getAuthenticationScheme()); } else { monitoringService.logUserLogout(user.getHsaId(), user.getAuthenticationScheme()); } } super.removeSessionInformation(sessionId); }  @Override void registerNewSession(String sessionId, Object principal); @Override void removeSessionInformation(String sessionId); }
WebcertLoggingSessionRegistryImpl extends SessionRegistryImpl { @Override public void removeSessionInformation(String sessionId) { LOGGER.debug("Attempting to remove session '{}'", sessionId); SessionInformation sessionInformation = getSessionInformation(sessionId); if (sessionInformation == null) { super.removeSessionInformation(sessionId); return; } Object principal = sessionInformation.getPrincipal(); if (principal instanceof WebCertUser) { WebCertUser user = (WebCertUser) principal; if (sessionInformation.isExpired()) { monitoringService.logUserSessionExpired(user.getHsaId(), user.getAuthenticationScheme()); } else { monitoringService.logUserLogout(user.getHsaId(), user.getAuthenticationScheme()); } } super.removeSessionInformation(sessionId); }  @Override void registerNewSession(String sessionId, Object principal); @Override void removeSessionInformation(String sessionId);  }