MongoDB C++ Driver legacy-1.0.1
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 public:
45 typedef stdx::function<SaslClientSession* (const std::string&)> SaslClientSessionFactoryFn;
46 static SaslClientSessionFactoryFn create;
47
51 enum Parameter {
52 parameterServiceName = 0,
53 parameterServiceHostname,
54 parameterMechanism,
55 parameterUser,
56 parameterPassword,
57 numParameters // Must be last
58 };
59
61 virtual ~SaslClientSession();
62
72 virtual void setParameter(Parameter id, const StringData& value);
73
77 virtual bool hasParameter(Parameter id);
78
89 virtual StringData getParameter(Parameter id);
90
96 virtual Status initialize() = 0;
97
113 virtual Status step(const StringData& inputData, std::string* outputData) = 0;
114
118 virtual bool isDone() const = 0;
119
120 private:
124 struct DataBuffer {
125 boost::scoped_array<char> data;
126 size_t size;
127 };
128
130 DataBuffer _parameters[numParameters];
131 };
132
133} // 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:51
virtual Status initialize()=0
Initializes a session for use.
virtual StringData getParameter(Parameter id)
Returns the value of a previously set parameter.
the main MongoDB namespace
Definition bulk_operation_builder.h:24
MONGO_CLIENT_API Status(MONGO_CLIENT_FUNC *saslClientAuthenticate)(DBClientWithCommands *client
Attempts to authenticate "client" using the SASL protocol.