Package net.shibboleth.idp.authn.impl
Class DefaultAuthenticationResultSerializer
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.idp.authn.impl.DefaultAuthenticationResultSerializer
- All Implemented Interfaces:
Component
,DestructableComponent
,InitializableComponent
,StorageSerializer<AuthenticationResult>
public class DefaultAuthenticationResultSerializer
extends AbstractInitializableComponent
implements StorageSerializer<AuthenticationResult>
Handles serialization of results, delegating handling of
Principal
objects to one or more
PrincipalSerializer
plugins.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
Field name of private credentials array.private static final String
Field name of authentication instant.private final AuthenticationResultPrincipalSerializer
Specialized serializer forAuthenticationResultPrincipal
that requires a circular ref.private static final String
Field name of Flow ID.private final javax.json.stream.JsonGeneratorFactory
JSON generator factory.private final GenericPrincipalSerializer
Generic principal serializer for any unsupported principals.private final org.slf4j.Logger
Class logger.private static final String
Field name of principal array.private Collection<PrincipalSerializer<String>>
Principal serializers.private final PrincipalServiceManager
Manager for principal services.private static final String
Field name of private credentials array.private static final String
Field name of public credentials array.private final javax.json.JsonReaderFactory
JSON reader factory.private static final String
Field name of X.509 certificates array. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.DefaultAuthenticationResultSerializer
(PrincipalServiceManager manager, GenericPrincipalSerializer defaultSerializer) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(long version, String context, String key, String value, Long expiration) private Principal
deserializePrincipal
(javax.json.JsonValue jsonValue) Attempt to deserialize a principal with the registered and default serializers.void
Returns theGenericPrincipalSerializer
used for any unsupported principals found in theAuthenticationResult
.serialize
(AuthenticationResult instance) private void
serializePrincipal
(javax.json.stream.JsonGenerator generator, Principal principal) Attempt to serialize a principal with the registered and default serializers.Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, 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.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
FLOW_ID_FIELD
Field name of Flow ID.- See Also:
-
AUTHN_INSTANT_FIELD
Field name of authentication instant.- See Also:
-
PRINCIPAL_ARRAY_FIELD
Field name of principal array.- See Also:
-
PUB_CREDS_ARRAY_FIELD
Field name of public credentials array.- See Also:
-
X509_CREDS_ARRAY_FIELD
Field name of X.509 certificates array.- See Also:
-
PRIV_CREDS_ARRAY_FIELD
Field name of private credentials array.- See Also:
-
ADDTL_DATA_FIELD
Field name of private credentials array.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
generatorFactory
@Nonnull private final javax.json.stream.JsonGeneratorFactory generatorFactoryJSON generator factory. -
readerFactory
@Nonnull private final javax.json.JsonReaderFactory readerFactoryJSON reader factory. -
principalServiceManager
Manager for principal services. -
principalSerializers
Principal serializers. -
authnResultPrincipalSerializer
Specialized serializer forAuthenticationResultPrincipal
that requires a circular ref. -
genericSerializer
Generic principal serializer for any unsupported principals.
-
-
Constructor Details
-
DefaultAuthenticationResultSerializer
Constructor.This is mostly left to facilitate tests that can live with essentially no real serialization support.
- Throws:
ComponentInitializationException
- if unable to instantiate internal defaults
-
DefaultAuthenticationResultSerializer
public DefaultAuthenticationResultSerializer(@Nonnull PrincipalServiceManager manager, @Nonnull GenericPrincipalSerializer defaultSerializer) Constructor.- Parameters:
manager
-PrincipalServiceManager
to usedefaultSerializer
- the default serializer to use- Since:
- 4.1.0
-
-
Method Details
-
getGenericPrincipalSerializer
Returns theGenericPrincipalSerializer
used for any unsupported principals found in theAuthenticationResult
.- Returns:
- generic principal serializer
-
doInitialize
- Overrides:
doInitialize
in classAbstractInitializableComponent
- Throws:
ComponentInitializationException
-
serialize
@Nonnull @NotEmpty public String serialize(@Nonnull AuthenticationResult instance) throws IOException - Specified by:
serialize
in interfaceStorageSerializer<AuthenticationResult>
- Throws:
IOException
-
deserialize
@Nonnull public 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 interfaceStorageSerializer<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 intoprincipal
- 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
-