Skip to content

Commit 11b0d95

Browse files
author
Dhawaj Kumar Tomar
committed
Add Javadocs to AuthConfigUtil
1 parent deb78e1 commit 11b0d95

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

core/src/main/java/org/testcontainers/utility/AuthConfigUtil.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,30 @@
77
import 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
1318
public 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

Comments
 (0)