MongoDB C++ Driver  legacy-1.1.2
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 
29 public:
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 {
51  return _done;
52  }
53 
54 private:
56  static const int maxCallbacks = 4;
57 
59  sasl_conn_t* _saslConnection;
60 
61  // Number of successfully completed conversation steps.
62  int _step;
63 
65  bool _done;
66 
68  boost::scoped_array<char> _secret;
69 
72  sasl_callback_t _callbacks[maxCallbacks];
73 };
74 
75 } // namespace mongo
Status represents an error state or the absence thereof.
Definition: status.h:50
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:52
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents...
Definition: string_data.h:43
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
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.
Implementation of the client side of a SASL authentication conversation.
Definition: cyrus_sasl_client_session.h:26