@@ -79,6 +79,8 @@ int Authenticator::onAuthenticationRequest(
7979 const bmqp_ctrlmsg::AuthenticationMessage& authenticationMsg,
8080 const InitialConnectionContextSp& context)
8181{
82+ // executed by one of the *IO* threads
83+
8284 // PRECONDITIONS
8385 BSLS_ASSERT_SAFE (authenticationMsg.isAuthenticateRequestValue ());
8486 BSLS_ASSERT_SAFE (context->isIncoming ());
@@ -95,14 +97,13 @@ int Authenticator::onAuthenticationRequest(
9597 authenticationMsg, // authenticationMessage
9698 context
9799 ->authenticationEncodingType (), // authenticationEncodingType
98- State::e_AUTHENTICATING, // state
99- mqbnet::ConnectionType::e_UNKNOWN // connectionType
100+ State::e_AUTHENTICATING // state
100101 );
101102
102103 context->setAuthenticationContext (authenticationContext);
103104
104105 // Authenticate
105- int rc = authenticateAsync (errorDescription, context, context-> channel () );
106+ int rc = authenticateAsync (errorDescription, context);
106107
107108 return rc;
108109}
@@ -112,6 +113,8 @@ int Authenticator::onAuthenticationResponse(
112113 BSLA_UNUSED const bmqp_ctrlmsg::AuthenticationMessage& authenticationMsg,
113114 BSLA_UNUSED const InitialConnectionContextSp& context)
114115{
116+ // executed by one of the *IO* threads
117+
115118 BALL_LOG_ERROR << " Not Implemented" ;
116119
117120 return -1 ;
@@ -160,22 +163,25 @@ int Authenticator::sendAuthenticationMessage(
160163 return rc_SUCCESS;
161164}
162165
163- int Authenticator::authenticateAsync (
164- bsl::ostream& errorDescription,
165- const InitialConnectionContextSp& context,
166- const bsl::shared_ptr<bmqio::Channel>& channel)
166+ int Authenticator::authenticateAsync (bsl::ostream& errorDescription,
167+ const InitialConnectionContextSp& context)
167168{
168- int rc = d_threadPool.enqueueJob (
169- bdlf::BindUtil::bindS (d_allocator_p,
170- &Authenticator::authenticate,
171- this ,
172- context,
173- channel));
169+ // executed by one of the *IO* threads
170+
171+ int rc = d_threadPool.enqueueJob (bdlf::BindUtil::bindS (
172+ d_allocator_p,
173+ &Authenticator::authenticate,
174+ this ,
175+ context,
176+ context->channel (),
177+ context->state () ==
178+ mqbnet::InitialConnectionState::e_DEFAULT_AUTHENTICATING));
174179
175180 if (rc != 0 ) {
176181 errorDescription
177182 << " Failed to enqueue authentication job for '"
178- << channel->peerUri () << " ' [rc: " << rc << " , message: "
183+ << context->channel ()->peerUri () << " ' [rc: " << rc
184+ << " , message: "
179185 << context->authenticationContext ()->authenticationMessage ()
180186 << " ]" ;
181187 }
@@ -185,7 +191,8 @@ int Authenticator::authenticateAsync(
185191
186192void Authenticator::authenticate (
187193 const InitialConnectionContextSp& context,
188- const bsl::shared_ptr<bmqio::Channel>& channel)
194+ const bsl::shared_ptr<bmqio::Channel>& channel,
195+ bool isDefaultAuthn)
189196{
190197 // executed by an *AUTHENTICATION* thread
191198
@@ -214,7 +221,8 @@ void Authenticator::authenticate(
214221
215222 int rc = rc_SUCCESS;
216223 bsl::string error;
217- mqbnet::InitialConnectionEvent::Enum input;
224+ mqbnet::InitialConnectionEvent::Enum input =
225+ InitialConnectionEvent::e_ERROR;
218226
219227 bdlb::ScopeExitAny handleEventOnReturn (
220228 bdlf::BindUtil::bind (&mqbnet::InitialConnectionContext::handleEvent,
@@ -242,18 +250,15 @@ void Authenticator::authenticate(
242250 if (processRc != rc_SUCCESS) {
243251 rc = (processRc * 10 ) + rc_PROCESS_AUTHENTICATION_FAILED;
244252 error = processErrStream.str ();
245- input = InitialConnectionEvent::e_ERROR;
246253 return ; // RETURN
247254 }
248255
249256 // In the case of a default authentication, we do not need to send
250257 // an AuthenticationResponse, we just need to continue the negotiation.
251- if (context->state () ==
252- mqbnet::InitialConnectionState::e_DEFAULT_AUTHENTICATING) {
258+ if (isDefaultAuthn) {
253259 if (status.category () != bmqp_ctrlmsg::StatusCategory::E_SUCCESS) {
254260 rc = (status.code () * 10 ) + rc_AUTHENTICATION_FAILED;
255261 error = status.message ();
256- input = InitialConnectionEvent::e_ERROR;
257262 }
258263 else {
259264 input = InitialConnectionEvent::e_AUTHN_SUCCESS;
@@ -272,14 +277,12 @@ void Authenticator::authenticate(
272277 if (status.category () != bmqp_ctrlmsg::StatusCategory::E_SUCCESS) {
273278 rc = (status.code () * 10 ) + rc_AUTHENTICATION_FAILED;
274279 error = status.message ();
275- input = InitialConnectionEvent::e_ERROR;
276280 return ; // RETURN
277281 }
278282
279283 if (sendRc != rc_SUCCESS) {
280284 rc = (sendRc * 10 ) + rc_SEND_AUTHENTICATION_RESPONSE_FAILED;
281285 error = sendResponseErrStream.str ();
282- input = InitialConnectionEvent::e_ERROR;
283286 return ; // RETURN
284287 }
285288
@@ -496,6 +499,8 @@ int Authenticator::handleAuthentication(
496499 const InitialConnectionContextSp& context,
497500 const bmqp_ctrlmsg::AuthenticationMessage& authenticationMsg)
498501{
502+ // executed by one of the *IO* threads
503+
499504 enum RcEnum {
500505 // Value for the various RC error categories
501506 rc_SUCCESS = 0 ,
0 commit comments