-
- All Implemented Interfaces:
-
org.readium.r2.lcp.LcpAuthenticating
public final class LcpDialogAuthentication implements LcpAuthenticating
An LcpAuthenticating implementation presenting a dialog to the user.
This authentication requires a view to anchor on. To use it, you'll need to call onParentViewAttachedToWindow every time it gets attached to a window and onParentViewDetachedFromWindow when it gets detached. You can typically achieve this with a View.OnAttachStateChangeListener. Without view to anchor on, retrievePassphrase will suspend until one is available.
-
-
Constructor Summary
Constructors Constructor Description LcpDialogAuthentication()
-
Method Summary
Modifier and Type Method Description final UnitonParentViewAttachedToWindow(View parentView)Call this method every time the anchor view gets attached to the window. final UnitonParentViewDetachedFromWindow()Call this method every time the anchor view gets detached from the window. StringretrievePassphrase(LcpAuthenticating.AuthenticatedLicense license, LcpAuthenticating.AuthenticationReason reason, Boolean allowUserInteraction)Retrieves the passphrase used to decrypt the given license. -
-
Method Detail
-
onParentViewAttachedToWindow
final Unit onParentViewAttachedToWindow(View parentView)
Call this method every time the anchor view gets attached to the window.
-
onParentViewDetachedFromWindow
final Unit onParentViewDetachedFromWindow()
Call this method every time the anchor view gets detached from the window.
-
retrievePassphrase
String retrievePassphrase(LcpAuthenticating.AuthenticatedLicense license, LcpAuthenticating.AuthenticationReason reason, Boolean allowUserInteraction)
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... }- Parameters:
license- Information to show to the user about the license being opened.reason- Reason why the passphrase is requested.allowUserInteraction- Indicates whether the user can be prompted for their passphrase.
-
-
-
-