Package com.easypost.easyvcr
Class Censors
java.lang.Object
com.easypost.easyvcr.Censors
Censoring capabilities for EasyVCR.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyBodyParameterCensors(String body)Censor the appropriate body elements.static StringapplyBodyParameterCensors(String body, String censorText, List<CensorElement> bodyElementsToCensor)Censor the appropriate body elements.applyHeaderCensors(Map<String,List<String>> headers)Censor the appropriate headers.applyHeaderCensors(Map<String,List<String>> headers, String censorText, List<CensorElement> headersToCensor)Censor the appropriate headers.applyUrlCensors(String url)Censor the appropriate query parameters.static StringapplyUrlCensors(String url, String censorText, List<CensorElement> queryParamsToCensor, List<RegexCensorElement> pathElementsToCensor)Censor the appropriate query parameters.censorBodyElements(List<CensorElement> elements)Add a rule to censor specified body elements.censorBodyElementsByKeys(List<String> elementKeys)Add a rule to censor specified body elements by their keys.censorBodyElementsByKeys(List<String> elementKeys, boolean caseSensitive)Add a rule to censor specified body elements by their keys.censorHeaders(List<CensorElement> headers)Add a rule to censor specified headers.censorHeadersByKeys(List<String> headerKeys)Add a rule to censor specified headers by their keys.censorHeadersByKeys(List<String> headerKeys, boolean caseSensitive)Add a rule to censor specified headers by their keys.static StringcensorJsonData(String data, String censorText, List<CensorElement> elementsToCensor)Apply censors to a JSON string.censorPathElements(List<RegexCensorElement> elements)Add a rule to censor specified path elements.censorPathElementsByPattern(List<String> patterns)Add a rule to censor specified path elements by regular expression patterns.censorPathElementsByPattern(List<String> patterns, boolean caseSensitive)Add a rule to censor specified path elements by regular expression patterns.censorQueryParameters(List<CensorElement> elements)Add a rule to censor specified query parameters.censorQueryParametersByKeys(List<String> parameterKeys)Add a rule to censor specified query parameters by their keys.censorQueryParametersByKeys(List<String> parameterKeys, boolean caseSensitive)Add a rule to censor specified query parameters by their keys.static Censorsregular()Default censors is to not censor anything.static Censorsstrict()Default sensitive censors is to censor common private information (i.e.
-
Constructor Details
-
Censors
public Censors()Initialize a new instance of the Censors factory, using default censor string. -
Censors
Initialize a new instance of the Censors factory.- Parameters:
censorString- The string to use to censor sensitive information.
-
-
Method Details
-
regular
Default censors is to not censor anything.- Returns:
- Default set of censors.
-
strict
Default sensitive censors is to censor common private information (i.e. API keys, auth tokens, etc.)- Returns:
- Default sensitive set of censors.
-
censorJsonData
public static String censorJsonData(String data, String censorText, List<CensorElement> elementsToCensor)Apply censors to a JSON string.- Parameters:
data- The JSON string to censor.censorText- The string to use to censor sensitive information.elementsToCensor- The body elements to censor.- Returns:
- The censored JSON string.
-
applyBodyParameterCensors
public static String applyBodyParameterCensors(String body, String censorText, List<CensorElement> bodyElementsToCensor)Censor the appropriate body elements.- Parameters:
body- String representation of request body to apply censors to.censorText- The string to use to censor sensitive information.bodyElementsToCensor- The body elements to censor.- Returns:
- Censored string representation of request body.
-
applyHeaderCensors
public static Map<String,List<String>> applyHeaderCensors(Map<String,List<String>> headers, String censorText, List<CensorElement> headersToCensor)Censor the appropriate headers.- Parameters:
headers- Map of headers to apply censors to.censorText- The string to use to censor sensitive information.headersToCensor- The headers to censor.- Returns:
- Censored map of headers.
-
applyUrlCensors
public static String applyUrlCensors(String url, String censorText, List<CensorElement> queryParamsToCensor, List<RegexCensorElement> pathElementsToCensor)Censor the appropriate query parameters.- Parameters:
url- Full URL string to apply censors to.censorText- The string to use to censor sensitive information.queryParamsToCensor- The query parameters to censor.pathElementsToCensor- The path elements to censor.- Returns:
- Censored URL string.
-
censorBodyElements
Add a rule to censor specified body elements.- Parameters:
elements- List of body elements to censor.- Returns:
- This Censors factory.
-
censorBodyElementsByKeys
Add a rule to censor specified body elements by their keys.- Parameters:
elementKeys- Keys of body elements to censor.caseSensitive- Whether to use case-sensitive censoring.- Returns:
- This Censors factory.
-
censorBodyElementsByKeys
Add a rule to censor specified body elements by their keys.- Parameters:
elementKeys- Keys of body elementKeys to censor.- Returns:
- This Censors factory.
-
censorHeaders
Add a rule to censor specified headers. Note: This will censor the header keys in both the request and response.- Parameters:
headers- List of headers to censor.- Returns:
- This Censors factory.
-
censorHeadersByKeys
Add a rule to censor specified headers by their keys. Note: This will censor the header keys in both the request and response.- Parameters:
headerKeys- Keys of headers to censor.caseSensitive- Whether to use case-sensitive censoring.- Returns:
- This Censors factory.
-
censorHeadersByKeys
Add a rule to censor specified headers by their keys. Note: This will censor the header keys in both the request and response.- Parameters:
headerKeys- Keys of headers to censor.- Returns:
- This Censors factory.
-
censorQueryParameters
Add a rule to censor specified query parameters.- Parameters:
elements- List of query parameters to censor.- Returns:
- This Censors factory.
-
censorQueryParametersByKeys
Add a rule to censor specified query parameters by their keys.- Parameters:
parameterKeys- Keys of query parameters to censor.caseSensitive- Whether to use case-sensitive censoring.- Returns:
- This Censors factory.
-
censorQueryParametersByKeys
Add a rule to censor specified query parameters by their keys.- Parameters:
parameterKeys- Keys of query parameters to censor.- Returns:
- This Censors factory.
-
censorPathElements
Add a rule to censor specified path elements.- Parameters:
elements- List of path elements to censor.- Returns:
- This Censors factory.
-
censorPathElementsByPattern
Add a rule to censor specified path elements by regular expression patterns.- Parameters:
patterns- Patterns of path elements to censor.caseSensitive- Whether to use case-sensitive pattern matching.- Returns:
- This Censors factory.
-
censorPathElementsByPattern
Add a rule to censor specified path elements by regular expression patterns.- Parameters:
patterns- Patterns of path elements to censor.- Returns:
- This Censors factory.
-
applyBodyParameterCensors
Censor the appropriate body elements.- Parameters:
body- String representation of request body to apply censors to.- Returns:
- Censored string representation of request body.
-
applyHeaderCensors
Censor the appropriate headers.- Parameters:
headers- Map of headers to apply censors to.- Returns:
- Censored map of headers.
-
applyUrlCensors
Censor the appropriate query parameters.- Parameters:
url- Full URL string to apply censors to.- Returns:
- Censored URL string.
-