@Test public void shouldConvertToJson() { NameCallback nameCallback = new NameCallback("Enter username:"); JsonValue jsonObject = restAuthNameCallbackHandler.convertToJson(nameCallback, 1); assertEquals("NameCallback", jsonObject.get("type").asString()); assertNotNull(jsonObject.get("output")); Assert.assertEquals(1, jsonObject.get("output").size()); Assert.assertEquals("Enter username:", jsonObject.get("output").get(0).get("value").asString()); assertNotNull(jsonObject.get("input")); Assert.assertEquals(1, jsonObject.get("input").size()); Assert.assertEquals("", jsonObject.get("input").get(0).get("value").asString()); }
public JsonValue convertToJson(NameCallback callback, int index) { String prompt = callback.getPrompt(); String name = callback.getName(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, name)) .build(); return jsonValue; }
RestAuthNameCallbackHandler extends AbstractRestAuthCallbackHandler<NameCallback> { public JsonValue convertToJson(NameCallback callback, int index) { String prompt = callback.getPrompt(); String name = callback.getName(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, name)) .build(); return jsonValue; } }
RestAuthNameCallbackHandler extends AbstractRestAuthCallbackHandler<NameCallback> { public JsonValue convertToJson(NameCallback callback, int index) { String prompt = callback.getPrompt(); String name = callback.getName(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, name)) .build(); return jsonValue; }  }
RestAuthNameCallbackHandler extends AbstractRestAuthCallbackHandler<NameCallback> { public JsonValue convertToJson(NameCallback callback, int index) { String prompt = callback.getPrompt(); String name = callback.getName(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, name)) .build(); return jsonValue; }  String getCallbackClassName(); NameCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, NameCallback originalCallback); JsonValue convertToJson(NameCallback callback, int index); NameCallback convertFromJson(NameCallback callback, JsonValue jsonCallback); }
RestAuthNameCallbackHandler extends AbstractRestAuthCallbackHandler<NameCallback> { public JsonValue convertToJson(NameCallback callback, int index) { String prompt = callback.getPrompt(); String name = callback.getName(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, name)) .build(); return jsonValue; }  String getCallbackClassName(); NameCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, NameCallback originalCallback); JsonValue convertToJson(NameCallback callback, int index); NameCallback convertFromJson(NameCallback callback, JsonValue jsonCallback);  }