class RateLimitGuard extends DigestAuthenticator {
    private static final int MIN_MS_BETWEEN_ATTEMPTS = 6000;

    private static final Logger logger = Logger.getLogger(RateLimitGuard.class.getName());

    protected long lastFailureTime = 0;
    
    public RateLimitGuard(Context context, String realm, String serverKey) throws IllegalArgumentException {
        super(context, realm, serverKey);
    }

    @Override
    protected boolean authenticate(Request request, Response response) {<FILL_FUNCTION_BODY>}
}

        boolean succeeded = super.authenticate(request, response);
        String authHeader = request.getHeaders().getFirstValue("Authorization", true);
        if (authHeader != null && !succeeded) {
            logger.warning("authentication failure "+request);
            // wait until at least LAG has passed from last failure
            // holding object lock the whole time, so no other checks
            // can happen in parallel
            long now = System.currentTimeMillis();
            long sleepMs = (lastFailureTime+MIN_MS_BETWEEN_ATTEMPTS)-now;
            if(sleepMs>0) {
                try {
                    Thread.sleep(sleepMs);
                } catch (InterruptedException e) {
                    // ignore
                }
            }
            lastFailureTime = now;
        }
        return succeeded;
    
<no_super_class>