private Driver getDriver(@Nonnull ConnectionConfig connectionConfig, @Nullable AuthToken authToken) { Config config = Config.build() .withLogging(NullLogging.NULL_LOGGING) .withEncryptionLevel(connectionConfig.encryption()).toConfig(); return driverProvider.apply(connectionConfig.driverUrl(), authToken, config); }
public BoltCypherExecutor(String url, String username, String password) { boolean hasPassword = password != null && !password.isEmpty(); AuthToken token = hasPassword ? AuthTokens.basic(username, password) : AuthTokens.none(); driver = GraphDatabase.driver(url, token, Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig()); }
@Override public CypherResult executeCypher(String cypherQuery, HashMap<String, Object> parameters) { try { Driver driver; if (encryption) { if (getNeo4jUsername() != null) { driver = GraphDatabase.driver(getNeo4jHost(), AuthTokens.basic(getNeo4jUsername(), getNeo4jPassword())); } else { driver = GraphDatabase.driver(getNeo4jHost()); } } else { if (getNeo4jUsername() != null) { driver = GraphDatabase.driver(getNeo4jHost(), AuthTokens.basic(getNeo4jUsername(), getNeo4jPassword()), Config.build().withEncryptionLevel(NONE).toConfig()); } else { driver = GraphDatabase.driver(getNeo4jHost(), Config.build().withEncryptionLevel(NONE).toConfig()); } } Session session = driver.session(); StatementResult response = session.run(cypherQuery, parameters); return buildResult(response); } catch (Exception ex) { throw new RuntimeException(ex); } }
private Config configuration() { return Config.build().withEncryptionLevel( Config.EncryptionLevel.NONE ) .withConnectionTimeout( 10, TimeUnit.SECONDS ) .toConfig(); }