&& !mongodbCredentials.getOptions().get("authenticationDatabase").isEmpty()) { mongoDBConfiguration = MongoDBConfiguration.builder() .add("username", mongodbCredentials.getUser()) .add("password", mongodbCredentials.getPassword()) .add("authenticationDatabase", mongodbCredentials.getOptions().get("authenticationDatabase")).build(); logger.debug("MongoDB 'authenticationDatabase' database parameter set to '{}'", mongodbCredentials.getOptions().get("authenticationDatabase")); } else { mongoDBConfiguration = MongoDBConfiguration.builder() .add("username", mongodbCredentials.getUser()) .add("password", mongodbCredentials.getPassword()).build();
builder.setUserPassword(mongodbCredentials.getUser(), mongodbCredentials.getPassword()); if (mongodbCredentials.getOptions().containsKey(MongoDBConfiguration.AUTHENTICATION_DATABASE)) { builder.setAuthenticationDatabase(mongodbCredentials.getOptions() .get(MongoDBConfiguration.AUTHENTICATION_DATABASE)); builder.add(MongoDBConfiguration.READ_PREFERENCE, mongodbCredentials.getOptions().get(MongoDBConfiguration.READ_PREFERENCE)); builder.setReplicaSet(mongodbCredentials.getOptions().get(MongoDBConfiguration.REPLICA_SET)); builder.setConnectionsPerHost(Integer.valueOf(mongodbCredentials.getOptions() .get(MongoDBConfiguration.CONNECTIONS_PER_HOST))); mongoDBConfiguration = builder.build();
public MongoDBAdaptorFactory(Configuration catalogConfiguration) throws CatalogDBException { MongoDBConfiguration mongoDBConfiguration = MongoDBConfiguration.builder() .setUserPassword( catalogConfiguration.getCatalog().getDatabase().getUser(), catalogConfiguration.getCatalog().getDatabase().getPassword()) .load(catalogConfiguration.getCatalog().getDatabase().getOptions()) .build(); List<DataStoreServerAddress> dataStoreServerAddresses = new LinkedList<>(); for (String hostPort : catalogConfiguration.getCatalog().getDatabase().getHosts()) { if (hostPort.contains(":")) { String[] split = hostPort.split(":"); int port = Integer.valueOf(split[1]); dataStoreServerAddresses.add(new DataStoreServerAddress(split[0], port)); } else { dataStoreServerAddresses.add(new DataStoreServerAddress(hostPort, 27017)); } } this.mongoManager = new MongoDataStoreManager(dataStoreServerAddresses); this.configuration = mongoDBConfiguration; this.database = getCatalogDatabase(catalogConfiguration.getDatabasePrefix()); logger = LoggerFactory.getLogger(this.getClass()); connect(); }
&& !mongodbCredentials.getOptions().get("authenticationDatabase").isEmpty()) { mongoDBConfiguration = MongoDBConfiguration.builder() .add("username", mongodbCredentials.getUser()) .add("password", mongodbCredentials.getPassword()) .add("authenticationDatabase", mongodbCredentials.getOptions().get("authenticationDatabase")).build(); logger.debug("MongoDB 'authenticationDatabase' database parameter set to '{}'", mongodbCredentials.getOptions().get("authenticationDatabase")); } else { mongoDBConfiguration = MongoDBConfiguration.builder() .add("username", mongodbCredentials.getUser()) .add("password", mongodbCredentials.getPassword()).build();
builder.setUserPassword(mongodbCredentials.getUser(), mongodbCredentials.getPassword()); if (mongodbCredentials.getOptions().containsKey(MongoDBConfiguration.AUTHENTICATION_DATABASE)) { builder.setAuthenticationDatabase(mongodbCredentials.getOptions() .get(MongoDBConfiguration.AUTHENTICATION_DATABASE)); builder.add(MongoDBConfiguration.READ_PREFERENCE, mongodbCredentials.getOptions().get(MongoDBConfiguration.READ_PREFERENCE)); builder.setReplicaSet(mongodbCredentials.getOptions().get(MongoDBConfiguration.REPLICA_SET)); builder.setConnectionsPerHost(Integer.valueOf(mongodbCredentials.getOptions() .get(MongoDBConfiguration.CONNECTIONS_PER_HOST))); mongoDBConfiguration = builder.build();
configuration.getAdmin().setAlgorithm("HS256"); MongoDBConfiguration mongoDBConfiguration = MongoDBConfiguration.builder() .add("username", configuration.getCatalog().getDatabase().getUser()) .add("password", configuration.getCatalog().getDatabase().getPassword()) .add("authenticationDatabase", configuration.getCatalog().getDatabase().getOptions().get("authenticationDatabase")) .build();
/** * Create a new Native instance. This is a convenience method, equivalent to {@code new MongoClientOptions.Native()}. * * @return a new instance of a Native */ public static Builder builder() { return new Builder(); }
public MongoCredentials(List<DataStoreServerAddress> dataStoreServerAddresses, String dbName, String mongoUser, String mongoPassword, Map<? extends String, ?> inputOptions, boolean checkConnection) throws IllegalOpenCGACredentialsException { this.mongoDbName = dbName; mongoDBConfiguration = MongoDBConfiguration.builder() .setUserPassword(mongoUser, mongoPassword) .setServerAddress(dataStoreServerAddresses) .load(inputOptions == null ? Collections.emptyMap() : inputOptions) .build(); if (checkConnection) { check(); } }
public MongoCredentials(String mongoHost, int mongoPort, String mongoDbName, String mongoUser, String mongoPassword, boolean checkConnection) throws IllegalOpenCGACredentialsException { this.mongoDbName = mongoDbName; mongoDBConfiguration = MongoDBConfiguration.builder() .setUserPassword(mongoUser, mongoPassword) .addServerAddress(new DataStoreServerAddress(mongoHost, mongoPort)) .build(); if (checkConnection) { check(); } }