use of org.neo4j.internal.kernel.api.security.AccessMode in project neo4j by neo4j.
the class AllStoreHolder method relationshipExists.
@Override
public boolean relationshipExists(long reference) {
ktx.assertOpen();
if (hasTxStateWithChanges()) {
TransactionState txState = txState();
if (txState.relationshipIsDeletedInThisTx(reference)) {
return false;
} else if (txState.relationshipIsAddedInThisTx(reference)) {
return true;
}
}
AccessMode mode = ktx.securityContext().mode();
CursorContext cursorContext = ktx.cursorContext();
boolean existsInRelStore = storageReader.relationshipExists(reference, cursorContext);
if (mode.allowsTraverseAllRelTypes()) {
return existsInRelStore;
} else if (!existsInRelStore) {
return false;
} else {
// DefaultNodeCursor already contains traversal checks within next()
try (DefaultRelationshipScanCursor rels = cursors.allocateRelationshipScanCursor(cursorContext)) {
ktx.dataRead().singleRelationship(reference, rels);
return rels.next();
}
}
}
use of org.neo4j.internal.kernel.api.security.AccessMode in project neo4j by neo4j.
the class BuiltInProcedures method listLabels.
@SystemProcedure
@Description("List all available labels in the database.")
@Procedure(name = "db.labels", mode = READ)
public Stream<LabelResult> listLabels() {
if (callContext.isSystemDatabase()) {
return Stream.empty();
}
AccessMode mode = kernelTransaction.securityContext().mode();
TokenRead tokenRead = kernelTransaction.tokenRead();
List<LabelResult> labelsInUse;
try (KernelTransaction.Revertable ignore = kernelTransaction.overrideWith(SecurityContext.AUTH_DISABLED)) {
// Get all labels that are in use as seen by a super user
labelsInUse = stream(LABELS.inUse(kernelTransaction)).filter(label -> mode.allowsTraverseNode(tokenRead.nodeLabel(label.name()))).map(LabelResult::new).collect(Collectors.toList());
}
return labelsInUse.stream();
}
Aggregations