Class SimplePrincipalSerializer<T extends Principal>
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.idp.authn.principal.AbstractPrincipalSerializer<String>
net.shibboleth.idp.authn.principal.SimplePrincipalSerializer<T>
- Type Parameters:
T
- principal type
- All Implemented Interfaces:
PrincipalSerializer<String>
,Component
,DestructableComponent
,InitializableComponent
- Direct Known Subclasses:
SealedPrincipalSerializer
@ThreadSafe public class SimplePrincipalSerializer<T extends Principal> extends AbstractPrincipalSerializer<String>
Principal serializer for string-based principals that serialize to a simple JSON structure.
- Since:
- 4.1.0
-
Field Summary
Fields Modifier and Type Field Description private Constructor<T>
ctor
Constructor.private String
fieldName
Field name.private Pattern
jsonPattern
Pattern used to determine if input is supported.private org.slf4j.Logger
log
Class logger.private Class<T>
principalType
Principal type. -
Constructor Summary
Constructors Constructor Description SimplePrincipalSerializer(Class<T> claz, String name)
Constructor. -
Method Summary
Modifier and Type Method Description T
deserialize(String value)
Deserialize the supplied value.protected String
getName(String serializedName)
Return the appropriate value to create thePrincipal
around based on the serialized form.protected String
getName(Principal principal)
Return the appropriate value to serialize from the input object.String
serialize(Principal principal)
Serialize the supplied principal.boolean
supports(String value)
Whether the supplied value can be deserialized.boolean
supports(Principal principal)
Whether the supplied principal can be serialized.Methods inherited from class net.shibboleth.idp.authn.principal.AbstractPrincipalSerializer
getJsonGenerator, getJsonReader
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, doInitialize, 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
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
principalType
Principal type. -
ctor
Constructor. -
fieldName
Field name. -
jsonPattern
Pattern used to determine if input is supported.
-
-
Constructor Details
-
SimplePrincipalSerializer
public SimplePrincipalSerializer(@Nonnull @ParameterName(name="claz") Class<T> claz, @Nonnull @NotEmpty @ParameterName(name="name") String name) throws NoSuchMethodException, SecurityExceptionConstructor.- Parameters:
claz
- principal typename
- field name of JSON structure- Throws:
SecurityException
- if the constructor cannot be accessedNoSuchMethodException
- if the constructor does not exist
-
-
Method Details
-
supports
Whether the supplied principal can be serialized.- Parameters:
principal
- to examine- Returns:
- whether principal can be serialized
-
serialize
Serialize the supplied principal.- Parameters:
principal
- to serialize- Returns:
- serialized value
- Throws:
IOException
- if an error occurs during serialization
-
getName
Return the appropriate value to serialize from the input object.- Parameters:
principal
- input object- Returns:
- the value to serialize.
- Throws:
IOException
- if an error occurs
-
supports
Whether the supplied value can be deserialized.- Parameters:
value
- to examine- Returns:
- whether value can be deserialized
-
deserialize
Deserialize the supplied value.- Parameters:
value
- to deserialize- Returns:
- principal
- Throws:
IOException
- if an error occurs during deserialization
-
getName
Return the appropriate value to create thePrincipal
around based on the serialized form.- Parameters:
serializedName
- the value in the serialization.- Returns:
- the transformed value
- Throws:
IOException
- if an error occurs
-