use of org.neo4j.ogm.config.UsernamePasswordCredentials in project neo4j-ogm by neo4j.
the class BoltDriver method initializeDriver.
private void initializeDriver() {
final String serviceUnavailableMessage = "Could not create driver instance";
Driver driver = null;
try {
if (credentials != null) {
UsernamePasswordCredentials usernameAndPassword = (UsernamePasswordCredentials) this.credentials;
AuthToken authToken = AuthTokens.basic(usernameAndPassword.getUsername(), usernameAndPassword.getPassword());
driver = createDriver(authToken);
} else {
LOGGER.debug("Bolt Driver credentials not supplied");
driver = createDriver(AuthTokens.none());
}
driver.verifyConnectivity();
boltDriver = driver;
// set null to skip close() in finally
driver = null;
} catch (ServiceUnavailableException e) {
throw new ConnectionException(serviceUnavailableMessage, e);
} finally {
if (driver != null) {
driver.close();
}
}
}
Aggregations