Class AbstractOIDCAttributeTranscoder
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.transcoding.AbstractAttributeTranscoder<net.minidev.json.JSONObject>
net.shibboleth.oidc.attribute.transcoding.AbstractOIDCAttributeTranscoder
- All Implemented Interfaces:
AttributeTranscoder<net.minidev.json.JSONObject>,OIDCAttributeTranscoder,Component,DestructableComponent,InitializableComponent
- Direct Known Subclasses:
OIDCByteAttributeTranscoder,OIDCScopedStringAttributeTranscoder,OIDCStringAttributeTranscoder
public abstract class AbstractOIDCAttributeTranscoder
extends AbstractAttributeTranscoder<net.minidev.json.JSONObject>
implements OIDCAttributeTranscoder
Abstract class for OIDC attribute encoders.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA function to produce a "canonical" name for an OIDC claim for transcoding rules. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.slf4j.LoggerClass logger.private Function<ProfileRequestContext,Set<String>> Strategy to lookup naming overrides in metadata.Fields inherited from interface net.shibboleth.oidc.attribute.transcoding.OIDCAttributeTranscoder
METADATA_TAG_NAME, PROP_ARRAY_AS_STRING, PROP_ASARRAY, PROP_ASBOOLEAN, PROP_ASINTEGER, PROP_BOOLEAN_AS_STRING, PROP_NAME, PROP_NAME_FROM_METADATA, PROP_NUMBER_AS_STRING, PROP_STRING_DELIMITER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected net.minidev.json.JSONObjectbuildClaim(ProfileRequestContext profileRequestContext, IdPAttribute attribute, TranscodingRule rule, Object claimValues) Builds an OIDC claim structure with the given values.protected IdPAttributebuildIdPAttribute(ProfileRequestContext profileRequestContext, net.minidev.json.JSONObject claim, TranscodingRule rule, List<IdPAttributeValue> attributeValues) Builds anIdPAttributefrom the given values.protected abstract List<IdPAttributeValue>decodeValues(ProfileRequestContext profileRequestContext, Object input, TranscodingRule rule) Subclasses should override this method to perform specific claim value decoding intoIdPAttributeValueobjects.doDecode(ProfileRequestContext profileRequestContext, net.minidev.json.JSONObject input, TranscodingRule rule) net.minidev.json.JSONObjectdoEncode(ProfileRequestContext profileRequestContext, IdPAttribute attribute, Class<? extends net.minidev.json.JSONObject> to, TranscodingRule rule) protected abstract ObjectencodeValues(ProfileRequestContext profileRequestContext, IdPAttribute attribute, TranscodingRule rule) Performs encoding ofIdPAttribute's values based on rule into a claim value.protected StringgetEncodedName(ProfileRequestContext profileRequestContext, IdPAttribute attribute, TranscodingRule rule) Get the encoded name for the attribute via SAML metadata (if enabled) or rule's name property.Class<net.minidev.json.JSONObject>protected StringgetNameFromMetadata(ProfileRequestContext profileRequestContext, String attributeId) If enabled, search metadata for a tag value prefixed by the input attribute ID followed by a space character.voidSets lookup strategy for obtaining tag-based naming overrides from metadata.Methods 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
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
nameFromMetadataLookupStrategy
Strategy to lookup naming overrides in metadata.
-
-
Constructor Details
-
AbstractOIDCAttributeTranscoder
public AbstractOIDCAttributeTranscoder()
-
-
Method Details
-
getEncodedType
- Specified by:
getEncodedTypein interfaceAttributeTranscoder<net.minidev.json.JSONObject>
-
setNameFromMetadataLookupStrategy
public void setNameFromMetadataLookupStrategy(@Nullable Function<ProfileRequestContext, Set<String>> strategy) Sets lookup strategy for obtaining tag-based naming overrides from metadata.- Parameters:
strategy- lookup strategy- Since:
- 3.1.0
-
getEncodedName
- Specified by:
getEncodedNamein interfaceAttributeTranscoder<net.minidev.json.JSONObject>
-
doEncode
@Nullable public net.minidev.json.JSONObject doEncode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull IdPAttribute attribute, @Nonnull Class<? extends net.minidev.json.JSONObject> to, @Nonnull TranscodingRule rule) throws AttributeEncodingException - Specified by:
doEncodein classAbstractAttributeTranscoder<net.minidev.json.JSONObject>- Throws:
AttributeEncodingException
-
buildClaim
@Nonnull protected net.minidev.json.JSONObject buildClaim(@Nullable ProfileRequestContext profileRequestContext, @Nullable IdPAttribute attribute, @Nonnull TranscodingRule rule, @Nullable Object claimValues) throws AttributeEncodingException Builds an OIDC claim structure with the given values.- Parameters:
profileRequestContext- current profile request contextattribute- the attribute being encodedrule- properties to control encodingclaimValues- the encoded value(s) for the claim- Returns:
- the OIDC claim (for the moment in the form of a single-valued JSON structure
- Throws:
AttributeEncodingException- if there's a problem constructing the claim
-
getEncodedName
protected String getEncodedName(@Nullable ProfileRequestContext profileRequestContext, @Nullable IdPAttribute attribute, @Nonnull TranscodingRule rule) throws AttributeEncodingException Get the encoded name for the attribute via SAML metadata (if enabled) or rule's name property.- Parameters:
profileRequestContext- current profile request contextattribute- the attribute being encodedrule- properties to control encoding- Returns:
- the name of the OIDC claim
- Throws:
AttributeEncodingException- if there's a problem constructing the name
-
encodeValues
@Nullable protected abstract Object encodeValues(@Nullable ProfileRequestContext profileRequestContext, @Nonnull IdPAttribute attribute, @Nonnull TranscodingRule rule) throws AttributeEncodingException Performs encoding ofIdPAttribute's values based on rule into a claim value.- Parameters:
profileRequestContext- current profile requestattribute- the attribute being encodedrule- properties to control encoding- Returns:
- Integer, Boolean, String, JSON Array or JSON Object value for claim
- Throws:
AttributeEncodingException- if there's a problem encoding the values
-
doDecode
@Nullable public IdPAttribute doDecode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull net.minidev.json.JSONObject input, @Nonnull TranscodingRule rule) throws AttributeDecodingException - Specified by:
doDecodein classAbstractAttributeTranscoder<net.minidev.json.JSONObject>- Throws:
AttributeDecodingException
-
buildIdPAttribute
@Nonnull protected IdPAttribute buildIdPAttribute(@Nullable ProfileRequestContext profileRequestContext, @Nonnull net.minidev.json.JSONObject claim, @Nonnull TranscodingRule rule, @Nonnull List<IdPAttributeValue> attributeValues) throws AttributeDecodingException Builds anIdPAttributefrom the given values.- Parameters:
profileRequestContext- current profile requestclaim- the claim being decodedrule- properties to control decodingattributeValues- the decoded values for the attribute- Returns:
- the IdPAttribute object
- Throws:
AttributeDecodingException- if there's a problem constructing the IdPAttribute
-
decodeValues
@Nonnull protected abstract List<IdPAttributeValue> decodeValues(@Nullable ProfileRequestContext profileRequestContext, @Nonnull Object input, @Nonnull TranscodingRule rule) throws AttributeDecodingException Subclasses should override this method to perform specific claim value decoding intoIdPAttributeValueobjects.- Parameters:
profileRequestContext- current profile request contextinput- the raw claim valuerule- properties to control decoding- Returns:
- a possibly empty list of decoded values
- Throws:
AttributeDecodingException- if there's a problem decoding the claim value
-
getNameFromMetadata
@Nullable protected String getNameFromMetadata(@Nullable ProfileRequestContext profileRequestContext, @Nonnull String attributeId) If enabled, search metadata for a tag value prefixed by the input attribute ID followed by a space character.The remaining portion of the value will be interpreted in a protocol-specific way.
- Parameters:
profileRequestContext- profile request contextattributeId- attribute ID- Returns:
- the first matching tag value from the installed lookup function
- Since:
- 3.1.0
-