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
Fields Modifier and Type Field Description private static String
ADDTL_DATA_FIELD
Field name of private credentials array.private static String
AUTHN_INSTANT_FIELD
Field name of authentication instant.private AuthenticationResultPrincipalSerializer
authnResultPrincipalSerializer
Specialized serializer forAuthenticationResultPrincipal
that requires a circular ref.private static String
FLOW_ID_FIELD
Field name of Flow ID.private javax.json.stream.JsonGeneratorFactory
generatorFactory
JSON generator factory.private GenericPrincipalSerializer
genericSerializer
Generic principal serializer for any unsupported principals.private org.slf4j.Logger
log
Class logger.private static String
PRINCIPAL_ARRAY_FIELD
Field name of principal array.private Collection<PrincipalSerializer<String>>
principalSerializers
Principal serializers.private PrincipalServiceManager
principalServiceManager
Manager for principal services.private static String
PRIV_CREDS_ARRAY_FIELD
Field name of private credentials array.private static String
PUB_CREDS_ARRAY_FIELD
Field name of public credentials array.private javax.json.JsonReaderFactory
readerFactory
JSON reader factory.private static String
X509_CREDS_ARRAY_FIELD
Field name of X.509 certificates array. -
Constructor Summary
Constructors Constructor Description DefaultAuthenticationResultSerializer()
Constructor.DefaultAuthenticationResultSerializer(PrincipalServiceManager manager, GenericPrincipalSerializer defaultSerializer)
Constructor. -
Method Summary
Modifier and Type Method Description AuthenticationResult
deserialize(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
doInitialize()
GenericPrincipalSerializer
getGenericPrincipalSerializer()
Returns theGenericPrincipalSerializer
used for any unsupported principals found in theAuthenticationResult
.String
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:
- Constant Field Values
-
AUTHN_INSTANT_FIELD
Field name of authentication instant.- See Also:
- Constant Field Values
-
PRINCIPAL_ARRAY_FIELD
Field name of principal array.- See Also:
- Constant Field Values
-
PUB_CREDS_ARRAY_FIELD
Field name of public credentials array.- See Also:
- Constant Field Values
-
X509_CREDS_ARRAY_FIELD
Field name of X.509 certificates array.- See Also:
- Constant Field Values
-
PRIV_CREDS_ARRAY_FIELD
Field name of private credentials array.- See Also:
- Constant Field Values
-
ADDTL_DATA_FIELD
Field name of private credentials array.- See Also:
- Constant Field Values
-
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 IOExceptionAttempt 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 IOExceptionAttempt 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
-