@Test public void shouldNotFailToConvertFromJsonWithTypeLowerCase() { PasswordCallback passwordCallback = new PasswordCallback("Enter password:", false); JsonValue jsonPasswordCallback = JsonValueBuilder.jsonValue() .array("input") .addLast(JsonValueBuilder.jsonValue().put("value", "PASSWORD").build()) .array("output") .addLast(JsonValueBuilder.jsonValue().put("value", "Enter password:").build()) .put("type", "passwordcallback") .build(); PasswordCallback convertedPasswordCallback = restAuthPasswordCallbackHandler.convertFromJson(passwordCallback, jsonPasswordCallback); Assert.assertEquals(passwordCallback, convertedPasswordCallback); Assert.assertEquals("Enter password:", convertedPasswordCallback.getPrompt()); Assert.assertEquals("PASSWORD", new String(convertedPasswordCallback.getPassword())); }
public PasswordCallback convertFromJson(PasswordCallback 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.setPassword(value.toCharArray()); return callback; }
RestAuthPasswordCallbackHandler extends AbstractRestAuthCallbackHandler<PasswordCallback> { public PasswordCallback convertFromJson(PasswordCallback 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.setPassword(value.toCharArray()); return callback; } }
RestAuthPasswordCallbackHandler extends AbstractRestAuthCallbackHandler<PasswordCallback> { public PasswordCallback convertFromJson(PasswordCallback 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.setPassword(value.toCharArray()); return callback; }  }
RestAuthPasswordCallbackHandler extends AbstractRestAuthCallbackHandler<PasswordCallback> { public PasswordCallback convertFromJson(PasswordCallback 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.setPassword(value.toCharArray()); return callback; }  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 PasswordCallback convertFromJson(PasswordCallback 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.setPassword(value.toCharArray()); return callback; }  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);  }