MongoDB C++ Driver  legacy-1.0.5
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cyrus_sasl_client_session.h
1 /* Copyright 2014 MongoDB Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "mongo/client/sasl_client_session.h"
17 
18 #include <sasl/sasl.h>
19 
20 namespace mongo {
21 
27  MONGO_DISALLOW_COPYING(CyrusSaslClientSession);
28  public:
29 
32 
36  virtual void setParameter(Parameter id, const StringData& value);
37 
44  sasl_secret_t* getPasswordAsSecret();
45 
46  virtual Status initialize();
47 
48  virtual Status step(const StringData& inputData, std::string* outputData);
49 
50  virtual bool isDone() const { return _done; }
51 
52  private:
54  static const int maxCallbacks = 4;
55 
57  sasl_conn_t* _saslConnection;
58 
59  // Number of successfully completed conversation steps.
60  int _step;
61 
63  bool _done;
64 
66  boost::scoped_array<char> _secret;
67 
70  sasl_callback_t _callbacks[maxCallbacks];
71  };
72 
73 } // namespace mongo
virtual void setParameter(Parameter id, const StringData &value)
Overriding to store the password data in sasl_secret_t format.
Parameter
Identifiers of parameters used to configure a SaslClientSession.
Definition: sasl_client_session.h:51
the main MongoDB namespace
Definition: bulk_operation_builder.h:24
virtual Status initialize()
Initializes a session for use.
Base class for the client side of a SASL authentication conversation.
Definition: sasl_client_session.h:42
virtual bool isDone() const
Returns true if the authentication completed successfully.
Definition: cyrus_sasl_client_session.h:50
sasl_secret_t * getPasswordAsSecret()
Returns the value of the parameterPassword parameter in the form of a sasl_secret_t, used by the Cyrus SASL library's SASL_CB_PASS callback.
virtual Status step(const StringData &inputData, std::string *outputData)
Takes one step of the SASL protocol on behalf of the client.
MONGO_CLIENT_API Status(MONGO_CLIENT_FUNC *saslClientAuthenticate)(DBClientWithCommands *client
Attempts to authenticate "client" using the SASL protocol.
Implementation of the client side of a SASL authentication conversation.
Definition: cyrus_sasl_client_session.h:26