public class StringRedactor extends Object
| Modifier and Type | Method and Description |
|---|---|
static StringRedactor |
createFromJsonFile(String fileName)
Create a StringRedactor based on the JSON found in a file.
|
static StringRedactor |
createFromJsonFile(String fileName,
LogRedactorMetrics metrics) |
static StringRedactor |
createFromJsonString(String json,
String rulesLocation)
Create a StringRedactor based on the JSON found in the given String.
|
static StringRedactor |
createFromJsonString(String json,
String rulesLocation,
LogRedactorMetrics metrics) |
static StringRedactor |
emptyStringRedactor(LogRedactorMetrics metrics,
Map<String,String> tags) |
void |
measureRuleCount() |
String |
redact(String msg)
The actual redaction - given a message, look through the list of
redaction rules and apply if matching.
|
Throwable |
redact(Throwable t) |
public static StringRedactor emptyStringRedactor(LogRedactorMetrics metrics, Map<String,String> tags)
public static StringRedactor createFromJsonFile(String fileName) throws IOException
{
"version": "1",
"rules": [
{ "description": "This is the first rule",
"trigger": "triggerstring 1",
"search": "regex 1",
"replace": "replace 1"
},
{ "description": "This is the second rule",
"trigger": "triggerstring 2",
"search": "regex 2",
"replace": "replace 2"
}
]
}
fileName - The name of the file to readIOException - We convert jackson exceptions to RedactionPolicyParseExceptions
because we shade and relocate jackson and don't want to expose it.public static StringRedactor createFromJsonFile(String fileName, LogRedactorMetrics metrics) throws IOException
IOExceptionpublic static StringRedactor createFromJsonString(String json, String rulesLocation) throws IOException
json - String containing json formatted rules.rulesLocation - String containing location of the redaction rules.IOException - We convert jackson exceptions to RedactionPolicyParseExceptions
because we shade and relocate jackson and don't want to expose it.public static StringRedactor createFromJsonString(String json, String rulesLocation, LogRedactorMetrics metrics) throws IOException
IOExceptionpublic String redact(String msg)
msg - The message to examine.public void measureRuleCount()
Copyright © 2023 Confluent, Inc.. All rights reserved.