Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.rmannibucau.featuredmock.http;
 
    private final boolean ssl;
    private final String protocol;
    private final SecureRandom secureRandom;
    private final TrustManager[] trustManagers;
    private final KeyManager[] keyManagers;
    public FeaturedChannelInitializer(final boolean sslfinal String protocolfinal SecureRandom secureRandom,
                                      final TrustManager[] trustManagersfinal KeyManager[] keyManagers) {
        this. = ssl;
        this. = protocol;
        this. = secureRandom;
        this. = trustManagers;
        this. = keyManagers;
    }
    @Override
    protected void initChannel(final SocketChannel chthrows Exception {
        final ChannelPipeline pipeline = ch.pipeline();
        if () {
            String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm");
            if (algorithm == null) {
                algorithm = "SunX509";
            }
            SSLContext clientContext;
            try {
                clientContext = SSLContext.getInstance();
                clientContext.init();
            } catch (Exception e) {
                throw new Error(
                    "Failed to initialize the client-side SSLContext"e);
            }
            final SSLEngine engine = clientContext.createSSLEngine();
            engine.setUseClientMode(true);
            pipeline.addLast("ssl"new SslHandler(engine));
        }
        pipeline
            .addLast("decoder"new HttpRequestDecoder())
            .addLast("aggregator"new HttpObjectAggregator(.))
            .addLast("encoder"new HttpResponseEncoder())
            .addLast("chunked-writer"new ChunkedWriteHandler())
            .addLast("featured-mock-server".);
    }
New to GrepCode? Check out our FAQ X