@DELETE public Response logout( @Context HttpServletRequest request, @Context HttpServletResponse response) { // if session does not exist try and catch sessionHelper.setRequest(request); sessionHelper.getSession().invalidate(); return Response.status(204).build(); }
@POST @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response login( @FormParam("username") String username, @FormParam("password") String password, @Context HttpServletRequest request, @Context HttpServletResponse response) { String SessionVariableKeyOfUserId = USER_ID; sessionHelper.setRequest(request); if (miscHelper.authenticate(username, password)) { getSessionHelper().addVariableToSession(username, SessionVariableKeyOfUserId); return Response.status(201).build(); } Error e = errorHelper.getInvalidCredentialError(); return Response.status(Integer.valueOf(e.getCode())).entity(e).build(); }