Class EncryptHmacSerializer<T>

java.lang.Object
com.fasterxml.jackson.databind.JsonSerializer<T>
com.fasterxml.jackson.databind.ser.std.StdSerializer<T>
com.fasterxml.jackson.databind.ser.std.StdScalarSerializer<T>
com.bld.crypto.serializer.EncryptCertificateSerializer<T>
com.bld.crypto.hmac.serializer.EncryptHmacSerializer<T>
Type Parameters:
T - the type of the value to sign
All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable, com.fasterxml.jackson.databind.jsonschema.SchemaAware, com.fasterxml.jackson.databind.ser.ContextualSerializer, Serializable

public class EncryptHmacSerializer<T> extends EncryptCertificateSerializer<T> implements com.fasterxml.jackson.databind.ser.ContextualSerializer
Jackson ContextualSerializer that signs a field value before writing it to the JSON output stream using HMAC.

The plain-text value is wrapped in a JSON envelope {"key":"&lt;annotationValue&gt;","value":"&lt;plainText&gt;"} and then signed. The envelope is verified during deserialisation to prevent cross-field substitution.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer

    com.fasterxml.jackson.databind.JsonSerializer.None
  • Field Summary

    Fields inherited from class com.bld.crypto.serializer.EncryptCertificateSerializer

    objMapper

    Fields inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer

    _handledType
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.fasterxml.jackson.databind.JsonSerializer<?>
    createContextual(com.fasterxml.jackson.databind.SerializerProvider prov, com.fasterxml.jackson.databind.BeanProperty property)
     
    protected String
    Encrypts the given plain-text string.

    Methods inherited from class com.bld.crypto.serializer.EncryptCertificateSerializer

    serialize

    Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdScalarSerializer

    acceptJsonFormatVisitor, getSchema, serializeWithType

    Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer

    _neitherNull, _nonEmpty, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow

    Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer

    getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, unwrappingSerializer, usesObjectId, withFilterId, withIgnoredProperties

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EncryptHmacSerializer

      public EncryptHmacSerializer()
  • Method Details

    • createContextual

      public com.fasterxml.jackson.databind.JsonSerializer<?> createContextual(com.fasterxml.jackson.databind.SerializerProvider prov, com.fasterxml.jackson.databind.BeanProperty property) throws com.fasterxml.jackson.databind.JsonMappingException
      Specified by:
      createContextual in interface com.fasterxml.jackson.databind.ser.ContextualSerializer
      Throws:
      com.fasterxml.jackson.databind.JsonMappingException
    • encryptValue

      protected String encryptValue(String word)
      Description copied from class: EncryptCertificateSerializer
      Encrypts the given plain-text string. Concrete subclasses supply the algorithm and key selection logic.
      Specified by:
      encryptValue in class EncryptCertificateSerializer<T>
      Parameters:
      word - the plain-text string to encrypt
      Returns:
      the encrypted, Base64-encoded string