Class AbstractSPSessionSerializer

All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, StorageSerializer<SPSession>
Direct Known Subclasses:
BasicSPSessionSerializer, CASSPSessionSerializer, SAML1SPSessionSerializer, SAML2SPSessionSerializer

@ThreadSafe public abstract class AbstractSPSessionSerializer extends AbstractInitializableComponent implements StorageSerializer<SPSession>
Base class for SPSession serializers that handles data common to all such objects.
  • Field Details


      @Nonnull @NotEmpty private static final String SERVICE_ID_FIELD
      Field name of service ID.
      See Also:

      @Nonnull @NotEmpty private static final String CREATION_INSTANT_FIELD
      Field name of creation instant.
      See Also:
    • log

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

      @Nonnull private final Duration expirationOffset
      Milliseconds to subtract from record expiration to establish session expiration value.
  • Constructor Details

    • AbstractSPSessionSerializer

      protected AbstractSPSessionSerializer(@Nonnull Duration offset)
      offset - time to subtract from record expiration to establish session expiration value
  • Method Details

    • serialize

      @Nonnull @NotEmpty public String serialize(@Nonnull SPSession instance) throws IOException
      Specified by:
      serialize in interface StorageSerializer<SPSession>
    • deserialize

      @Nonnull public SPSession deserialize(long version, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable Long expiration) throws IOException
      Specified by:
      deserialize in interface StorageSerializer<SPSession>
    • doSerializeAdditional

      protected void doSerializeAdditional(@Nonnull SPSession instance, @Nonnull generator)
      Override this method to handle serialization of additional data.

      The serialization "context" is the continuation of a JSON struct.

      instance - object to serialize
      generator - JSON generator to write to
    • doDeserialize

      @Nonnull protected abstract SPSession doDeserialize(@Nonnull javax.json.JsonObject obj, @Nonnull @NotEmpty String id, @Nonnull Instant creation, @Nonnull Instant expiration) throws IOException
      Implement this method to return the appropriate type of object, populated with the basic information supplied.

      The JSON object supplied is a structure that may contain additional data created by the concrete subclass during serialization.

      obj - JSON structure to parse
      id - the identifier of the service associated with this session
      creation - creation time of session
      expiration - expiration time of session
      the newly constructed object
      IOException - if an error occurs during deserialization