class AuthenticatorHelper {

    public static boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName) {
        if (newPassword == null || newPassword.isEmpty()) {
            LOG.error("verifyPasswordStrength failed because newPassword or principalName is null or empty");
            return false;
        } else if (newPassword != null && newPassword.trim().length() < 8) {
            LOG.error("verifyPasswordStrength failed because newPassword is too short, should be at least 8 chars long");
            return false;
        } else if (newPassword != null && !verifyCharSets(newPassword)) {
            LOG.error("verifyPasswordStrength failed because newPassword doesn't have a char from each char set");
            return false;
        }
        if (principalName == null) {
            principalName = "";
        }
        try {
            FileBasedAuthenticator.getInstance().verifyPasswordStrength(oldPassword, newPassword, getESAPIUser(principalName));
        } catch (AuthenticationException e) {
            // e.g. if newPassword is too similar to oldPassword
            LOG.error("verifyPasswordStrength failed because: " + e.getUserMessage() + " " + e.getLogMessage());
            return false;
        }
        return true;
    }

}