本文整理汇总了Java中org.neo4j.driver.v1.AuthTokens类的典型用法代码示例。如果您正苦于以下问题:Java AuthTokens类的具体用法?Java AuthTokens怎么用?Java AuthTokens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthTokens类属于org.neo4j.driver.v1包,在下文中一共展示了AuthTokens类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldAuthenticateAndAuthorizeKalleMoraeusAsAdmin
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
@Test
public void shouldAuthenticateAndAuthorizeKalleMoraeusAsAdmin() throws Exception
{
Driver driver = GraphDatabase.driver( server.boltURI(), AuthTokens.basic( "moraeus", "suearom" ) );
Session session = driver.session();
session.run( "CREATE (a:Person {name:'Kalle Moraeus', title:'Riksspelman'})" );
StatementResult result =
session.run( "MATCH (a:Person) WHERE a.name = 'Kalle Moraeus' RETURN a.name AS name, a.title AS title" );
assertTrue( result.hasNext() );
while ( result.hasNext() )
{
Record record = result.next();
assertThat( record.get( "name" ).asString(), equalTo( "Kalle Moraeus" ) );
assertThat( record.get( "title" ).asString(), equalTo( "Riksspelman" ) );
System.out.println( record.get( "title" ).asString() + " " + record.get( "name" ).asString() );
}
session.close();
driver.close();
}
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:23,代码来源:MyAuthPluginIT.java
示例2: clear
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
@Override
public void clear(Graph graph, Configuration configuration) throws Exception {
// check graph instance
if (graph != null) {
// close graph instance
graph.close();
}
// connect to server
try (Driver driver = GraphDatabase.driver(configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JUrlConfigurationKey), AuthTokens.basic(configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JUsernameConfigurationKey), configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JPasswordConfigurationKey)), Config.defaultConfig())) {
// open session
try (Session session = driver.session()) {
// begin transaction
try (org.neo4j.driver.v1.Transaction transaction = session.beginTransaction()) {
// delete everything in database
transaction.run(new Statement("MATCH (n) DETACH DELETE n"));
// commit
transaction.success();
}
}
}
}
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:22,代码来源:Neo4JTestGraphProvider.java
示例3: connect
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
@Override
public void connect(@Nonnull ConnectionConfig connectionConfig) throws CommandException {
if (isConnected()) {
throw new CommandException("Already connected");
}
final AuthToken authToken = AuthTokens.basic(connectionConfig.username(), connectionConfig.password());
try {
driver = getDriver(connectionConfig, authToken);
reconnect();
} catch (Throwable t) {
try {
silentDisconnect();
} catch (Exception e) {
t.addSuppressed(e);
}
throw t;
}
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:21,代码来源:BoltStateHandler.java
示例4: Neo4jConnectionManager
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
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");
}
}
开发者ID:apache,项目名称:zeppelin,代码行数:21,代码来源:Neo4jConnectionManager.java
示例5: init
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void init() {
if (driver == null) {
String address = String.format("bolt://%s", hostname);
driver = GraphDatabase.driver(address, AuthTokens.basic(password, username));
logger.info("NeoDriver created: {}", driver.toString());
}
}
开发者ID:telstra,项目名称:open-kilda,代码行数:11,代码来源:NeoDriver.java
示例6: Neo4jConnector
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
public Neo4jConnector(String path, String usr, String pwd){
this.path = path;
this.usr= usr;//"C:/Users/Utente/Documents/Dottorato/Dataset/ontologies/biopax.owl";
this.pwd= pwd;
driver= GraphDatabase.driver(path,AuthTokens.basic(usr, pwd));
session = driver.session();
}
开发者ID:Giuseppe-Rizzo,项目名称:owl2neo4j,代码行数:10,代码来源:Neo4jConnector.java
示例7: shouldAuthenticateNeo4jUser
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
@Test
public void shouldAuthenticateNeo4jUser() throws Throwable
{
// When & Then
try( Driver driver = GraphDatabase.driver( server.boltURI(),
AuthTokens.basic( "neo4j", "neo4j" ) );
Session session = driver.session() )
{
Value single = session.run( "RETURN 1" ).single().get( 0 );
assertThat( single.asLong(), equalTo( 1L ) );
}
}
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:13,代码来源:MyAuthPluginIT.java
示例8: init
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
public void init(Neo4jSyncConfManager configuration)
{
log.info("configure neo4j connection to {}, user {}",configuration.getNeo4jHostname(),configuration.getNeo4jUsername());
Driver driver = GraphDatabase.driver("bolt://"+configuration.getNeo4jHostname(),
AuthTokens.basic(configuration.getNeo4jUsername(), configuration.getNeo4jPassword()));
session = driver.session();
}
开发者ID:larusba,项目名称:doc2graph,代码行数:8,代码来源:BoltNeo4jConnector.java
示例9: open
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
public static Graph open(Configuration configuration) {
if (configuration == null)
throw Graph.Exceptions.argumentCanNotBeNull("configuration");
try {
// neo4j driver configuration
Config config = Config.build()
.toConfig();
// graph name
String graphName = configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JGraphNameConfigurationKey);
// create driver instance
Driver driver = GraphDatabase.driver(configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JUrlConfigurationKey), AuthTokens.basic(configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JUsernameConfigurationKey), configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JPasswordConfigurationKey)), config);
// create providers
Neo4JElementIdProvider<?> vertexIdProvider = loadProvider(driver, configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JVertexIdProviderClassNameConfigurationKey));
Neo4JElementIdProvider<?> edgeIdProvider = loadProvider(driver, configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JEdgeIdProviderClassNameConfigurationKey));
// graph instance
Neo4JGraph graph;
// check a read partition is required
if (graphName != null)
graph = new Neo4JGraph(new AnyLabelReadPartition(graphName), new String[]{graphName}, driver, vertexIdProvider, edgeIdProvider, configuration);
else
graph = new Neo4JGraph(new NoReadPartition(), new String[]{}, driver, vertexIdProvider, edgeIdProvider, configuration);
// close driver when graph is closed
graph.addCloseListener(g -> driver.close());
// return graph instance
return graph;
}
catch (Throwable ex) {
// throw runtime exception
throw new RuntimeException("Error creating Graph instance from configuration", ex);
}
}
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:32,代码来源:Neo4JGraphFactory.java
示例10: CypherPoolingDbConnectionStore
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
public CypherPoolingDbConnectionStore(Map<String, String> properties, CypherBiQueryStore store) {
super(properties, store);
String endPoint = properties.get("endpoint");
String user = properties.get("user");
String password = properties.get("password");
driver = GraphDatabase.driver(endPoint, AuthTokens.basic(user, password));
}
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:9,代码来源:CypherPoolingDbConnectionStore.java
示例11: testRemoteBasicAuth
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
@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;
}
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:15,代码来源:DBAuthTest.java
示例12: bolt
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
private Block bolt(final String uri, final String dbkey, final String user, final String pass) {
return unit -> {
AuthToken token = unit.mock(AuthToken.class);
unit.mockStatic(AuthTokens.class);
expect(AuthTokens.basic(user, pass)).andReturn(token);
Binder binder = unit.get(Binder.class);
Session session = unit.registerMock(Session.class);
LinkedBindingBuilder<Session> lbbs = unit.mock(LinkedBindingBuilder.class);
lbbs.toInstance(session);
expect(binder.bind(Key.get(Session.class))).andReturn(lbbs);
Driver driver = unit.registerMock(Driver.class);
expect(driver.session()).andReturn(session);
LinkedBindingBuilder lbb = unit.mock(LinkedBindingBuilder.class);
lbb.toInstance(driver);
expect(binder.bind(Key.get(Driver.class))).andReturn(lbb);
unit.mockStatic(GraphDatabase.class);
expect(GraphDatabase.driver(uri, token)).andReturn(driver);
ServiceKey keys = unit.get(ServiceKey.class);
keys.generate(eq(Driver.class), eq(dbkey), unit.capture(Consumer.class));
keys.generate(eq(Session.class), eq(dbkey), unit.capture(Consumer.class));
};
}
开发者ID:jooby-project,项目名称:jooby,代码行数:33,代码来源:Neo4jTest.java
示例13: create
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
public static Neo4jModule create(String neo4jHost, int neo4jPort, int maxIdleSessions) {
Neo4jSessionFactory sessionFactory = Neo4jSessionFactory.create(
neo4jHost,
neo4jPort,
AuthTokens.none(),
maxIdleSessions
);
return new Neo4jModule(sessionFactory);
}
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:10,代码来源:Neo4jModule.java
示例14: authTokens
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
private static AuthToken authTokens(String username, String password) {
if (username.isEmpty()) {
return AuthTokens.none();
}
return AuthTokens.basic(username, password);
}
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:7,代码来源:Main.java
示例15: prepare
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
@Before
public void prepare() throws IOException {
dump = folder.newFile("dump.cypher");
exporter = new ExerciseExporter(graphDb.boltURI().toString(), AuthTokens.none());
}
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:6,代码来源:ExerciseExporterTest.java
示例16: getAuthToken
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
public AuthToken getAuthToken() {
if (username == null) {
return AuthTokens.none();
}
return AuthTokens.basic(username, password);
}
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:7,代码来源:ReplConfiguration.java
示例17: pkiAuthToken
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
private static AuthToken pkiAuthToken( String username, PrivateKey privateKey )
{
String encryptedUsername = encrypt( privateKey, username );
Map<String,Object> authParams = singletonMap( ENCRYPTED_USERNAME_PARAMETER_NAME, encryptedUsername );
return AuthTokens.custom( username, "", "", "", authParams );
}
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:7,代码来源:PkiAuthPluginIT.java
示例18: setAuth
import org.neo4j.driver.v1.AuthTokens; //导入依赖的package包/类
@Override
public void setAuth(String userId, String password) {
if (userId != null && password != null)
this.authToken = AuthTokens.basic(userId, password);
}
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:6,代码来源:BoltDBAccess.java
注:本文中的org.neo4j.driver.v1.AuthTokens类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论