Virtru SDK for C++  2.8.0
Virtru C++ SDK library - Create, Read, and Manage TDF3 Files
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
virtru_client.h
Go to the documentation of this file.
1 /*
2 * Copyright © 2018 - 2019 Virtru Corporation
3 *
4 * SPDX - License - Identifier: MIT
5 *
6 */
7 //
8 // Virtru TDF3 SDK
9 //
10 // Created by Sujan Reddy on 2019/07/17.
11 //
12 
13 #ifndef VIRTRU_TDF3_SDK_VIRTRU_CLIENT_H
14 #define VIRTRU_TDF3_SDK_VIRTRU_CLIENT_H
15 
16 #include <string>
17 #include <vector>
18 
19 #include "virtru_policy.h"
24 #include "tdf_constants.h"
25 #include "virtru_credentials.h"
26 
29 
30 namespace virtru {
31 
33  class ILogger;
34  class VirtruTDF3Builder;
35  class EncryptFileParams;
36 
37  class Client {
38  public:
46  Client(std::string owner, std::string appId);
47 
55  Client(std::string owner, std::string apiKey, std::string apiSecret);
56 
63  Client(std::string owner, std::string organizationName, std::string clientId, std::string clientSecret);
64 
67  Client(const Credentials& credentials);
68 
70  Client() = delete;
71 
73  ~Client();
74 
76  Client(const Client& client) = delete;
77 
79  Client& operator=(const Client& client) = delete;
80 
82  Client(Client&& client) = delete;
83 
85  Client& operator=(Client&& client) = delete;
86 
87  public:
88 
95  void setKasUrl(const std::string& kasUrl);
96 
100  void setOIDCProviderUrl(const std::string& oidcUrl);
101 
106  void setEasUrl(const std::string& easUrl);
107 
111  void setAcmUrl(const std::string& acmUrl);
112 
116  void setSecureReaderURL(const std::string& srUrl);
117 
121  void setEncryptedStorageURL(const std::string& encryptedStorageUrl);
122 
126  void setRCAServiceURL(const std::string& rcaServiceURL);
127 
132  void setProtocol(Protocol protocol);
133 
138  void setOffline(bool state);
139 
145  void setKeyAccessType(KeyAccessType keyAccessType);
146 
147  public:
152 
153  //JAVACPPSKIPBEGIN
159  void setExternalLogger(std::shared_ptr<ILogger> externalLogger, LogLevel logLevel = LogLevel::Current);
160  //JAVACPPSKIPEND
161 
162  public:
163  void setCertAuthority(const std::string& certAuthority);
168 
169  public: // Encrypt and Decrypt
174  std::string encryptFile(const EncryptFileParams& encryptFileParam);
175 
180  std::pair<std::string, std::string> encryptFileToRCA(const EncryptFileParams& encryptFileParam);
181 
186  std::string encryptStream(const EncryptStreamParams& encryptStreamParams);
187 
188  //JAVACPPSKIPBEGIN
193  std::pair<std::string, std::string> encryptString(const EncryptStringParams& encryptStringParams);
194  //JAVACPPSKIPEND
195 
200  std::pair<std::string, std::string> encryptStringToRCA(const EncryptStringParams& encryptStringParams);
201 
205  void decryptFile(const std::string& inFilepath, const std::string& outFilepath);
206 
210  void decryptRCAToFile(const std::string& rcaLink, const std::string& outFilepath);
211 
215  void decryptStream(std::istream& inStream, std::ostream& outStream);
216 
220  std::string decryptString(std::string tdfData);
221 
225  std::string decryptRCAToString(const std::string& rcaLink);
226 
227  public: // Update policy
231  void updatePolicyForUUID(const Policy& policy, const std::string& policyUUID);
232 
236  void updatePolicyForUUIDs(const Policy& policy, const std::vector<std::string>& policyUUIDs);
237 
241  void updatePolicyForFile(const Policy& policy, const std::string& tdfFile);
242 
246  void updatePolicyForFiles(const Policy& policy, const std::vector<std::string>& files);
247 
251  void revokePolicy(const std::string& policyUUID);
252 
256  void revokePolicies(const std::vector<std::string>& policyUUIDs);
257 
260  void revokeFile(const std::string& tdfFile);
261 
264  void revokeFiles(const std::vector<std::string>& files);
265 
266  public: // Retrieve policy
270  Policy fetchPolicyForUUID(const std::string& policyUUID);
271 
274  std::string getUserId();
275 
276  private:
278  void initClient();
279 
281  std::string prepareForEncrypt(const EncryptParams& encryptParams);
282 
283  private:
284  std::unique_ptr<VirtruTDF3Builder> m_virtruTDF3Builder;
285  };
286 }
287 
288 
289 
290 #endif // VIRTRU_TDF3_SDK_VIRTRU_CLIENT_H
void setRCAServiceURL(const std::string &rcaServiceURL)
std::string encryptStream(const EncryptStreamParams &encryptStreamParams)
void setAcmUrl(const std::string &acmUrl)
Definition: virtru_policy.h:27
std::pair< std::string, std::string > encryptString(const EncryptStringParams &encryptStringParams)
void revokePolicy(const std::string &policyUUID)
void decryptRCAToFile(const std::string &rcaLink, const std::string &outFilepath)
void setSecureReaderURL(const std::string &srUrl)
LogLevel
Defines a log level.
Definition: tdf_constants.h:52
Client()=delete
Default constructor is not supported.
void updatePolicyForFile(const Policy &policy, const std::string &tdfFile)
void setExternalLogger(std::shared_ptr< ILogger > externalLogger, LogLevel logLevel=LogLevel::Current)
std::pair< std::string, std::string > encryptStringToRCA(const EncryptStringParams &encryptStringParams)
std::string prepareForEncrypt(const EncryptParams &encryptParams)
Prepare tdf3 builder object for encrypt.
std::unique_ptr< VirtruTDF3Builder > m_virtruTDF3Builder
Data.
Definition: virtru_client.h:284
KeyAccessType
Definition: tdf_constants.h:40
void setKeyAccessType(KeyAccessType keyAccessType)
void revokeFiles(const std::vector< std::string > &files)
void decryptFile(const std::string &inFilepath, const std::string &outFilepath)
void updatePolicyForUUIDs(const Policy &policy, const std::vector< std::string > &policyUUIDs)
void setProtocol(Protocol protocol)
std::pair< std::string, std::string > encryptFileToRCA(const EncryptFileParams &encryptFileParam)
void setEasUrl(const std::string &easUrl)
void setKasUrl(const std::string &kasUrl)
Policy fetchPolicyForUUID(const std::string &policyUUID)
std::string getUserId()
std::string decryptString(std::string tdfData)
Definition: virtru_credentials.h:31
Definition: virtru_client.h:37
void setOffline(bool state)
Definition: virtru_encrypt_stream_params.h:24
void enableConsoleLogging(LogLevel logLevel=LogLevel::Current)
Definition: virtru_encrypt_file_params.h:25
Definition: virtru_encrypt_string_params.h:24
void updatePolicyForFiles(const Policy &policy, const std::vector< std::string > &files)
void revokeFile(const std::string &tdfFile)
Protocol
Definition: tdf_constants.h:45
Definition: virtru_encrypt_params.h:24
std::string decryptRCAToString(const std::string &rcaLink)
void setEncryptedStorageURL(const std::string &encryptedStorageUrl)
Client & operator=(const Client &client)=delete
Assignment operator.
void setCertAuthority(const std::string &certAuthority)
void updatePolicyForUUID(const Policy &policy, const std::string &policyUUID)
std::string encryptFile(const EncryptFileParams &encryptFileParam)
void setOIDCProviderUrl(const std::string &oidcUrl)
no-op, value indicates current level should be retained
void decryptStream(std::istream &inStream, std::ostream &outStream)
void initClient()
A helper method to update the TDF builder;.
~Client()
Destroy the Client instance.
void revokePolicies(const std::vector< std::string > &policyUUIDs)