class UserRest {

    @POST
    @Path("{username}/password")
    @RolesAllowed("user")
    @ApiOperation("Changes a Mobi User's password if it is the User making the request")
    public Response changePassword(@Context ContainerRequestContext context,
                            @PathParam("username") String username,
                            @QueryParam("currentPassword") String currentPassword,
                            @QueryParam("newPassword") String newPassword) {
        if (StringUtils.isEmpty(username)) {
            throw ErrorUtils.sendError("Current username must be provided", Response.Status.BAD_REQUEST);
        }
        checkCurrentUser(getActiveUsername(context), username);
        if (StringUtils.isEmpty(currentPassword)) {
            throw ErrorUtils.sendError("Current password must be provided", Response.Status.BAD_REQUEST);
        }
        if (StringUtils.isEmpty(newPassword)) {
            throw ErrorUtils.sendError("New password must be provided", Response.Status.BAD_REQUEST);
        }
        try {
            if (!engineManager.checkPassword(rdfEngine.getEngineName(), username, currentPassword)) {
                throw ErrorUtils.sendError("Invalid password", Response.Status.UNAUTHORIZED);
            }
            return changePassword(username, newPassword);
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex.getMessage(), Response.Status.BAD_REQUEST);
        }
    }

}