Kea 3.3.4
rbac_role.cc
Go to the documentation of this file.
1// Copyright (C) 2026 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <rbac/rbac.h>
10#include <rbac_log.h>
11
12using namespace isc;
13using namespace isc::data;
14using namespace isc::log;
15using namespace isc::rbac;
16using namespace std;
17
18namespace isc {
19namespace rbac {
20
23 if (!cfg) {
24 isc_throw(BadValue, "parse null role assignment config");
25 }
26 if (cfg->getType() != Element::string) {
27 isc_throw(BadValue, "role assignment config is not a string");
28 }
29 const string& role = cfg->stringValue();
30 if (role == "remote-address") {
31 return (RolePtr(new RemoteRole()));
32 } else if (role == "cert-subject") {
33 return (RolePtr(new SubjectRole()));
34 } else if (role == "cert-issuer") {
35 return (RolePtr(new IssuerRole()));
36 } else if (role == "basic-authentication") {
37 return (RolePtr(new BasicAuthRole()));
38 } else if (role == "custom-value") {
39 return (RolePtr(new CustomRole()));
40 } else {
41 isc_throw(BadValue, "unknown role assignment keyword '" << role << "'");
42 }
43}
44
45} // end of namespace rbac
46} // end of namespace isc
@ string
Definition data.h:157
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
Role assignment using the basic HTTP authentication.
Definition rbac_role.h:158
Role assignment using the custom value.
Definition rbac_role.h:186
Role assignment using the issuer.
Definition rbac_role.h:130
Role assignment using the remote address.
Definition rbac_role.h:77
static RolePtr parse(data::ConstElementPtr cfg)
Parse a role assignment value.
Definition rbac_role.cc:22
Role assignment using the subject.
Definition rbac_role.h:102
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
boost::shared_ptr< Role > RolePtr
Type of shared pointers to Role.
Definition rbac_role.h:20
Defines the logger used by the top-level component of kea-lfc.