@Override public SaslServer createSaslServer(final String mechanism, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { final long timeout; if (props.containsKey(WildFlySasl.AUTHENTICATION_TIMEOUT)) { timeout = Long.parseLong((String) props.get(WildFlySasl.AUTHENTICATION_TIMEOUT)); } else { timeout = DEFAULT_TIMEOUT; } final SaslServer delegateSaslServer = delegate.createSaslServer(mechanism, protocol, serverName, props, cbh); return (delegateSaslServer == null) ? null : new DelegatingTimeoutSaslServer(delegateSaslServer, scheduledExecutorService, timeout); }
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); }
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 SaslServer createSaslServer(final String mechanism, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { final long timeout; if (props.containsKey(WildFlySasl.AUTHENTICATION_TIMEOUT)) { timeout = Long.parseLong((String) props.get(WildFlySasl.AUTHENTICATION_TIMEOUT)); } else { timeout = DEFAULT_TIMEOUT; } final SaslServer delegateSaslServer = delegate.createSaslServer(mechanism, protocol, serverName, props, cbh); return (delegateSaslServer == null) ? null : new DelegatingTimeoutSaslServer(delegateSaslServer, scheduledExecutorService, timeout); }
@Override public synchronized void dispose() throws SaslException { cancelTimeoutTask(); super.dispose(); }
@Override public synchronized void dispose() throws SaslException { cancelTimeoutTask(); super.dispose(); }
@Override public SaslServer createSaslServer(final String mechanism, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { final long timeout; if (props.containsKey(WildFlySasl.AUTHENTICATION_TIMEOUT)) { timeout = Long.parseLong((String) props.get(WildFlySasl.AUTHENTICATION_TIMEOUT)); } else { timeout = DEFAULT_TIMEOUT; } final SaslServer delegateSaslServer = delegate.createSaslServer(mechanism, protocol, serverName, props, cbh); return (delegateSaslServer == null) ? null : new DelegatingTimeoutSaslServer(delegateSaslServer, scheduledExecutorService, timeout); }
@Override public synchronized void dispose() throws SaslException { cancelTimeoutTask(); super.dispose(); }
@Override public SaslServer createSaslServer(final String mechanism, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException { final long timeout; if (props.containsKey(WildFlySasl.AUTHENTICATION_TIMEOUT)) { timeout = Long.parseLong((String) props.get(WildFlySasl.AUTHENTICATION_TIMEOUT)); } else { timeout = DEFAULT_TIMEOUT; } final SaslServer delegateSaslServer = delegate.createSaslServer(mechanism, protocol, serverName, props, cbh); return (delegateSaslServer == null) ? null : new DelegatingTimeoutSaslServer(delegateSaslServer, scheduledExecutorService, timeout); }
@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 void dispose() throws SaslException { cancelTimeoutTask(); super.dispose(); }