Package net.shibboleth.idp.saml.attribute.transcoding

# Class AbstractSAMLAttributeTranscoder<AttributeType extends SAMLObject,EncodedType extends IdPAttributeValue>

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.transcoding.AbstractAttributeTranscoder<AttributeType>
net.shibboleth.idp.saml.attribute.transcoding.AbstractSAMLAttributeTranscoder<AttributeType,EncodedType>

Type Parameters:
  `AttributeType` - type of object produced
  `EncodedType` - the type of data that can be handled by the transcoder

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

Direct Known Subclasses:
  `AbstractSAML1AttributeTranscoder`, `AbstractSAML2AttributeTranscoder`, `AbstractSAML2NameIDTranscoder`

public abstract class AbstractSAMLAttributeTranscoder<AttributeType extends SAMLObject,EncodedType extends IdPAttributeValue> extends AbstractAttributeTranscoder<AttributeType>
Base class for transcoders that support SAML attributes.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.slf4j.Logger`
`log`
Class logger.

## Constructor Summary

Constructors
Constructor
Description
`AbstractSAMLAttributeTranscoder()`

## Method Summary

Modifier and Type
Method
Description
`protected abstract AttributeType`
`buildAttribute(ProfileRequestContext profileRequestContext, IdPAttribute attribute, Class<? extends AttributeType> to, TranscodingRule rule, List<XMLObject> attributeValues)`
Builds a SAML attribute element from the given attribute values.
`protected abstract IdPAttribute`
`buildIdPAttribute(ProfileRequestContext profileRequestContext, AttributeType attribute, TranscodingRule rule, List<IdPAttributeValue> attributeValues)`
Builds an `IdPAttribute` from the given values.
`protected abstract boolean`
`canEncodeValue(IdPAttribute idpAttribute, IdPAttributeValue value)`
Checks if the given value can be handled by the transcoder.
`protected abstract IdPAttributeValue`
`decodeValue(ProfileRequestContext profileRequestContext, AttributeType attribute, TranscodingRule rule, XMLObject value)`
Function to decode a single `XMLObject` into an `IdPAttributeValue`.
`IdPAttribute`
`doDecode(ProfileRequestContext profileRequestContext, AttributeType input, TranscodingRule rule)`
Decode the supplied object into a protocol-neutral representation.
`AttributeType`
`doEncode(ProfileRequestContext profileRequestContext, IdPAttribute attribute, Class<? extends AttributeType> to, TranscodingRule rule)`
Encode the supplied attribute into a protocol specific representation.
`protected abstract XMLObject`
`encodeValue(ProfileRequestContext profileRequestContext, IdPAttribute attribute, TranscodingRule rule, EncodedType value)`
Encodes an attribute value into a SAML AttributeValue element.
`protected String`
`getStringValue(XMLObject object)`
Function to return an XML object in string form.
`protected abstract Iterable<XMLObject>`
`getValues(AttributeType input)`
Returns the values to decode from the concrete input object.

### Methods inherited from class net.shibboleth.idp.attribute.transcoding.AbstractAttributeTranscoder

`decode, encode, getNameFromMetadata, setActivationCondition, setNameFromMetadataLookupStrategy`

### 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.

## Constructor Details

### AbstractSAMLAttributeTranscoder

public AbstractSAMLAttributeTranscoder()

## Method Details

### doEncode

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

Specified by:
  `doEncode` in class `AbstractAttributeTranscoder<AttributeType extends SAMLObject>`
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 public IdPAttribute doDecode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull AttributeType input, @Nonnull TranscodingRule rule) throws AttributeDecodingException
Decode the supplied object into a protocol-neutral representation.

Specified by:
  `doDecode` in class `AbstractAttributeTranscoder<AttributeType extends SAMLObject>`
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

### getStringValue

@Nullable protected String getStringValue(@Nullable XMLObject object)
Function to return an XML object in string form.

Parameters:
  `object` - object to decode
Returns:
  decoded string, or null

### canEncodeValue

protected abstract boolean canEncodeValue(@Nonnull IdPAttribute idpAttribute, @Nonnull IdPAttributeValue value)
Checks if the given value can be handled by the transcoder.

In many cases this is simply a check to see if the given object is of the right type.

Parameters:
  `idpAttribute` - the attribute being encoded, never null
  `value` - the value to check, never null
Returns:
  true if the transcoder can encode this value, false if not

### buildAttribute

@Nonnull protected abstract AttributeType buildAttribute(@Nullable ProfileRequestContext profileRequestContext, @Nullable IdPAttribute attribute, @Nonnull Class<? extends AttributeType> to, @Nonnull TranscodingRule rule, @Nonnull List<XMLObject> attributeValues) throws AttributeEncodingException
Builds a SAML attribute element from the given attribute values.

Parameters:
  `profileRequestContext` - current profile request
  `attribute` - the attribute being encoded
  `to` - target type to create
  `rule` - properties to control encoding
  `attributeValues` - the encoded values for the attribute
Returns:
  the SAML attribute object
Throws:
  `AttributeEncodingException` - thrown if there is a problem constructing the SAML attribute

### encodeValue

@Nullable protected abstract XMLObject encodeValue(@Nullable ProfileRequestContext profileRequestContext, @Nonnull IdPAttribute attribute, @Nonnull TranscodingRule rule, @Nonnull EncodedType value) throws AttributeEncodingException
Encodes an attribute value into a SAML AttributeValue element.

Parameters:
  `profileRequestContext` - current profile request
  `attribute` - the attribute being encoded
  `rule` - properties to control encoding
  `value` - the value to encode
Returns:
  the attribute value or null if the resulting attribute value would be empty
Throws:
  `AttributeEncodingException` - thrown if there is a problem encoding the attribute value

### buildIdPAttribute

@Nonnull protected abstract IdPAttribute buildIdPAttribute(@Nullable ProfileRequestContext profileRequestContext, @Nonnull AttributeType attribute, @Nonnull TranscodingRule rule, @Nonnull List<IdPAttributeValue> attributeValues) throws AttributeDecodingException
Builds an `IdPAttribute` from the given values.

Parameters:
  `profileRequestContext` - current profile request
  `attribute` - the attribute being decoded
  `rule` - properties to control decoding
  `attributeValues` - the decoded values for the attribute
Returns:
  the IdPAttribute object
Throws:
  `AttributeDecodingException` - thrown if there is a problem constructing the IdPAttribute

### getValues

@Nonnull protected abstract Iterable<XMLObject> getValues(@Nonnull AttributeType input)
Returns the values to decode from the concrete input object.

Parameters:
  `input` - input object
Returns:
  values to decode

### decodeValue

@Nullable protected abstract IdPAttributeValue decodeValue(@Nullable ProfileRequestContext profileRequestContext, @Nonnull AttributeType attribute, @Nonnull TranscodingRule rule, @Nullable XMLObject value)
Function to decode a single `XMLObject` into an `IdPAttributeValue`.

Parameters:
  `profileRequestContext` - current profile request
  `attribute` - the attribute being decoded
  `rule` - properties to control decoding
  `value` - the value to decode
Returns:
  the returned final `IdPAttributeValue` or null if decoding failed