Package com.manning.nettyinaction.chapter11

Source Code of com.manning.nettyinaction.chapter11.SecureChatServerIntializer

package com.manning.nettyinaction.chapter11;

import io.netty.channel.Channel;
import io.netty.channel.group.ChannelGroup;
import io.netty.handler.ssl.SslHandler;

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

public class SecureChatServerIntializer extends ChatServerInitializer {
    private final SSLContext context;

    public SecureChatServerIntializer(ChannelGroup group, SSLContext context) {
        super(group);
        this.context = context;
    }

    @Override
    protected void initChannel(Channel ch) throws Exception {
        super.initChannel(ch);
        SSLEngine engine = context.createSSLEngine();
        engine.setUseClientMode(false);
        ch.pipeline().addFirst(new SslHandler(engine));
    }
}
TOP

Related Classes of com.manning.nettyinaction.chapter11.SecureChatServerIntializer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.