Interface PasswordEnroller

All Superinterfaces:
PasswordPolicyProvider

public interface PasswordEnroller extends PasswordPolicyProvider
The object in charge of password enrollment. It must be implemented by the developer of the SDK.
  private void passwordEnroller() {
      PasswordEnroller passwordEnroller = new PasswordEnroller() {
          @Override
          public void enrollPassword(PasswordEnrollmentContext context, PasswordEnrollmentHandler handler) {
              if (context.lastRecoverableError().isPresent()) {
                  // Display error informing that the previously provided password did not have
                  // valid syntax.
              }
              askUserForPassword(handler);
          }

          @Override
          public PasswordPolicy passwordPolicy() {
              return PasswordPolicy.defaultPasswordPolicy();
          }
      };
 }

 /**
   Asks the user to provide the new password. If the user cancels the operation,
   invokes {@code PasswordEnrollmentHandler#cancel}. If the user provides a password,
   invokes {@code PasswordEnrollmentHandler#password}
 /
 private void askUserForPassword(PasswordEnrollmentHandler handler) {
      //
 }
 
See Also:
  • Method Details

    • enrollPassword

      void enrollPassword(PasswordEnrollmentContext context, PasswordEnrollmentHandler handler)
      The method that will be invoked till either the user provides a password that is conform with the format expected by the password policy or till the operation is canceled (through the PasswordEnrollmentHandler.cancel().
      Parameters:
      context - the context
      handler - the object that must be invoked with the new password
    • passwordPolicy

      PasswordPolicy passwordPolicy()
      Returns the object defining the constraints of the password (minimum length, required special characters, etc.) that will be enrolled.
      Specified by:
      passwordPolicy in interface PasswordPolicyProvider
      Returns:
      the PasswordPolicy
    • onValidCredentialsProvided

      void onValidCredentialsProvided()
      This method is invoked when valid password credentials were provided during registration.

      This method can be used for instance to hide the UI used to ask for credentials to the user (some text fields to get password credentials) and then display some progress message indicating that the registration is ongoing.

      Note that invoking this method does not mean that the registration completed successfully (this is notified through methods such as Registration.onSuccess(Runnable) once the FIDO UAF server validates the request generated with the credentials).