@Override
        public void run() {

            // Get start time of cleanup check
            long checkStart = System.currentTimeMillis();

            // For each code still being tracked, remove those which are old
            // enough that they would fail validation against the secret key
            Iterator<Map.Entry<UsedCode, Long>> entries = invalidCodes.entrySet().iterator();
            while (entries.hasNext()) {

                Map.Entry<UsedCode, Long> entry = entries.next();
                long invalidUntil = entry.getValue();

                // If code is sufficiently old, evict it and check the next one
                if (checkStart >= invalidUntil)
                    entries.remove();

            }

            // Log completion and duration
            logger.debug("TOTP tracking cleanup check completed in {} ms.",
                    System.currentTimeMillis() - checkStart);

        }
Task which iterates through all explicitly-invalidated codes, evicting
those codes which are old enough that they would fail validation against
the secret key anyway.
extensions/guacamole-auth-totp/src/main/java/org/apache/guacamole/auth/totp/user/CodeUsageTrackingService.java