    public ChannelPipeline getPipeline() throws Exception {
        String mode = Play.configuration.getProperty("play.netty.clientAuth", "none");
        String enabledCiphers = Play.configuration.getProperty("play.ssl.enabledCiphers", "");
        ChannelPipeline pipeline = pipeline();
        SSLEngine engine = SslHttpServerContextFactory.getServerContext().createSSLEngine();
        engine.setUseClientMode(false);
        if (enabledCiphers != null && enabledCiphers.length() > 0) {
            engine.setEnabledCipherSuites(enabledCiphers.replaceAll(" ", "").split(","));
        }
        if ("want".equalsIgnoreCase(mode)) {
            engine.setWantClientAuth(true);
        } else if ("need".equalsIgnoreCase(mode)) {
            engine.setNeedClientAuth(true);
        }
        engine.setEnableSessionCreation(true);
        pipeline.addLast("ssl", new SslHandler(engine));
        String[] handlers = pipelineConfig.split(",");
        if(handlers.length <= 0){
            Logger.error("You must defined at least the SslPlayHandler in \"play.netty.pipeline\"");
            return pipeline;
        }
        String handler = handlers[handlers.length - 1];
        ChannelHandler instance = getInstance(handler);
        SslPlayHandler sslPlayHandler = (SslPlayHandler) instance;
        if (instance == null || !(instance instanceof SslPlayHandler) ||  sslPlayHandler != null) {
            Logger.error("The last handler must be the SslPlayHandler in \"play.netty.pipeline\"");
            return pipeline;
        }    
        for (int i = 0; i < handlers.length - 1; i++) {
            handler = handlers[i];
            try {
                String name = getName(handler.trim());
                instance = getInstance(handler);
                if (instance != null) {
                    pipeline.addLast(name, instance); 
                    sslPlayHandler.pipelines.put("Ssl" + name, instance);
                }
            } catch(Throwable e) {
                Logger.error(" error adding " + handler, e);
            }
        }
        if (sslPlayHandler != null) {
            pipeline.addLast("handler", instance);
            sslPlayHandler.pipelines.put("SslHandler", instance);
        } 
        return pipeline;
    }

    public ChannelPipeline getPipeline() throws Exception {
        String mode = Play.configuration.getProperty("play.netty.clientAuth", "none");
        String enabledCiphers = Play.configuration.getProperty("play.ssl.enabledCiphers", "");
        ChannelPipeline pipeline = pipeline();
        SSLEngine engine = SslHttpServerContextFactory.getServerContext().createSSLEngine();
        engine.setUseClientMode(false);
        if (enabledCiphers != null && enabledCiphers.length() > 0) {
            engine.setEnabledCipherSuites(enabledCiphers.replaceAll(" ", "").split(","));
        }
        if ("want".equalsIgnoreCase(mode)) {
            engine.setWantClientAuth(true);
        } else if ("need".equalsIgnoreCase(mode)) {
            engine.setNeedClientAuth(true);
        }
        engine.setEnableSessionCreation(true);
        pipeline.addLast("ssl", new SslHandler(engine));
        String[] handlers = pipelineConfig.split(",");
        if(handlers.length <= 0){
            Logger.error("You must defined at least the SslPlayHandler in \"play.netty.pipeline\"");
            return pipeline;
        }
        String handler = handlers[handlers.length - 1];
        ChannelHandler instance = getInstance(handler);
        SslPlayHandler sslPlayHandler = (SslPlayHandler) instance;
        if (instance == null || !(instance instanceof SslPlayHandler) || sslPlayHandler == null) {
            Logger.error("The last handler must be the SslPlayHandler in \"play.netty.pipeline\"");
            return pipeline;
        }    
        for (int i = 0; i < handlers.length - 1; i++) {
            handler = handlers[i];
            try {
                String name = getName(handler.trim());
                instance = getInstance(handler);
                if (instance != null) {
                    pipeline.addLast(name, instance); 
                    sslPlayHandler.pipelines.put("Ssl" + name, instance);
                }
            } catch(Throwable e) {
                Logger.error(" error adding " + handler, e);
            }
        }
        if (sslPlayHandler != null) {
            pipeline.addLast("handler", sslPlayHandler);
            sslPlayHandler.pipelines.put("SslHandler", sslPlayHandler);
        } 
        return pipeline;
    }
