Package com.macasaet.fernet
Interface StringObjectValidator<T>
- Type Parameters:
T- The type of the payload. The Fernet token encodes the payload in binary. The type T should be a domain object or data transfer object representation of that data.
- All Superinterfaces:
Validator<T>
public interface StringObjectValidator<T> extends Validator<T>
A
Validator for payloads that represent objects as Strings (e.g. JSON or XML). This validator converts the
payload to a String then delegates to getStringTransformer() to convert that String to an object. If the
deserialisation library you use already provides a way to convert binary into objects, then you can use
Validator directly instead.
Copyright © 2017 Carlos Macasaet.
- Author:
- Carlos Macasaet
-
Method Summary
Modifier and Type Method Description default java.nio.charset.CharsetgetCharset()default java.util.function.Function<byte[],java.lang.String>getStringCreator()Override this to specify an alternative way to convert binary data into a String.java.util.function.Function<java.lang.String,T>getStringTransformer()Plug in your String deserialisation method here.default java.util.function.Function<byte[],T>getTransformer()Implement this to define how decrypted content is deserialised into domain objects.Methods inherited from interface com.macasaet.fernet.Validator
getClock, getMaxClockSkew, getObjectValidator, getTimeToLive, validateAndDecrypt, validateAndDecrypt
-
Method Details
-
getCharset
default java.nio.charset.Charset getCharset() -
getStringCreator
default java.util.function.Function<byte[],java.lang.String> getStringCreator()Override this to specify an alternative way to convert binary data into a String. The default implementation uses the UTF-8 character set.- Returns:
- a method for converting a byte array into a String
-
getTransformer
Description copied from interface:ValidatorImplement this to define how decrypted content is deserialised into domain objects.- Specified by:
getTransformerin interfaceValidator<T>- Returns:
- a method for converting the decrypted payload into a domain object
-
getStringTransformer
java.util.function.Function<java.lang.String,T> getStringTransformer()Plug in your String deserialisation method here.- Returns:
- a method for converting a String into an Object.
-