@PermitAll @POST @Path("/login") @Consumes("application/json") @Produces("application/json") public Response login(@QueryParam("user") String username, String password) { username = EncodingUtil.decode(username); logger.info(username + " is signing in"); User user = this.findUser(username); ResponseBuilder builder; if (user == null) { logger.info("Incorrect username: "******"Incorrect password for this username: "******" is logged"); builder = Response.status(Response.Status.OK).entity(user); return builder.build(); } } return builder.build(); }
@RolesAllowed(value = {"Admin", "Manager", "Contestant"}) @POST @Path("/logout") @Consumes("application/json") @Produces("application/json") public Response logout(User user) { ResponseBuilder builder; if (user == null) { logger.info("Null entry on logout"); builder = Response.status(Response.Status.NO_CONTENT); return builder.build(); } logger.info("Removing " + user.getUsername() + "'s key"); Authorizator auth = new Authorizator(); auth.deleteKey(user); builder = Response.status(Response.Status.OK); return builder.build(); }