|
16 | 16 | */
|
17 | 17 | package org.neo4j.driver.internal.async;
|
18 | 18 |
|
19 |
| -import java.time.Duration; |
20 |
| -import java.util.Map; |
21 | 19 | import java.util.Objects;
|
22 |
| -import java.util.Set; |
23 | 20 | import java.util.concurrent.CompletionStage;
|
24 | 21 | import org.neo4j.driver.AuthTokenManager;
|
25 |
| -import org.neo4j.driver.Value; |
26 | 22 | import org.neo4j.driver.exceptions.SecurityException;
|
27 | 23 | import org.neo4j.driver.exceptions.SecurityRetryableException;
|
28 |
| -import org.neo4j.driver.internal.bolt.api.AccessMode; |
29 |
| -import org.neo4j.driver.internal.bolt.api.AuthData; |
30 | 24 | import org.neo4j.driver.internal.bolt.api.BoltConnection;
|
31 |
| -import org.neo4j.driver.internal.bolt.api.BoltConnectionState; |
32 |
| -import org.neo4j.driver.internal.bolt.api.BoltProtocolVersion; |
33 |
| -import org.neo4j.driver.internal.bolt.api.BoltServerAddress; |
34 |
| -import org.neo4j.driver.internal.bolt.api.DatabaseName; |
35 |
| -import org.neo4j.driver.internal.bolt.api.NotificationConfig; |
36 | 25 | import org.neo4j.driver.internal.bolt.api.ResponseHandler;
|
37 |
| -import org.neo4j.driver.internal.bolt.api.TelemetryApi; |
38 |
| -import org.neo4j.driver.internal.bolt.api.TransactionType; |
39 |
| -import org.neo4j.driver.internal.bolt.api.summary.BeginSummary; |
40 |
| -import org.neo4j.driver.internal.bolt.api.summary.CommitSummary; |
41 |
| -import org.neo4j.driver.internal.bolt.api.summary.DiscardSummary; |
42 |
| -import org.neo4j.driver.internal.bolt.api.summary.LogoffSummary; |
43 |
| -import org.neo4j.driver.internal.bolt.api.summary.LogonSummary; |
44 |
| -import org.neo4j.driver.internal.bolt.api.summary.PullSummary; |
45 |
| -import org.neo4j.driver.internal.bolt.api.summary.ResetSummary; |
46 |
| -import org.neo4j.driver.internal.bolt.api.summary.RollbackSummary; |
47 |
| -import org.neo4j.driver.internal.bolt.api.summary.RouteSummary; |
48 |
| -import org.neo4j.driver.internal.bolt.api.summary.RunSummary; |
49 |
| -import org.neo4j.driver.internal.bolt.api.summary.TelemetrySummary; |
50 | 26 | import org.neo4j.driver.internal.security.InternalAuthToken;
|
51 | 27 |
|
52 |
| -public class BoltConnectionWithAuthTokenManager implements BoltConnection { |
53 |
| - private final BoltConnection delegate; |
| 28 | +final class BoltConnectionWithAuthTokenManager extends DelegatingBoltConnection { |
54 | 29 | private final AuthTokenManager authTokenManager;
|
55 | 30 |
|
56 | 31 | public BoltConnectionWithAuthTokenManager(BoltConnection delegate, AuthTokenManager authTokenManager) {
|
57 |
| - this.delegate = Objects.requireNonNull(delegate); |
| 32 | + super(delegate); |
58 | 33 | this.authTokenManager = Objects.requireNonNull(authTokenManager);
|
59 | 34 | }
|
60 | 35 |
|
61 |
| - @Override |
62 |
| - public CompletionStage<BoltConnection> route( |
63 |
| - DatabaseName databaseName, String impersonatedUser, Set<String> bookmarks) { |
64 |
| - return delegate.route(databaseName, impersonatedUser, bookmarks).thenApply(ignored -> this); |
65 |
| - } |
66 |
| - |
67 |
| - @Override |
68 |
| - public CompletionStage<BoltConnection> beginTransaction( |
69 |
| - DatabaseName databaseName, |
70 |
| - AccessMode accessMode, |
71 |
| - String impersonatedUser, |
72 |
| - Set<String> bookmarks, |
73 |
| - TransactionType transactionType, |
74 |
| - Duration txTimeout, |
75 |
| - Map<String, Value> txMetadata, |
76 |
| - String txType, |
77 |
| - NotificationConfig notificationConfig) { |
78 |
| - return delegate.beginTransaction( |
79 |
| - databaseName, |
80 |
| - accessMode, |
81 |
| - impersonatedUser, |
82 |
| - bookmarks, |
83 |
| - transactionType, |
84 |
| - txTimeout, |
85 |
| - txMetadata, |
86 |
| - txType, |
87 |
| - notificationConfig) |
88 |
| - .thenApply(ignored -> this); |
89 |
| - } |
90 |
| - |
91 |
| - @Override |
92 |
| - public CompletionStage<BoltConnection> runInAutoCommitTransaction( |
93 |
| - DatabaseName databaseName, |
94 |
| - AccessMode accessMode, |
95 |
| - String impersonatedUser, |
96 |
| - Set<String> bookmarks, |
97 |
| - String query, |
98 |
| - Map<String, Value> parameters, |
99 |
| - Duration txTimeout, |
100 |
| - Map<String, Value> txMetadata, |
101 |
| - NotificationConfig notificationConfig) { |
102 |
| - return delegate.runInAutoCommitTransaction( |
103 |
| - databaseName, |
104 |
| - accessMode, |
105 |
| - impersonatedUser, |
106 |
| - bookmarks, |
107 |
| - query, |
108 |
| - parameters, |
109 |
| - txTimeout, |
110 |
| - txMetadata, |
111 |
| - notificationConfig) |
112 |
| - .thenApply(ignored -> this); |
113 |
| - } |
114 |
| - |
115 |
| - @Override |
116 |
| - public CompletionStage<BoltConnection> run(String query, Map<String, Value> parameters) { |
117 |
| - return delegate.run(query, parameters).thenApply(ignored -> this); |
118 |
| - } |
119 |
| - |
120 |
| - @Override |
121 |
| - public CompletionStage<BoltConnection> pull(long qid, long request) { |
122 |
| - return delegate.pull(qid, request).thenApply(ignored -> this); |
123 |
| - } |
124 |
| - |
125 |
| - @Override |
126 |
| - public CompletionStage<BoltConnection> discard(long qid, long number) { |
127 |
| - return delegate.discard(qid, number).thenApply(ignored -> this); |
128 |
| - } |
129 |
| - |
130 |
| - @Override |
131 |
| - public CompletionStage<BoltConnection> commit() { |
132 |
| - return delegate.commit().thenApply(ignored -> this); |
133 |
| - } |
134 |
| - |
135 |
| - @Override |
136 |
| - public CompletionStage<BoltConnection> rollback() { |
137 |
| - return delegate.rollback().thenApply(ignored -> this); |
138 |
| - } |
139 |
| - |
140 |
| - @Override |
141 |
| - public CompletionStage<BoltConnection> reset() { |
142 |
| - return delegate.reset().thenApply(ignored -> this); |
143 |
| - } |
144 |
| - |
145 |
| - @Override |
146 |
| - public CompletionStage<BoltConnection> logoff() { |
147 |
| - return delegate.logoff().thenApply(ignored -> this); |
148 |
| - } |
149 |
| - |
150 |
| - @Override |
151 |
| - public CompletionStage<BoltConnection> logon(Map<String, Value> authMap) { |
152 |
| - return delegate.logon(authMap).thenApply(ignored -> this); |
153 |
| - } |
154 |
| - |
155 |
| - @Override |
156 |
| - public CompletionStage<BoltConnection> telemetry(TelemetryApi telemetryApi) { |
157 |
| - return delegate.telemetry(telemetryApi).thenApply(ignored -> this); |
158 |
| - } |
159 |
| - |
160 |
| - @Override |
161 |
| - public CompletionStage<BoltConnection> clear() { |
162 |
| - return delegate.clear(); |
163 |
| - } |
164 |
| - |
165 | 36 | @Override
|
166 | 37 | public CompletionStage<Void> flush(ResponseHandler handler) {
|
167 |
| - return delegate.flush(new ResponseHandler() { |
168 |
| - |
169 |
| - @Override |
170 |
| - public void onError(Throwable throwable) { |
171 |
| - handler.onError(mapSecurityError(throwable)); |
172 |
| - } |
173 |
| - |
174 |
| - @Override |
175 |
| - public void onBeginSummary(BeginSummary summary) { |
176 |
| - handler.onBeginSummary(summary); |
177 |
| - } |
178 |
| - |
179 |
| - @Override |
180 |
| - public void onRunSummary(RunSummary summary) { |
181 |
| - handler.onRunSummary(summary); |
182 |
| - } |
183 |
| - |
184 |
| - @Override |
185 |
| - public void onRecord(Value[] fields) { |
186 |
| - handler.onRecord(fields); |
187 |
| - } |
188 |
| - |
189 |
| - @Override |
190 |
| - public void onPullSummary(PullSummary summary) { |
191 |
| - handler.onPullSummary(summary); |
192 |
| - } |
193 |
| - |
194 |
| - @Override |
195 |
| - public void onDiscardSummary(DiscardSummary summary) { |
196 |
| - handler.onDiscardSummary(summary); |
197 |
| - } |
198 |
| - |
199 |
| - @Override |
200 |
| - public void onCommitSummary(CommitSummary summary) { |
201 |
| - handler.onCommitSummary(summary); |
202 |
| - } |
203 |
| - |
204 |
| - @Override |
205 |
| - public void onRollbackSummary(RollbackSummary summary) { |
206 |
| - handler.onRollbackSummary(summary); |
207 |
| - } |
208 |
| - |
209 |
| - @Override |
210 |
| - public void onResetSummary(ResetSummary summary) { |
211 |
| - handler.onResetSummary(summary); |
212 |
| - } |
213 |
| - |
214 |
| - @Override |
215 |
| - public void onRouteSummary(RouteSummary summary) { |
216 |
| - handler.onRouteSummary(summary); |
217 |
| - } |
218 |
| - |
219 |
| - @Override |
220 |
| - public void onLogoffSummary(LogoffSummary summary) { |
221 |
| - handler.onLogoffSummary(summary); |
222 |
| - } |
223 |
| - |
224 |
| - @Override |
225 |
| - public void onLogonSummary(LogonSummary summary) { |
226 |
| - handler.onLogonSummary(summary); |
227 |
| - } |
228 |
| - |
229 |
| - @Override |
230 |
| - public void onTelemetrySummary(TelemetrySummary summary) { |
231 |
| - handler.onTelemetrySummary(summary); |
232 |
| - } |
233 |
| - |
234 |
| - @Override |
235 |
| - public void onIgnored() { |
236 |
| - handler.onIgnored(); |
237 |
| - } |
238 |
| - |
239 |
| - @Override |
240 |
| - public void onComplete() { |
241 |
| - handler.onComplete(); |
242 |
| - } |
243 |
| - }); |
244 |
| - } |
245 |
| - |
246 |
| - @Override |
247 |
| - public CompletionStage<Void> forceClose(String reason) { |
248 |
| - return delegate.forceClose(reason); |
249 |
| - } |
250 |
| - |
251 |
| - @Override |
252 |
| - public CompletionStage<Void> close() { |
253 |
| - return delegate.close(); |
254 |
| - } |
255 |
| - |
256 |
| - @Override |
257 |
| - public BoltConnectionState state() { |
258 |
| - return delegate.state(); |
259 |
| - } |
260 |
| - |
261 |
| - @Override |
262 |
| - public CompletionStage<AuthData> authData() { |
263 |
| - return delegate.authData(); |
264 |
| - } |
265 |
| - |
266 |
| - @Override |
267 |
| - public String serverAgent() { |
268 |
| - return delegate.serverAgent(); |
269 |
| - } |
270 |
| - |
271 |
| - @Override |
272 |
| - public BoltServerAddress serverAddress() { |
273 |
| - return delegate.serverAddress(); |
274 |
| - } |
275 |
| - |
276 |
| - @Override |
277 |
| - public BoltProtocolVersion protocolVersion() { |
278 |
| - return delegate.protocolVersion(); |
279 |
| - } |
280 |
| - |
281 |
| - @Override |
282 |
| - public boolean telemetrySupported() { |
283 |
| - return delegate.telemetrySupported(); |
| 38 | + return delegate.flush(new ErrorMappingResponseHandler(handler, this::mapSecurityError)); |
284 | 39 | }
|
285 | 40 |
|
286 | 41 | private Throwable mapSecurityError(Throwable throwable) {
|
|
0 commit comments