Skip to content

Commit c807b2a

Browse files
committed
DATAMONGO-601 - Fixed exposing password by MongoDbUtils.
MongoDbUtils is now not exposing the plain password in the exception message piped into CannotGetMongoDbConnectionException but uses the newly introduced toString() method of UserCredentials (see DATACMNS-275).
1 parent 19ad2d3 commit c807b2a

File tree

1 file changed

+2
-2
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core

1 file changed

+2
-2
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDbUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ private static DB doGetDB(Mongo mongo, String databaseName, UserCredentials cred
112112
String password = credentials.hasPassword() ? credentials.getPassword() : null;
113113

114114
if (!db.authenticate(username, password == null ? null : password.toCharArray())) {
115-
throw new CannotGetMongoDbConnectionException("Failed to authenticate to database [" + databaseName
116-
+ "], username = [" + username + "], password = [" + password + "]", databaseName, credentials);
115+
throw new CannotGetMongoDbConnectionException("Failed to authenticate to database [" + databaseName + "], "
116+
+ credentials.toString(), databaseName, credentials);
117117
}
118118
}
119119
}

0 commit comments

Comments
 (0)