1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
3 package org.opendaylight.openflowjava.protocol.impl.clients;
5 import io.netty.channel.ChannelInitializer;
6 import io.netty.channel.ChannelPipeline;
7 import io.netty.channel.socket.SocketChannel;
8 import io.netty.handler.ssl.SslHandler;
10 import javax.net.ssl.SSLEngine;
12 import org.opendaylight.openflowjava.protocol.impl.core.SslContextFactory;
14 import com.google.common.util.concurrent.SettableFuture;
16 /** Initializes secured {@link SimpleClient} pipeline
18 * @author michal.polkorab
20 public class SimpleClientInitializer extends ChannelInitializer<SocketChannel> {
22 private SettableFuture<Boolean> sf;
25 * @param sf future notifier of connected channel
27 public SimpleClientInitializer(SettableFuture<Boolean> sf) {
32 public void initChannel(SocketChannel ch) throws Exception {
33 ChannelPipeline pipeline = ch.pipeline();
35 SslContextFactory.getClientContext().createSSLEngine();
36 engine.setUseClientMode(true);
37 pipeline.addLast("ssl", new SslHandler(engine));
38 pipeline.addLast("handler", new SimpleClientHandler(sf));