Package net.shibboleth.idp.attribute.transcoding

# Class AbstractAttributeTranscoder<T>

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.transcoding.AbstractAttributeTranscoder<T>

Type Parameters:
  `T` - type of object supported

All Implemented Interfaces:
  `AttributeTranscoder<T>`, `Component`, `DestructableComponent`, `InitializableComponent`

Direct Known Subclasses:
  `AbstractSAMLAttributeTranscoder`

public abstract class AbstractAttributeTranscoder<T> extends AbstractInitializableComponent implements AttributeTranscoder<T>
Base class for transcoders.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Predicate<ProfileRequestContext>`
`activationCondition`
Condition for use of this transcoder.
`private final org.slf4j.Logger`
`log`
Class logger.
`private Function<ProfileRequestContext,Set<String>>`
`nameFromMetadataLookupStrategy`
Strategy to lookup naming overrides in metadata.

## Constructor Summary

Constructors
Constructor
Description
`AbstractAttributeTranscoder()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`private boolean`
`checkActivation(ProfileRequestContext profileRequestContext, TranscodingRule rule)`
Apply any activation rules to the request.
`IdPAttribute`
`decode(ProfileRequestContext profileRequestContext, T input, TranscodingRule rule)`
Decode the supplied object into a protocol-neutral representation.
`protected abstract IdPAttribute`
`doDecode(ProfileRequestContext profileRequestContext, T input, TranscodingRule rule)`
Decode the supplied object into a protocol-neutral representation.
`protected abstract T`
`doEncode(ProfileRequestContext profileRequestContext, IdPAttribute attribute, Class<? extends T> to, TranscodingRule rule)`
Encode the supplied attribute into a protocol specific representation.
`T`
`encode(ProfileRequestContext profileRequestContext, IdPAttribute attribute, Class<? extends T> to, TranscodingRule rule)`
Encode the supplied attribute into a protocol specific representation.
`protected String`
`getNameFromMetadata(ProfileRequestContext profileRequestContext, String attributeId)`
If enabled, search metadata for a tag value prefixed by the input attribute ID followed by a space character.
`void`
`setActivationCondition(Predicate<ProfileRequestContext> condition)`
Set an activation condition for this transcoder.
`void`
`setNameFromMetadataLookupStrategy(Function<ProfileRequestContext,Set<String>> strategy)`
Sets lookup strategy for obtaining tag-based naming overrides from metadata.

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface net.shibboleth.idp.attribute.transcoding.AttributeTranscoder

`getEncodedName, getEncodedType`

### Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

`initialize, isInitialized`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### activationCondition

@Nonnull private Predicate<ProfileRequestContext> activationCondition
Condition for use of this transcoder.

### nameFromMetadataLookupStrategy

@Nullable private Function<ProfileRequestContext,Set<String>> nameFromMetadataLookupStrategy
Strategy to lookup naming overrides in metadata.

## Constructor Details

### AbstractAttributeTranscoder

public AbstractAttributeTranscoder()
Constructor.

## Method Details

### setActivationCondition

public void setActivationCondition(@Nonnull Predicate<ProfileRequestContext> condition)
Set an activation condition for this transcoder.

Parameters:
  `condition` - condition to set

### 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:
  5.1.0

### encode

@Nullable public T encode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull IdPAttribute attribute, @Nonnull Class<? extends T> to, @Nonnull TranscodingRule rule) throws AttributeEncodingException
Encode the supplied attribute into a protocol specific representation.

Specified by:
  `encode` in interface `AttributeTranscoder<T>`
Parameters:
  `profileRequestContext` - current profile request context
  `attribute` - the attribute to encode
  `to` - specific type of object to encode
  `rule` - properties governing the encoding process, principally the resulting object's naming
Returns:
  the Object the attribute was encoded into
Throws:
  `AttributeEncodingException` - if unable to successfully encode attribute

### decode

@Nullable public IdPAttribute decode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull T input, @Nonnull TranscodingRule rule) throws AttributeDecodingException
Decode the supplied object into a protocol-neutral representation.

Specified by:
  `decode` in interface `AttributeTranscoder<T>`
Parameters:
  `profileRequestContext` - current profile request context
  `input` - the object to decode
  `rule` - properties governing the decoding process, principally the resulting attribute's naming
Returns:
  the attribute the object was decoded into
Throws:
  `AttributeDecodingException` - if unable to successfully decode object

### 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 context
  `attributeId` - attribute ID
Returns:
  the first matching tag value from the installed lookup function
Since:
  5.1.0

### doEncode

@Nullable protected abstract T doEncode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull IdPAttribute attribute, @Nonnull Class<? extends T> to, @Nonnull TranscodingRule rule) throws AttributeEncodingException
Encode the supplied attribute into a protocol specific representation.

Parameters:
  `profileRequestContext` - current profile request context
  `attribute` - the attribute to encode
  `to` - specific type of object to encode
  `rule` - properties governing the encoding process, principally the resulting object's naming
Returns:
  the Object the attribute was encoded into
Throws:
  `AttributeEncodingException` - if unable to successfully encode attribute

### doDecode

@Nullable protected abstract IdPAttribute doDecode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull T input, @Nonnull TranscodingRule rule) throws AttributeDecodingException
Decode the supplied object into a protocol-neutral representation.

Parameters:
  `profileRequestContext` - current profile request context
  `input` - the object to decode
  `rule` - properties governing the decoding process, principally the resulting attribute's naming
Returns:
  the attribute the object was decoded into
Throws:
  `AttributeDecodingException` - if unable to successfully decode object

### checkActivation

private boolean checkActivation(@Nullable ProfileRequestContext profileRequestContext, @Nonnull TranscodingRule rule)
Apply any activation rules to the request.

Parameters:
  `profileRequestContext` - current profile request context
  `rule` - properties governing the transoding process
Returns:
  true iff the process should continue