Kea 3.3.3
gss_tsig_impl.h
Go to the documentation of this file.
1// Copyright (C) 2021-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#ifndef GSS_TSIG_IMPL_H
8#define GSS_TSIG_IMPL_H
9
13#include <hooks/hooks.h>
14
15#include <chrono>
16#include <memory>
17
18#include <boost/multi_index/composite_key.hpp>
19#include <boost/multi_index/ordered_index.hpp>
20
21namespace isc {
22namespace gss_tsig {
23
26
29
31typedef boost::multi_index_container<
32 // It holds pointers to GSS-TSIG key objects.
34 boost::multi_index::indexed_by<
35 // First index is the by DNS name.
36 boost::multi_index::hashed_unique<
37 boost::multi_index::tag<GssTsigKeyNameTag>,
38 boost::multi_index::const_mem_fun<ManagedKey, std::string,
40 >,
41
42 // Second index is by DNS server (parent) ID with the inception
43 // date to sort search results.
44 boost::multi_index::ordered_non_unique<
45 boost::multi_index::tag<GssTsigKeyServerTag>,
46 boost::multi_index::composite_key<
48 // The DNS server (parent) ID.
49 boost::multi_index::const_mem_fun<ManagedKey, std::string,
51 // The inception date.
52 boost::multi_index::const_mem_fun<GssTsigKey,
53 std::chrono::system_clock::time_point,
55 >
56 >
57 >
59
65public:
68
70 virtual ~GssTsigImpl();
71
77
82
89
94 io_service_ = io_service;
95 }
96
101 DnsServerPtr getServer(const std::string& id) const;
102
107 void start();
108
112 void stop();
113
118 void processAllServersKeys(bool rekey = false);
119
124 void processServerKeys(DnsServerPtr server, bool rekey = false);
125
130 void createKey(DnsServerPtr server,
131 std::chrono::time_point<std::chrono::system_clock> now);
132
141 ManagedKeyPtr findKey(const d2::DnsServerInfoPtr& server_info,
142 bool& useGssTsig, bool& fallback);
143
148 ManagedKeyPtr findKey(const std::string& name) const;
149
153 void purgeKeys();
154
158 void getHandler(isc::hooks::CalloutHandle& handle) const;
159
163 void getAllHandler(isc::hooks::CalloutHandle& handle) const;
164
168 void listHandler(isc::hooks::CalloutHandle& handle) const;
169
173 void keyGetHandler(isc::hooks::CalloutHandle& handle) const;
174
179
184
189
194
199
204
209
210protected:
213
216
219
221 std::unique_ptr<std::string> krb5_client_ktname_prev_;
222
224 std::unique_ptr<std::string> krb5ccname_prev_;
225
228};
229
231typedef std::unique_ptr<GssTsigImpl> GssTsigImplPtr;
232
233} // end of namespace isc::gss_tsig
234} // end of namespace isc
235
236#endif // GSS_TSIG_IMPL_H
GSS-TSIG hook configuration.
isc::asiolink::IOServicePtr getIOService()
Get the hook I/O service.
void rekeyAllHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-rekey-all command handler.
std::unique_ptr< std::string > krb5_client_ktname_prev_
The previous value of client key table environment variable.
isc::asiolink::IOServicePtr io_service_
The hook I/O service.
void stop()
Stop method.
void purgeAllHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-purge-all command handler.
void finishConfigure(isc::d2::D2CfgContextPtr d2_config)
Finish configure.
GssTsigCfg cfg_
GSS-TSIG hook configuration.
void commandProcessed(isc::hooks::CalloutHandle &handle)
The command_processed handler.
void start()
Start method.
void keyExpireHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-key-expire command handler.
void purgeHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-purge command handler.
void rekeyHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-rekey command handler.
void getAllHandler(isc::hooks::CalloutHandle &handle) const
The gss-tsig-get-all command handler.
void configure(isc::data::ConstElementPtr config)
Configure.
void keyDelHandler(isc::hooks::CalloutHandle &handle)
The gss-tsig-key-del command handler.
DnsServerPtr getServer(const std::string &id) const
Get the DNS server from its ID.
void processAllServersKeys(bool rekey=false)
Process GSS-TSIG keys for all servers.
ManagedKeyList keys_
Map of GSS-TSIG keys by name.
void setIOService(isc::asiolink::IOServicePtr io_service)
Set the hook I/O service.
ManagedKeyPtr findKey(const d2::DnsServerInfoPtr &server_info, bool &useGssTsig, bool &fallback)
Find a GSS-TSIG key by server info.
void purgeKeys()
Purge very old GSS-TSIG keys.
void processServerKeys(DnsServerPtr server, bool rekey=false)
Process GSS-TSIG keys for a specific server.
std::unique_ptr< std::string > krb5ccname_prev_
The previous value of credential cache environment variable.
void keyGetHandler(isc::hooks::CalloutHandle &handle) const
The gss-tsig-key-get command handler.
isc::asiolink::IntervalTimerPtr purge_timer_
The purge periodic timer.
virtual ~GssTsigImpl()
Destructor.
void listHandler(isc::hooks::CalloutHandle &handle) const
The gss-tsig-list command handler.
void getHandler(isc::hooks::CalloutHandle &handle) const
The gss-tsig-get command handler.
void createKey(DnsServerPtr server, std::chrono::time_point< std::chrono::system_clock > now)
Create new GSS-TSIG key.
GSS-TSIG extension of the D2 TSIG key class.
std::chrono::system_clock::time_point getInception() const
Get the key inception.
Managed GSS-TSIG key.
Definition managed_key.h:25
std::string getKeyNameStr() const
Get the key name as a string.
Definition managed_key.h:54
std::string getParentID() const
Get the DNS server (parent) ID.
Definition managed_key.h:61
Per-packet callout handle.
int rekey(CalloutHandle &handle)
The gss-tsig-rekey command.
boost::shared_ptr< DnsServerInfo > DnsServerInfoPtr
Defines a pointer for DnsServerInfo instances.
Definition d2_config.h:554
boost::shared_ptr< D2CfgContext > D2CfgContextPtr
Pointer to a configuration context.
Definition d2_cfg_mgr.h:32
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:30
boost::multi_index_container< ManagedKeyPtr, boost::multi_index::indexed_by< boost::multi_index::hashed_unique< boost::multi_index::tag< GssTsigKeyNameTag >, boost::multi_index::const_mem_fun< ManagedKey, std::string, &ManagedKey::getKeyNameStr > >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< GssTsigKeyServerTag >, boost::multi_index::composite_key< ManagedKey, boost::multi_index::const_mem_fun< ManagedKey, std::string, &ManagedKey::getParentID >, boost::multi_index::const_mem_fun< GssTsigKey, std::chrono::system_clock::time_point, &GssTsigKey::getInception > > > > > ManagedKeyList
A multi index container holding GSS-TSIG keys.
std::unique_ptr< GssTsigImpl > GssTsigImplPtr
Type of pointer to a GSS-TSIG hook configuration.
boost::shared_ptr< DnsServer > DnsServerPtr
A pointer to a DNS server.
boost::shared_ptr< ManagedKey > ManagedKeyPtr
Type of pointer to a Managed GSS-TSIG key.
Defines the logger used by the top-level component of kea-lfc.
Tag for the name index for searching GSS-TSIG key.
Tag for the server ID index for searching GSS-TSIG key.