Class DefaultAuthenticationResultSerializer

  • All Implemented Interfaces:
    net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.InitializableComponent, org.opensaml.storage.StorageSerializer<net.shibboleth.idp.authn.AuthenticationResult>

    public class DefaultAuthenticationResultSerializer
    extends net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
    implements org.opensaml.storage.StorageSerializer<net.shibboleth.idp.authn.AuthenticationResult>
    Handles serialization of results, delegating handling of Principal objects to one or more PrincipalSerializer plugins.
    • Field Detail

      • AUTHN_INSTANT_FIELD

        @Nonnull
        @NotEmpty
        private static final String AUTHN_INSTANT_FIELD
        Field name of authentication instant.
        See Also:
        Constant Field Values
      • PRINCIPAL_ARRAY_FIELD

        @Nonnull
        @NotEmpty
        private static final String PRINCIPAL_ARRAY_FIELD
        Field name of principal array.
        See Also:
        Constant Field Values
      • PUB_CREDS_ARRAY_FIELD

        @Nonnull
        @NotEmpty
        private static final String PUB_CREDS_ARRAY_FIELD
        Field name of public credentials array.
        See Also:
        Constant Field Values
      • PRIV_CREDS_ARRAY_FIELD

        @Nonnull
        @NotEmpty
        private static final String PRIV_CREDS_ARRAY_FIELD
        Field name of private credentials array.
        See Also:
        Constant Field Values
      • ADDTL_DATA_FIELD

        @Nonnull
        @NotEmpty
        private static final String ADDTL_DATA_FIELD
        Field name of private credentials array.
        See Also:
        Constant Field Values
      • log

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

        @Nonnull
        private final javax.json.stream.JsonGeneratorFactory generatorFactory
        JSON generator factory.
      • readerFactory

        @Nonnull
        private final javax.json.JsonReaderFactory readerFactory
        JSON reader factory.
      • principalSerializers

        @Nonnull
        @NonnullElements
        private Collection<net.shibboleth.idp.authn.principal.PrincipalSerializer<String>> principalSerializers
        Principal serializers.
      • authnResultPrincipalSerializer

        @Nonnull
        private final AuthenticationResultPrincipalSerializer authnResultPrincipalSerializer
        Specialized serializer for AuthenticationResultPrincipal that requires a circular ref.
      • genericSerializer

        @Nonnull
        private final GenericPrincipalSerializer genericSerializer
        Generic principal serializer for any unsupported principals.
    • Constructor Detail

      • DefaultAuthenticationResultSerializer

        public DefaultAuthenticationResultSerializer()
        Constructor.
    • Method Detail

      • setPrincipalSerializers

        public void setPrincipalSerializers​(@Nonnull @NonnullElements
                                            Collection<net.shibboleth.idp.authn.principal.PrincipalSerializer<String>> serializers)
        Set the principal serializers used for principals found in the AuthenticationResult.
        Parameters:
        serializers - principal serializers to use
      • doInitialize

        public void doInitialize()
                          throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
        Overrides:
        doInitialize in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
        Throws:
        net.shibboleth.utilities.java.support.component.ComponentInitializationException
      • serialize

        @Nonnull
        @NotEmpty
        public String serialize​(@Nonnull
                                net.shibboleth.idp.authn.AuthenticationResult instance)
                         throws IOException
        Specified by:
        serialize in interface org.opensaml.storage.StorageSerializer<net.shibboleth.idp.authn.AuthenticationResult>
        Throws:
        IOException
      • deserialize

        @Nonnull
        public net.shibboleth.idp.authn.AuthenticationResult 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 org.opensaml.storage.StorageSerializer<net.shibboleth.idp.authn.AuthenticationResult>
        Throws:
        IOException
      • serializePrincipal

        private void serializePrincipal​(@Nonnull
                                        javax.json.stream.JsonGenerator generator,
                                        @Nonnull
                                        Principal principal)
                                 throws IOException
        Attempt to serialize a principal with the registered and default serializers.
        Parameters:
        generator - the JSON context to write into
        principal - object to serialize
        Throws:
        IOException - if serialization fails
      • deserializePrincipal

        @Nullable
        private Principal deserializePrincipal​(@Nonnull
                                               javax.json.JsonValue jsonValue)
                                        throws IOException
        Attempt to deserialize a principal with the registered and default serializers.
        Parameters:
        jsonValue - the JSON object to parse
        Returns:
        the Principal recovered, or null
        Throws:
        IOException - if an error occurs