Package javax.net.ssl

Examples of javax.net.ssl.SSLEngine


        // Create a default pipeline implementation.
        ChannelPipeline pipeline = ch.pipeline();

        // add HTTPS support
        if (secure) {
            SSLEngine engine = SSLFactory.getInstance().sslContext().createSSLEngine();
            engine.setUseClientMode(false);
            pipeline.addLast("ssl", new SslHandler(engine));
        }

        // add logging
        if (logger.isDebugEnabled()) {
View Full Code Here


        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = Channels.pipeline();

            if (sslOptions != null) {
                SSLEngine engine = sslOptions.context.createSSLEngine();
                engine.setUseClientMode(true);
                engine.setEnabledCipherSuites(sslOptions.cipherSuites);
                SslHandler handler = new SslHandler(engine);
                handler.setCloseOnSSLException(true);
                pipeline.addLast("ssl", handler);
            }
View Full Code Here

                            pipeline.addLast("logger", new LoggingHandler(logger));
                        }

                        // add HTTPS proxy -> server support
                        if (secure) {
                            SSLEngine engine = SSLFactory.getInstance().sslContext().createSSLEngine();
                            engine.setUseClientMode(true);
                            pipeline.addLast("proxy -> server ssl", new SslHandler(engine));
                        }

                        // add handler
                        pipeline.addLast(new ProxyRelayHandler(inboundChannel, bufferedCapacity, new ResponseInterceptor(), logger));
