Microsoft Information Protection SDK-consensoMicrosoft Information Protection SDK - Consent
La classe enum mip::Consent
implementa un approccio semplice che consente agli sviluppatori di applicazioni di fornire un'esperienza di consenso personalizzata in base all'endpoint a cui si accede dall'SDK.The mip::Consent
enum class implements an easy-to-use approach that permits application developers to provide a custom consent experience based on the endpoint that is being accessed by the SDK. La notifica può informare un utente dei dati che verranno raccolti e di come ottenere la rimozione dei dati o fornire qualsiasi altra informazione necessaria per legge o in base ai criteri di conformità.The notification can inform a user of the data that will be collected, how to get the data removed, or any other information that is required by law or compliance policies. Quando l'utente concede il consenso, l'applicazione può continuare.Once the user grants consent, the application can continue.
ImplementazioneImplementation
Il consenso viene implementato estendendo la classe di base mip::Consent
e implementando GetUserConsent
per restituire uno dei valori di enumerazione mip::Consent
.Consent is implemented by extending the mip::Consent
base class and implementing GetUserConsent
to return one of the mip::Consent
enum values.
L'oggetto derivato da mip::Consent
viene passato al costruttore mip::FileProfile::Settings
o mip::ProtectionProfile::Settings
.The object derived from mip::Consent
is passed in to the mip::FileProfile::Settings
or mip::ProtectionProfile::Settings
constructor.
Quando un utente esegue un'operazione che richiede il consenso, l'SDK chiama il metodo GetUserConsent
passando l'URL di destinazione come parametro.When a user performs an operation that would require providing consent, the SDK calls the GetUserConsent
method, passing in the destination URL as the parameter. Questo è il metodo in cui si implementerebbe la visualizzazione delle informazioni necessarie per l'utente, consentendogli di decidere se acconsentire o meno all'uso del servizio.It's in this method where one would implement displaying the necessary information to the user, allowing them to make a decision on whether or not they consent to using the service.
Opzioni per il consensoConsent Options
- AcceptAlways: fornisce il consenso e memorizza la decisione.AcceptAlways: Consent and remember the decision.
- Accept: fornisce il consenso una sola volta.Accept: Consent once.
- Reject: non fornisce il consenso.Reject: Do not consent.
Quando l'SDK richiede il consenso dell'utente con questo metodo, l'applicazione client deve presentare all'utente l'URL.When the SDK requests user consent with this method, the client application should present the URL to the user. Le applicazioni client devono offrire un modo per ottenere il consenso dell'utente e restituire l'enumerazione di consenso appropriata che corrisponde alla decisione dell'utente.Client applications should provide some means of obtaining user consent and return the appropriate Consent enum that corresponds to the user's decision.
Implementazione di esempioSample implementation
consent_delegate_impl.hconsent_delegate_impl.h
class ConsentDelegateImpl final : public mip::ConsentDelegate {
public:
ConsentDelegateImpl() = default;
virtual mip::Consent GetUserConsent(const std::string& url) override;
};
consent_delegate_impl.cppconsent_delegate_impl.cpp
Quando l'SDK richiede il consenso, il metodo GetUserConsent
viene chiamato dall'SDK e l'URL viene passato come parametro.When the SDK requires consent, the GetUserConsent
method is called by the SDK, and the URL passed in as a parameter. Nell'esempio seguente l'utente riceve una notifica che l'SDK si connetterà all'URL specificato e fornisce all'utente un'opzione nella riga di comando.In the sample below, the user is notified that the SDK will connect to that provided URL and provides the user with an option on the commandline. In base alla scelta da parte dell'utente, l'utente accetta o rifiuta il consenso e viene passato all'SDK.Based on the choice by the user, the user accepts or rejects consent and that is passed to the SDK. Se l'utente rifiuta di concedere il consenso all'applicazione genererà un'eccezione e non verrà effettuata alcuna chiamata al servizio di protezione.If the user declines to consent the application will throw an exception and no call is made to the protection service.
Consent ConsentDelegateImpl::GetUserConsent(const string& url) {
//Print the consent URL, ask user to choose
std::cout << "SDK will connect to: " << url << std::endl;
std::cout << "1) Accept Always" << std::endl;
std::cout << "2) Accept" << std::endl;
std::cout << "3) Reject" << std::endl;
std::cout << "Select an option: ";
char input;
std::cin >> input;
switch (input)
{
case '1':
return Consent::AcceptAlways;
break;
case '2':
return Consent::Accept;
break;
case '3':
return Consent::Reject;
break;
default:
return Consent::Reject;
}
}
A scopo di test e sviluppo, è ConsentDelegate
possibile implementare un semplice aspetto simile al seguente:For testing and development purposes, a simple ConsentDelegate
can be implemented that looks like:
Consent ConsentDelegateImpl::GetUserConsent(const string& url) {
return Consent::AcceptAlways;
}
Tuttavia, nel codice di produzione è possibile che l'utente debba presentare una scelta per il consenso, a seconda dei requisiti e delle normative regionali o aziendali.However, in production code the user may be required to be presented with a choice to consent, depending on regional or business requirements and regulations.