Beispiel #1
0
  @PermitAll
  @GET
  @Path("/searchuser")
  @Consumes("application/json")
  @Produces("application/json")
  public Response searchUser(@QueryParam("q") String username) {

    logger.info("Searching for user " + username);

    User user = this.findUser(username);

    ResponseBuilder builder;

    if (user == null) {
      ForCodeError error = ErrorFactory.getErrorFromIndex(ErrorFactory.USER_NOT_FOUND);
      builder = Response.status(Response.Status.NOT_FOUND).entity(error);

      logger.info("Unsuccessful attempt to find user.");
    } else {

      user.setPassword(null);
      user.setUserKey(null);

      builder = Response.status(Response.Status.FOUND).entity(user);

      logger.info("Successful attempt to find user.");
    }

    return builder.build();
  }
Beispiel #2
0
  @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();
  }