Package 

Class LcpDialogAuthentication

  • All Implemented Interfaces:
    org.readium.r2.lcp.LcpAuthenticating

    
    public final class LcpDialogAuthentication
     implements LcpAuthenticating
                        

    An LcpAuthenticating implementation presenting a dialog to the user.

    For this authentication to trigger, you must provide a sender parameter of type Activity, Fragment or View to Streamer::open() or LcpService::retrieveLicense(). It will be used as the host view for the dialog.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

      • LcpDialogAuthentication

        LcpDialogAuthentication()
    • Method Detail

      • retrievePassphrase

         String retrievePassphrase(LcpAuthenticating.AuthenticatedLicense license, LcpAuthenticating.AuthenticationReason reason, Boolean allowUserInteraction, Object sender)

        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.
        sender - Free object that can be used by reading apps to give some UX context when presenting dialogs.