Skip to content

Commit 1449b68

Browse files
committed
Gardening: PasswordAuthenticator polish
Modifications ------------- Make DEFAULT_SASL_MECHANISMS unmodifiable. Move @nullable annotation next to type. Add a toString() method that omits auth header, so someone doesn't come along later and add one that leaks sensitive info. Change-Id: I3208da9b4fd2298f00508cb2908c2bcd060e4f50 Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/233959 Reviewed-by: Michael Reiche <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent ee6eb99 commit 1449b68

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

core-io/src/main/java/com/couchbase/client/core/env/PasswordAuthenticator.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,15 @@
5151
public class PasswordAuthenticator implements Authenticator {
5252

5353
private static final Set<SaslMechanism> DEFAULT_SASL_MECHANISMS =
54-
EnumSet.of(SaslMechanism.SCRAM_SHA512, SaslMechanism.SCRAM_SHA256, SaslMechanism.SCRAM_SHA1);
55-
54+
unmodifiableSet(EnumSet.of(
55+
SaslMechanism.SCRAM_SHA512,
56+
SaslMechanism.SCRAM_SHA256,
57+
SaslMechanism.SCRAM_SHA1
58+
));
5659

5760
private final Supplier<UsernameAndPassword> usernameAndPassword;
5861
private final Set<SaslMechanism> allowedSaslMechanisms;
59-
@Nullable private final String cachedHttpAuthHeader;
62+
private final @Nullable String cachedHttpAuthHeader;
6063

6164
/**
6265
* Creates a new {@link Builder} which allows to customize this authenticator.
@@ -430,4 +433,12 @@ private Supplier<UsernameAndPassword> resolveUsernameAndPasswordSupplier() {
430433
);
431434
}
432435
}
436+
437+
@Override
438+
public String toString() {
439+
// Omit sensitive information like password or auth header.
440+
return "PasswordAuthenticator{" +
441+
"allowedSaslMechanisms=" + allowedSaslMechanisms +
442+
'}';
443+
}
433444
}

0 commit comments

Comments
 (0)