Interface PinPolicy
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn object that can be used to build aPinPolicythat checks for the minimum and maximum PIN length. -
Method Summary
Modifier and TypeMethodDescriptionstatic PinPolicy.Builderbuilder()Returns an object that can be used to build aPinPolicy.intThe maximum length of the PIN.intThe minimum length of the PIN.default voidvalidatePinForEnrollment(char[] pin, Runnable onSuccess, Consumer<PinEnrollmentError.CustomValidationError> errorConsumer) Performs validation other than the minimum and maximum PIN length during PIN enrollment.default voidvalidatePinForPinChange(char[] pin, Runnable onSuccess, Consumer<PinChangeRecoverableError.CustomValidationError> errorConsumer) Performs validation other than the minimum and maximum PIN length during PIN change.
-
Method Details
-
builder
Returns an object that can be used to build aPinPolicy.- Returns:
- a
PinPolicybuilder
-
minLength
int minLength()The minimum length of the PIN.- Returns:
- the minimum length of the PIN
-
maxLength
int maxLength()The maximum length of the PIN.- Returns:
- the maximum length of the PIN
-
validatePinForEnrollment
default void validatePinForEnrollment(@NonNull char[] pin, @NonNull Runnable onSuccess, @NonNull Consumer<PinEnrollmentError.CustomValidationError> errorConsumer) Performs validation other than the minimum and maximum PIN length during PIN enrollment.This must be implemented in the case you require additional criteria for a PIN to be valid: the PIN must contain a minimum number of distinct digits, sequences of consecutive digits are disallowed, etc.
If this method is not implemented, only the PIN minimum and maximum length will be validated during PIN enrollment.
If validation fails, the implementation must invoke the provided
Consumer<PinEnrollmentError.CustomValidationError>with the error. The error will be the one returned by thePinEnrollmentContext.lastRecoverableError()method.The implementation must guarantee that, one (and only one) of
onSuccessanderrorConsumeris invoked, and that the one invoked is invoked only once.This method will be invoked in the main/UI thread.
Synchronous implementation example that requires PIN to have at least 4 different digits:
@Override public void validatePinForEnrollment(char[] pin, Runnable onSuccess, Consumer<PinEnrollmentError.CustomValidationError> errorConsumer) { if (hasLessThan4DifferentDigits(pin)) { errorConsumer.accept(PinEnrollmentError.CustomValidationError.builder() .description("The PIN has less than 4 consecutive digits.") .build()); } else { onSuccess.run(); } }- Parameters:
pin- the PIN to be validatedonSuccess- the object to be invoked if the validation is successfulerrorConsumer- the object to be invoked with the error if the validation fails
-
validatePinForPinChange
default void validatePinForPinChange(@NonNull char[] pin, @NonNull Runnable onSuccess, @NonNull Consumer<PinChangeRecoverableError.CustomValidationError> errorConsumer) Performs validation other than the minimum and maximum PIN length during PIN change.This must be implemented in the case you require additional criteria for a PIN to be valid: the PIN must contain a minimum number of distinct digits, sequences of consecutive digits are disallowed, etc.
If this method is not implemented, only the PIN minimum and maximum length will be validated during PIN change.
If validation fails, the implementation must invoke the provided
Consumer<PinChangeRecoverableError.CustomValidationError>with the error. The error will be the one returned by thePinChangeContext.lastRecoverableError()method.The implementation must guarantee that, one (and only one) of
onSuccessanderrorConsumeris invoked, and that the one invoked is invoked only once.This method will be invoked in the main/UI thread.
Synchronous implementation example that requires the PIN to be the same as a confirmation PIN provided in another field:
@Override public void validatePinForPinChange(char[] pin, Runnable onSuccess, Consumer<PinChangeRecoverableError.CustomValidationError> errorConsumer) { if (isDifferentThanConfirmationPIN(pin)) { errorConsumer.accept(PinChangeRecoverableError.CustomValidationError.builder() .description("The provided PINs do not match.") .build()); } else { onSuccess.run(); } }- Parameters:
pin- the PIN to be validatedonSuccess- the object to be invoked if the validation is successfulerrorConsumer- the object to be invoked with the error if the validation fails
-