pulsar-client-cpp
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 
26 namespace pulsar {
27 
31 class 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 
68 typedef std::shared_ptr<CryptoKeyReader> CryptoKeyReaderPtr;
69 
70 class 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_ */
pulsar::DefaultCryptoKeyReader
Definition: CryptoKeyReader.h:70
pulsar::EncryptionKeyInfo
Definition: EncryptionKeyInfo.h:35
pulsar::Result
Result
Definition: Result.h:31
pulsar::CryptoKeyReader
Definition: CryptoKeyReader.h:31
pulsar
Definition: Authentication.h:31