36
36
import java .util .function .Function ;
37
37
import java .util .function .Supplier ;
38
38
import org .neo4j .driver .internal .bolt .api .AccessMode ;
39
+ import org .neo4j .driver .internal .bolt .api .AuthToken ;
39
40
import org .neo4j .driver .internal .bolt .api .BasicResponseHandler ;
40
41
import org .neo4j .driver .internal .bolt .api .BoltAgent ;
41
42
import org .neo4j .driver .internal .bolt .api .BoltConnection ;
51
52
import org .neo4j .driver .internal .bolt .api .SecurityPlan ;
52
53
import org .neo4j .driver .internal .bolt .api .exception .BoltTransientException ;
53
54
import org .neo4j .driver .internal .bolt .api .exception .MinVersionAcquisitionException ;
54
- import org .neo4j .driver .internal .bolt .api .values .Value ;
55
55
import org .neo4j .driver .internal .bolt .pooledimpl .impl .PooledBoltConnection ;
56
56
import org .neo4j .driver .internal .bolt .pooledimpl .impl .util .FutureUtil ;
57
57
@@ -129,7 +129,7 @@ public CompletionStage<Void> init(
129
129
public CompletionStage <BoltConnection > connect (
130
130
SecurityPlan securityPlan ,
131
131
DatabaseName databaseName ,
132
- Supplier <CompletionStage <Map < String , Value >>> authMapStageSupplier ,
132
+ Supplier <CompletionStage <AuthToken >> authTokenStageSupplier ,
133
133
AccessMode mode ,
134
134
Set <String > bookmarks ,
135
135
String impersonatedUser ,
@@ -145,7 +145,7 @@ public CompletionStage<BoltConnection> connect(
145
145
146
146
var acquisitionFuture = new CompletableFuture <PooledBoltConnection >();
147
147
148
- authMapStageSupplier .get ().whenComplete ((authMap , authThrowable ) -> {
148
+ authTokenStageSupplier .get ().whenComplete ((authToken , authThrowable ) -> {
149
149
if (authThrowable != null ) {
150
150
acquisitionFuture .completeExceptionally (authThrowable );
151
151
return ;
@@ -168,8 +168,8 @@ public CompletionStage<BoltConnection> connect(
168
168
acquisitionFuture ,
169
169
securityPlan ,
170
170
databaseName ,
171
- authMap ,
172
- authMapStageSupplier ,
171
+ authToken ,
172
+ authTokenStageSupplier ,
173
173
mode ,
174
174
bookmarks ,
175
175
impersonatedUser ,
@@ -191,8 +191,8 @@ private void connect(
191
191
CompletableFuture <PooledBoltConnection > acquisitionFuture ,
192
192
SecurityPlan securityPlan ,
193
193
DatabaseName databaseName ,
194
- Map < String , Value > authMap ,
195
- Supplier <CompletionStage <Map < String , Value >>> authMapStageSupplier ,
194
+ AuthToken authToken ,
195
+ Supplier <CompletionStage <AuthToken >> authTokenStageSupplier ,
196
196
AccessMode mode ,
197
197
Set <String > bookmarks ,
198
198
String impersonatedUser ,
@@ -207,7 +207,7 @@ private void connect(
207
207
empty .set (pooledConnectionEntries .isEmpty ());
208
208
try {
209
209
// go over existing entries first
210
- connectionEntryWithMetadata = acquireExistingEntry (authMap , minVersion );
210
+ connectionEntryWithMetadata = acquireExistingEntry (authToken , minVersion );
211
211
} catch (MinVersionAcquisitionException e ) {
212
212
acquisitionFuture .completeExceptionally (e );
213
213
return ;
@@ -284,8 +284,8 @@ private void connect(
284
284
acquisitionFuture ,
285
285
securityPlan ,
286
286
databaseName ,
287
- authMap ,
288
- authMapStageSupplier ,
287
+ authToken ,
288
+ authTokenStageSupplier ,
289
289
mode ,
290
290
bookmarks ,
291
291
impersonatedUser ,
@@ -305,7 +305,7 @@ private void connect(
305
305
purge (entry );
306
306
metricsListener .afterConnectionReleased (poolId , inUseEvent );
307
307
});
308
- reauthStage (entryWithMetadata , authMap ).whenComplete ((ignored2 , throwable2 ) -> {
308
+ reauthStage (entryWithMetadata , authToken ).whenComplete ((ignored2 , throwable2 ) -> {
309
309
if (!acquisitionFuture .complete (pooledConnection )) {
310
310
// acquisition timed out
311
311
CompletableFuture <PooledBoltConnection > pendingAcquisition ;
@@ -336,7 +336,9 @@ private void connect(
336
336
.connect (
337
337
securityPlan ,
338
338
databaseName ,
339
- empty .get () ? () -> CompletableFuture .completedStage (authMap ) : authMapStageSupplier ,
339
+ empty .get ()
340
+ ? () -> CompletableFuture .completedStage (authToken )
341
+ : authTokenStageSupplier ,
340
342
mode ,
341
343
bookmarks ,
342
344
impersonatedUser ,
@@ -395,7 +397,7 @@ private void connect(
395
397
}
396
398
397
399
private synchronized ConnectionEntryWithMetadata acquireExistingEntry (
398
- Map < String , Value > authMap , BoltProtocolVersion minVersion ) {
400
+ AuthToken authToken , BoltProtocolVersion minVersion ) {
399
401
ConnectionEntryWithMetadata connectionEntryWithMetadata = null ;
400
402
var iterator = pooledConnectionEntries .iterator ();
401
403
while (iterator .hasNext ()) {
@@ -431,10 +433,10 @@ private synchronized ConnectionEntryWithMetadata acquireExistingEntry(
431
433
}
432
434
433
435
// the pool must not have unauthenticated connections
434
- var authData = connection .authData ().toCompletableFuture ().getNow (null );
436
+ var authInfo = connection .authInfo ().toCompletableFuture ().getNow (null );
435
437
436
- var expiredByError = minAuthTimestamp > 0 && authData .authAckMillis () <= minAuthTimestamp ;
437
- var authMatches = authMap .equals (authData . authMap ());
438
+ var expiredByError = minAuthTimestamp > 0 && authInfo .authAckMillis () <= minAuthTimestamp ;
439
+ var authMatches = authToken .equals (authInfo . authToken ());
438
440
var reauthNeeded = expiredByError || !authMatches ;
439
441
440
442
if (reauthNeeded ) {
@@ -461,14 +463,14 @@ private synchronized ConnectionEntryWithMetadata acquireExistingEntry(
461
463
}
462
464
463
465
private CompletionStage <Void > reauthStage (
464
- ConnectionEntryWithMetadata connectionEntryWithMetadata , Map < String , Value > authMap ) {
466
+ ConnectionEntryWithMetadata connectionEntryWithMetadata , AuthToken authToken ) {
465
467
CompletionStage <Void > stage ;
466
468
if (connectionEntryWithMetadata .reauthNeeded ) {
467
469
stage = connectionEntryWithMetadata
468
470
.connectionEntry
469
471
.connection
470
472
.logoff ()
471
- .thenCompose (conn -> conn .logon (authMap ))
473
+ .thenCompose (conn -> conn .logon (authToken ))
472
474
.handle ((ignored , throwable ) -> {
473
475
if (throwable != null ) {
474
476
connectionEntryWithMetadata .connectionEntry .connection .close ();
@@ -500,11 +502,11 @@ private CompletionStage<Void> livenessCheckStage(ConnectionEntry entry) {
500
502
}
501
503
502
504
@ Override
503
- public CompletionStage <Void > verifyConnectivity (SecurityPlan securityPlan , Map < String , Value > authMap ) {
505
+ public CompletionStage <Void > verifyConnectivity (SecurityPlan securityPlan , AuthToken authToken ) {
504
506
return connect (
505
507
securityPlan ,
506
508
null ,
507
- () -> CompletableFuture .completedStage (authMap ),
509
+ () -> CompletableFuture .completedStage (authToken ),
508
510
AccessMode .WRITE ,
509
511
Collections .emptySet (),
510
512
null ,
@@ -516,11 +518,11 @@ public CompletionStage<Void> verifyConnectivity(SecurityPlan securityPlan, Map<S
516
518
}
517
519
518
520
@ Override
519
- public CompletionStage <Boolean > supportsMultiDb (SecurityPlan securityPlan , Map < String , Value > authMap ) {
521
+ public CompletionStage <Boolean > supportsMultiDb (SecurityPlan securityPlan , AuthToken authToken ) {
520
522
return connect (
521
523
securityPlan ,
522
524
null ,
523
- () -> CompletableFuture .completedStage (authMap ),
525
+ () -> CompletableFuture .completedStage (authToken ),
524
526
AccessMode .WRITE ,
525
527
Collections .emptySet (),
526
528
null ,
@@ -535,11 +537,11 @@ public CompletionStage<Boolean> supportsMultiDb(SecurityPlan securityPlan, Map<S
535
537
}
536
538
537
539
@ Override
538
- public CompletionStage <Boolean > supportsSessionAuth (SecurityPlan securityPlan , Map < String , Value > authMap ) {
540
+ public CompletionStage <Boolean > supportsSessionAuth (SecurityPlan securityPlan , AuthToken authToken ) {
539
541
return connect (
540
542
securityPlan ,
541
543
null ,
542
- () -> CompletableFuture .completedStage (authMap ),
544
+ () -> CompletableFuture .completedStage (authToken ),
543
545
AccessMode .WRITE ,
544
546
Collections .emptySet (),
545
547
null ,
0 commit comments