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 Class Reference

#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
 
Clientoperator= (const Client &client)=delete
 
 Client (Client &&client)=delete
 
Clientoperator= (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
 

Constructor & Destructor Documentation

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.

Parameters
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

Parameters
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.

Parameters
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

Parameters
credentials- The Credentials object containing authorization details
virtru::Client::Client ( )
delete

Default constructor is not supported.

virtru::Client::~Client ( )

Destroy the Client instance.

virtru::Client::Client ( const Client client)
delete

Copy constructor.

virtru::Client::Client ( Client &&  client)
delete

Move copy constructor.

Member Function Documentation

void virtru::Client::decryptFile ( const std::string &  inFilepath,
const std::string &  outFilepath 
)

Decrypt the contents of the TDF file into its original content.

Parameters
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.

Parameters
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)

Parameters
rcaLink- The link contains the information of remote content
Returns
plain data - Return the decrypted tdf data.
void virtru::Client::decryptStream ( std::istream &  inStream,
std::ostream &  outStream 
)

Decrypt the contents of the TDF stream data into its original content.

Parameters
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

Parameters
tdfData- The tdf data to be decrypted.
Returns
plain data - Return the decrypted tdf data.
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.

Parameters
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.

Parameters
encryptFileParams- Object holding all the required information for encrypt operations
Returns
Policy uuid of the TDF, can be used later to update the policy controls
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.

Parameters
encryptFileParams- Object holding all the required information for encrypt operations
Returns
std::pair of policy uuid and RCA tdf link. policy uuid can be used later to update the policy controls
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.

Parameters
encryptStreamParams- Object holding all the required information for encrypt operations
Returns
Policy uuid of the TDF, can be used later to update the policy controls
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.

Parameters
encryptFileParam- Object holding all the required information for encrypt operations
Returns
std::pair of policy uuid and tdf data. policy uuid can be used later to update the policy controls
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.

Parameters
encryptFileParam- Object holding all the required information for encrypt operations
Returns
std::pair of policy uuid and rca link. policy uuid can be used later to update the policy controls
Policy virtru::Client::fetchPolicyForUUID ( const std::string &  policyUUID)

Return the policy associated with the given policyId.

Parameters
policyUUID- The policy uuid of the TDF.
Returns
Policy - The policy associated with the TDF.
std::string virtru::Client::getUserId ( )

Return the userId associated with this client according to the EntityObject

Returns
userId - The userId associated with this client
void virtru::Client::initClient ( )
private

A helper method to update the TDF builder;.

Client& virtru::Client::operator= ( const Client client)
delete

Assignment operator.

Client& virtru::Client::operator= ( Client &&  client)
delete

Move assignment operator.

std::string virtru::Client::prepareForEncrypt ( const EncryptParams encryptParams)
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.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
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'

Parameters
keyAccessType- The key access type.
void virtru::Client::setOffline ( bool  state)

Set the offline mode.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
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.

Parameters
srUrl- The secure reader url
void virtru::Client::updatePolicyForFile ( const Policy policy,
const std::string &  tdfFile 
)

Update the policy for the given TDF file

Parameters
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

Parameters
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.

Parameters
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.

Parameters
policy- The policy object with new controls
policyUUIDs- The vector of policy uuids for the TDFs

Member Data Documentation

std::unique_ptr<VirtruTDF3Builder> virtru::Client::m_virtruTDF3Builder
private

Data.


The documentation for this class was generated from the following file: