connections/mongo/src/main/java/org/keycloak/connections/mongo/DefaultMongoConnectionFactoryProvider.java
/**
     * Override this method if you want more possibility to configure Mongo client. It can be also used to inject mongo client
     * from different source.
     *
     * This method can assume that "config" is already set and can use it.
     *
     * @return mongoClient instance, which will be shared for whole Keycloak
     *
     * @throws UnknownHostException
     */
Override this method if you want more possibility to configure Mongo client. It can be also used to inject mongo client
from different source.

This method can assume that "config" is already set and can use it.

@return mongoClient instance, which will be shared for whole Keycloak


Override this method if you want more possibility to configure Mongo client . It can be also used to inject mongo client from different source . This method can assume that " config " is already set and can use it . @return mongoClient instance which will be shared for whole Keycloak
protected MongoClient createMongoClient() throws UnknownHostException {
        String host = config.get("host", ServerAddress.defaultHost());
        int port = config.getInt("port", ServerAddress.defaultPort());
        String dbName = config.get("db", "keycloak");
        String user = config.get("user");
        String password = config.get("password");
        MongoClientOptions clientOptions = getClientOptions();
        MongoClient client;
        if (user != null && password != null) {
            MongoCredential credential = MongoCredential.createMongoCRCredential(user, dbName, password.toCharArray());
            client = new MongoClient(new ServerAddress(host, port), Collections.singletonList(credential), clientOptions);
        } else {
            client = new MongoClient(new ServerAddress(host, port), clientOptions);
        }
        logger.debugv("Initialized mongo model. host: %s, port: %d, db: %s", host, port, dbName);
        return client;
    }
protected MongoClient createMongoClient ( ) throws UnknownHostException { String host = config . get ( "host" , ServerAddress . defaultHost ( ) ) ; int port = config . getInt ( "port" , ServerAddress . defaultPort ( ) ) ; String dbName = config . get ( "db" , "keycloak" ) ; String user = config . get ( "user" ) ; String password = config . get ( "password" ) ; MongoClientOptions clientOptions = getClientOptions ( ) ; MongoClient client ; if ( user != null && password != null ) { MongoCredential credential = MongoCredential . createMongoCRCredential ( user , dbName , password . toCharArray ( ) ) ; client = new MongoClient ( new ServerAddress ( host , port ) , Collections . singletonList ( credential ) , clientOptions ) ; } else { client = new MongoClient ( new ServerAddress ( host , port ) , clientOptions ) ; } logger . debugv ( "Initialized mongo model. host: %s, port: %d, db: %s" , host , port , dbName ) ; return client ; }
Override this method if you want more possibility to configure Mongo client.
Override this method if you want more possibility to configure Mongo client .