private JSONObject getResponseJson(String last, Map<String, String> previousIdps, boolean setLast, boolean setPrev) {
        JSONObject json = new JSONObject();
        if (setLast) {
            try {
                json.accumulate("lastIdP", last);
            } catch (JSONException ex) {
                LOG.log(Level.INFO, null, ex);
            }
        }
        if (setPrev) {
            for (int i = 0; i < 10; i++) {
                if (previousIdps.containsKey(getId(i))) {
                    try {
                        JSONObject prevObj = new JSONObject();
                        prevObj.accumulate("entityID", previousIdps.get(getId(i)));
                        json.accumulate("previousIdPs", prevObj);
                    } catch (JSONException ex) {
                        LOG.log(Level.INFO, null, ex);
                    }
                }
            }
        }

        return json;
    }