24#ifndef KEYRING_READER_SERVICE_IMPL_TEMPLATE_INCLUDED
25#define KEYRING_READER_SERVICE_IMPL_TEMPLATE_INCLUDED
32#include <mysqld_error.h>
46namespace service_implementation {
64template <
typename Backend,
typename Data_extension = data::Data>
66 const char *data_id,
const char *auth_id,
73 ER_NOTE_KEYRING_COMPONENT_NOT_INITIALIZED);
77 if (data_id ==
nullptr || !*data_id) {
79 ER_NOTE_KEYRING_COMPONENT_EMPTY_DATA_ID);
87 ER_NOTE_KEYRING_COMPONENT_KEY_READ_ITERATOR_INIT_FAILED);
91 if (keyring_operations.
is_valid(it) ==
false) {
93 ER_NOTE_KEYRING_COMPONENT_READ_DATA_NOT_FOUND, data_id,
94 (auth_id ==
nullptr || !*auth_id) ?
"NULL" : auth_id);
101 LogComponentErr(
ERROR_LEVEL, ER_KEYRING_COMPONENT_EXCEPTION,
"init",
102 "keyring_reader_with_status");
120template <
typename Backend,
typename Data_extension = data::Data>
128 ER_NOTE_KEYRING_COMPONENT_NOT_INITIALIZED);
134 LogComponentErr(
ERROR_LEVEL, ER_KEYRING_COMPONENT_EXCEPTION,
"deinit",
135 "keyring_reader_with_status");
153template <
typename Backend,
typename Data_extension = data::Data>
156 size_t *data_type_size,
162 ER_NOTE_KEYRING_COMPONENT_NOT_INITIALIZED);
166 if (data_size ==
nullptr || data_type_size ==
nullptr) {
175 ER_NOTE_KEYRING_COMPONENT_KEY_READ_ITERATOR_FETCH_FAILED);
179 *data_size = data.data().length();
180 *data_type_size = data.type().length();
183 LogComponentErr(
ERROR_LEVEL, ER_KEYRING_COMPONENT_EXCEPTION,
"fetch_length",
184 "keyring_reader_with_status");
207template <
typename Backend,
typename Data_extension = data::Data>
210 size_t data_buffer_length,
size_t *data_size,
char *data_type_buffer,
211 size_t data_type_buffer_length,
size_t *data_type_size,
217 ER_NOTE_KEYRING_COMPONENT_NOT_INITIALIZED);
225 ER_NOTE_KEYRING_COMPONENT_KEY_READ_ITERATOR_FETCH_FAILED);
229 if (data_buffer_length < data.data().length() || data_buffer ==
nullptr) {
234 if (data_type_buffer_length < data.type().length() ||
235 data_type_buffer ==
nullptr) {
240 memset(data_buffer, 0, data_buffer_length);
241 memset(data_type_buffer, 0, data_type_buffer_length);
243 memcpy(data_buffer, data.data().c_str(), data.data().length());
244 *data_size = data.data().length();
246 memcpy(data_type_buffer, data.type().c_str(), data.type().length());
247 *data_type_size = data.type().length();
251 memset(data_buffer, 0, data_buffer_length);
252 memset(data_type_buffer, 0, data_type_buffer_length);
253 LogComponentErr(
ERROR_LEVEL, ER_KEYRING_COMPONENT_EXCEPTION,
"fetch",
254 "keyring_reader_with_status");
Sensitive data storage.
Definition: data.h:40
Definition: iterator.h:33
Keyring operations A class to perform operations on keyring.
Definition: operations.h:483
bool get_iterator_data(std::unique_ptr< iterator::Iterator< Data_extension > > &it, meta::Metadata &metadata, Data_extension &data)
Get data from iterator.
Definition: operations.h:737
void deinit_forward_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Iterator destruction.
Definition: operations.h:694
bool is_valid(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Check iterator validity.
Definition: operations.h:708
bool init_read_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it, const meta::Metadata &metadata)
Iterator creation for read.
Definition: operations.h:662
Definition: service_requirements.h:36
bool keyring_initialized()
Keyring component status.
Definition: component_callbacks.cc:29
@ ERROR_LEVEL
Definition: my_loglevel.h:43
@ INFORMATION_LEVEL
Definition: my_loglevel.h:45
int init_reader_template(const char *data_id, const char *auth_id, std::unique_ptr< Iterator< Data_extension > > &it, Keyring_operations< Backend, Data_extension > &keyring_operations, Component_callbacks &callbacks)
Initialize reader.
Definition: keyring_reader_service_impl_template.h:65
bool fetch_template(std::unique_ptr< Iterator< Data_extension > > &it, unsigned char *data_buffer, size_t data_buffer_length, size_t *data_size, char *data_type_buffer, size_t data_type_buffer_length, size_t *data_type_size, Keyring_operations< Backend, Data_extension > &keyring_operations, Component_callbacks &callbacks)
Fetches data from keyring.
Definition: keyring_reader_service_impl_template.h:208
bool fetch_length_template(std::unique_ptr< Iterator< Data_extension > > &it, size_t *data_size, size_t *data_type_size, Keyring_operations< Backend, Data_extension > &keyring_operations, Component_callbacks &callbacks)
Fetch length of the data.
Definition: keyring_reader_service_impl_template.h:154
bool deinit_reader_template(std::unique_ptr< Iterator< Data_extension > > &it, Keyring_operations< Backend, Data_extension > &keyring_operations, Component_callbacks &callbacks)
Deinitialize reader.
Definition: keyring_reader_service_impl_template.h:121
Definition: keyring_encryption_service_definition.h:32
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2438