Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25053e20 authored by Eric Biggers's avatar Eric Biggers
Browse files

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
parent e4c9d2de
Loading
Loading
Loading
Loading
+0 −37
Original line number Diff line number Diff line
@@ -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<PasswordValidationError> 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
     *