Sha256: c56c1fc705cf7c7facfacd808f9082bf1ab9995741dffb716cec759930a19072
Contents?: true
Size: 1.76 KB
Versions: 32
Compression:
Stored size: 1.76 KB
Contents
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2018 Couchbase, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <cbsasl/mechanism.h> #include <algorithm> #include <iterator> #include <vector> namespace couchbase { namespace sasl { Mechanism select_mechanism(const std::vector<std::string>& available_mechanisms) { // Search what we've got backends for const std::vector<std::pair<std::string, Mechanism>> mechs = { { std::string{ "SCRAM-SHA512" }, Mechanism::SCRAM_SHA512 }, { std::string{ "SCRAM-SHA256" }, Mechanism::SCRAM_SHA256 }, { std::string{ "SCRAM-SHA1" }, Mechanism::SCRAM_SHA1 }, { std::string{ "PLAIN" }, Mechanism::PLAIN } }; for (const auto& mechanism : mechs) { if (std::find(available_mechanisms.begin(), available_mechanisms.end(), mechanism.first) != available_mechanisms.end()) { return mechanism.second; } } throw unknown_mechanism("unknown mechanism"); // TODO: avoid this exception } } // namespace sasl } // namespace couchbase
Version data entries
32 entries across 32 versions & 1 rubygems