@Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws SSLException { if (parent.contains(SslFilter.class)) { throw new IllegalStateException( "Only one " + SslFilter.class.getName() + " is permitted."); } IoSession session = parent.getSession(); session.setAttribute(NEXT_FILTER, nextFilter); // Create an SSL handler and start handshake. SslHandler handler = new SslHandler(this, sslContext, session); session.setAttribute(SSL_HANDLER, handler); }
/** * Executed just before the filter is added into the chain, we do : * <ul> * <li>check that we don't have a SSL filter already present * <li>we update the next filter * <li>we create the SSL handler helper class * <li>and we store it into the session's Attributes * </ul> */ @Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws SSLException { // Check that we don't have a SSL filter already present in the chain if (parent.contains(SslFilter.class)) { String msg = "Only one SSL filter is permitted in a chain."; LOGGER.error(msg); throw new IllegalStateException(msg); } LOGGER.debug("Adding the SSL Filter {} to the chain", name); IoSession session = parent.getSession(); session.setAttribute(NEXT_FILTER, nextFilter); // Create a SSL handler and start handshake. SslHandler sslHandler = new SslHandler(this, session); // Adding the supported ciphers in the SSLHandler if ((enabledCipherSuites == null) || (enabledCipherSuites.length == 0)) { enabledCipherSuites = sslContext.getServerSocketFactory().getSupportedCipherSuites(); } sslHandler.init(); session.setAttribute(SSL_HANDLER, sslHandler); }
/** * Executed just before the filter is added into the chain, we do : * <ul> * <li>check that we don't have a SSL filter already present * <li>we update the next filter * <li>we create the SSL handler helper class * <li>and we store it into the session's Attributes * </ul> */ @Override public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws SSLException { // Check that we don't have a SSL filter already present in the chain if (parent.contains(SslFilter.class)) { String msg = "Only one SSL filter is permitted in a chain."; LOGGER.error(msg); throw new IllegalStateException(msg); } LOGGER.debug("Adding the SSL Filter {} to the chain", name); IoSession session = parent.getSession(); session.setAttribute(NEXT_FILTER, nextFilter); // Create a SSL handler and start handshake. SslHandler sslHandler = new SslHandler(this, session); // Adding the supported ciphers in the SSLHandler if ((enabledCipherSuites == null) || (enabledCipherSuites.length == 0)) { enabledCipherSuites = sslContext.getServerSocketFactory().getSupportedCipherSuites(); } sslHandler.init(); session.setAttribute(SSL_HANDLER, sslHandler); }