Skip to content

Commit d923a9d

Browse files
committed
modity authenticator (can't compile)
Signed-off-by: Emelia Lei <[email protected]>
1 parent e5becab commit d923a9d

5 files changed

+121
-240
lines changed

Diff for: src/groups/mqb/mqba/mqba_authenticator.cpp

+6-30
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,9 @@ const int k_AUTHENTICATION_READTIMEOUT = 3 * 60; // 3 minutes
3939

4040
}
4141

42-
// -----------------------
42+
// -------------------
4343
// class Authenticator
44-
// -----------------------
45-
46-
void Authenticator::readCallback(const bmqio::Status& status,
47-
int* numNeeded,
48-
bdlbb::Blob* blob,
49-
const AuthenticationContextSp& context)
50-
{
51-
}
52-
53-
int Authenticator::decodeNegotiationMessage(
54-
bsl::ostream& errorDescription,
55-
const AuthenticationContextSp& context,
56-
const bdlbb::Blob& blob)
57-
{
58-
return 0;
59-
}
44+
// -------------------
6045

6146
int Authenticator::onAuthenticationRequest(
6247
bsl::ostream& errorDescription,
@@ -85,15 +70,12 @@ void Authenticator::initiateOutboundAuthentication(
8570
{
8671
}
8772

88-
void Authenticator::scheduleRead(const AuthenticationContextSp& context)
89-
{
90-
}
91-
9273
// CREATORS
9374
Authenticator::Authenticator(bslma::Allocator* allocator)
9475
: d_allocator_p(allocator)
9576
, d_clusterCatalog_p(0)
9677
{
78+
// NOTHING
9779
}
9880

9981
/// Destructor
@@ -102,16 +84,10 @@ Authenticator::~Authenticator()
10284
// NOTHING: (required because of inheritance)
10385
}
10486

105-
void Authenticator::authenticate(
106-
mqbnet::AuthenticatorContext* context,
107-
const bsl::shared_ptr<bmqio::Channel>& channel,
108-
const mqbnet::Authenticator::AuthenticationCb& authenticationCb)
87+
int Authenticator::authenticationOutboundOrReverse(
88+
const AuthenticationContextSp& context)
10989
{
110-
// Create a AuthenticationContextSp for that connection
111-
AuthenticationContextSp AuthenticationContext;
112-
AuthenticationContext.createInplace(d_allocator_p);
113-
114-
AuthenticationContext->d_authenticationCb = authenticationCb;
90+
return 0;
11591
}
11692

11793
} // close package namespace

Diff for: src/groups/mqb/mqba/mqba_authenticator.h

+8-76
Original file line numberDiff line numberDiff line change
@@ -57,55 +57,16 @@ class Dispatcher;
5757

