Virtru SDK for C++
2.8.0
Virtru C++ SDK library - Create, Read, and Manage TDF3 Files
|
#include <virtru_client.h>
Public Member Functions | |
Client (std::string owner, std::string appId) | |
Client (std::string owner, std::string apiKey, std::string apiSecret) | |
Client (std::string owner, std::string organizationName, std::string clientId, std::string clientSecret) | |
Client (const Credentials &credentials) | |
Client ()=delete | |
~Client () | |
Client (const Client &client)=delete | |
Client & | operator= (const Client &client)=delete |
Client (Client &&client)=delete | |
Client & | operator= (Client &&client)=delete |
void | setKasUrl (const std::string &kasUrl) |
void | setOIDCProviderUrl (const std::string &oidcUrl) |
void | setEasUrl (const std::string &easUrl) |
void | setAcmUrl (const std::string &acmUrl) |
void | setSecureReaderURL (const std::string &srUrl) |
void | setEncryptedStorageURL (const std::string &encryptedStorageUrl) |
void | setRCAServiceURL (const std::string &rcaServiceURL) |
void | setProtocol (Protocol protocol) |
void | setOffline (bool state) |
void | setKeyAccessType (KeyAccessType keyAccessType) |
void | enableConsoleLogging (LogLevel logLevel=LogLevel::Current) |
void | setExternalLogger (std::shared_ptr< ILogger > externalLogger, LogLevel logLevel=LogLevel::Current) |
void | setCertAuthority (const std::string &certAuthority) |
std::string | encryptFile (const EncryptFileParams &encryptFileParam) |
std::pair< std::string, std::string > | encryptFileToRCA (const EncryptFileParams &encryptFileParam) |
std::string | encryptStream (const EncryptStreamParams &encryptStreamParams) |
std::pair< std::string, std::string > | encryptString (const EncryptStringParams &encryptStringParams) |
std::pair< std::string, std::string > | encryptStringToRCA (const EncryptStringParams &encryptStringParams) |
void | decryptFile (const std::string &inFilepath, const std::string &outFilepath) |
void | decryptRCAToFile (const std::string &rcaLink, const std::string &outFilepath) |
void | decryptStream (std::istream &inStream, std::ostream &outStream) |
std::string | decryptString (std::string tdfData) |
std::string | decryptRCAToString (const std::string &rcaLink) |
void | updatePolicyForUUID (const Policy &policy, const std::string &policyUUID) |
void | updatePolicyForUUIDs (const Policy &policy, const std::vector< std::string > &policyUUIDs) |
void | updatePolicyForFile (const Policy &policy, const std::string &tdfFile) |
void | updatePolicyForFiles (const Policy &policy, const std::vector< std::string > &files) |
void | revokePolicy (const std::string &policyUUID) |
void | revokePolicies (const std::vector< std::string > &policyUUIDs) |
void | revokeFile (const std::string &tdfFile) |
void | revokeFiles (const std::vector< std::string > &files) |
Policy | fetchPolicyForUUID (const std::string &policyUUID) |
std::string | getUserId () |
Private Member Functions | |
void | initClient () |
std::string | prepareForEncrypt (const EncryptParams &encryptParams) |
Private Attributes | |
std::unique_ptr < VirtruTDF3Builder > | m_virtruTDF3Builder |
virtru::Client::Client | ( | std::string | owner, |
std::string | appId | ||
) |
DEPRECATED in favor of OIDC client credential flows Constructs a new Client instance with owner and appId.
owner | - The owner's email address to be used to authenticate for encrypt, decrypt and policy management. Any data encrypted will be owned by the supplied email address. The owner will always have access to the encrypted data (TDF). |
appId | - The virtru application ID can be obtained from the Virtru Dashboard |
virtru::Client::Client | ( | std::string | owner, |
std::string | apiKey, | ||
std::string | apiSecret | ||
) |
DEPRECATED in favor of OIDC client credential flows Constructs a new Client instance with owner and HMAC apiKey/apiSecret. Contact Virtru to get your organization's HMAC apiKey/apiSecret
owner | - The owner's email address to be used to authenticate for encrypt, decrypt and policy management. |
apiKey | - The HMAC api key |
apiSecret | - The HMAC api secret |
virtru::Client::Client | ( | std::string | owner, |
std::string | organizationName, | ||
std::string | clientId, | ||
std::string | clientSecret | ||
) |
Constructs a new Client instance with Owner and OIDC client credentials, associated with a specific organization/realm.
owner | - The owner's email address to be used to authenticate for encrypt, decrypt |
organizationName | - The OIDC realm or organization the client belongs to |
clientId | - The clientId part of the client credentialset issued to the client - The clientSecret part of the client credentialset issued to the client |
virtru::Client::Client | ( | const Credentials & | credentials | ) |
Constructs a new Client instance based on a Credentials object
credentials | - The Credentials object containing authorization details |
|
delete |
Default constructor is not supported.
virtru::Client::~Client | ( | ) |
Destroy the Client instance.
|
delete |
Copy constructor.
|
delete |
Move copy constructor.
void virtru::Client::decryptFile | ( | const std::string & | inFilepath, |
const std::string & | outFilepath | ||
) |
Decrypt the contents of the TDF file into its original content.
inFilepath | - The TDF file on which the decryption is performed |
outFilepath | - The file path of the original content after successful decryption |
void virtru::Client::decryptRCAToFile | ( | const std::string & | rcaLink, |
const std::string & | outFilepath | ||
) |
Decrypt the remote contents(RCA) file into its original content.
rcaLink | - The link contains the information of remote content |
outFilepath | - The file path of the original content after successful decryption |
std::string virtru::Client::decryptRCAToString | ( | const std::string & | rcaLink | ) |
Decrypt the remote content TDF(RCA)
rcaLink | - The link contains the information of remote content |
void virtru::Client::decryptStream | ( | std::istream & | inStream, |
std::ostream & | outStream | ||
) |
Decrypt the contents of the TDF stream data into its original content.
inStream | - The TDF stream on which the decryption is performed |
outStream | - The output stream with the original content after successful decryption |
std::string virtru::Client::decryptString | ( | std::string | tdfData | ) |
Decrypt the TDF data
tdfData | - The tdf data to be decrypted. |
void virtru::Client::enableConsoleLogging | ( | LogLevel | logLevel = LogLevel::Current | ) |
Optional - Logging
Enable the internal logger class to write logs to the console for given LogLevel. The default Loglevel is to keep the current level if not specified.
logLevel | - The log level |
std::string virtru::Client::encryptFile | ( | const EncryptFileParams & | encryptFileParam | ) |
Encrypt the contents of the input file into a TDF. In the process of encryption, a policy is associated with the TDF. The policy has a unique id which can be used to identify the TDF policy.
encryptFileParams | - Object holding all the required information for encrypt operations |
std::pair<std::string, std::string> virtru::Client::encryptFileToRCA | ( | const EncryptFileParams & | encryptFileParam | ) |
Encrypt the contents of the input file into a RCA TDF. In the process of encryption, a policy is associated with the TDF. The policy has a unique id which can be used to identify the TDF policy.
encryptFileParams | - Object holding all the required information for encrypt operations |
std::string virtru::Client::encryptStream | ( | const EncryptStreamParams & | encryptStreamParams | ) |
Encrypt the contents of the stream into a TDF. In the process of encryption, a policy is associated with the TDF. The policy has a unique id which can be used to identify the TDF policy.
encryptStreamParams | - Object holding all the required information for encrypt operations |
std::pair<std::string, std::string> virtru::Client::encryptString | ( | const EncryptStringParams & | encryptStringParams | ) |
Encrypt the plain data into a TDF. In the process of encryption, a policy is associated with the TDF. The policy has a unique id which can be used to identify the TDF policy.
encryptFileParam | - Object holding all the required information for encrypt operations |
std::pair<std::string, std::string> virtru::Client::encryptStringToRCA | ( | const EncryptStringParams & | encryptStringParams | ) |
Encrypt the plain data into a remote TDF. In the process of encryption, a policy is associated with the TDF. The policy has a unique id which can be used to identify the TDF policy.
encryptFileParam | - Object holding all the required information for encrypt operations |
Policy virtru::Client::fetchPolicyForUUID | ( | const std::string & | policyUUID | ) |
Return the policy associated with the given policyId.
policyUUID | - The policy uuid of the TDF. |
std::string virtru::Client::getUserId | ( | ) |
Return the userId associated with this client according to the EntityObject
|
private |
A helper method to update the TDF builder;.
|
private |
Prepare tdf3 builder object for encrypt.
void virtru::Client::revokeFile | ( | const std::string & | tdfFile | ) |
Revoke access for all users that were granted access to the TDF file. The owner of the TDF will still have access.
tdfFile | - The TDF file |
void virtru::Client::revokeFiles | ( | const std::vector< std::string > & | files | ) |
Revoke access for all users that were granted acccess to the TDF files. The owner of the TDF will still have access.
files | - Vector of TDF files. |
void virtru::Client::revokePolicies | ( | const std::vector< std::string > & | policyUUIDs | ) |
Revoke access for all users that were granted access to the TDF files associated with the specified policies. The owner of the TDF will still have access.
policyUUIDs | - Vector of policy uuids |
void virtru::Client::revokePolicy | ( | const std::string & | policyUUID | ) |
Revoke access for all the users that were granted access to the TDF file associated with the specified policy. The owner of the TDF will still have access.
policyUUID | - The policy uuid of the TDF |
void virtru::Client::setAcmUrl | ( | const std::string & | acmUrl | ) |
Set the ACM url that will be used for TDF policy sync operations. Optional - this method should be only used if you have your own acm server infrastructure.
acmUrl | - The ACM server url |
void virtru::Client::setCertAuthority | ( | const std::string & | certAuthority | ) |
Optional - configure root CA's
Set the cert authority which will be used in SSL handshake for all the network I/O.
NOTE: This is optional. If not specified, the SDK will supply a default.
certAuthority | - A string which holds the cert authority which will be used in SSL handshake for all the network I/O |
void virtru::Client::setEasUrl | ( | const std::string & | easUrl | ) |
DEPRECATED OIDC auth flows do not use EAS. Set the EAS url that will be used for TDF operations. Optional - this method should be only used if you have your own entity attribute server infrastructure.
easUrl | - The EAS (Entity Attribute Server) url |
void virtru::Client::setEncryptedStorageURL | ( | const std::string & | encryptedStorageUrl | ) |
Set the encrypted storage url that will be used for storing remote TDFs. Optional - this method should be only used if you have your own secure storage server infrastructure.
encryptedStorageUrl | - The encrypted storage url |
void virtru::Client::setExternalLogger | ( | std::shared_ptr< ILogger > | externalLogger, |
LogLevel | logLevel = LogLevel::Current |
||
) |
Optional - Set the external logger instance. The internal logger will be used if the caller does not specify one. The caller is responsible for ownership of the logger instance.
NOTE: Once you use this method, the internal logger class is freed, and the internal logger will no longer be used.
externalLogger | - The external logger instance (std::shared_ptr). |
logLevel | - The log level, the default is to keep the current level if not specified. |
void virtru::Client::setKasUrl | ( | const std::string & | kasUrl | ) |
Optional
Note: Defaults will be used if these methods are not used. the KAS url that will be used for TDF operations. Optional - this method should be only used if you have your own key access server infrastructure.
kasUrl | - The KAS (Key Access Server) url |
void virtru::Client::setKeyAccessType | ( | KeyAccessType | keyAccessType | ) |
Set the type of key access. The types of key access are 'Remote' and 'Wrapped'. Remote - The key is stored on remote server. Wrapped - The key is embedded in TDF. The default is the recommended type 'Remote'
keyAccessType | - The key access type. |
void virtru::Client::setOffline | ( | bool | state | ) |
Set the offline mode.
state | - If true, all the TDFs will be encrypted in offline mode that means the sysmetric key stored part of the TDF instead on the server. NOTE: This is same as setKeyAccessType |
void virtru::Client::setOIDCProviderUrl | ( | const std::string & | oidcUrl | ) |
Set the OIDC provider url that the client will authenticate with, if using OIDC credentials. Optional - You should typically only set this if you're not using Virtru's OIDC provider.
oidcUrl | - The OIDC IdP (Identity Provider) url to use. |
void virtru::Client::setProtocol | ( | Protocol | protocol | ) |
Set the TDF protocol (format) to be used for encryption and decryption operations. HTML is the default format. The protocols refer to the data format after encryption. Options are .tdf (which is a zip) or HTML.
protocol | - type of the protocol (format) |
void virtru::Client::setRCAServiceURL | ( | const std::string & | rcaServiceURL | ) |
Set the rca service url that will be used for storing remote TDFs. Optional - this method should be only used if you have your own rca service server infrastructure.
rcaServiceURL | - The rca service url |
void virtru::Client::setSecureReaderURL | ( | const std::string & | srUrl | ) |
Set the secure reader url which will be used in html format TDF. This is the URL that will be used on opening the .html TDF. Optional - Should be only used if you host your own secure reader.
srUrl | - The secure reader url |
void virtru::Client::updatePolicyForFile | ( | const Policy & | policy, |
const std::string & | tdfFile | ||
) |
Update the policy for the given TDF file
policy | - The policy object with new controls |
tdfFile | - The TDF file path |
void virtru::Client::updatePolicyForFiles | ( | const Policy & | policy, |
const std::vector< std::string > & | files | ||
) |
Update the policy for multiple TDF files
policy | - The policy object with new controls |
files | - List of TDF files |
void virtru::Client::updatePolicyForUUID | ( | const Policy & | policy, |
const std::string & | policyUUID | ||
) |
Update the policy for a given TDF file using its policy uuid.
policy | - The policy object with new controls |
policyUUID | - The policy uuid of the TDF |
void virtru::Client::updatePolicyForUUIDs | ( | const Policy & | policy, |
const std::vector< std::string > & | policyUUIDs | ||
) |
Update the policy for multiple TDFs using their policy uuids.
policy | - The policy object with new controls |
policyUUIDs | - The vector of policy uuids for the TDFs |
|
private |
Data.