Class EmailMasker

java.lang.Object
com.fayupable.logged.spring.security.EmailMasker

public final class EmailMasker extends Object
Masks e-mail-like values for CallerMode.MASKED.

A value is treated as an e-mail address only when it contains exactly one @ with a non-empty part on both sides. Such a value keeps the first character of its local part and its whole domain, for example jane.doe@example.com becomes j***@example.com: enough to tell tenants or identity providers apart while troubleshooting, without identifying the person. Anything else (a numeric user id, a plain username) is returned unchanged.

  • Method Details

    • mask

      public static String mask(String value)
      Masks value if it looks like an e-mail address.
      Parameters:
      value - the value to mask, may be null
      Returns:
      the masked value, or value itself if it is not e-mail-like