use of org.forgerock.json.JsonException in project OpenAM by OpenRock.
the class PublishServiceConsumerImpl method parseResponse.
/*
The response is created in SoapSTSPublishServiceRequestHandler#handleQuery.
*/
private Set<SoapSTSInstanceConfig> parseResponse(String response) throws STSPublishException {
Set<SoapSTSInstanceConfig> instanceConfigs = new HashSet<>();
JsonValue json;
try {
json = JsonValueBuilder.toJsonValue(response);
} catch (JsonException e) {
throw new STSPublishException(ResourceException.INTERNAL_ERROR, e.getMessage(), e);
}
JsonValue queryResult = json.get(RESULT);
if (queryResult.isCollection()) {
int size = queryResult.asCollection().size();
for (int ndx = 0; ndx < size; ndx++) {
final SoapSTSInstanceConfig soapSTSInstanceConfig = SoapSTSInstanceConfig.fromJson(queryResult.get(ndx));
/*
check for duplicates: duplicates cannot really be present because the combination of realm and deployment
uri constitutes the identity of the soap-sts instance, and duplicate entries will result in LDAP errors
when the instance is persisted in the SMS, but paranoia pays...
*/
if (!instanceConfigs.add(soapSTSInstanceConfig)) {
logger.error("The set of published soap-sts instances contains a duplicate!! The duplicate instance: " + queryResult.get(ndx));
}
}
return instanceConfigs;
} else {
throw new STSPublishException(ResourceException.INTERNAL_ERROR, "Unexpected state: the query result is not " + "a collection. The query result: " + queryResult.toString());
}
}
use of org.forgerock.json.JsonException in project OpenAM by OpenRock.
the class RestAuthHiddenValueCallbackHandler method convertFromJson.
/**
* {@inheritDoc}
*/
public HiddenValueCallback convertFromJson(HiddenValueCallback callback, JsonValue jsonCallback) throws RestAuthException {
validateCallbackType(CALLBACK_NAME, jsonCallback);
JsonValue input = jsonCallback.get("input");
if (input.size() != 1) {
throw new JsonException("JSON Callback does not include an input field");
}
JsonValue inputField = input.get(0);
String value = inputField.get("value").asString();
callback.setValue(value);
return callback;
}
use of org.forgerock.json.JsonException in project OpenAM by OpenRock.
the class RestAuthChoiceCallbackHandler method convertFromJson.
/**
* {@inheritDoc}
*/
public ChoiceCallback convertFromJson(ChoiceCallback callback, JsonValue jsonCallback) throws RestAuthException {
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);
int selectedIndex = toInteger(inputField.get("value"));
callback.setSelectedIndex(selectedIndex);
return callback;
}
use of org.forgerock.json.JsonException in project OpenAM by OpenRock.
the class RestAuthConfirmationCallbackHandler method convertFromJson.
/**
* {@inheritDoc}
*/
public ConfirmationCallback convertFromJson(ConfirmationCallback callback, JsonValue jsonCallback) throws RestAuthException {
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 inputFieldValue = input.get(0).get("value").required();
int value;
if (inputFieldValue.isString()) {
value = Integer.parseInt(inputFieldValue.asString());
} else {
value = inputFieldValue.asInteger();
}
callback.setSelectedIndex(value);
return callback;
}
use of org.forgerock.json.JsonException in project OpenAM by OpenRock.
the class RestAuthPasswordCallbackHandler method convertFromJson.
/**
* {@inheritDoc}
*/
public PasswordCallback convertFromJson(PasswordCallback callback, JsonValue jsonCallback) throws RestAuthException {
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;
}
Aggregations