24#ifndef OPERATIONS_INCLUDED
25#define OPERATIONS_INCLUDED
482template <
typename Backend,
typename Data_extension = data::Data>
512 if (
valid_ ==
true)
return true;
514 return !
cache_.store(metadata, secret_data);
529 Data_extension fetched_data;
530 if (!metadata.
valid())
return true;
531 if (!
cache_.get(metadata, fetched_data))
return true;
534 if ((*backend_).get(metadata, fetched_data))
return true;
554 Data_extension &data) {
555 if (!metadata.
valid())
return true;
556 if (!
cache_.get(metadata, data))
return true;
572 Data_extension stored_data(data);
573 if (!metadata.
valid())
return true;
574 Data_extension fetched_data;
575 if (
cache_.get(metadata, fetched_data))
return true;
576 if ((*backend_).store(metadata, stored_data))
return true;
593 if (!
cache_.store(metadata, stored_data)) {
595 (void)(*backend_).erase(metadata, stored_data);
611 if (!metadata.
valid())
return true;
612 Data_extension fetched_data;
614 if (!
cache_.get(metadata, fetched_data))
return true;
616 if ((*backend_).erase(metadata, fetched_data))
return true;
635 if (!metadata.
valid())
return true;
637 Data_extension generated_data(g_data);
638 if (
cache_.get(metadata, generated_data))
return true;
639 if ((*backend_).generate(metadata, generated_data,
length))
return true;
641 if (!
cache_.store(metadata, generated_data)) {
643 (void)(*backend_).erase(metadata, generated_data);
665 if (!
valid())
return true;
666 if (!metadata.
valid())
return true;
667 it = std::make_unique<iterator::Iterator<Data_extension>>(
cache_, metadata);
668 return (it.get() ==
nullptr);
683 if (!
valid())
return true;
684 it = std::make_unique<iterator::Iterator<Data_extension>>(
cache_,
cached);
685 return (it.get() ==
nullptr);
709 return (
valid() && it.get() !=
nullptr && (*it).valid(
cache_.version()));
722 if (
valid() && it.get() !=
nullptr)
return !((*it).next(
cache_.version()));
740 if (!
valid() || it.get() ==
nullptr || !(*it).valid(
cache_.version()))
742 if (!(*it).metadata(
cache_.version(), metadata))
return true;
744 if (!(*it).data(
cache_.version(), data))
return true;
746 cache_.get(metadata, data);
747 if ((*backend_).get(metadata, data))
return true;
749 return !metadata.
valid();
766 if (!
valid() || it.get() ==
nullptr || !(*it).valid(
cache_.version()))
768 if (!(*it).metadata(
cache_.version(), metadata))
return true;
769 if (!(*it).data(
cache_.version(), data))
return true;
771 return !metadata.
valid();
780 return (*backend_).maximum_data_length();
796 if (backend ==
nullptr || backend->size() == 0) {
801 if (backend->load_cache(*
this) ==
true)
return;
807 if (backend->size() !=
cache_.size()) {
Sensitive data storage.
Definition: data.h:40
virtual const Data get_data() const
Return self.
Definition: data.cc:65
Definition: iterator.h:33
Keyring operations A class to perform operations on keyring.
Definition: operations.h:483
bool erase(const meta::Metadata &metadata)
Remove API.
Definition: operations.h:610
bool next(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Move iterator forward.
Definition: operations.h:721
bool generate(const meta::Metadata &metadata, const data::Type type, size_t length)
Generate API.
Definition: operations.h:633
Keyring_operations(bool cache_data, Backend *backend)
Constructor.
Definition: operations.h:493
bool get_data_extension(const meta::Metadata &metadata, Data_extension &data)
Get Backend-specific data extension.
Definition: operations.h:553
bool store(const meta::Metadata &metadata, const data::Data &data)
Store API.
Definition: operations.h:571
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
size_t maximum_data_length() const
Maximum data length supported.
Definition: operations.h:779
bool init_forward_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it, bool cached)
Iterator creation.
Definition: operations.h:681
bool cache_data_
Flag to cache data.
Definition: operations.h:817
void deinit_forward_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Iterator destruction.
Definition: operations.h:694
bool valid()
Validity.
Definition: operations.h:787
~Keyring_operations()=default
bool insert(const meta::Metadata &metadata, Data_extension secret_data)
Insert API to populate cache.
Definition: operations.h:510
bool is_valid(std::unique_ptr< iterator::Iterator< Data_extension > > &it)
Check iterator validity.
Definition: operations.h:708
void load_cache()
Definition: operations.h:790
bool init_read_iterator(std::unique_ptr< iterator::Iterator< Data_extension > > &it, const meta::Metadata &metadata)
Iterator creation for read.
Definition: operations.h:662
cache::Datacache< Data_extension > cache_
Metadata cache.
Definition: operations.h:815
std::unique_ptr< Backend > backend_
Keyring backend.
Definition: operations.h:819
size_t keyring_size()
Keyring size.
Definition: operations.h:784
bool get_iterator_metadata(std::unique_ptr< iterator::Iterator< Data_extension > > &it, meta::Metadata &metadata, Data_extension &data)
Get metadata from iterator.
Definition: operations.h:763
bool get(const meta::Metadata &metadata, data::Data &data)
Search API.
Definition: operations.h:528
bool valid_
Validity.
Definition: operations.h:821
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
std::string Type
Data types.
Definition: data.h:33
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:2439
required string type
Definition: replication_group_member_actions.proto:34
static double cached
Definition: xcom_statistics.cc:101