use of com.hack23.cia.service.api.action.application.DestroyApplicationSessionRequest in project cia by Hack23.
the class DestroyApplicationSessionServiceITest method serviceDestroyApplicationSessionRequestSuccessTest.
/**
* Service destroy application session request success test.
*
* @throws Exception
* the exception
*/
@Test
@PerfTest(threads = 4, duration = 3000, warmUp = 1500)
@Required(max = 1000, average = 600, percentile95 = 850, throughput = 10)
public void serviceDestroyApplicationSessionRequestSuccessTest() throws Exception {
setAuthenticatedAnonymousUser();
final CreateApplicationSessionRequest createTestApplicationSession = createTestApplicationSession();
final DestroyApplicationSessionRequest destroyApplicationSessionRequest = new DestroyApplicationSessionRequest();
destroyApplicationSessionRequest.setSessionId(createTestApplicationSession.getSessionId());
final ServiceResponse response = applicationManager.service(destroyApplicationSessionRequest);
assertNotNull(EXPECT_A_RESULT, response);
assertEquals(EXPECT_SUCCESS, ServiceResult.SUCCESS, response.getResult());
final ApplicationSession applicationSession = applicationSessionDAO.findFirstByProperty(ApplicationSession_.sessionId, createTestApplicationSession.getSessionId());
assertNotNull(EXPECT_A_RESULT, applicationSession);
assertNotNull(EXPECT_A_RESULT, applicationSession.getDestroyedDate());
}
use of com.hack23.cia.service.api.action.application.DestroyApplicationSessionRequest in project cia by Hack23.
the class DestroyApplicationSessionService method processService.
@Override
@Secured({ "ROLE_ANONYMOUS" })
public DestroyApplicationSessionResponse processService(final DestroyApplicationSessionRequest serviceRequest) {
final DestroyApplicationSessionResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final ApplicationSession applicationSession = applicationSessionDAO.findFirstByProperty(ApplicationSession_.sessionId, serviceRequest.getSessionId());
if (applicationSession != null) {
LOGGER.info("Destroy Application session: {}", applicationSession.getSessionId());
applicationSession.setDestroyedDate(new Date());
applicationSessionDAO.persist(applicationSession);
return new DestroyApplicationSessionResponse(ServiceResult.SUCCESS);
} else {
LOGGER.warn("Failed to destroy Application session, no session found for id: {}", serviceRequest.getSessionId());
return new DestroyApplicationSessionResponse(ServiceResult.FAILURE);
}
}
use of com.hack23.cia.service.api.action.application.DestroyApplicationSessionRequest in project cia by Hack23.
the class HttpSessionDestroyedEventListener method onApplicationEvent.
@Override
public void onApplicationEvent(final HttpSessionDestroyedEvent event) {
final HttpSession httpSession = event.getSession();
final Collection<SimpleGrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority(ROLE_ANONYMOUS));
final DestroyApplicationSessionRequest destroyApplicationSessionRequest = new DestroyApplicationSessionRequest();
destroyApplicationSessionRequest.setSessionId(httpSession.getId());
SecurityContextHolder.getContext().setAuthentication(new AnonymousAuthenticationToken(KEY, PRINCIPAL, authorities));
applicationManager.service(destroyApplicationSessionRequest);
SecurityContextHolder.getContext().setAuthentication(null);
LOGGER.info(LOG_MSG_SESSION_DESTROYED_SESSION_ID, httpSession.getId());
}
Aggregations