Search in sources :

Example 1 with STSPrincipal

use of org.forgerock.openam.sts.STSPrincipal in project OpenAM by OpenRock.

the class PrincipalFromSessionImpl method parsePrincipalFromResponse.

private Principal parsePrincipalFromResponse(String response) throws TokenValidationException {
    JsonValue responseJson;
    try {
        responseJson = JsonValueBuilder.toJsonValue(response);
    } catch (JsonException e) {
        String message = "Exception caught getting the text of the json principal from session response: " + e;
        throw new TokenValidationException(ResourceException.INTERNAL_ERROR, message, e);
    }
    JsonValue principalIdJsonValue = responseJson.get(ID);
    if (!principalIdJsonValue.isString()) {
        String message = "Principal from session response does not contain " + ID + " string entry. The obtained entry: " + principalIdJsonValue.toString() + "; The response: " + responseJson.toString();
        throw new TokenValidationException(ResourceException.INTERNAL_ERROR, message);
    }
    return new STSPrincipal(principalIdJsonValue.asString());
}
Also used : JsonException(org.forgerock.json.JsonException) JsonValue(org.forgerock.json.JsonValue) TokenValidationException(org.forgerock.openam.sts.TokenValidationException) STSPrincipal(org.forgerock.openam.sts.STSPrincipal)

Aggregations

JsonException (org.forgerock.json.JsonException)1 JsonValue (org.forgerock.json.JsonValue)1 STSPrincipal (org.forgerock.openam.sts.STSPrincipal)1 TokenValidationException (org.forgerock.openam.sts.TokenValidationException)1