retrievePassphrase method
Future<String?>
retrievePassphrase(
- AuthenticatedLicense license,
- AuthenticationReason reason,
- bool allowUserInteraction, {
- Object? sender,
override
Retrieves the passphrase used to decrypt the given license.
If allowUserInteraction
is true, the reading app can prompt the user to enter the
passphrase. Otherwise, use a background retrieval method (e.g. web service) or return null.
The returned passphrase can be clear or already hashed.
You can implement an asynchronous pop-up with callbacks using suspendCoroutine
:
suspendCoroutine<String?> { cont ->
cancelButton.setOnClickListener {
cont.resume(null)
}
okButton.setOnClickListener {
cont.resume(passwordEditText.text.toString())
}
// show pop-up...
}
@param license Information to show to the user about the license being opened. @param reason Reason why the passphrase is requested. It should be used to prompt the user. @param allowUserInteraction Indicates whether the user can be prompted for their passphrase. @param sender Free object that can be used by reading apps to give some UX context when presenting dialogs.
Implementation
@override
Future<String?> retrievePassphrase(AuthenticatedLicense license,
AuthenticationReason reason, bool allowUserInteraction,
{Object? sender}) async {
if (reason != AuthenticationReason.passphraseNotFound) {
return fallback?.retrievePassphrase(
license, reason, allowUserInteraction = allowUserInteraction,
sender: sender);
}
return passphrase;
}