Skip to content

oidcext:OIDCString

jalauros edited this page Nov 2, 2017 · 31 revisions

Default functionality of OIDCString encoder is to encode an IdPAttribute with simple string values as a JSON object with string value. If IdPAttribute has multiple string values they are catenated to a single string value with space as delimeter. There are several options to alter the behaviour.

Multiple values may be encoded also as JSON array instead of catenating all to single string. Options allow also presenting values as JSON integer or as JSON boolean. When presenting values as integer, nonparsable values are discarded. If output is set to be presented as JSON array all parsable values are placed to array, otherwise the first parsable value is treated as the result. When presenting values as boolean all strings matching 'true' (ignoring the case) are considered to be true, others false. If output is set to be presented as JSON array all boolean values are placed to array, otherwise the first value is treated as the result.

Options allow also wrapping the result to JSON Object (for instance to form address claim).

Schema Name and Location

This xsi:type is defined by the org.geant.idpextension.oidc.attribute.encoder schema, which is located at https://github.com/CSCfi/shibboleth-idp-oidc-extension/blob/master/idp-oidc-extension-impl/src/main/resources/schema/idp-oidc-extension-attribute-encoder.xsd and used by the reference installation from classpath:/schema/idp-oidc-extension-attribute-encoder.xsd

JSON Encoder Attributes

  • asBoolean, present value as a JSON boolean. Default value is false.
  • asInt, present value as a JSON integer. Default value is false.
  • asArray, set values to JSON Array. Default value is false.
  • asObject, wrap result to JSON object. Default value is false.
  • fieldName, if result is wrapped to JSON object the field name for the value. Setting this attribute in such case is mandatory.
  • stringDelimiter, delimiter used when catenating multiple values to single string. Default is " ".

Example

<AttributeEncoder xsi:type="oidcext:OIDCString" name="affiliation" asArray="true"/> <AttributeEncoder xsi:type="oidcext:OIDCString" name="age" asInt="true"/> <AttributeEncoder xsi:type="oidcext:OIDCString" asObject="true" fieldName="formatted" name="address"/> "address":{ "formatted":"Street Address P.O. Box 555 Finland" }