Package com.networknt.mask
Class Mask
- java.lang.Object
-
- com.networknt.mask.Mask
-
public class Mask extends Object
A utility to mask sensitive data based on regex pattern before logging- Author:
- Steve Hu
-
-
Field Summary
Fields Modifier and Type Field Description static StringMASK_REPLACEMENT_CHARstatic StringMASK_TYPE_JSONstatic StringMASK_TYPE_REGEXstatic StringMASK_TYPE_STRING
-
Constructor Summary
Constructors Constructor Description Mask()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringmaskJson(com.jayway.jsonpath.DocumentContext ctx, String key)static StringmaskJson(InputStream input, String key)Replace values in JSON using json pathstatic StringmaskJson(Object input, String key)Replace values in JSON using json pathstatic StringmaskJson(String input, String key)Replace values in JSON using json pathstatic StringmaskRegex(String input, String key, String name)Replace a string input with a pattern found in regex section with key as index.static StringmaskString(String input, String key)Mask the input string with a list of patterns indexed by key in string section in mask.json This is usually used to mask header values, query parameters and uri parameters
-
-
-
Field Detail
-
MASK_REPLACEMENT_CHAR
public static final String MASK_REPLACEMENT_CHAR
- See Also:
- Constant Field Values
-
MASK_TYPE_STRING
public static final String MASK_TYPE_STRING
- See Also:
- Constant Field Values
-
MASK_TYPE_REGEX
public static final String MASK_TYPE_REGEX
- See Also:
- Constant Field Values
-
MASK_TYPE_JSON
public static final String MASK_TYPE_JSON
- See Also:
- Constant Field Values
-
-
Method Detail
-
maskString
public static String maskString(String input, String key)
Mask the input string with a list of patterns indexed by key in string section in mask.json This is usually used to mask header values, query parameters and uri parameters- Parameters:
input- String The source of the string that needs to be maskedkey- String The key that maps to a list of patterns for masking in config file- Returns:
- Masked result
-
maskRegex
public static String maskRegex(String input, String key, String name)
Replace a string input with a pattern found in regex section with key as index. Usually, it is used to replace header, query parameter, uri parameter to same length of stars(*)- Parameters:
input- String The source of the string that needs to be maskedkey- String The key maps to a list of name to pattern pairname- String The name of the pattern in the key list- Returns:
- String Masked result
-
maskJson
public static String maskJson(String input, String key)
Replace values in JSON using json path- Parameters:
input- String The source of the string that needs to be maskedkey- String The key maps to a list of json path for masking- Returns:
- String Masked result
-
maskJson
public static String maskJson(InputStream input, String key)
Replace values in JSON using json path- Parameters:
input- InputStream inputStream of json that needs to be maskedkey- String The key maps to a list of json path for masking- Returns:
- String Masked result
-
maskJson
public static String maskJson(Object input, String key)
Replace values in JSON using json path- Parameters:
input- Object POJO of json that needs to be maskedkey- String The key maps to a list of json path for masking- Returns:
- String Masked result
-
-