@Test public void shouldNotFailToConvertFromJsonWithTypeLowerCase() { NameCallback nameCallback = new NameCallback("Enter username:"); JsonValue jsonNameCallback = JsonValueBuilder.jsonValue() .array("input") .addLast(JsonValueBuilder.jsonValue().put("value", "USERNAME").build()) .array("output") .addLast(JsonValueBuilder.jsonValue().put("value", "Enter username:").build()) .put("type", "namecallback") .build(); NameCallback convertedNameCallback = restAuthNameCallbackHandler.convertFromJson(nameCallback, jsonNameCallback); Assert.assertEquals(nameCallback, convertedNameCallback); Assert.assertEquals("Enter username:", convertedNameCallback.getPrompt()); Assert.assertEquals("USERNAME", convertedNameCallback.getName()); }
public NameCallback convertFromJson(NameCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setName(value); return callback; }
RestAuthNameCallbackHandler extends AbstractRestAuthCallbackHandler<NameCallback> { public NameCallback convertFromJson(NameCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setName(value); return callback; } }
RestAuthNameCallbackHandler extends AbstractRestAuthCallbackHandler<NameCallback> { public NameCallback convertFromJson(NameCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setName(value); return callback; }  }
RestAuthNameCallbackHandler extends AbstractRestAuthCallbackHandler<NameCallback> { public NameCallback convertFromJson(NameCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setName(value); return callback; }  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 NameCallback convertFromJson(NameCallback callback, JsonValue jsonCallback) { validateCallbackType(CALLBACK_NAME, jsonCallback); JsonValue input = jsonCallback.get("input"); if (input.size() != 1) { throw new JsonException("JSON Callback does not include a input field"); } JsonValue inputField = input.get(0); String value = inputField.get("value").asString(); callback.setName(value); return callback; }  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);  }