driver-core/src/main/com/mongodb/MongoCredential.java
public static MongoCredential createCredential(final String userName, final String database, final char[] password) {
        return new MongoCredential(null, userName, database, password);
    }
public static MongoCredential createCredential(final String userName, final String database, final char[] password) {
        return new MongoCredential(null, userName, database, password);
    }
Creates a MongoCredential instance with an unspecified mechanism.  The client will negotiate the best mechanism based on the
version of the server that the client is authenticating to.

<p>If the server version is 4.0 or higher, the driver will negotiate with the server preferring the SCRAM-SHA-256 mechanism. 3.x
servers will authenticate using SCRAM-SHA-1, older servers will authenticate using the MONGODB_CR mechanism.</p>

@param userName the user name
@param database the database where the user is defined
@param password the user's password
@return the credential

@since 2.13
@mongodb.driver.manual core/authentication/#authentication-scram-sha-256 SCRAM-SHA-256
@mongodb.driver.manual core/authentication/#authentication-scram-sha-1 SCRAM-SHA-1
@mongodb.driver.manual core/authentication/#mongodb-cr-authentication MONGODB-CR