Class AbstractCASAttributeTranscoder<EncodedType extends IdPAttributeValue>

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.
  • 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()
      Get the class representing the type of object supported by this transcoder.
      Specified by:
      getEncodedType in interface AttributeTranscoder<EncodedType extends IdPAttributeValue>
      Returns:
      object type supported
    • getEncodedName

      @Nullable public String getEncodedName​(@Nonnull TranscodingRule rule)
      Get the name of the encoded object that would be created by a given set of instructions.
      Specified by:
      getEncodedName in interface AttributeTranscoder<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 AttributeEncodingException
      Encode the supplied attribute into a protocol specific representation.
      Specified by:
      doEncode in class AbstractAttributeTranscoder<Attribute>
      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 Attribute input, @Nonnull TranscodingRule rule) throws AttributeDecodingException
      Decode the supplied object into a protocol-neutral representation.
      Specified by:
      doDecode in class AbstractAttributeTranscoder<Attribute>
      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
    • 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 @NonnullElements 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