1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (C) 2022-2024 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Kea Hooks Basic
// Commercial End User License Agreement v2.0. See COPYING file in the premium/
// directory.

#include <config.h>

#include <rbac.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <rbac_log.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

using namespace isc;
using namespace isc::data;
using namespace isc::log;
using namespace isc::rbac;
using namespace std;

namespace isc {
namespace rbac {

RolePtr
Role::parse(ConstElementPtr cfg) {
    if (!cfg) {
        isc_throw(BadValue, "parse null role assignment config");
    }
    if (cfg->getType() != Element::string) {
        isc_throw(BadValue, "role assignment config is not a string");
    }
    const string& role = cfg->stringValue();
    if (role == "remote-address") {
        return (RolePtr(new RemoteRole()));
    } else if (role == "cert-subject") {
        return (RolePtr(new SubjectRole()));
    } else if (role == "cert-issuer") {
        return (RolePtr(new IssuerRole()));
    } else if (role == "basic-authentication") {
        return (RolePtr(new BasicAuthRole()));
    } else if (role == "custom-value") {
        return (RolePtr(new CustomRole()));
    } else {
        isc_throw(BadValue, "unknown role assignment keyword '" << role << "'");
    }
}

} // end of namespace rbac
} // end of namespace isc