MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
sasl_client_session.h
1/* Copyright 2012 10gen 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#pragma once
17
18#include <boost/scoped_array.hpp>
19#include <string>
20
21#include "mongo/base/disallow_copying.h"
22#include "mongo/base/status.h"
23#include "mongo/base/string_data.h"
24#include "mongo/client/export_macros.h"
25#include "mongo/stdx/functional.h"
26
27namespace mongo {
28
43 MONGO_DISALLOW_COPYING(SaslClientSession);
44
45public:
46 typedef stdx::function<SaslClientSession*(const std::string&)> SaslClientSessionFactoryFn;
47 static SaslClientSessionFactoryFn create;
48
52 enum Parameter {
53 parameterServiceName = 0,
54 parameterServiceHostname,
55 parameterMechanism,
56 parameterUser,
57 parameterPassword,
58 numParameters // Must be last
59 };
60
62 virtual ~SaslClientSession();
63
73 virtual void setParameter(Parameter id, const StringData& value);
74
78 virtual bool hasParameter(Parameter id);
79
91
97 virtual Status initialize() = 0;
98
114 virtual Status step(const StringData& inputData, std::string* outputData) = 0;
115
119 virtual bool isDone() const = 0;
120
121private:
125 struct DataBuffer {
126 boost::scoped_array<char> data;
127 size_t size;
128 };
129
131 DataBuffer _parameters[numParameters];
132};
133
134} // namespace mongo
Base class for the client side of a SASL authentication conversation.
Definition sasl_client_session.h:42
virtual bool hasParameter(Parameter id)
Returns true if "id" identifies a parameter previously set by a call to setParameter().
virtual Status step(const StringData &inputData, std::string *outputData)=0
Takes one step of the SASL protocol on behalf of the client.
virtual bool isDone() const =0
Returns true if the authentication completed successfully.
virtual void setParameter(Parameter id, const StringData &value)
Sets the parameter identified by "id" to "value".
Parameter
Identifiers of parameters used to configure a SaslClientSession.
Definition sasl_client_session.h:52
virtual Status initialize()=0
Initializes a session for use.
virtual StringData getParameter(Parameter id)
Returns the value of a previously set parameter.
Status represents an error state or the absence thereof.
Definition status.h:50
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