Class OIDCStringAttributeTranscoder
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.transcoding.AbstractAttributeTranscoder<net.minidev.json.JSONObject>
net.shibboleth.oidc.attribute.transcoding.AbstractOIDCAttributeTranscoder
net.shibboleth.oidc.attribute.transcoding.impl.OIDCStringAttributeTranscoder
- All Implemented Interfaces:
net.shibboleth.idp.attribute.transcoding.AttributeTranscoder<net.minidev.json.JSONObject>,OIDCAttributeTranscoder,Component,DestructableComponent,InitializableComponent
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.shibboleth.oidc.attribute.transcoding.AbstractOIDCAttributeTranscoder
AbstractOIDCAttributeTranscoder.NamingFunction -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.slf4j.LoggerClass logger.static final StringWhether to parse the values into and out as a JSON object.Fields inherited from interface net.shibboleth.oidc.attribute.transcoding.OIDCAttributeTranscoder
PROP_ARRAY_AS_STRING, PROP_ASARRAY, PROP_ASBOOLEAN, PROP_ASINTEGER, PROP_BOOLEAN_AS_STRING, PROP_NAME, PROP_NUMBER_AS_STRING, PROP_STRING_DELIMITER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<net.shibboleth.idp.attribute.IdPAttributeValue>decodeValues(ProfileRequestContext profileRequestContext, Object input, net.shibboleth.idp.attribute.transcoding.TranscodingRule rule) protected ObjectencodeValues(ProfileRequestContext profileRequestContext, net.shibboleth.idp.attribute.IdPAttribute attribute, net.shibboleth.idp.attribute.transcoding.TranscodingRule rule) private ObjecttoJSONObject(String value) Parses string as JSONObject.private List<?>transformValues(net.shibboleth.idp.attribute.transcoding.TranscodingRule rule, Stream<String> attributeValues) Converts string values to List of Integer, String or Boolean depending on rule.Methods inherited from class net.shibboleth.oidc.attribute.transcoding.AbstractOIDCAttributeTranscoder
buildClaim, buildIdPAttribute, doDecode, doEncode, getEncodedName, getEncodedTypeMethods inherited from class net.shibboleth.idp.attribute.transcoding.AbstractAttributeTranscoder
decode, encode, setActivationConditionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.idp.attribute.transcoding.AttributeTranscoder
decode, encodeMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
PROP_ASOBJECT
Whether to parse the values into and out as a JSON object.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger.
-
-
Constructor Details
-
OIDCStringAttributeTranscoder
public OIDCStringAttributeTranscoder()
-
-
Method Details
-
encodeValues
@Nullable protected Object encodeValues(@Nullable ProfileRequestContext profileRequestContext, @Nonnull net.shibboleth.idp.attribute.IdPAttribute attribute, @Nonnull net.shibboleth.idp.attribute.transcoding.TranscodingRule rule) throws net.shibboleth.idp.attribute.AttributeEncodingException - Specified by:
encodeValuesin classAbstractOIDCAttributeTranscoder- Throws:
net.shibboleth.idp.attribute.AttributeEncodingException
-
decodeValues
@Nonnull @NonnullElements protected List<net.shibboleth.idp.attribute.IdPAttributeValue> decodeValues(@Nullable ProfileRequestContext profileRequestContext, @Nonnull Object input, @Nonnull net.shibboleth.idp.attribute.transcoding.TranscodingRule rule) throws net.shibboleth.idp.attribute.AttributeDecodingException - Specified by:
decodeValuesin classAbstractOIDCAttributeTranscoder- Throws:
net.shibboleth.idp.attribute.AttributeDecodingException
-
toJSONObject
@Nonnull private Object toJSONObject(@Nonnull @NotEmpty String value) throws net.shibboleth.idp.attribute.AttributeEncodingException Parses string as JSONObject.- Parameters:
value- string to parse- Returns:
- string parsed as JSONObject
- Throws:
net.shibboleth.idp.attribute.AttributeEncodingException- if parsing fails
-
transformValues
@Nonnull @NonnullElements @NotLive @Unmodifiable private List<?> transformValues(@Nonnull net.shibboleth.idp.attribute.transcoding.TranscodingRule rule, @Nonnull @NonnullElements Stream<String> attributeValues) Converts string values to List of Integer, String or Boolean depending on rule.- Parameters:
rule- transcoding ruleattributeValues- IdPAttribute values- Returns:
- list of String, Boolean or Integer objects
-