Package net.shibboleth.idp.cas.attribute
Class AbstractCASAttributeTranscoder<EncodedType extends IdPAttributeValue>
java.lang.Object
net.shibboleth.utilities.java.support.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:
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 CASAttribute
for transcoding rules. -
Field Summary
Fields Modifier and Type Field Description private org.slf4j.Logger
log
Class logger.Fields inherited from interface net.shibboleth.idp.cas.attribute.CASAttributeTranscoder
PROP_NAME
-
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 anIdPAttribute
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 anIdPAttributeValue
.IdPAttribute
doDecode(ProfileRequestContext profileRequestContext, Attribute input, TranscodingRule rule)
Decode the supplied object into a protocol-neutral representation.Attribute
doEncode(ProfileRequestContext profileRequestContext, IdPAttribute attribute, Class<? extends Attribute> to, TranscodingRule rule)
Encode the supplied attribute into a protocol specific representation.protected abstract String
encodeValue(ProfileRequestContext profileRequestContext, IdPAttribute attribute, TranscodingRule rule, EncodedType value)
Encodes an attribute value into a string.String
getEncodedName(TranscodingRule rule)
Get the name of the encoded object that would be created by a given set of instructions.Class<Attribute>
getEncodedType()
Get the class representing the type of object supported by this transcoder.Methods inherited from class net.shibboleth.idp.attribute.transcoding.AbstractAttributeTranscoder
decode, encode, setActivationCondition
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, doInitialize, 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.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger.
-
-
Constructor Details
-
AbstractCASAttributeTranscoder
public AbstractCASAttributeTranscoder()
-
-
Method Details
-
getEncodedType
Get the class representing the type of object supported by this transcoder.- Specified by:
getEncodedType
in interfaceAttributeTranscoder<EncodedType extends IdPAttributeValue>
- Returns:
- object type supported
-
getEncodedName
Get the name of the encoded object that would be created by a given set of instructions.- Specified by:
getEncodedName
in interfaceAttributeTranscoder<EncodedType extends IdPAttributeValue>
- Parameters:
rule
- properties governing the encoding process- Returns:
- a canonical name for objects produced by this transcoder for the given instructions
-
doEncode
@Nullable public Attribute doEncode(@Nullable ProfileRequestContext profileRequestContext, @Nonnull IdPAttribute attribute, @Nonnull Class<? extends Attribute> to, @Nonnull TranscodingRule rule) throws AttributeEncodingExceptionEncode the supplied attribute into a protocol specific representation.- Specified by:
doEncode
in classAbstractAttributeTranscoder<Attribute>
- Parameters:
profileRequestContext
- current profile request contextattribute
- the attribute to encodeto
- specific type of object to encoderule
- 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 Attribute input, @Nonnull TranscodingRule rule) throws AttributeDecodingExceptionDecode the supplied object into a protocol-neutral representation.- Specified by:
doDecode
in classAbstractAttributeTranscoder<Attribute>
- Parameters:
profileRequestContext
- current profile request contextinput
- the object to decoderule
- 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
-
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 nullvalue
- 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 AttributeEncodingExceptionEncodes an attribute value into a string.- Parameters:
profileRequestContext
- current profile requestattribute
- the attribute being encodedrule
- properties to control encodingvalue
- 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 @NonnullElements List<IdPAttributeValue> attributeValues) throws AttributeDecodingExceptionBuilds anIdPAttribute
from the given values.- Parameters:
profileRequestContext
- current profile requestattribute
- the attribute being decodedrule
- properties to control decodingattributeValues
- 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 anIdPAttributeValue
.- Parameters:
profileRequestContext
- current profile requestattribute
- the attribute being decodedrule
- properties to control decodingvalue
- the value to decode- Returns:
- the returned final
IdPAttributeValue
or null if decoding failed
-