Package org.apache.juneau.http
Class RedactedHeaders
java.lang.Object
org.apache.juneau.http.RedactedHeaders
Utility for masking the values of header names that commonly carry account credentials
(bearer tokens, session cookies, API keys, and the like) before they are written somewhere
observable, such as a log line or an echoed-back response body.
Matching is always case-insensitive, mirroring HTTP header-name semantics.
Callers that need a different or extended header set (for example, an additional
internal-trace header) can pass their own name collection to the two-argument overloads
rather than being limited to DEFAULT.
- Since:
- 10.0.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisSensitive(String name) Returnstrueif the given header name is inDEFAULT(case-insensitive).static booleanisSensitive(String name, Collection<String> names) Returnstrueif the given header name matches one ofnames, case-insensitively.static Stringstatic Stringredact(String name, String value, Collection<String> names) MasksvaluewithREDACTEDifnamematches one ofnames(case-insensitive); otherwise returnsvalueunchanged.
-
Field Details
-
REDACTED
Sentinel value substituted for a masked header value.- See Also:
-
DEFAULT
Canonical set of header names commonly used to carry credentials, matched case-insensitively.
-
-
Method Details
-
isSensitive
Returnstrueif the given header name is inDEFAULT(case-insensitive).- Parameters:
name- The header name to test. Can benull(returnsfalse).- Returns:
trueif the name matches one ofDEFAULT, case-insensitively.
-
isSensitive
Returnstrueif the given header name matches one ofnames, case-insensitively.- Parameters:
name- The header name to test. Can benull(returnsfalse).names- The candidate header names. Can benullor empty (returnsfalse).nullelements are ignored.- Returns:
trueifnamematches one ofnames, case-insensitively.
-
redact
MasksvaluewithREDACTEDifnameis inDEFAULT(case-insensitive); otherwise returnsvalueunchanged.- Parameters:
name- The header name. Can benull(never matches;valueis returned as-is).value- The header value to mask. Can benull.- Returns:
REDACTEDifnameis sensitive, elsevalue.
-
redact
MasksvaluewithREDACTEDifnamematches one ofnames(case-insensitive); otherwise returnsvalueunchanged.- Parameters:
name- The header name. Can benull(never matches;valueis returned as-is).value- The header value to mask. Can benull.names- The candidate header names. Can benullor empty (nothing is masked).- Returns:
REDACTEDifnamematches one ofnames, elsevalue.
-