@Test public void shouldConvertToJson() { PasswordCallback passwordCallback = new PasswordCallback("Enter password:", false); JsonValue jsonObject = restAuthPasswordCallbackHandler.convertToJson(passwordCallback, 1); assertEquals("PasswordCallback", jsonObject.get("type").asString()); assertNotNull(jsonObject.get("output")); Assert.assertEquals(1, jsonObject.get("output").size()); Assert.assertEquals("Enter password:", 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(PasswordCallback callback, int index) { String prompt = callback.getPrompt(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, "")) .build(); return jsonValue; }
RestAuthPasswordCallbackHandler extends AbstractRestAuthCallbackHandler<PasswordCallback> { public JsonValue convertToJson(PasswordCallback callback, int index) { String prompt = callback.getPrompt(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, "")) .build(); return jsonValue; } }
RestAuthPasswordCallbackHandler extends AbstractRestAuthCallbackHandler<PasswordCallback> { public JsonValue convertToJson(PasswordCallback callback, int index) { String prompt = callback.getPrompt(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, "")) .build(); return jsonValue; }  }
RestAuthPasswordCallbackHandler extends AbstractRestAuthCallbackHandler<PasswordCallback> { public JsonValue convertToJson(PasswordCallback callback, int index) { String prompt = callback.getPrompt(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, "")) .build(); return jsonValue; }  PasswordCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, PasswordCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(PasswordCallback callback, int index); PasswordCallback convertFromJson(PasswordCallback callback, JsonValue jsonCallback); }
RestAuthPasswordCallbackHandler extends AbstractRestAuthCallbackHandler<PasswordCallback> { public JsonValue convertToJson(PasswordCallback callback, int index) { String prompt = callback.getPrompt(); JsonValue jsonValue = JsonValueBuilder.jsonValue() .put("type", CALLBACK_NAME) .array("output") .addLast(createOutputField("prompt", prompt)) .array("input") .addLast(createInputField(index, "")) .build(); return jsonValue; }  PasswordCallback handle(HttpHeaders headers, HttpServletRequest request, HttpServletResponse response,
            JsonValue postBody, PasswordCallback originalCallback); String getCallbackClassName(); JsonValue convertToJson(PasswordCallback callback, int index); PasswordCallback convertFromJson(PasswordCallback callback, JsonValue jsonCallback);  }