Class SensitiveMasker

java.lang.Object
com.github.catomat0.aoploghelper.logging.mask.SensitiveMasker

public class SensitiveMasker extends Object
Best-effort masker used when logging method arguments, return values and exception messages.

Two independent layers:

  • Keyword layer — Map entries and key=value / "key":"value" string pairs whose key contains any configured keyword are replaced with "***".
  • PII layer — regex-based masking for e-mail, phone numbers, credit cards and Korean resident-registration numbers, applied to any string content.
On top of those, sanitizeForLog(String) also strips control characters (\n, \r, \t, ESC) to defeat log-line injection.

This is NOT a security boundary — do not rely on it to sanitize data leaving the process.

  • Constructor Details

    • SensitiveMasker

      public SensitiveMasker(Collection<String> keywords)
    • SensitiveMasker

      public SensitiveMasker(Collection<String> keywords, boolean piiEnabled)
  • Method Details

    • mask

      public Object mask(Object value)
    • sanitizeForLog

      public String sanitizeForLog(String input)
      Runs full masking and then strips control characters so the result is safe to embed in a single log line. Use this on any string that mixes user-controlled content into the log.
    • maskArgs

      public List<Object> maskArgs(Object[] args)