class RestAuthRedirectCallbackHandler extends AbstractRestAuthCallbackHandler<RedirectCallback> {

    public JsonValue convertToJson(RedirectCallback callback, int index) throws RestAuthException {

        JsonValue callbacksJson = json(array(
                createOutputField("redirectUrl", callback.getRedirectUrl()),
                createOutputField("redirectMethod", callback.getMethod()),
                createOutputField("trackingCookie", callback.getTrackingCookie())));

        JsonValue jsonValue = json(object(
                field("type", CALLBACK_NAME),
                field("output", callbacksJson.getObject())
        ));

        if (callback.getRedirectData() != null) {
            callbacksJson.add(createOutputField("redirectData", callback.getRedirectData()));
        }

        return jsonValue;
    }

}