pulsar-client-cpp
Loading...
Searching...
No Matches
CryptoKeyReader.h
1
19#ifndef CRYPTOKEYREADER_H_
20#define CRYPTOKEYREADER_H_
21
22#include <pulsar/EncryptionKeyInfo.h>
23#include <pulsar/Result.h>
24#include <pulsar/defines.h>
25
26namespace pulsar {
27
31class PULSAR_PUBLIC CryptoKeyReader {
32 public:
34 virtual ~CryptoKeyReader();
35
52 virtual Result getPublicKey(const std::string& keyName, std::map<std::string, std::string>& metadata,
53 EncryptionKeyInfo& encKeyInfo) const = 0;
54
63 virtual Result getPrivateKey(const std::string& keyName, std::map<std::string, std::string>& metadata,
64 EncryptionKeyInfo& encKeyInfo) const = 0;
65
66}; /* namespace pulsar */
67
68typedef std::shared_ptr<CryptoKeyReader> CryptoKeyReaderPtr;
69
70class PULSAR_PUBLIC DefaultCryptoKeyReader : public CryptoKeyReader {
71 private:
72 std::string publicKeyPath_;
73 std::string privateKeyPath_;
74 void readFile(std::string fileName, std::string& fileContents) const;
75
76 public:
86 DefaultCryptoKeyReader(const std::string& publicKeyPath, const std::string& privateKeyPath);
88
103 Result getPublicKey(const std::string& keyName, std::map<std::string, std::string>& metadata,
104 EncryptionKeyInfo& encKeyInfo) const;
105
116 Result getPrivateKey(const std::string& keyName, std::map<std::string, std::string>& metadata,
117 EncryptionKeyInfo& encKeyInfo) const;
118 static CryptoKeyReaderPtr create(const std::string& publicKeyPath, const std::string& privateKeyPath);
119}; /* namespace pulsar */
120
121} // namespace pulsar
122
123#endif /* CRYPTOKEYREADER_H_ */
Definition CryptoKeyReader.h:31
virtual Result getPrivateKey(const std::string &keyName, std::map< std::string, std::string > &metadata, EncryptionKeyInfo &encKeyInfo) const =0
virtual Result getPublicKey(const std::string &keyName, std::map< std::string, std::string > &metadata, EncryptionKeyInfo &encKeyInfo) const =0
Definition CryptoKeyReader.h:70
Result getPublicKey(const std::string &keyName, std::map< std::string, std::string > &metadata, EncryptionKeyInfo &encKeyInfo) const
Result getPrivateKey(const std::string &keyName, std::map< std::string, std::string > &metadata, EncryptionKeyInfo &encKeyInfo) const
DefaultCryptoKeyReader(const std::string &publicKeyPath, const std::string &privateKeyPath)
Definition EncryptionKeyInfo.h:35
Definition Authentication.h:31
Result
Definition Result.h:32