Microsoft Information Protection SDK - Concetti relativi al profilo dell'API CriteriMicrosoft Information Protection SDK - Policy API profile concepts
mip::Profile
deve essere caricato prima di poter eseguire qualsiasi operazione dell'API Criteri.The mip::Profile
must be loaded before any Policy API operations can be performed.
I due esempi seguenti mostrano come creare l'oggetto profileSettings usando l'archiviazione locale o solo in memoria per l'archiviazione degli stati.The two examples below show how to create the profileSettings object using local storage for state storage as well as in-memory only.
Caricare un profiloLoad a Profile
Dopo aver definito MipContext
e ProfileObserver
, verranno usati per creare un'istanza di mip::PolicyProfile
.Now that the MipContext
and ProfileObserver
are defined, we'll use the them to instantiate mip::PolicyProfile
. Per creare mip::PolicyProfile
l'oggetto mip::PolicyProfile::Settings
sono mip::MipContext
necessari e.Creating the mip::PolicyProfile
object requires mip::PolicyProfile::Settings
and mip::MipContext
.
Parametri di Profile::SettingsProfile::Settings Parameters
Il PolicyProfile::Settings
costruttore accetta quattro parametri, elencati di seguito:The PolicyProfile::Settings
constructor accepts four parameters, listed below:
const std::shared_ptr<MipContext>
: Oggettomip::MipContext
inizializzato per archiviare le informazioni sull'applicazione, il percorso di stato e così via.const std::shared_ptr<MipContext>
: Themip::MipContext
object that was initialized to store application info, state path, etc.mip::CacheStorageType
: Definisce come archiviare lo stato: in memoria, su disco o su disco e crittografato.mip::CacheStorageType
: Defines how to store state: In memory, on disk, or on disk and encrypted. Per informazioni dettagliate, vedere concetti relativi all'archiviazione della cache.For more details, see the Cache storage concepts.std::shared_ptr<mip::PolicyProfile::Observer> observer
: Puntatore condiviso all'implementazione del profiloObserver
(inPolicyProfile
,ProtectionProfile
eFileProfile
).std::shared_ptr<mip::PolicyProfile::Observer> observer
: A shared pointer to the profileObserver
implementation (inPolicyProfile
,ProtectionProfile
, andFileProfile
).
I due esempi seguenti mostrano come creare l'oggetto profileSettings usando l'archiviazione locale o solo in memoria per l'archiviazione degli stati.The two examples below show how to create the profileSettings object using local storage for state storage as well as in-memory only.
Archiviare lo stato solo in memoriaStore state in memory only
mip::ApplicationInfo appInfo {clientId, "APP NAME", "1.2.3" };
mMipContext = mip::MipContext::Create(appInfo,
"mip_app_data",
mip::LogLevel::Trace,
nullptr /*loggerDelegateOverride*/,
nullptr /*telemetryOverride*/);
PolicyProfile::Settings profileSettings(
mipContext, // mipContext object
mip::CacheStorageType::InMemory, // use in memory storage
std::make_shared<PolicyProfileObserverImpl>()); // new protection profile observer
Leggere/scrivere le impostazioni del profilo dal percorso di archiviazione su discoRead/write profile settings from storage path on disk
mip::ApplicationInfo appInfo {clientId, "APP NAME", "1.2.3" };
mMipContext = mip::MipContext::Create(appInfo,
"mip_app_data",
mip::LogLevel::Trace,
nullptr /*loggerDelegateOverride*/,
nullptr /*telemetryOverride*/);
PolicyProfile::Settings profileSettings(
mipContext, // mipContext object
mip::CacheStorageType::OnDisk, // use on disk storage
std::make_shared<PolicyProfileObserverImpl>()); // new protection profile observer
Usare poi il modello promise/future per caricare il Profile
.Next, use the promise/future pattern to load the Profile
.
auto profilePromise = std::make_shared<std::promise<std::shared_ptr<Profile>>>();
auto profileFuture = profilePromise->get_future();
Profile::LoadAsync(profileSettings, profilePromise);
Se un profilo è caricato correttamente, ProfileObserver::OnLoadSuccess
, l'implementazione di mip::Profile::Observer::OnLoadSuccess
riceve una notifica.If a profile is successfully loaded, ProfileObserver::OnLoadSuccess
, our implementation of mip::Profile::Observer::OnLoadSuccess
is notified. L'oggetto risultante, in questo caso mip::Profile
, nonché il contesto, vengono passati come parametri alla funzione dell'osservatore.The resulting object, in this case a mip::Profile
, as well as the context, are passed in as parameters to the observer function.
Il contesto è un puntatore a std::promise
creato per gestire l'operazione asincrona.The context is a pointer to the std::promise
we created to handle the async operation. La funzione imposta semplicemente il valore della promessa sull'oggetto profilo passato per il primo parametro.The function simply sets the value of the promise to the Profile object that was passed in for the first parameter. Quando la funzione main usa Future.get()
, il risultato può essere archiviato in un nuovo oggetto nel thread chiamante.When the main function uses Future.get()
, the result can be stored in a new object in the calling thread.
//get the future value and store in profile.
auto profile = profileFuture.get();
RiepilogoPutting it Together
Dopo aver completato l'implementazione degli osservatori e del delegato di autenticazione, è ora possibile caricare completamente un profilo.Having fully implemented the observers and authentication delegate, it's now possible to fully load a profile. Il frammento di codice riportato di seguito presuppone che tutte le intestazioni necessarie siano già incluse.The code snip below assumes all necessary headers are already included.
int main()
{
const string userName = "MyTestUser@consoto.com";
const string password = "P@ssw0rd!";
const string clientId = "MyClientId";
mip::ApplicationInfo appInfo {clientId, "APP NAME", "1.2.3" };
auto mipContext = mip::MipContext::Create(appInfo,
"mip_app_data",
mip::LogLevel::Trace,
nullptr /*loggerDelegateOverride*/,
nullptr /*telemetryOverride*/);
PolicyProfile::Settings profileSettings(
mipContext, // mipContext object
mip::CacheStorageType::OnDisk, // use on disk storage
std::make_shared<PolicyProfileObserverImpl>()); // new protection profile observer
auto profilePromise = std::make_shared<promise<shared_ptr<PolicyProfile>>>();
auto profileFuture = profilePromise->get_future();
Profile::LoadAsync(profileSettings, profilePromise);
auto profile = profileFuture.get();
}
Il risultato finale è il caricamento corretto del profilo e l'archiviazione nell'oggetto denominato profile
.The end result being that we've successfully loaded the profile and stored in the object called profile
.
Passaggi successiviNext Steps
Ora che il profilo è stato aggiunto, il passaggio successivo consiste nell'aggiungere un motore al profilo.Now that the profile has been added, the next step is to add an engine to the profile.
Concetti relativi al motore dei criteriPolicy engine concepts