DelegatingTimeoutSaslServer(final SaslServer delegate, final ScheduledExecutorService scheduledExecutorService, final long timeout) { super(delegate); // Schedule a task to terminate the authentication attempt if it takes too long timeoutTask = scheduledExecutorService.schedule(() -> { synchronized (this) { if (! (isComplete() && ! complete)) { dispose(); terminated = true; } else { complete = true; } return null; } }, timeout, TimeUnit.SECONDS); }
DelegatingTimeoutSaslServer(final SaslServer delegate, final ScheduledExecutorService scheduledExecutorService, final long timeout) { super(delegate); // Schedule a task to terminate the authentication attempt if it takes too long timeoutTask = scheduledExecutorService.schedule(() -> { synchronized (this) { if (! (isComplete() && ! complete)) { dispose(); terminated = true; } else { complete = true; } return null; } }, timeout, TimeUnit.SECONDS); }
DelegatingTimeoutSaslServer(final SaslServer delegate, final ScheduledExecutorService scheduledExecutorService, final long timeout) { super(delegate); // Schedule a task to terminate the authentication attempt if it takes too long timeoutTask = scheduledExecutorService.schedule(() -> { synchronized (this) { if (! (isComplete() && ! complete)) { dispose(); terminated = true; } else { complete = true; } return null; } }, timeout, TimeUnit.SECONDS); }
@Override public synchronized byte[] evaluateResponse(final byte[] response) throws SaslException { if (terminated) { throw sasl.mechServerTimedOut().toSaslException(); } try { final byte[] challenge = delegate.evaluateResponse(response); if (isComplete() && ! complete) { complete = true; cancelTimeoutTask(); } return challenge; } catch (SaslException | RuntimeException | Error e) { if (isComplete() && ! complete) { complete = true; cancelTimeoutTask(); } throw e; } }
@Override public synchronized byte[] evaluateResponse(final byte[] response) throws SaslException { if (terminated) { throw sasl.mechServerTimedOut().toSaslException(); } try { final byte[] challenge = delegate.evaluateResponse(response); if (isComplete() && ! complete) { complete = true; cancelTimeoutTask(); } return challenge; } catch (SaslException | RuntimeException | Error e) { if (isComplete() && ! complete) { complete = true; cancelTimeoutTask(); } throw e; } }
@Override public synchronized byte[] evaluateResponse(final byte[] response) throws SaslException { if (terminated) { throw sasl.mechServerTimedOut().toSaslException(); } try { final byte[] challenge = delegate.evaluateResponse(response); if (isComplete() && ! complete) { complete = true; cancelTimeoutTask(); } return challenge; } catch (SaslException | RuntimeException | Error e) { if (isComplete() && ! complete) { complete = true; cancelTimeoutTask(); } throw e; } }
DelegatingTimeoutSaslServer(final SaslServer delegate, final ScheduledExecutorService scheduledExecutorService, final long timeout) { super(delegate); // Schedule a task to terminate the authentication attempt if it takes too long timeoutTask = scheduledExecutorService.schedule(() -> { synchronized (this) { if (! (isComplete() && ! complete)) { dispose(); terminated = true; } else { complete = true; } return null; } }, timeout, TimeUnit.SECONDS); }
@Override public synchronized byte[] evaluateResponse(final byte[] response) throws SaslException { if (terminated) { throw sasl.mechServerTimedOut().toSaslException(); } try { final byte[] challenge = delegate.evaluateResponse(response); if (isComplete() && ! complete) { complete = true; cancelTimeoutTask(); } return challenge; } catch (SaslException | RuntimeException | Error e) { if (isComplete() && ! complete) { complete = true; cancelTimeoutTask(); } throw e; } }