View Full Code Here

                                        public void operationComplete(ChannelFuture channelFuture) throws Exception {
                                            removeCodecSupport(ctx);

                                            // downstream
                                            if (secure) {
                                                SSLEngine clientEngine = SSLFactory.getInstance().sslContext().createSSLEngine();
                                                clientEngine.setUseClientMode(true);
                                                outboundChannel.pipeline().addLast("outbound relay ssl", new SslHandler(clientEngine));
                                            }
                                            Logger outboundLogger = LoggerFactory.getLogger("                -->");
                                            if (logger.isDebugEnabled()) {
                                                outboundChannel.pipeline().addLast("outbound relay logger", new LoggingHandler(outboundLogger));
                                            }
                                            outboundChannel.pipeline().addLast(new ProxyRelayHandler(ctx.channel(), 1048576, new RequestInterceptor(null), outboundLogger));


                                            // upstream
                                            if (secure) {
                                                SSLEngine serverEngine = SSLFactory.getInstance().sslContext().createSSLEngine();
                                                serverEngine.setUseClientMode(false);
                                                ctx.channel().pipeline().addLast("upstream relay ssl", new SslHandler(serverEngine));
                                            }
                                            Logger inboundLogger = LoggerFactory.getLogger("<-- ");
                                            if (logger.isDebugEnabled()) {
                                                ctx.channel().pipeline().addLast("upstream relay logger", new LoggingHandler(inboundLogger));
View Full Code Here

    }

    /* ------------------------------------------------------------ */
    protected SSLEngine createSSLEngine() throws IOException
    {
        SSLEngine engine=null;
        try
        {
            engine=_context.createSSLEngine();
            engine.setUseClientMode(false);
           
            if (_wantClientAuth)
                engine.setWantClientAuth(_wantClientAuth);
            if (_needClientAuth)
                engine.setNeedClientAuth(_needClientAuth);
           
            if (_excludeCipherSuites!=null&&_excludeCipherSuites.length>0)
            {
                List<String> excludedCSList=Arrays.asList(_excludeCipherSuites);
                String[] enabledCipherSuites=engine.getEnabledCipherSuites();
                List<String> enabledCSList=new ArrayList<String>(Arrays.asList(enabledCipherSuites));

                for (String cipherName : excludedCSList)
                {
                    if (enabledCSList.contains(cipherName))
                    {
                        enabledCSList.remove(cipherName);
                    }
                }
                enabledCipherSuites=enabledCSList.toArray(new String[enabledCSList.size()]);

                engine.setEnabledCipherSuites(enabledCipherSuites);
            }

        }
        catch (Exception e)
        {
View Full Code Here

  
    protected void doStart() throws Exception
    {
        _context=createSSLContext();
       
        SSLEngine engine=createSSLEngine();
        SSLSession ssl_session=engine.getSession();
       
        setHeaderBufferSize(ssl_session.getApplicationBufferSize());
        setRequestBufferSize(ssl_session.getApplicationBufferSize());
        setResponseBufferSize(ssl_session.getApplicationBufferSize());
       
View Full Code Here

    {
        super.customize(endpoint,request);
        request.setScheme(HttpSchemes.HTTPS);
       
        SslHttpChannelEndPoint sslHttpChannelEndpoint=(SslHttpChannelEndPoint)endpoint;
        SSLEngine sslEngine=sslHttpChannelEndpoint.getSSLEngine();

        try
        {
            SSLSession sslSession=sslEngine.getSession();
            String cipherSuite=sslSession.getCipherSuite();
            Integer keySize;
            X509Certificate[] certs;

            CachedInfo cachedInfo=(CachedInfo)sslSession.getValue(CACHED_INFO_ATTR);
View Full Code Here

                    // TODO need to send this over channel unencrypted and setup endpoint to ignore the 200 OK response.

                    throw new IllegalStateException("Not Implemented");
                }

                SSLEngine engine=newSslEngine();
                ep = new SslHttpChannelEndPoint(_sslBuffers,channel,selectSet,key,engine);
            }
            else
            {
                ep=new SelectChannelEndPoint(channel,selectSet,key);
View Full Code Here

            if (_sslContext==null)
            {
                _sslContext = SelectConnector.this._httpClient.getSSLContext();
            }

            SSLEngine sslEngine = _sslContext.createSSLEngine();
            sslEngine.setUseClientMode(true);
            sslEngine.beginHandshake();

            if (_sslBuffers==null)
            {
                AbstractBuffers buffers = new AbstractBuffers()
                {
                    protected Buffer newBuffer( int size )
                    {
                        return new IndirectNIOBuffer( size);
                    }
                };

                buffers.setRequestBufferSize( sslEngine.getSession().getPacketBufferSize());
                buffers.setResponseBufferSize(sslEngine.getSession().getApplicationBufferSize());

                try
                {
                    buffers.start();
                }
View Full Code Here

        }

        if (producer.getConfiguration().getSslHandler() != null) {
            return producer.getConfiguration().getSslHandler();
        } else if (sslContext != null) {
            SSLEngine engine = sslContext.createSSLEngine();
            engine.setUseClientMode(true);
            return new SslHandler(engine);
        } else {
            if (producer.getConfiguration().getKeyStoreFile() == null && producer.getConfiguration().getKeyStoreResource() == null) {
                LOG.debug("keystorefile is null");
            }
            if (producer.getConfiguration().getTrustStoreFile() == null && producer.getConfiguration().getTrustStoreResource() == null) {
                LOG.debug("truststorefile is null");
            }
            if (producer.getConfiguration().getPassphrase().toCharArray() == null) {
                LOG.debug("passphrase is null");
            }
            SSLEngineFactory sslEngineFactory;
            if (producer.getConfiguration().getKeyStoreFile() != null || producer.getConfiguration().getTrustStoreFile() != null) {
                sslEngineFactory = new SSLEngineFactory(
                    producer.getConfiguration().getKeyStoreFormat(),
                    producer.getConfiguration().getSecurityProvider(),
                    producer.getConfiguration().getKeyStoreFile(),
                    producer.getConfiguration().getTrustStoreFile(),
                    producer.getConfiguration().getPassphrase().toCharArray());
            } else {
                sslEngineFactory = new SSLEngineFactory(producer.getContext().getClassResolver(),
                        producer.getConfiguration().getKeyStoreFormat(),
                        producer.getConfiguration().getSecurityProvider(),
                        producer.getConfiguration().getKeyStoreResource(),
                        producer.getConfiguration().getTrustStoreResource(),
                        producer.getConfiguration().getPassphrase().toCharArray());
            }
            SSLEngine sslEngine = sslEngineFactory.createClientSSLEngine();
            return new SslHandler(sslEngine);
        }
    }
View Full Code Here

TOP

Related Classes of javax.net.ssl.SSLEngine

Copyright © 2018 www.massapicom. 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.