5858
namespace mqba {
5959

60-
// =======================
60+
// ===================
6161
// class Authenticator
62-
// =======================
62+
// ===================
6363

6464
/// Authenticator for a BlazingMQ session with client or broker
6565
class Authenticator : public mqbnet::Authenticator {
6666
public:
6767
// TYPES
6868

6969
private:
70-
// PRIVATE TYPES
71-
struct ConnectionType {
72-
// Enum representing the type of session being negotiated, from that
73-
// side of the connection's point of view.
74-
enum Enum {
75-
e_UNKNOWN,
76-
e_CLUSTER_PROXY, // Reverse connection proxy -> broker
77-
e_CLUSTER_MEMBER, // Cluster node -> cluster node
78-
e_CLIENT, // Either SDK or Proxy -> Proxy or cluster node
79-
e_ADMIN
80-
};
81-
};
82-
83-
/// Struct used to hold the context associated to a session being
84-
/// negotiated
85-
struct AuthenticationContext {
86-
// PUBLIC DATA
87-
88-
/// The associated authenticatorContext, passed in by the caller.
89-
mqbnet::AuthenticatorContext* d_authenticatorContext_p;
90-
91-
/// The channel to use for the authentication.
92-
bsl::shared_ptr<bmqio::Channel> d_channelSp;
93-
94-
/// The callback to invoke to notify of the status of the
95-
/// authentication.
96-
mqbnet::Authenticator::AuthenticationCb d_authenticationCb;
97-
98-
/// The negotiation message received from the remote peer.
99-
bmqp_ctrlmsg::NegotiationMessage d_authenticationMessage;
100-
101-
/// True if this is a "reversed" connection (on either side of the
102-
/// connection).
103-
bool d_isReversed;
104-
105-
/// The type of the session being negotiated.
106-
ConnectionType::Enum d_connectionType;
107-
};
108-
10970
typedef bsl::shared_ptr<AuthenticationContext> AuthenticationContextSp;
11071

11172
private:
@@ -127,25 +88,6 @@ class Authenticator : public mqbnet::Authenticator {
12788
private:
12889
// PRIVATE MANIPULATORS
12990

130-
/// Read callback method invoked when receiving data in the specified
131-
/// `blob`, if the specified `status` indicates success. The specified
132-
/// `numNeeded` can be used to indicate if more bytes are needed in
133-
/// order to get a full message. The specified `context` holds the
134-
/// negotiation context associated to this read.
135-
void readCallback(const bmqio::Status& status,
136-
int* numNeeded,
137-
bdlbb::Blob* blob,
138-
const AuthenticationContextSp& context);
139-
140-
/// Decode the negotiation messages received in the specified `blob` and
141-
/// store it, on success, in the corresponding member of the specified
142-
/// `context`, returning 0. Return a non-zero code on error and
143-
/// populate the specified `errorDescription` with a description of the
144-
/// error.
145-
int decodeNegotiationMessage(bsl::ostream& errorDescription,
146-
const AuthenticationContextSp& context,
147-
const bdlbb::Blob& blob);
148-
14991
/// Invoked when received a `ClientIdentity` negotiation message with
15092
/// the specified `context`. Creates and return a Session on success,
15193
/// or return a null pointer and populate the specified
@@ -176,10 +118,6 @@ class Authenticator : public mqbnet::Authenticator {
176118
void
177119
initiateOutboundAuthentication(const AuthenticationContextSp& context);
178120

179-
/// Schedule a read for the negotiation of the session of the specified
180-
/// `context`.
181-
void scheduleRead(const AuthenticationContextSp& context);
182-
183121
public:
184122
// TRAITS
185123
BSLMF_NESTED_TRAIT_DECLARATION(Authenticator, bslma::UsesBslmaAllocator)
@@ -205,25 +143,19 @@ class Authenticator : public mqbnet::Authenticator {
205143
// MANIPULATORS
206144
// (virtual: mqbnet::Authenticator)
207145

208-
/// Negotiate the connection on the specified `channel` associated with
209-
/// the specified negotiation `context` and invoke the specified
210-
/// `negotiationCb` once the negotiation is complete (either success or
211-
/// failure). Note that if no negotiation are needed, the
212-
/// `negotiationCb` may be invoked directly from inside the call to
213-
/// `negotiate`.
214-
void authenticate(mqbnet::AuthenticatorContext* context,
215-
const bsl::shared_ptr<bmqio::Channel>& channel,
216-
const mqbnet::Authenticator::AuthenticationCb&
217-
authenticationCb) BSLS_KEYWORD_OVERRIDE;
146+
/// Send out outbound authentication message or reverse connection request
147+
/// with the specified `context`.
148+
int authenticationOutboundOrReverse(const AuthenticationContextSp& context)
149+
BSLS_KEYWORD_OVERRIDE;
218150
};
219151

220152
// ============================================================================
221153
// INLINE DEFINITIONS
222154
// ============================================================================
223155

224-
// -----------------------
156+
// -------------------
225157
// class Authenticator
226-
// -----------------------
158+
// -------------------
227159

228160
inline Authenticator&
229161
Authenticator::setClusterCatalog(mqbblp::ClusterCatalog* value)
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2025 Bloomberg Finance L.P.
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
// mqbnet_authenticationcontext.cpp -*-C++-*-
17+
#include <mqbnet_authenticationcontext.h>
18+
19+
#include <mqbscm_version.h>
20+
namespace BloombergLP {
21+
namespace mqbnet {
22+
23+
// NOTHING
24+
25+
} // close package namespace
26+
} // close enterprise namespace

Diff for: src/groups/mqb/mqbnet/mqbnet_authenticationcontext.h

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2025 Bloomberg Finance L.P.
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
// mqbnet_authenticationcontext.h -*-C++-*-
17+
#ifndef INCLUDED_MQBNET_AUTHENTICATIONCONTEXT
18+
#define INCLUDED_MQBNET_AUTHENTICATIONCONTEXT
19+
20+
/// @file mqbnet_authenticationcontext.h
21+
///
22+
/// @brief Provide the context for initial connection handler for establishing
23+
/// sessions.
24+
///
25+
26+
// MQB
27+
#include <mqbnet_initialconnectioncontext.h>
28+
29+
// BMQ
30+
#include <bmqp_ctrlmsg_messages.h>
31+
32+
namespace BloombergLP {
33+
namespace mqbnet {
34+
35+
struct ConnectionType {
36+
// Enum representing the type of session being authenticated, from that
37+
// side of the connection's point of view.
38+
enum Enum {
39+
e_UNKNOWN,
40+
e_CLUSTER_PROXY, // Reverse connection proxy -> broker
41+
e_CLUSTER_MEMBER, // Cluster node -> cluster node
42+
e_CLIENT, // Either SDK or Proxy -> Proxy or cluster node
43+
e_ADMIN
44+
};
45+
};
46+
47+
// ===========================
48+
// class AuthenticationContext
49+
// ===========================
50+
51+
// VST for an implementation of AuthenticationContext
52+
struct AuthenticationContext {
53+
// DATA
54+
/// The associated InitialConnectionContext passed in by the caller.
55+
/// Held, not owned
56+
InitialConnectionContext* d_initialConnectionContext_p;
57+
58+
/// The authentication message received from the remote peer.
59+
bmqp_ctrlmsg::AuthenticationMessage d_authenticationMessage;
60+
61+
/// The cluster involved in the session being authenticated,
62+
/// or empty if none.
63+
bsl::string d_clusterName;
64+
65+
/// True if this is a "reversed" connection (on either side of the
66+
/// connection).
67+
bool d_isReversed;
68+
69+
/// The type of the session being authenticated.
70+
ConnectionType::Enum d_connectionType;
71+
};
72+
73+
} // close package namespace
74+
} // close enterprise namespace
75+
76+
#endif

0 commit comments

Comments
 (0)