pulsar-client-cpp
Loading...
Searching...
No Matches
EncryptionContext.h
1
19#pragma once
20
21#include <cstdint>
22#include <string>
23#include <unordered_map>
24#include <vector>
25
26#include "CompressionType.h"
27#include "defines.h"
28
29namespace pulsar {
30
31namespace proto {
32class MessageMetadata;
33}
34
35struct PULSAR_PUBLIC EncryptionKey {
36 std::string key;
37 std::string value;
38 std::unordered_map<std::string, std::string> metadata;
39
40 EncryptionKey(const std::string& key, const std::string& value,
41 const decltype(EncryptionKey::metadata)& metadata)
42 : key(key), value(value), metadata(metadata) {}
43};
44
49class PULSAR_PUBLIC EncryptionContext {
50 public:
51 using KeysType = std::vector<EncryptionKey>;
52
56 const KeysType& keys() const noexcept { return keys_; }
57
61 const std::string& param() const noexcept { return param_; }
62
66 const std::string& algorithm() const noexcept { return algorithm_; }
67
71 CompressionType compressionType() const noexcept { return compressionType_; }
72
76 uint32_t uncompressedMessageSize() const noexcept { return uncompressedMessageSize_; }
77
81 int32_t batchSize() const noexcept { return batchSize_; }
82
90 bool isDecryptionFailed() const noexcept { return isDecryptionFailed_; }
91
97 EncryptionContext(const proto::MessageMetadata&, bool);
98
99 private:
100 KeysType keys_;
101 std::string param_;
102 std::string algorithm_;
103 CompressionType compressionType_{CompressionNone};
104 uint32_t uncompressedMessageSize_{0};
105 int32_t batchSize_{-1};
106 bool isDecryptionFailed_{false};
107
108 void setDecryptionFailed(bool failed) noexcept { isDecryptionFailed_ = failed; }
109
110 friend class ConsumerImpl;
111};
112
113} // namespace pulsar
int32_t batchSize() const noexcept
Definition EncryptionContext.h:81
CompressionType compressionType() const noexcept
Definition EncryptionContext.h:71
uint32_t uncompressedMessageSize() const noexcept
Definition EncryptionContext.h:76
const std::string & param() const noexcept
Definition EncryptionContext.h:61
const KeysType & keys() const noexcept
Definition EncryptionContext.h:56
const std::string & algorithm() const noexcept
Definition EncryptionContext.h:66
bool isDecryptionFailed() const noexcept
Definition EncryptionContext.h:90
EncryptionContext(const proto::MessageMetadata &, bool)
Definition Authentication.h:31