77import org .jetbrains .annotations .NotNull ;
88
99/**
10- * TODO: Javadocs
10+ * Utility methods for safely representing {@link AuthConfig} objects as strings.
11+ * <p>
12+ * This class masks sensitive authentication information such as passwords,
13+ * authentication tokens, and registry tokens before including them in the
14+ * returned string. It is intended for logging and debugging purposes where
15+ * exposing secrets would be a security risk.
1116 */
1217@ UtilityClass
1318public class AuthConfigUtil {
1419
20+ /**
21+ * Returns a safe string representation of the given {@link AuthConfig}.
22+ * <p>
23+ * Sensitive fields including the password, authentication value, and
24+ * registry token are replaced with an obfuscated placeholder, while
25+ * non-sensitive fields such as the username, email, and registry address
26+ * are included in the output. If the supplied configuration is
27+ * {@code null}, the string {@code "null"} is returned.
28+ *
29+ * @param authConfig the authentication configuration to represent safely;
30+ * may be {@code null}
31+ * @return a string representation with sensitive values hidden, or
32+ * {@code "null"} if {@code authConfig} is {@code null}
33+ */
1534 public static String toSafeString (AuthConfig authConfig ) {
1635 if (authConfig == null ) {
1736 return "null" ;
@@ -28,6 +47,17 @@ public static String toSafeString(AuthConfig authConfig) {
2847 .toString ();
2948 }
3049
50+ /**
51+ * Returns an obfuscated representation of a potentially sensitive value.
52+ * <p>
53+ * If the value is {@code null} or empty, the string {@code "blank"} is
54+ * returned. Otherwise, the actual value is concealed by returning
55+ * {@code "hidden non-blank value"}.
56+ *
57+ * @param value the value to obfuscate
58+ * @return {@code "blank"} if the value is null or empty; otherwise
59+ * {@code "hidden non-blank value"}
60+ */
3161 @ NotNull
3262 private static String obfuscated (String value ) {
3363 return Strings .isNullOrEmpty (value ) ? "blank" : "hidden non-blank value" ;
0 commit comments