From 25053e2043640d373b1960dae0b6a023a64e7117 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 27 Jun 2023 23:01:26 +0000 Subject: [PATCH] Remove PasswordMetrics#validatePassword() PasswordMetrics#validatePassword() is no longer used since all its callers were to converted to use PasswordMetrics#validateCredential() instead. So, remove it. Bug: 219511761 Bug: 232900169 Bug: 243881358 Test: build Change-Id: Ica7adff4f7171b24518cd916f1d4f6d4707851d6 --- .../android/app/admin/PasswordMetrics.java | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/core/java/android/app/admin/PasswordMetrics.java b/core/java/android/app/admin/PasswordMetrics.java index 9b64d8fe84b4d..93c0c8a4a47ae 100644 --- a/core/java/android/app/admin/PasswordMetrics.java +++ b/core/java/android/app/admin/PasswordMetrics.java @@ -135,17 +135,6 @@ public final class PasswordMetrics implements Parcelable { } } - private static boolean hasInvalidCharacters(byte[] password) { - // Allow non-control Latin-1 characters only. - for (byte b : password) { - char c = (char) b; - if (c < 32 || c > 127) { - return true; - } - } - return false; - } - @Override public int describeContents() { return 0; @@ -536,32 +525,6 @@ public final class PasswordMetrics implements Parcelable { return validatePasswordMetrics(adminMetrics, minComplexity, actualMetrics); } - /** - * Validates a proposed lockscreen credential against minimum metrics and complexity. - * - * @param adminMetrics minimum metrics to satisfy admin requirements - * @param minComplexity minimum complexity imposed by the requester - * @param isPin whether to validate as a PIN (true) or password (false) - * @param password the proposed lockscreen credential as a byte[]. Must be the value from - * {@link LockscreenCredential#getCredential()}. - * - * @return a list of validation errors. An empty list means the credential is OK. - * - * TODO: merge this into validateCredential() and remove the redundant hasInvalidCharacters(), - * once all external callers are removed - */ - public static List validatePassword( - PasswordMetrics adminMetrics, int minComplexity, boolean isPin, byte[] password) { - - if (hasInvalidCharacters(password)) { - return Collections.singletonList( - new PasswordValidationError(CONTAINS_INVALID_CHARACTERS, 0)); - } - - final PasswordMetrics enteredMetrics = computeForPasswordOrPin(password, isPin); - return validatePasswordMetrics(adminMetrics, minComplexity, enteredMetrics); - } - /** * Validates password metrics against minimum metrics and complexity *