Skip to content

Commit d875d88

Browse files
committed
hardcode authn identity
Signed-off-by: Emelia Lei <[email protected]>
1 parent b485062 commit d875d88

15 files changed

+880
-630
lines changed

src/groups/bmq/bmqa/bmqa_session.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@ int SessionUtil::createApplication(SessionImpl* sessionImpl)
249249

250250
static bsls::AtomicInt s_sessionInstanceCount(0);
251251

252+
// Authentication Message
253+
bmqp_ctrlmsg::AuthenticationMessage authenticaionMessage;
254+
bmqp_ctrlmsg::AuthenticateRequest& ar =
255+
authenticaionMessage.makeAuthenticateRequest();
256+
bsl::string str = "username:password";
257+
ar.mechanism() = "basic";
258+
ar.data() = bsl::vector<char>(str.begin(), str.end()); // hexBinary
259+
252260
// Negotiation Message
253261
bmqp_ctrlmsg::NegotiationMessage negotiationMessage;
254262
bmqp_ctrlmsg::ClientIdentity& ci = negotiationMessage.makeClientIdentity();
@@ -314,6 +322,7 @@ int SessionUtil::createApplication(SessionImpl* sessionImpl)
314322
sessionImpl->d_application_mp.load(
315323
new (*(sessionImpl->d_allocator_p))
316324
bmqimp::Application(options,
325+
authenticaionMessage,
317326
negotiationMessage,
318327
eventHandler,
319328
sessionImpl->d_allocator_p),

src/groups/bmq/bmqimp/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ its components directly, but rather use the accessor public APIs from 'bmqa'.
1313

1414
Component Synopsis
1515
------------------
16-
Component | Provides ...
17-
----------------------------------|-----------------------------------------------------------
18-
`bmqimp_application` | the top level object to manipulate a session with bmqbrkr.
19-
`bmqimp_brokersession` | the implementation of a session with the bmqbrkr.
20-
`bmqimp_event` | a value-semantic type representing an event.
21-
`bmqimp_eventqueue` | a thread safe queue of pooled bmqimp::Event items.
22-
`bmqpimp_eventsstats` | a mechanism to keep track of Events statistics.
23-
`bmqpimp_queue` | a type object to represent information about a queue.
24-
`bmqimp_stat` | utilities for stat manipulation.
25-
`bmqimp_negotiatedchannelfactory` | a channel factory that negotiates with a peer.
16+
Component | Provides ...
17+
-----------------------------------------|-----------------------------------------------------------
18+
`bmqimp_application` | the top level object to manipulate a session with bmqbrkr.
19+
`bmqimp_brokersession` | the implementation of a session with the bmqbrkr.
20+
`bmqimp_event` | a value-semantic type representing an event.
21+
`bmqimp_eventqueue` | a thread safe queue of pooled bmqimp::Event items.
22+
`bmqpimp_eventsstats` | a mechanism to keep track of Events statistics.
23+
`bmqpimp_queue` | a type object to represent information about a queue.
24+
`bmqimp_stat` | utilities for stat manipulation.
25+
`bmqimp_initialconnectionchannelfactory` | a channel factory that negotiates with a peer.

src/groups/bmq/bmqimp/bmqimp_application.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// BMQ
2121
#include <bmqex_executionpolicy.h>
2222
#include <bmqex_systemexecutor.h>
23+
#include <bmqimp_initialconnectionchannelfactory.h>
2324
#include <bmqio_channelutil.h>
2425
#include <bmqio_connectoptions.h>
2526
#include <bmqio_status.h>
@@ -388,7 +389,7 @@ bmqt::GenericResult::Enum Application::startChannel()
388389
.setAttemptInterval(attemptInterval)
389390
.setAutoReconnect(true);
390391

391-
d_negotiatedChannelFactory.connect(
392+
d_initialConnectionChannelFactory.connect(
392393
&status,
393394
&d_connectHandle_mp,
394395
options,
@@ -554,10 +555,11 @@ Application::stateCb(bmqimp::BrokerSession::State::Enum oldState,
554555
}
555556

556557
Application::Application(
557-
const bmqt::SessionOptions& sessionOptions,
558-
const bmqp_ctrlmsg::NegotiationMessage& negotiationMessage,
559-
const EventQueue::EventHandlerCallback& eventHandlerCB,
560-
bslma::Allocator* allocator)
558+
const bmqt::SessionOptions& sessionOptions,
559+
const bmqp_ctrlmsg::AuthenticationMessage& authenticationMessage,
560+
const bmqp_ctrlmsg::NegotiationMessage& negotiationMessage,
561+
const EventQueue::EventHandlerCallback& eventHandlerCB,
562+
bslma::Allocator* allocator)
561563
: d_allocatorStatContext(bmqst::StatContextConfiguration("Allocators",
562564
allocator),
563565
allocator)
@@ -602,12 +604,15 @@ Application::Application(
602604
bdlf::PlaceHolders::_2), // handle
603605
allocator),
604606
allocator)
605-
, d_negotiatedChannelFactory(
606-
NegotiatedChannelFactoryConfig(&d_statChannelFactory,
607-
negotiationMessage,
608-
sessionOptions.connectTimeout(),
609-
d_blobSpPool_sp.get(),
610-
allocator),
607+
, d_initialConnectionChannelFactory(
608+
InitialConnectionChannelFactoryConfig(
609+
&d_statChannelFactory,
610+
authenticationMessage,
611+
sessionOptions.connectTimeout(), // TODO: different for authn?
612+
negotiationMessage,
613+
sessionOptions.connectTimeout(),
614+
d_blobSpPool_sp.get(),
615+
allocator),
611616
allocator)
612617
, d_connectHandle_mp()
613618
, d_brokerSession(&d_scheduler,
@@ -771,9 +776,9 @@ Application::createMonitor(const bsl::shared_ptr<bmqio::Channel>& channel)
771776
{
772777
int maxMissedHeartbeats = k_DEFAULT_MAX_MISSED_HEARTBEATS;
773778

774-
channel->properties().load(
775-
&maxMissedHeartbeats,
776-
NegotiatedChannelFactory::k_CHANNEL_PROPERTY_MAX_MISSED_HEARTBEATS);
779+
channel->properties().load(&maxMissedHeartbeats,
780+
InitialConnectionChannelFactory::
781+
k_CHANNEL_PROPERTY_MAX_MISSED_HEARTBEATS);
777782

778783
bsl::shared_ptr<bmqp::HeartbeatMonitor> monitor(
779784
new (d_allocator) bmqp::HeartbeatMonitor(maxMissedHeartbeats),
@@ -794,9 +799,9 @@ void Application::startHeartbeat(
794799

795800
int heartbeatIntervalMs = k_DEFAULT_HEARTBEAT_INTERVAL_MS;
796801

797-
channel->properties().load(
798-
&heartbeatIntervalMs,
799-
NegotiatedChannelFactory::k_CHANNEL_PROPERTY_HEARTBEAT_INTERVAL_MS);
802+
channel->properties().load(&heartbeatIntervalMs,
803+
InitialConnectionChannelFactory::
804+
k_CHANNEL_PROPERTY_HEARTBEAT_INTERVAL_MS);
800805

801806
bsls::TimeInterval interval;
802807
interval.addMilliseconds(heartbeatIntervalMs);

src/groups/bmq/bmqimp/bmqimp_application.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
#include <bmqimp_brokersession.h>
4040
#include <bmqimp_eventqueue.h>
41-
#include <bmqimp_negotiatedchannelfactory.h>
41+
#include <bmqimp_initialconnectionchannelfactory.h>
4242
#include <bmqp_ctrlmsg_messages.h>
4343
#include <bmqp_heartbeatmonitor.h>
4444
#include <bmqt_sessionoptions.h>
@@ -81,7 +81,7 @@ namespace bmqimp {
8181
class Application {
8282
public:
8383
// PUBLIC TYPES
84-
typedef bmqp::BlobPoolUtil::BlobSpPool BlobSpPool;
84+
typedef bmqp::BlobPoolUtil::BlobSpPool BlobSpPool;
8585
typedef bmqp::BlobPoolUtil::BlobSpPoolSp BlobSpPoolSp;
8686

8787
private:
@@ -134,7 +134,7 @@ class Application {
134134

135135
bmqio::StatChannelFactory d_statChannelFactory;
136136

137-
NegotiatedChannelFactory d_negotiatedChannelFactory;
137+
InitialConnectionChannelFactory d_initialConnectionChannelFactory;
138138

139139
ChannelFactoryOpHandleMp d_connectHandle_mp;
140140

@@ -226,7 +226,8 @@ class Application {
226226
const bsl::shared_ptr<bmqp::HeartbeatMonitor>& monitor);
227227
bsl::shared_ptr<bmqp::HeartbeatMonitor>
228228
createMonitor(const bsl::shared_ptr<bmqio::Channel>& channel);
229-
void startHeartbeat(const bsl::shared_ptr<bmqio::Channel>& channel,
229+
void
230+
startHeartbeat(const bsl::shared_ptr<bmqio::Channel>& channel,
230231
const bsl::shared_ptr<bmqp::HeartbeatMonitor>& monitor);
231232
void stopHeartbeat();
232233

@@ -252,10 +253,12 @@ class Application {
252253
/// negotiation. The application will use the specified
253254
/// `eventHandlerCB`. Use the specified `allocator` for all memory
254255
/// allocations.
255-
Application(const bmqt::SessionOptions& sessionOptions,
256-
const bmqp_ctrlmsg::NegotiationMessage& negotiationMessage,
257-
const EventQueue::EventHandlerCallback& eventHandlerCB,
258-
bslma::Allocator* allocator);
256+
Application(
257+
const bmqt::SessionOptions& sessionOptions,
258+
const bmqp_ctrlmsg::AuthenticationMessage& authenticationMessage,
259+
const bmqp_ctrlmsg::NegotiationMessage& negotiationMessage,
260+
const EventQueue::EventHandlerCallback& eventHandlerCB,
261+
bslma::Allocator* allocator);
259262

260263
/// Destructor
261264
~Application();

src/groups/bmq/bmqimp/bmqimp_application.t.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ static void test1_breathingTest()
4545

4646
// Create a default application
4747
bmqt::SessionOptions options(bmqtst::TestHelperUtil::allocator());
48+
bmqp_ctrlmsg::AuthenticationMessage authenticaionMessage(
49+
bmqtst::TestHelperUtil::allocator());
4850
bmqp_ctrlmsg::NegotiationMessage negotiationMessage(
4951
bmqtst::TestHelperUtil::allocator());
5052
bmqimp::EventQueue::EventHandlerCallback emptyEventHandler;
5153

5254
bmqimp::Application obj(options,
55+
authenticaionMessage,
5356
negotiationMessage,
5457
emptyEventHandler,
5558
bmqtst::TestHelperUtil::allocator());
@@ -78,11 +81,14 @@ static void test2_startStopTest()
7881

7982
// Create a default application, make sure it can start/stop
8083
bmqt::SessionOptions options(bmqtst::TestHelperUtil::allocator());
84+
bmqp_ctrlmsg::AuthenticationMessage authenticaionMessage(
85+
bmqtst::TestHelperUtil::allocator());
8186
bmqp_ctrlmsg::NegotiationMessage negotiationMessage(
8287
bmqtst::TestHelperUtil::allocator());
8388
bmqimp::EventQueue::EventHandlerCallback emptyEventHandler;
8489

8590
bmqimp::Application obj(options,
91+
authenticaionMessage,
8692
negotiationMessage,
8793
emptyEventHandler,
8894
bmqtst::TestHelperUtil::allocator());
@@ -130,11 +136,14 @@ static void test3_startStopAsyncTest()
130136

131137
// Create a default application, make sure it can start/stop
132138
bmqt::SessionOptions options(bmqtst::TestHelperUtil::allocator());
139+
bmqp_ctrlmsg::AuthenticationMessage authenticaionMessage(
140+
bmqtst::TestHelperUtil::allocator());
133141
bmqp_ctrlmsg::NegotiationMessage negotiationMessage(
134142
bmqtst::TestHelperUtil::allocator());
135143
bmqimp::EventQueue::EventHandlerCallback emptyEventHandler;
136144

137145
bmqimp::Application obj(options,
146+
authenticaionMessage,
138147
negotiationMessage,
139148
emptyEventHandler,
140149
bmqtst::TestHelperUtil::allocator());

src/groups/bmq/bmqimp/bmqimp_brokersession.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include <bmqscm_version.h>
2020
// BMQ
21-
#include <bmqimp_negotiatedchannelfactory.h>
21+
#include <bmqimp_initialconnectionchannelfactory.h>
2222
#include <bmqimp_queue.h>
2323
#include <bmqp_ackeventbuilder.h>
2424
#include <bmqp_ackmessageiterator.h>
@@ -407,7 +407,7 @@ void BrokerSession::SessionFsm::setStarted(
407407
// Temporary safety switch to control configure request.
408408
d_session.d_channel_sp->properties().load(
409409
&d_session.d_doConfigureStream,
410-
NegotiatedChannelFactory::k_CHANNEL_PROPERTY_CONFIGURE_STREAM);
410+
InitialConnectionChannelFactory::k_CHANNEL_PROPERTY_CONFIGURE_STREAM);
411411
}
412412

413413
bmqt::GenericResult::Enum
@@ -6051,7 +6051,7 @@ void BrokerSession::onOpenQueueResponse(
60516051

60526052
if (d_channel_sp->properties().load(
60536053
&isMPsEx,
6054-
NegotiatedChannelFactory::k_CHANNEL_PROPERTY_MPS_EX)) {
6054+
InitialConnectionChannelFactory::k_CHANNEL_PROPERTY_MPS_EX)) {
60556055
BSLS_ASSERT_SAFE(isMPsEx);
60566056
queue->setOldStyle(false);
60576057
}

0 commit comments

Comments
 (0)