class SessionLogoutResource {

  @Timed @ExceptionMetered
  @POST
  @Produces(APPLICATION_JSON)
  public Response logout(@Nullable @CookieParam(value = "session") Cookie sessionCookie) {
    if (sessionCookie != null) {
      Optional<User> user = cookieAuthenticator.authenticate(sessionCookie);

      if (user.isPresent()) {
        logger.info("User logged out: {}", user.get().getName());
      } else {
        logger.warn("Invalid user cookie on logout.");
      }
    }

    NewCookie expiredCookie = cookieFactory.getExpiredSessionCookie();

    return Response.ok()
        .header(HttpHeaders.SET_COOKIE, expiredCookie.toString())
        .build();
  }

  @Inject public  SessionLogoutResource(CookieAuthenticator cookieAuthenticator,
      AuthenticatedEncryptedCookieFactory cookieFactory);

}