Virgil Security C++ SDK
Public Member Functions | Static Public Member Functions | List of all members
virgil::sdk::cards::CardManager Class Reference

Class responsible for operations with Virgil Cards. More...

#include <CardManager.h>

Public Member Functions

 CardManager (std::shared_ptr< crypto::Crypto > crypto, std::shared_ptr< jwt::interfaces::AccessTokenProviderInterface > accessTokenProvider, std::shared_ptr< verification::CardVerifierInterface > cardVerifier, std::function< std::future< RawSignedModel >(RawSignedModel)> signCallback=nullptr, std::shared_ptr< client::CardClientInterface > cardClient=std::make_shared< client::CardClient >(), bool retryOnUnauthorized=true)
 Constructor. More...
 
RawSignedModel generateRawCard (const crypto::keys::PrivateKey &privateKey, const crypto::keys::PublicKey &publicKey, const std::string &identity, const std::string &previousCardId=std::string(), const std::unordered_map< std::string, std::string > &extraFields=std::unordered_map< std::string, std::string >()) const
 Generates self signed RawSignedModel. More...
 
Card parseCard (const RawSignedModel &model) const
 Imports and verifies Card from RawSignedModel using self Crypto instance. More...
 
std::future< CardpublishCard (const RawSignedModel &rawCard) const
 Asynchronously creates Virgil Card instance on the Virgil Cards Service and associates it with unique identifier Also makes the Card accessible for search/get queries from other users RawSignedModel should be at least selfSigned. More...
 
std::future< CardpublishCard (const crypto::keys::PrivateKey &privateKey, const crypto::keys::PublicKey &publicKey, const std::string &identity=std::string(), const std::string &previousCardId=std::string(), const std::unordered_map< std::string, std::string > &extraFields=std::unordered_map< std::string, std::string >()) const
 Generates self signed RawSignedModel, asynchronously creates Virgil Card instance on the Virgil Cards Service and associates it with unique identifier. More...
 
std::future< CardgetCard (const std::string &cardId) const
 Asynchronously returns Card with given identifier. More...
 
std::future< std::vector< Card > > searchCards (const std::string &identity) const
 Asynchronously performs search of Virgil Cards using identity on the Virgil Cards Service. More...
 
Card importCardFromBase64 (const std::string &base64) const
 Imports and verifies Card from base64 encoded std::string. More...
 
Card importCardFromJson (const std::string json) const
 Imports and verifies Card from json std::string. More...
 
Card importCardFromRawCard (const RawSignedModel &rawCard) const
 Imports and verifies Card from RawSignedModel. More...
 
std::string exportCardAsBase64 (const Card &card) const
 Exports Card as base64 encoded std::string. More...
 
std::string exportCardAsJson (const Card &card) const
 Exports Card as json std::string. More...
 
RawSignedModel exportCardAsRawCard (const Card &card) const
 Exports Card as RawSignedModel. More...
 
const std::shared_ptr< crypto::Crypto > & crypto () const
 Getter. More...
 
const std::shared_ptr< jwt::interfaces::AccessTokenProviderInterface > & accessTokenProvider () const
 Getter. More...
 
const std::shared_ptr< verification::CardVerifierInterface > & cardVerifier () const
 Getter. More...
 
const ModelSignermodelSigner () const
 Getter. More...
 
const std::shared_ptr< client::CardClientInterface > & cardClient () const
 Getter. More...
 
const std::function< std::future< RawSignedModel >RawSignedModel)> & signCallback () const
 Getter. More...
 
bool retryOnUnauthorized () const
 Getter. More...
 

Static Public Member Functions

static RawSignedModel generateRawCard (const std::shared_ptr< crypto::Crypto > &crypto, const ModelSigner &modelSigner, const crypto::keys::PrivateKey &privateKey, const crypto::keys::PublicKey &publicKey, const std::string &identity, const std::string &previousCardId=std::string(), const std::unordered_map< std::string, std::string > &extraFields=std::unordered_map< std::string, std::string >())
 Generates self signed RawSignedModel. More...
 
