Class OIDCStringAttributeTranscoder

All Implemented Interfaces:
AttributeTranscoder<JSONObject>, OIDCAttributeTranscoder, Component, DestructableComponent, InitializableComponent

public class OIDCStringAttributeTranscoder extends AbstractOIDCAttributeTranscoder
Class encoding string attributes to string json object. Name of the attribute will be set as the key. The string contains attribute value. If there are several attribute values they are delimited with delimiter(space is default) or placed to array. If the value is set to be interpreted as int, only values that may be parsed to int are used. In case output is interpreted as int but not set to array, only the first parsable value is used. If the value is interpreted as boolean the value is true if string value equals to "true" ignoring the case. If boolean values are not set to array the first string value is considered to be the result. Finally, the result may be placed to json Object.

For decoding, attempt to convert the input JSON type into a StringAttributeValue in the following way for the following JSON types:

  • If a String, convert directly to a string attribute value.
  • If an Integer or Double (a number type) and PROP_NUMBER_AS_STRING is true, convert to string, else return an empty values list.
  • If a Boolean and PROP_BOOLEAN_AS_STRING is true, convert boolean to 'true' or 'false' string, else return an empty values list.
  • If a JSON Array and PROP_ARRAY_AS_STRING is true, convert to a string by serializing the array to a JSON string.
  • If a JSON Array and PROP_ARRAY_AS_STRING is false, attempt to recursively convert elements of the array to string attribute values using the same set of rules. If any element fails to convert it will be excluded from the result.
  • If a JSON Object and PROP_ASOBJECT is true, convert the object to a string by serializing into JSON. Else, return an empty values list.
  • For any other unknown type, return an empty values list.