use of com.mongodb.ServerAddress in project cas by apereo.
the class MongoDbCloudConfigBootstrapConfiguration method mongo.
@Override
public Mongo mongo() throws Exception {
final MongoCredential credential = MongoCredential.createCredential(mongoClientUri().getUsername(), getDatabaseName(), mongoClientUri().getPassword());
final String hostUri = mongoClientUri().getHosts().get(0);
final String[] host = hostUri.split(":");
return new MongoClient(new ServerAddress(host[0], host.length > 1 ? Integer.parseInt(host[1]) : DEFAULT_PORT), Collections.singletonList(credential), mongoClientOptions());
}
use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class AuthenticatingConnectionTest method setUp.
@Before
public void setUp() throws Exception {
userName = System.getProperty("org.mongodb.test.userName", "bob");
password = System.getProperty("org.mongodb.test.password", "pwd123");
source = System.getProperty("org.mongodb.test.source", "admin");
serverAddress = new ServerAddress(System.getProperty("org.mongodb.test.serverAddress", getPrimary().toString()));
InternalConnectionFactory internalConnectionFactory = new InternalStreamConnectionFactory(new SocketStreamFactory(SocketSettings.builder().build(), getSslSettings()), Collections.<MongoCredential>emptyList(), new NoOpConnectionListener(), null, null);
internalConnection = internalConnectionFactory.create(new ServerId(new ClusterId(), serverAddress));
}
use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class PlainAuthenticatorTest method setUp.
@Before
public void setUp() throws Exception {
String host = System.getProperty("org.mongodb.test.host");
userName = System.getProperty("org.mongodb.test.userName");
source = System.getProperty("org.mongod.test.source");
password = System.getProperty("org.mongodb.test.password");
internalConnection = new InternalStreamConnectionFactory(streamFactory, Collections.<MongoCredential>emptyList(), new NoOpConnectionListener(), null, null).create(new ServerId(new ClusterId(), new ServerAddress(host)));
connectionDescription = new ConnectionDescription(new ServerId(new ClusterId(), new ServerAddress()));
}
use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class X509AuthenticatorNoUserNameTest method before.
@Before
public void before() {
connection = new TestInternalConnection(new ServerId(new ClusterId(), new ServerAddress("localhost", 27017)));
connectionDescriptionThreeTwo = new ConnectionDescription(new ConnectionId(new ServerId(new ClusterId(), new ServerAddress())), new ServerVersion(3, 2), ServerType.STANDALONE, 1000, 16000, 48000);
connectionDescriptionThreeFour = new ConnectionDescription(new ConnectionId(new ServerId(new ClusterId(), new ServerAddress())), new ServerVersion(3, 4), ServerType.STANDALONE, 1000, 16000, 48000);
credential = MongoCredential.createMongoX509Credential("CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US");
subject = new X509Authenticator(this.credential);
}
use of com.mongodb.ServerAddress in project mongo-java-driver by mongodb.
the class X509AuthenticatorUnitTest method before.
@Before
public void before() {
connection = new TestInternalConnection(new ServerId(new ClusterId(), new ServerAddress("localhost", 27017)));
connectionDescription = new ConnectionDescription(new ServerId(new ClusterId(), new ServerAddress()));
credential = MongoCredential.createMongoX509Credential("CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US");
subject = new X509Authenticator(this.credential);
}
Aggregations