Package org.keycloak.utils
Class JsonUtils
java.lang.Object
org.keycloak.utils.JsonUtils
Utility methods for manipulating JSON objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetJsonValue(com.fasterxml.jackson.databind.JsonNode node, String claim) Returns the value corresponding to the givenclaim.static ObjectgetJsonValue(com.fasterxml.jackson.databind.JsonNode node, List<String> paths) static booleanDetermines if the givenclaimcontains paths.static voidmapClaim(List<String> split, Object attributeValue, Map<String, Object> jsonObject, boolean isMultivalued) Maps the Claim with the valueattributeValueinto thejsonObjectunder the pathsplit.splitClaimPath(String claim) Splits the givenclaiminto separate paths if the value contains separators as perCLAIM_COMPONENT.
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
splitClaimPath
Splits the givenclaiminto separate paths if the value contains separators as perCLAIM_COMPONENT.- Parameters:
claim- the claim- Returns:
- a list with the paths
-
mapClaim
public static void mapClaim(List<String> split, Object attributeValue, Map<String, Object> jsonObject, boolean isMultivalued) Maps the Claim with the valueattributeValueinto thejsonObjectunder the pathsplit.
Input- split = ["user", "profile", "email"]
- attributeValue = "alice@example.com"
- isMultivalued = false
- jsonObject = {"foo": "bar"}
Output{ "user": { "profile": { "email": "alice@example.com" } }, "foo": "bar" }- Parameters:
split- The claim path (as created bysplitClaimPath(String)) of the (sub-)claim to map into.attributeValue- the value to map into the claim.jsonObject- the object that contains the claims (e.g., the value that will be used as the claim container)isMultivalued- whether the claim should be treated as multivalued (i.e., multiple values for the same claim should be built into a JSON array).
-
hasPath
Determines if the givenclaimcontains paths.- Parameters:
claim- the claim- Returns:
trueif theclaimcontains paths. Otherwise, false.
-
getJsonValue
Returns the value corresponding to the given
claim.- Parameters:
node- the JSON nodeclaim- the claim- Returns:
- the value
-
getJsonValue
-