static Card parseCard (const RawSignedModel &model, const std::shared_ptr< crypto::Crypto > &crypto)
 Imports Card from RawSignedModel. More...
 

Detailed Description

Class responsible for operations with Virgil Cards.

Constructor & Destructor Documentation

virgil::sdk::cards::CardManager::CardManager ( std::shared_ptr< crypto::Crypto crypto,
std::shared_ptr< jwt::interfaces::AccessTokenProviderInterface accessTokenProvider,
std::shared_ptr< verification::CardVerifierInterface cardVerifier,
std::function< std::future< RawSignedModel >(RawSignedModel)>  signCallback = nullptr,
std::shared_ptr< client::CardClientInterface cardClient = std::make_shared< client::CardClient >(),
bool  retryOnUnauthorized = true 
)

Constructor.

Parameters
cryptoCrypto instance
accessTokenProviderAccessTokenProviderInterface implementation used for getting Access Token when performing queries
cardVerifierCardVerifierInterface implementation used for verifying Cards
signCallbackstd::function called to perform additional signatures for card before publishing
cardClientCardClientInterface implementation used for performing queries
retryOnUnauthorizedwill automatically perform second query with forceReload = true AccessToken if true

Member Function Documentation

const std::shared_ptr<jwt::interfaces::AccessTokenProviderInterface>& virgil::sdk::cards::CardManager::accessTokenProvider ( ) const

Getter.

Returns
std::shared_ptr to AccessTokenProviderInterface implementation
const std::shared_ptr<client::CardClientInterface>& virgil::sdk::cards::CardManager::cardClient ( ) const

Getter.

Returns
std::shared_ptr to CardClientInterface implementation
const std::shared_ptr<verification::CardVerifierInterface>& virgil::sdk::cards::CardManager::cardVerifier ( ) const

Getter.

Returns
std::shared_ptr to CardVerifierInterface implementation
const std::shared_ptr<crypto::Crypto>& virgil::sdk::cards::CardManager::crypto ( ) const

Getter.

Returns
std::shared_ptr to Crypto instance
std::string virgil::sdk::cards::CardManager::exportCardAsBase64 ( const Card card) const

Exports Card as base64 encoded std::string.

Parameters
cardCard instance to export
Returns
base64 encoded std::string with Card
std::string virgil::sdk::cards::CardManager::exportCardAsJson ( const Card card) const

Exports Card as json std::string.

Parameters
cardCard instance to import
Returns
json std::string with Card
RawSignedModel virgil::sdk::cards::CardManager::exportCardAsRawCard ( const Card card) const

Exports Card as RawSignedModel.

Parameters
cardCard instance to export
Returns
RawSignedModel representing Card
static RawSignedModel virgil::sdk::cards::CardManager::generateRawCard ( const std::shared_ptr< crypto::Crypto > &  crypto,
const ModelSigner modelSigner,
const crypto::keys::PrivateKey privateKey,
const crypto::keys::PublicKey publicKey,
const std::string &  identity,
const std::string &  previousCardId = std::string(),
const std::unordered_map< std::string, std::string > &  extraFields = std::unordered_map< std::string, std::string >() 
)
static

Generates self signed RawSignedModel.

Parameters
cryptoCrypto instance for exporting PublicKey
modelSignerModelSigner instance for self signing model
privateKeyPrivateKey to self sign with
publicKeyPublicKey instance
identityidentity of Card
previousCardIdidentifier of Virgil Card with same identity this Card will replace
extraFieldsstd::unordered_map with extra data to sign with model
Returns
self signed RawSignedModel
RawSignedModel virgil::sdk::cards::CardManager::generateRawCard ( const crypto::keys::PrivateKey privateKey,
const crypto::keys::PublicKey publicKey,
const std::string &  identity,
const std::string &  previousCardId = std::string(),
const std::unordered_map< std::string, std::string > &  extraFields = std::unordered_map< std::string, std::string >() 
) const

