|
14 | 14 | package com.rabbitmq.stream.impl;
|
15 | 15 |
|
16 | 16 | import static com.rabbitmq.stream.Constants.*;
|
17 |
| -import static com.rabbitmq.stream.impl.Utils.encodeRequestCode; |
18 |
| -import static com.rabbitmq.stream.impl.Utils.encodeResponseCode; |
19 |
| -import static com.rabbitmq.stream.impl.Utils.extractResponseCode; |
20 |
| -import static com.rabbitmq.stream.impl.Utils.formatConstant; |
21 |
| -import static com.rabbitmq.stream.impl.Utils.noOpConsumer; |
| 17 | +import static com.rabbitmq.stream.impl.Utils.*; |
22 | 18 | import static java.lang.String.format;
|
23 | 19 | import static java.lang.String.join;
|
24 | 20 | import static java.util.concurrent.TimeUnit.SECONDS;
|
@@ -495,10 +491,21 @@ private void authenticate() {
|
495 | 491 | } else if (saslAuthenticateResponse.isChallenge()) {
|
496 | 492 | challenge = saslAuthenticateResponse.challenge;
|
497 | 493 | } else if (saslAuthenticateResponse.isAuthenticationFailure()) {
|
498 |
| - throw new AuthenticationFailureException( |
| 494 | + String message = |
499 | 495 | "Unexpected response code during authentication: "
|
500 |
| - + formatConstant(saslAuthenticateResponse.getResponseCode()), |
501 |
| - saslAuthenticateResponse.getResponseCode()); |
| 496 | + + formatConstant(saslAuthenticateResponse.getResponseCode()); |
| 497 | + if (saslAuthenticateResponse.getResponseCode() |
| 498 | + == RESPONSE_CODE_AUTHENTICATION_FAILURE_LOOPBACK) { |
| 499 | + message += |
| 500 | + ". The user is not authorized to connect from a remote host. " |
| 501 | + + "If the broker is running locally, make sure the '" |
| 502 | + + this.host |
| 503 | + + "' hostname is resolved to " |
| 504 | + + "the loopback interface (localhost, 127.0.0.1, ::1). " |
| 505 | + + "See https://www.rabbitmq.com/access-control.html#loopback-users."; |
| 506 | + } |
| 507 | + throw new AuthenticationFailureException( |
| 508 | + message, saslAuthenticateResponse.getResponseCode()); |
502 | 509 | } else {
|
503 | 510 | throw new StreamException(
|
504 | 511 | "Unexpected response code during authentication: "
|
@@ -2234,7 +2241,7 @@ public static class ClientParameters {
|
2234 | 2241 | private ShutdownListener shutdownListener = shutdownContext -> {};
|
2235 | 2242 | private SaslConfiguration saslConfiguration = DefaultSaslConfiguration.PLAIN;
|
2236 | 2243 | private CredentialsProvider credentialsProvider =
|
2237 |
| - new DefaultUsernamePasswordCredentialsProvider("guest", "guest"); |
| 2244 | + new DefaultUsernamePasswordCredentialsProvider(DEFAULT_USERNAME, "guest"); |
2238 | 2245 | private ChunkChecksum chunkChecksum = JdkChunkChecksum.CRC32_SINGLETON;
|
2239 | 2246 | private MetricsCollector metricsCollector = NoOpMetricsCollector.SINGLETON;
|
2240 | 2247 | private SslContext sslContext;
|
@@ -2438,6 +2445,10 @@ Codec codec() {
|
2438 | 2445 | return this.codec;
|
2439 | 2446 | }
|
2440 | 2447 |
|
| 2448 | + CredentialsProvider credentialsProvider() { |
| 2449 | + return this.credentialsProvider; |
| 2450 | + } |
| 2451 | + |
2441 | 2452 | public ClientParameters channelCustomizer(Consumer<Channel> channelCustomizer) {
|
2442 | 2453 | this.channelCustomizer = channelCustomizer;
|
2443 | 2454 | return this;
|
|
0 commit comments