Class ValueMaskingUtil
java.lang.Object
dev.blaauwendraad.masker.json.util.ValueMaskingUtil
Class containing utility methods to replace a particular target value with a mask. This can be used for
length obfuscation and ignoring escaping characters in string values.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
flushReplacementOperations
(MaskingState maskingState) Performs all replacement operations to the message array, must be called at the end of the replacements.static void
replaceTargetValueWithFixedLengthAsteriskMask
(MaskingState maskingState, int maskLength, int targetValueLength) static void
replaceTargetValueWithFixedLengthMask
(MaskingState maskingState, int maskLength, int targetValueLength, byte maskByte) Replaces a target value (byte slice) with a mask byte.
-
Method Details
-
replaceTargetValueWithFixedLengthMask
public static void replaceTargetValueWithFixedLengthMask(MaskingState maskingState, int maskLength, int targetValueLength, byte maskByte) Replaces a target value (byte slice) with a mask byte. If lengths of both target value and mask are equal, the replacement is done in-place, otherwise a replacement operation is recorded to be performed as a batch usingflushReplacementOperations(dev.blaauwendraad.masker.json.MaskingState)
.- Parameters:
maskLength
- the length of the fixed-length mask byte string.targetValueLength
- the length of the target value slice.maskByte
- the byte used for each byte in the mask
-
replaceTargetValueWithFixedLengthAsteriskMask
public static void replaceTargetValueWithFixedLengthAsteriskMask(MaskingState maskingState, int maskLength, int targetValueLength) -
flushReplacementOperations
Performs all replacement operations to the message array, must be called at the end of the replacements.For every operation that required resizing of the original array, to avoid copying the array multiple times, those operations were stored in a list and can be performed in one go, thus resizing the array only once.
Replacement operation is only recorded if the length of the target value is different from the length of the mask, otherwise the replacement must have been done in-place.
- Parameters:
maskingState
- the current state of theJsonMasker
instance.
-