Kea: managed_key.h Source File

| Kea 3.0.2-git

managed_key.h
Go to the documentation of this file.
1// Copyright (C) 2021-2025 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#ifndef MANAGED_KEY_H
8#define MANAGED_KEY_H
9
10#include <cc/cfg_to_element.h>
11#include <gss_tsig_key.h>
12#include <tkey_exchange.h>
13#include <list>
14#include <mutex>
15
16namespace isc {
17namespace gss_tsig {
18
23 class ManagedKey : public GssTsigKey, public TKeyExchange::Callback,
24 public isc::data::CfgToElement {
25public:
32 enum Status {
33 NOT_READY,
34 USABLE,
35 EXPIRED,
36 IN_ERROR
37 };
38
40 static std::string statusToText(Status status);
41
45 ManagedKey(const std::string& name);
46
48 virtual ~ManagedKey() = default;
49
53 std::string getKeyNameStr() const {
54 return (getKeyName().toText());
55 }
56
60 std::string getParentID() const {
61 return (parent_id_);
62 }
63
67 void setParentID(const std::string& parent_id) {
68 parent_id_ = parent_id;
69 }
70
74 Status getStatus() const {
75 return (status_);
76 }
77
81 void setStatus(Status status) {
82 status_ = status;
83 }
84
88 TKeyExchange::Status getTKeyStatus() const {
89 return (tkey_status_);
90 }
91
95 void setTKeyStatus(TKeyExchange::Status tkey_status) {
96 tkey_status_ = tkey_status;
97 }
98
102 TKeyExchangePtr& getTKeyExchange() {
103 return (tkey_ex_);
104 }
105
109 void operator()(TKeyExchange::Status tkey_status);
110
114 static std::string genName(const std::string& server);
115
128 isc::data::ElementPtr toElement() const;
129
135 virtual dns::TSIGContextPtr createContext();
136
137private:
139 std::string parent_id_;
140
142 Status status_;
143
145 TKeyExchange::Status tkey_status_;
146
148 TKeyExchangePtr tkey_ex_;
149
150public:
152 boost::scoped_ptr<std::mutex> mutex_;
153};
154
156 typedef boost::shared_ptr<ManagedKey> ManagedKeyPtr;
157
158} // end of namespace isc::gss_tsig
159} // end of namespace isc
160
161#endif // MANAGED_KEY_H
cfg_to_element.h
isc::dns::TSIGKey::getKeyName
const Name & getKeyName() const
Getter Methods.
Definition tsigkey.cc:204
isc::dns::TSIGKey::toText
std::string toText() const
Converts the TSIGKey to a string value.
Definition tsigkey.cc:234
isc::gss_tsig::GssTsigKey::GssTsigKey
GssTsigKey(const std::string &key_name, gss_ctx_id_t sec_ctx=GSS_C_NO_CONTEXT)
Constructor.
Definition gss_tsig_key.cc:18
isc::gss_tsig::ManagedKey::getKeyNameStr
std::string getKeyNameStr() const
Get the key name as a string.
Definition managed_key.h:53
isc::gss_tsig::ManagedKey::genName
static std::string genName(const std::string &server)
Create a random name from a suffix.
Definition managed_key.cc:41
isc::gss_tsig::ManagedKey::getParentID
std::string getParentID() const
Get the DNS server (parent) ID.
Definition managed_key.h:60
isc::gss_tsig::ManagedKey::createContext
virtual dns::TSIGContextPtr createContext()
Create GssTsigContext context.
Definition managed_key.cc:131
isc::gss_tsig::ManagedKey::toElement
isc::data::ElementPtr toElement() const
Unparse a key object.
Definition managed_key.cc:83
isc::gss_tsig::ManagedKey::mutex_
boost::scoped_ptr< std::mutex > mutex_
Mutex for protecting key state.
Definition managed_key.h:152
isc::gss_tsig::ManagedKey::setTKeyStatus
void setTKeyStatus(TKeyExchange::Status tkey_status)
Set the TKEY exchange status.
Definition managed_key.h:95
isc::gss_tsig::ManagedKey::getTKeyExchange
TKeyExchangePtr & getTKeyExchange()
Get the TKEY exchange.
Definition managed_key.h:102
isc::gss_tsig::ManagedKey::setStatus
void setStatus(Status status)
Set the key status.
Definition managed_key.h:81
isc::gss_tsig::ManagedKey::~ManagedKey
virtual ~ManagedKey()=default
Destructor.
isc::gss_tsig::ManagedKey::setParentID
void setParentID(const std::string &parent_id)
Set the DNS server (parent) ID.
Definition managed_key.h:67
isc::gss_tsig::ManagedKey::getTKeyStatus
TKeyExchange::Status getTKeyStatus() const
Get the TKEY exchange status.
Definition managed_key.h:88
isc::gss_tsig::ManagedKey::statusToText
static std::string statusToText(Status status)
Convert a status to its textual form.
Definition managed_key.cc:27
isc::gss_tsig::ManagedKey::getStatus
Status getStatus() const
Get the key status.
Definition managed_key.h:74
isc::gss_tsig::ManagedKey::ManagedKey
ManagedKey(const std::string &name)
Constructor.
Definition managed_key.cc:50
isc::gss_tsig::ManagedKey::operator()
void operator()(TKeyExchange::Status tkey_status)
The TKEY exchange completion handler.
Definition managed_key.cc:56
isc::gss_tsig::ManagedKey::Status
Status
A key status.
Definition managed_key.h:32
isc::gss_tsig::ManagedKey::EXPIRED
@ EXPIRED
Expired (no longer usable).
Definition managed_key.h:35
isc::gss_tsig::ManagedKey::USABLE
@ USABLE
Usable.
Definition managed_key.h:34
isc::gss_tsig::ManagedKey::IN_ERROR
@ IN_ERROR
Setup failed.
Definition managed_key.h:36
isc::gss_tsig::ManagedKey::NOT_READY
@ NOT_READY
Not yet ready (not yet usable).
Definition managed_key.h:33
isc::gss_tsig::TKeyExchange::Callback
Callback for the TKeyExchange class.
Definition tkey_exchange.h:58
isc::gss_tsig::TKeyExchange::Status
Status
A status code of the TKeyExchange.
Definition tkey_exchange.h:39
gss_tsig_key.h
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:28
isc::dns::name
Definition name.cc:69
isc::dns::TSIGContextPtr
boost::shared_ptr< TSIGContext > TSIGContextPtr
Definition tsig.h:435
isc::gss_tsig
Definition gss_tsig_api.cc:17
isc::gss_tsig::TKeyExchangePtr
boost::shared_ptr< TKeyExchange > TKeyExchangePtr
Definition tkey_exchange.h:21
isc::gss_tsig::ManagedKeyPtr
boost::shared_ptr< ManagedKey > ManagedKeyPtr
Type of pointer to a Managed GSS-TSIG key.
Definition managed_key.h:156
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
isc::data::CfgToElement
Abstract class for configuration Cfg_* classes.
Definition cfg_to_element.h:29
tkey_exchange.h