File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
main/java/org/springframework/amqp/rabbit/connection
test/java/org/springframework/amqp/rabbit/connection Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 51
51
import com .rabbitmq .client .MetricsCollector ;
52
52
import com .rabbitmq .client .SaslConfig ;
53
53
import com .rabbitmq .client .SocketConfigurator ;
54
+ import com .rabbitmq .client .impl .CredentialsProvider ;
55
+ import com .rabbitmq .client .impl .CredentialsRefreshService ;
54
56
import com .rabbitmq .client .impl .nio .NioParams ;
55
57
56
58
/**
@@ -450,6 +452,24 @@ public void setPassword(String password) {
450
452
this .connectionFactory .setPassword (password );
451
453
}
452
454
455
+ /**
456
+ * Set a credentials provider (e.g. OAUTH2).
457
+ * @param provider the provider.
458
+ * @since 2.3
459
+ */
460
+ public void setCredentialsProvider (CredentialsProvider provider ) {
461
+ this .connectionFactory .setCredentialsProvider (provider );
462
+ }
463
+
464
+ /**
465
+ * Set a refresh service.
466
+ * @param service the service.
467
+ * @since 2.3
468
+ */
469
+ public void setCredentialsRefreshService (CredentialsRefreshService service ) {
470
+ this .connectionFactory .setCredentialsRefreshService (service );
471
+ }
472
+
453
473
/**
454
474
* @param virtualHost the virtual host.
455
475
* @see com.rabbitmq.client.ConnectionFactory#setVirtualHost(java.lang.String)
Original file line number Diff line number Diff line change 19
19
import static org .assertj .core .api .Assertions .assertThat ;
20
20
import static org .assertj .core .api .Assertions .fail ;
21
21
import static org .mockito .BDDMockito .given ;
22
+ import static org .mockito .Mockito .mock ;
22
23
import static org .mockito .Mockito .never ;
23
24
import static org .mockito .Mockito .spy ;
24
25
import static org .mockito .Mockito .verify ;
41
42
import com .rabbitmq .client .Channel ;
42
43
import com .rabbitmq .client .Connection ;
43
44
import com .rabbitmq .client .ConnectionFactory ;
45
+ import com .rabbitmq .client .impl .CredentialsProvider ;
46
+ import com .rabbitmq .client .impl .CredentialsRefreshService ;
44
47
45
48
46
49
@@ -257,4 +260,18 @@ public void testTypeSettersOverrideProps() {
257
260
}
258
261
}
259
262
263
+ @ Test
264
+ public void credentials () {
265
+ RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean ();
266
+ CredentialsProvider provider = mock (CredentialsProvider .class );
267
+ fb .setCredentialsProvider (provider );
268
+ CredentialsRefreshService service = mock (CredentialsRefreshService .class );
269
+ fb .setCredentialsRefreshService (service );
270
+ assertThat (TestUtils .getPropertyValue (fb .getRabbitConnectionFactory (), "credentialsProvider" ))
271
+ .isSameAs (provider );
272
+ assertThat (TestUtils .getPropertyValue (fb .getRabbitConnectionFactory (), "credentialsRefreshService" ))
273
+ .isSameAs (service );
274
+ }
275
+
276
+
260
277
}
You can’t perform that action at this time.
0 commit comments