Package net.shibboleth.idp.cas.attribute

# Class AbstractCASAttributeTranscoder<EncodedType extends IdPAttributeValue>

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.transcoding.AbstractAttributeTranscoder<Attribute>
net.shibboleth.idp.cas.attribute.AbstractCASAttributeTranscoder<EncodedType>

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

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

Direct Known Subclasses:
  `CASDateTimeAttributeTranscoder`, `CASScopedStringAttributeTranscoder`, `CASStringAttributeTranscoder`

public abstract class AbstractCASAttributeTranscoder<EncodedType extends IdPAttributeValue> extends AbstractAttributeTranscoder<Attribute> implements CASAttributeTranscoder
Base class for transcoders that support CAS attributes.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`AbstractCASAttributeTranscoder.NamingFunction`
A function to produce a "canonical" name for a CAS `Attribute` for transcoding rules.

## Field Summary

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

### Fields inherited from interface net.shibboleth.idp.cas.attribute.CASAttributeTranscoder

`METADATA_TAG_NAME, PROP_NAME, PROP_NAME_FROM_METADATA`

## Constructor Summary

Constructors
Constructor
Description
`AbstractCASAttributeTranscoder()`

## Method Summary

Modifier and Type
Method
Description
`protected IdPAttribute`
`buildIdPAttribute(ProfileRequestContext profileRequestContext, Attribute 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, Attribute attribute, TranscodingRule rule, String value)`
Function to decode a single string value into an `IdPAttributeValue`.
`IdPAttribute`
`doDecode(ProfileRequestContext profileRequestContext, Attribute input, TranscodingRule rule)`
`Attribute`
`doEncode(ProfileRequestContext profileRequestContext, IdPAttribute attribute, Class<? extends Attribute> to, TranscodingRule rule)`
`protected abstract String`
`encodeValue(ProfileRequestContext profileRequestContext, IdPAttribute attribute, TranscodingRule rule, EncodedType value)`
Encodes an attribute value into a string.
`String`
`getEncodedName(TranscodingRule rule)`
`protected String`
`getEncodedName(ProfileRequestContext profileRequestContext, IdPAttribute attribute, TranscodingRule rule)`
Obtain the encoded name of the CAS Attribute either from metadata or statically.
`Class<Attribute>`
`getEncodedType()`

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

`decode, encode`

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

### AbstractCASAttributeTranscoder

public AbstractCASAttributeTranscoder()

## Method Details

### getEncodedType

@Nonnull public Class<Attribute> getEncodedType()

Specified by:
  `getEncodedType` in interface `AttributeTranscoder<EncodedType extends IdPAttributeValue>`

### getEncodedName

@Nullable public String getEncodedName(@Nonnull TranscodingRule rule)

Specified by:
  `getEncodedName` in interface `AttributeTranscoder<EncodedType extends IdPAttributeValue>`

### doEncode

@Nullable public Attribute doEncode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull IdPAttribute attribute, @Nonnull Class<? extends Attribute> to, @Nonnull TranscodingRule rule) throws AttributeEncodingException

Specified by:
  `doEncode` in class `AbstractAttributeTranscoder<Attribute>`
Throws:
  `AttributeEncodingException`

### doDecode

@Nullable public IdPAttribute doDecode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull Attribute input, @Nonnull TranscodingRule rule) throws AttributeDecodingException

Specified by:
  `doDecode` in class `AbstractAttributeTranscoder<Attribute>`
Throws:
  `AttributeDecodingException`

### getEncodedName

@Nonnull protected String getEncodedName(@Nullable ProfileRequestContext profileRequestContext, @Nonnull IdPAttribute attribute, @Nonnull TranscodingRule rule)
Obtain the encoded name of the CAS Attribute either from metadata or statically.

With CAS, there's always a name to use because it will fallback to using the attribute ID.

Parameters:
  `profileRequestContext` - profile request context
  `attribute` - attribute to encode
  `rule` - trancoding rule
Returns:
  the encoded name
Since:
  5.1.0

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

### encodeValue

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

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 IdPAttribute buildIdPAttribute(@Nullable ProfileRequestContext profileRequestContext, @Nonnull Attribute 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

### decodeValue

@Nullable protected abstract IdPAttributeValue decodeValue(@Nullable ProfileRequestContext profileRequestContext, @Nonnull Attribute attribute, @Nonnull TranscodingRule rule, @Nullable String value)
Function to decode a single string value 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