Package net.shibboleth.idp.authn.impl
Class DefaultAuthenticationResultSerializer
java.lang.Object
net.shibboleth.shared.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 StringField name of private credentials array.private static final StringField name of authentication instant.private final AuthenticationResultPrincipalSerializerSpecialized serializer forAuthenticationResultPrincipalthat requires a circular ref.private static final StringField name of Flow ID.private final JsonGeneratorFactoryJSON generator factory.private final GenericPrincipalSerializerGeneric principal serializer for any unsupported principals.private final org.slf4j.LoggerClass logger.private static final StringField name of principal array.private Collection<PrincipalSerializer<String>>Principal serializers.private final PrincipalServiceManagerManager for principal services.private static final StringField name of private credentials array.private static final StringField name of public credentials array.private final JsonReaderFactoryJSON reader factory.private static final StringField 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 PrincipaldeserializePrincipal(JsonValue jsonValue) Attempt to deserialize a principal with the registered and default serializers.voidReturns theGenericPrincipalSerializerused for any unsupported principals found in theAuthenticationResult.serialize(AuthenticationResult instance) private voidserializePrincipal(JsonGenerator generator, Principal principal) Attempt to serialize a principal with the registered and default serializers.Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.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
JSON generator factory. -
readerFactory
JSON reader factory. -
principalServiceManager
Manager for principal services. -
principalSerializers
Principal serializers. -
authnResultPrincipalSerializer
Specialized serializer forAuthenticationResultPrincipalthat 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-PrincipalServiceManagerto usedefaultSerializer- the default serializer to use- Since:
- 4.1.0
-
-
Method Details
-
getGenericPrincipalSerializer
Returns theGenericPrincipalSerializerused for any unsupported principals found in theAuthenticationResult.- Returns:
- generic principal serializer
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
serialize
@Nonnull @NotEmpty public String serialize(@Nonnull AuthenticationResult instance) throws IOException - Specified by:
serializein 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:
deserializein interfaceStorageSerializer<AuthenticationResult>- Throws:
IOException
-
serializePrincipal
private void serializePrincipal(@Nonnull 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
Attempt to deserialize a principal with the registered and default serializers.- Parameters:
jsonValue- the JSON object to parse- Returns:
- the
Principalrecovered, or null - Throws:
IOException- if an error occurs
-