Interface PinChanger

All Superinterfaces:
PinPolicyProvider
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface PinChanger extends PinPolicyProvider
The object in charge of PIN enrollment. It must be implemented by the developer of the SDK.
     PinChanger pinChanger = (context, handler) -> {
         PinAuthenticatorLockState lockState = context.protectionStatus().lockState();
         if (lockState == PinAuthenticatorLockState.FAILED_ATTEMPT_COOLDOWN) {
             // Inform the user that the PIN authenticator is locked temporarily
         } else if (lockState == PinAuthenticatorLockState.FAILED_ATTEMPT_RETRIES) {
             int remainingRetries = context.protectionStatus().remainingRetries();
             // Inform the user of the remaining retries before the PIN gets locked
             // forever
         }
         if (context.lastRecoverableError().isPresent()) {
             // Display error informing that the previously provided PINs were not valid
         }
         char[] oldPin = askUserForOldPin();
         char[] newPin = askUserForNewPin();
         if (oldPin != null && newPin != null) {
             handler.pins(oldPin, newPin);
         }
         else {
             handler.cancel();
         }
     };

 /**
  * Asks the user to provide the old PIN. If the user cancels the operation,
  * returns null.
  * @return the old PIN or null if user cancels the operation.
  */
 private char[] askUserForOldPin() {
     [...]
 }

 /**
  * Asks the user to provide the new PIN. If the user cancels the operation,
  * returns null.
  * @return the new PIN or null if user cancels the operation.
  */
 private char[] askUserForNewPin() {
     [...]
 }
 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    The method that will be invoked till either the user provides the old PIN and a new PIN that conforms to the format expected by the SDK (i.e.
    default PinPolicy
    Returns the object defining the minimum and maximum length of the new PIN value.
  • Method Details

    • changePin

      void changePin(PinChangeContext context, PinChangeHandler handler)
      The method that will be invoked till either the user provides the old PIN and a new PIN that conforms to the format expected by the SDK (i.e. a 6 digit PIN), or till the operation is canceled (through the PinChangeHandler.cancel()), or till the PIN authenticator is permanently locked because the user provided too many times an invalid PIN.
      Parameters:
      context - the context
      handler - the object that must be invoked with the new and old PINs
    • pinPolicy

      default PinPolicy pinPolicy()
      Returns the object defining the minimum and maximum length of the new PIN value. If not implemented, it will return a PIN policy with a minimum and maximum length of 6 digits.
      Specified by:
      pinPolicy in interface PinPolicyProvider
      Returns:
      the PinPolicy