use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class CommunitySecurityModule method setup.
@Override
public void setup(Dependencies dependencies) throws KernelException {
Config config = dependencies.config();
Procedures procedures = dependencies.procedures();
LogProvider logProvider = dependencies.logService().getUserLogProvider();
FileSystemAbstraction fileSystem = dependencies.fileSystem();
final UserRepository userRepository = getUserRepository(config, logProvider, fileSystem);
final UserRepository initialUserRepository = getInitialUserRepository(config, logProvider, fileSystem);
final PasswordPolicy passwordPolicy = new BasicPasswordPolicy();
procedures.writerCreateToken(true);
BasicAuthManager authManager = new BasicAuthManager(userRepository, passwordPolicy, Clocks.systemClock(), initialUserRepository);
dependencies.lifeSupport().add(dependencies.dependencySatisfier().satisfyDependency(authManager));
procedures.registerComponent(UserManager.class, ctx -> authManager, false);
procedures.registerProcedure(AuthProcedures.class);
}
use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class ConfiguredProceduresTestBase method shouldNotRunProcedureWithMismatchingWildCardAllowed.
@Test
public void shouldNotRunProcedureWithMismatchingWildCardAllowed() throws Throwable {
configuredSetup(stringMap(SecuritySettings.procedure_roles.name(), "tes.*:role1"));
userManager.newRole("role1", "noneSubject");
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
ProcedureSignature numNodes = procedures.procedure(new QualifiedName(new String[] { "test" }, "numNodes"));
assertThat(Arrays.asList(numNodes.allowed()), empty());
assertFail(noneSubject, "CALL test.numNodes", "Read operations are not allowed");
}
use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class ConfiguredProceduresTestBase method shouldNotSetProcedureAllowedIfSettingNotSet.
@Test
public void shouldNotSetProcedureAllowedIfSettingNotSet() throws Throwable {
configuredSetup(defaultConfiguration());
Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
ProcedureSignature numNodes = procedures.procedure(new QualifiedName(new String[] { "test" }, "numNodes"));
assertThat(Arrays.asList(numNodes.allowed()), empty());
}
use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class GraphDatabaseServiceExecuteTest method shouldBeAbleToUseResultsOfPointProcedureAsInputToDistanceFunction.
@Test
public void shouldBeAbleToUseResultsOfPointProcedureAsInputToDistanceFunction() throws Exception {
// given procedure that produces a point
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
Procedures procedures = ((GraphDatabaseAPI) graphDb).getDependencyResolver().resolveDependency(Procedures.class);
procedures.registerProcedure(PointProcs.class);
// when calling procedure that produces a point
Result result = graphDb.execute("CALL spatial.point(144.317718, -37.031738) YIELD point " + "RETURN distance(point({longitude: 144.317718, latitude: -37.031738}), point) AS dist");
// then
Double dist = (Double) result.next().get("dist");
assertThat(dist, equalTo(0.0));
}
use of org.neo4j.kernel.impl.proc.Procedures in project neo4j by neo4j.
the class DataSourceModule method setupProcedures.
private Procedures setupProcedures(PlatformModule platform, EditionModule editionModule) {
File pluginDir = platform.config.get(GraphDatabaseSettings.plugin_dir);
Log internalLog = platform.logging.getInternalLog(Procedures.class);
Procedures procedures = new Procedures(new SpecialBuiltInProcedures(Version.getNeo4jVersion(), platform.databaseInfo.edition.toString()), pluginDir, internalLog, new ProcedureConfig(platform.config));
platform.life.add(procedures);
platform.dependencies.satisfyDependency(procedures);
procedures.registerType(Node.class, new SimpleConverter(NTNode, Node.class));
procedures.registerType(Relationship.class, new SimpleConverter(NTRelationship, Relationship.class));
procedures.registerType(Path.class, new SimpleConverter(NTPath, Path.class));
procedures.registerType(Geometry.class, new SimpleConverter(NTGeometry, Geometry.class));
procedures.registerType(Point.class, new SimpleConverter(NTPoint, Point.class));
// Register injected public API components
Log proceduresLog = platform.logging.getUserLog(Procedures.class);
procedures.registerComponent(Log.class, (ctx) -> proceduresLog, true);
Guard guard = platform.dependencies.resolveDependency(Guard.class);
procedures.registerComponent(ProcedureTransaction.class, new ProcedureTransactionProvider(), true);
procedures.registerComponent(TerminationGuard.class, new TerminationGuardProvider(guard), true);
// Below components are not public API, but are made available for internal
// procedures to call, and to provide temporary workarounds for the following
// patterns:
// - Batch-transaction imports (GDAPI, needs to be real and passed to background processing threads)
// - Group-transaction writes (same pattern as above, but rather than splitting large transactions,
// combine lots of small ones)
// - Bleeding-edge performance (KernelTransaction, to bypass overhead of working with Core API)
procedures.registerComponent(DependencyResolver.class, (ctx) -> platform.dependencies, false);
procedures.registerComponent(KernelTransaction.class, (ctx) -> ctx.get(KERNEL_TRANSACTION), false);
procedures.registerComponent(GraphDatabaseAPI.class, (ctx) -> platform.graphDatabaseFacade, false);
// Security procedures
procedures.registerComponent(SecurityContext.class, ctx -> ctx.get(SECURITY_CONTEXT), true);
// Edition procedures
try {
editionModule.registerProcedures(procedures);
} catch (KernelException e) {
internalLog.error("Failed to register built-in edition procedures at start up: " + e.getMessage());
}
return procedures;
}
Aggregations