if ( usernameObject != null ) {
DB admin = this.mongo.getDB( "admin" );
String username = usernameObject.toString();
Object passwordObject = this.cfg.get( Environment.MONGODB_PASSWORD );
String password = passwordObject != null ? passwordObject.toString() : "";
boolean auth = admin.authenticate( username, password.toCharArray() );
if ( !auth ) {
throw log.authenticationFailed( username );
}
}
if ( !this.mongo.getDatabaseNames().contains( dbName ) ) {