package org.java_websocket.server;
import java.io.IOException;
import java.net.Socket;
import java.nio.channels.ByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;

import org.java_websocket.SSLSocketChannel2;
import org.java_websocket.WebSocketAdapter;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.drafts.Draft;


public class DefaultSSLWebSocketServerFactory implements WebSocketServer.WebSocketServerFactory {
	protected SSLContext sslcontext;
	protected ExecutorService exec;

	public DefaultSSLWebSocketServerFactory( SSLContext sslContext ) {
		this( sslContext, Executors.newSingleThreadScheduledExecutor() );
	}

	public DefaultSSLWebSocketServerFactory( SSLContext sslContext , ExecutorService exec ) {
		if( sslContext == null || exec == null )
			throw new IllegalArgumentException();
		this.sslcontext = sslContext;
		this.exec = exec;
	}

	@Override
	public ByteChannel wrapChannel( SocketChannel channel, SelectionKey key ) throws IOException {
		SSLEngine e = sslcontext.createSSLEngine();
		e.setUseClientMode( false );
		return new SSLSocketChannel2( channel, e, exec, key );
	}

	@Override
	public WebSocketImpl createWebSocket( WebSocketAdapter a, Draft d) {
		return new WebSocketImpl( a, d );
	}

	@Override
	public WebSocketImpl createWebSocket( WebSocketAdapter a, List<Draft> d) {
		return new WebSocketImpl( a, d );
	}
	@Override
	public void close() {
		exec.shutdown();
	}
}
@@ -189,32 +189,85 @@
 .SocketChannel;%0A
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0A
 import java.util
@@ -1286,16 +1286,550 @@
 gine();%0A
+%09%09/**%0A%09%09 * See https://github.com/TooTallNate/Java-WebSocket/issues/466%0A%09%09 *%0A%09%09 * We remove TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 from the enabled ciphers since it is just available when you patch your java installation directly.%0A%09%09 * E.g. firefox requests this cipher and this causes some dcs/instable connections%0A%09%09 */%0A%09%09List%3CString%3E ciphers = new ArrayList%3CString%3E( Arrays.asList(e.getEnabledCipherSuites()));%0A%09%09ciphers.remove(%22TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256%22);%0A%09%09e.setEnabledCipherSuites( ciphers.toArray(new String%5B%5D%7B%7D));%0A
 %09%09e.setU

Fix for #466