namespace isc {
namespace data {
-const std::list<std::string> DefaultCredentials::DEFAULT_CREDENTIALS = {
+const std::unordered_set<std::string>
+DefaultCredentials::DEFAULT_CREDENTIALS = {
#ifndef IGNORE_KEA_DEFAULT_CREDENTIALS
#ifndef ALLOW_KEATEST
"keatest",
#endif
};
-void DefaultCredentials::check(const std::string& value) {
- for (auto const& cred : DEFAULT_CREDENTIALS) {
- if (value == cred) {
- isc_throw(DefaultCredential,
- "illegal use of a default value as credential");
- }
+void
+DefaultCredentials::check(const std::string& value) {
+ if (DEFAULT_CREDENTIALS.count(value)) {
+ isc_throw(DefaultCredential,
+ "illegal use of a default value as credential");
}
}
#define DEFAULT_CREDENTIALS_H
#include <exceptions/exceptions.h>
-#include <list>
+#include <unordered_set>
#include <string>
namespace isc {
/// @brief Base class for default credentials.
struct DefaultCredentials {
/// @brief Default credentials.
- ///
- /// @note Using a list as there are only a few default credentials.
- static const std::list<std::string> DEFAULT_CREDENTIALS;
+ static const std::unordered_set<std::string> DEFAULT_CREDENTIALS;
/// @brief Check if the value is a default credential.
///