Java Code Examples for org.neo4j.driver.v1.AuthTokens#basic()
The following examples show how to use
org.neo4j.driver.v1.AuthTokens#basic() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Neo4jConnectionManager.java From zeppelin with Apache License 2.0 | 6 votes |
public Neo4jConnectionManager(Properties properties) { this.neo4jUrl = properties.getProperty(NEO4J_SERVER_URL); this.config = Config.build() .withMaxIdleSessions(Integer.parseInt(properties.getProperty(NEO4J_MAX_CONCURRENCY))) .toConfig(); String authType = properties.getProperty(NEO4J_AUTH_TYPE); switch (Neo4jAuthType.valueOf(authType.toUpperCase())) { case BASIC: String username = properties.getProperty(NEO4J_AUTH_USER); String password = properties.getProperty(NEO4J_AUTH_PASSWORD); this.authToken = AuthTokens.basic(username, password); break; case NONE: LOGGER.debug("Creating NONE authentication"); this.authToken = AuthTokens.none(); break; default: throw new RuntimeException("Neo4j authentication type not supported"); } }
Example 2
Source File: Neo4jBoltClient.java From streams with Apache License 2.0 | 6 votes |
public void start() throws Exception { Objects.nonNull(config); assertThat("config.getScheme().startsWith(\"tcp\")", config.getScheme().startsWith("tcp")); LOGGER.info("Neo4jConfiguration.start {}", config); AuthToken authToken = null; if( StringUtils.isNotBlank(config.getUsername()) && StringUtils.isNotBlank(config.getPassword())) { authToken = AuthTokens.basic( config.getUsername(), config.getPassword() ); } if( authToken == null ) { client = GraphDatabase.driver("bolt://" + config.getHosts().get(0) + ":" + config.getPort()); } else { client = GraphDatabase.driver("bolt://" + config.getHosts().get(0) + ":" + config.getPort(), authToken); } Objects.nonNull(client); }
Example 3
Source File: Neo4jContainerTest.java From testcontainers-java with MIT License | 5 votes |
private static Driver getDriver(Neo4jContainer container) { AuthToken authToken = AuthTokens.none(); if (container.getAdminPassword() != null) { authToken = AuthTokens.basic("neo4j", container.getAdminPassword()); } return GraphDatabase.driver(container.getBoltUrl(), authToken); }
Example 4
Source File: DBAuthTest.java From jcypher with Apache License 2.0 | 5 votes |
@Test public void testRemoteBasicAuth() { Properties props = new Properties(); props.setProperty(DBProperties.SERVER_ROOT_URI, "http://localhost:7474"); // not Bolt props.setProperty(DBProperties.DATABASE_DIR, "C:/NEO4J_DBS/01"); DBType dbType = DBType.REMOTE; AuthToken auth = AuthTokens.basic("user", "password"); IDBAccess dba = DBAccessFactory.createDBAccess(dbType, props, auth); String bauth = ((RemoteDBAccess)dba).getAuth(); assertEquals("Basic dXNlcjpwYXNzd29yZA==", bauth); return; }
Example 5
Source File: BoltDBAccess.java From jcypher with Apache License 2.0 | 4 votes |
@Override public void setAuth(String userId, String password) { if (userId != null && password != null) this.authToken = AuthTokens.basic(userId, password); }