/** * Copyright 2013-2015 Seagate Technology LLC. * * This Source Code Form is subject to the terms of the Mozilla * Public License, v. 2.0. If a copy of the MPL was not * distributed with this file, You can obtain one at * https://mozilla.org/MP:/2.0/. * * This program is distributed in the hope that it will be useful, * but is provided AS-IS, WITHOUT ANY WARRANTY; including without * the implied warranty of MERCHANTABILITY, NON-INFRINGEMENT or * FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public * License for more details. * * See www.openkinetic.org for more project information */ package com.seagate.kinetic.simulator.io.provider.nio.ssl; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.socket.SocketChannel; import io.netty.handler.ssl.SslHandler; import java.util.logging.Logger; import javax.net.ssl.SSLEngine; import com.seagate.kinetic.common.lib.TlsUtil; import com.seagate.kinetic.common.protocol.codec.KineticDecoder; import com.seagate.kinetic.common.protocol.codec.KineticEncoder; import com.seagate.kinetic.simulator.io.provider.nio.NioMessageServiceHandler; //import com.seagate.kinetic.proto.Kinetic; import com.seagate.kinetic.simulator.io.provider.spi.MessageService; public class SslChannelInitializer extends ChannelInitializer<SocketChannel> { private static final Logger logger = Logger .getLogger(SslChannelInitializer.class.getName()); private MessageService lcservice = null; public SslChannelInitializer(MessageService lcservice2) { this.lcservice = lcservice2; } @Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); SSLEngine engine = SslContextFactory.getServerContext() .createSSLEngine(); engine.setUseClientMode(false); // enable TLS v1.x protocols. TlsUtil.enableSupportedProtocols(engine); // add ssl handler pipeline.addLast("ssl", new SslHandler(engine)); // decoder pipeline.addLast("decoder", new KineticDecoder()); // encoder pipeline.addLast("encoder", new KineticEncoder()); // pipeline.addLast("handler", new SslMessageServiceHandler(lcservice)); pipeline.addLast("handler", new NioMessageServiceHandler(lcservice, true)); logger.info("ssl nio channel initialized ... "); } }