Generates self signed RawSignedModel.

Parameters
privateKeyPrivateKey to self sign with
publicKeyPublicKey instance
identityidentity of Card
previousCardIdidentifier of Virgil Card with same identity this Card will replace
extraFieldsstd::unordered_map with extra data to sign with model
Returns
self signed RawSignedModel
std::future<Card> virgil::sdk::cards::CardManager::getCard ( const std::string &  cardId) const

Asynchronously returns Card with given identifier.

Parameters
cardIdidentifier of card to return
Returns
std::future with found and verified Card
Card virgil::sdk::cards::CardManager::importCardFromBase64 ( const std::string &  base64) const

Imports and verifies Card from base64 encoded std::string.

Parameters
base64base64 encoded std::string with Card
Returns
imported and verified Card
Card virgil::sdk::cards::CardManager::importCardFromJson ( const std::string  json) const

Imports and verifies Card from json std::string.

Parameters
jsonstd::string with json structure of Card
Returns
imported and verified Card
Card virgil::sdk::cards::CardManager::importCardFromRawCard ( const RawSignedModel rawCard) const

Imports and verifies Card from RawSignedModel.

Parameters
rawCardRawSignedModel to import
Returns
imported and verified Card
const ModelSigner& virgil::sdk::cards::CardManager::modelSigner ( ) const

Getter.

Returns
ModelSigner instance
static Card virgil::sdk::cards::CardManager::parseCard ( const RawSignedModel model,
const std::shared_ptr< crypto::Crypto > &  crypto 
)
static

Imports Card from RawSignedModel.

Parameters
modelRawSignedModel instance to import
cryptoCrypto instance
Returns
imported Card
Card virgil::sdk::cards::CardManager::parseCard ( const RawSignedModel model) const

Imports and verifies Card from RawSignedModel using self Crypto instance.

Parameters
modelRawSignedModel to import
Returns
imported Card
std::future<Card> virgil::sdk::cards::CardManager::publishCard ( const RawSignedModel rawCard) const

Asynchronously creates Virgil Card instance on the Virgil Cards Service and associates it with unique identifier Also makes the Card accessible for search/get queries from other users RawSignedModel should be at least selfSigned.

Parameters
rawCardself signed RawSignedModel
Returns
std::future with published and verified Card
std::future<Card> virgil::sdk::cards::CardManager::publishCard ( const crypto::keys::PrivateKey privateKey,
const crypto::keys::PublicKey publicKey,
const std::string &  identity = std::string(),
const std::string &  previousCardId = std::string(),
const std::unordered_map< std::string, std::string > &  extraFields = std::unordered_map< std::string, std::string >() 
) const

Generates self signed RawSignedModel, asynchronously creates Virgil Card instance on the Virgil Cards Service and associates it with unique identifier.

Parameters
privateKeyPrivateKey to self sign RawSignedModel with
publicKeyPublicKey instance for generating RawSignedModel
identityidentity for generating RawSignedModel. Will be taken from token if omitted
previousCardIdidentifier of Virgil Card to replace
extraFieldsstd::unordered_map with extra data to sign RawSignedModel with
Returns
std::future with published and verified Card
bool virgil::sdk::cards::CardManager::retryOnUnauthorized ( ) const

Getter.

Returns
true if CardManager will automatically perform second query with forceReload = true AccessToken, false otherwise
std::future<std::vector<Card> > virgil::sdk::cards::CardManager::searchCards ( const std::string &  identity) const

Asynchronously performs search of Virgil Cards using identity on the Virgil Cards Service.

Parameters
identityidentity of Card to search
Returns
std::future with std::vector of found and verified Cards
const std::function<std::future<RawSignedModel>RawSignedModel)>& virgil::sdk::cards::CardManager::signCallback ( ) const

Getter.

Returns
std::function called to perform additional signatures for card before publishing

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