From 11b0d954f001237ccd41ce06b3767596126120ef Mon Sep 17 00:00:00 2001 From: Dhawaj Kumar Tomar Date: Sun, 12 Jul 2026 20:40:30 +0800 Subject: [PATCH] Add Javadocs to AuthConfigUtil --- .../utility/AuthConfigUtil.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/testcontainers/utility/AuthConfigUtil.java b/core/src/main/java/org/testcontainers/utility/AuthConfigUtil.java index 8ed91a5e34e..acec976d5de 100644 --- a/core/src/main/java/org/testcontainers/utility/AuthConfigUtil.java +++ b/core/src/main/java/org/testcontainers/utility/AuthConfigUtil.java @@ -7,11 +7,30 @@ import org.jetbrains.annotations.NotNull; /** - * TODO: Javadocs + * Utility methods for safely representing {@link AuthConfig} objects as strings. + *

+ * This class masks sensitive authentication information such as passwords, + * authentication tokens, and registry tokens before including them in the + * returned string. It is intended for logging and debugging purposes where + * exposing secrets would be a security risk. */ @UtilityClass public class AuthConfigUtil { + /** + * Returns a safe string representation of the given {@link AuthConfig}. + *

+ * Sensitive fields including the password, authentication value, and + * registry token are replaced with an obfuscated placeholder, while + * non-sensitive fields such as the username, email, and registry address + * are included in the output. If the supplied configuration is + * {@code null}, the string {@code "null"} is returned. + * + * @param authConfig the authentication configuration to represent safely; + * may be {@code null} + * @return a string representation with sensitive values hidden, or + * {@code "null"} if {@code authConfig} is {@code null} + */ public static String toSafeString(AuthConfig authConfig) { if (authConfig == null) { return "null"; @@ -28,6 +47,17 @@ public static String toSafeString(AuthConfig authConfig) { .toString(); } + /** + * Returns an obfuscated representation of a potentially sensitive value. + *

+ * If the value is {@code null} or empty, the string {@code "blank"} is + * returned. Otherwise, the actual value is concealed by returning + * {@code "hidden non-blank value"}. + * + * @param value the value to obfuscate + * @return {@code "blank"} if the value is null or empty; otherwise + * {@code "hidden non-blank value"} + */ @NotNull private static String obfuscated(String value) { return Strings.isNullOrEmpty(value) ? "blank" : "hidden non-blank value";