Class GenericPrincipalSerializer
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.idp.authn.principal.AbstractPrincipalSerializer<String>
net.shibboleth.idp.authn.principal.GenericPrincipalSerializer
- All Implemented Interfaces:
PrincipalSerializer<String>
,Component
,DestructableComponent
,InitializableComponent
@ThreadSafeAfterInit public class GenericPrincipalSerializer extends AbstractPrincipalSerializer<String>
Principal serializer for arbitrary principal types.
- Since:
- 4.1.0
-
Field Summary
Fields Modifier and Type Field Description private Set<Class<? extends Principal>>
compatiblePrincipalTypes
A cache of Principal types that support string-based construction.private static Pattern
JSON_PATTERN
Pattern used to determine if input is supported.private org.slf4j.Logger
log
Class logger.private static String
PRINCIPAL_NAME_FIELD
Field name of principal name.private static String
PRINCIPAL_TYPE_FIELD
Field name of principal type.private BiMap<String,Integer>
symbolics
Shrinkage of long constants into symbolic numbers. -
Constructor Summary
Constructors Constructor Description GenericPrincipalSerializer()
Constructor. -
Method Summary
Modifier and Type Method Description Principal
deserialize(String value)
Deserialize the supplied value.protected String
desymbolize(javax.json.JsonValue field)
Map a field value to a string, either directly or via the symbolic map.String
serialize(Principal principal)
Serialize the supplied principal.void
setSymbolics(Map<String,Integer> mappings)
Sets mappings of string constants to symbolic constants.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
-
PRINCIPAL_TYPE_FIELD
Field name of principal type.- See Also:
- Constant Field Values
-
PRINCIPAL_NAME_FIELD
Field name of principal name.- See Also:
- Constant Field Values
-
JSON_PATTERN
Pattern used to determine if input is supported. -
log
@Nonnull private final org.slf4j.Logger logClass logger. -
symbolics
Shrinkage of long constants into symbolic numbers. -
compatiblePrincipalTypes
A cache of Principal types that support string-based construction.
-
-
Constructor Details
-
GenericPrincipalSerializer
public GenericPrincipalSerializer()Constructor.
-
-
Method Details
-
setSymbolics
Sets mappings of string constants to symbolic constants.- Parameters:
mappings
- string to symbolic mappings
-
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
-
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
-
desymbolize
Map a field value to a string, either directly or via the symbolic map.- Parameters:
field
- the object field to examine- Returns:
- the resulting string, or null if invalid
-