當前位置: 首頁>>代碼示例>>Java>>正文


Java SslHandler類代碼示例

本文整理匯總了Java中org.jboss.netty.handler.ssl.SslHandler的典型用法代碼示例。如果您正苦於以下問題:Java SslHandler類的具體用法?Java SslHandler怎麽用?Java SslHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SslHandler類屬於org.jboss.netty.handler.ssl包,在下文中一共展示了SslHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newChannel

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
@Override
public SocketChannel newChannel(ChannelPipeline pipeline) {
  try {
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(null, new TrustManager[]{new PermissiveTrustManager()},
                    null);
    SSLEngine sslEngine = sslContext.createSSLEngine();
    sslEngine.setUseClientMode(true);
    // addFirst() will make SSL handling the first stage of decoding
    // and the last stage of encoding
    pipeline.addFirst("ssl", new SslHandler(sslEngine));
    return super.newChannel(pipeline);
  } catch (Exception ex) {
    throw new RuntimeException("Cannot create SSL channel", ex);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:17,代碼來源:TestAvroSource.java

示例2: channelConnected

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
@Override
public void channelConnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel connected " + e);
    }

    NettyServerCnxn cnxn = new NettyServerCnxn(ctx.getChannel(),
            zkServer, NettyServerCnxnFactory.this);
    ctx.setAttachment(cnxn);

    if (secure) {
        SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
        ChannelFuture handshakeFuture = sslHandler.handshake();
        handshakeFuture.addListener(new CertificateVerifier(sslHandler, cnxn));
    } else {
        allChannels.add(ctx.getChannel());
        addCnxn(cnxn);
    }
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:22,代碼來源:NettyServerCnxnFactory.java

示例3: getPipeline

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  if (sslFactory != null) {
    pipeline.addLast("ssl", new SslHandler(sslFactory.createSSLEngine()));
  }
  pipeline.addLast("decoder", new HttpRequestDecoder());
  pipeline.addLast("aggregator", new HttpChunkAggregator(1 << 16));
  pipeline.addLast("encoder", new HttpResponseEncoder());
  pipeline.addLast("chunking", new ChunkedWriteHandler());
  pipeline.addLast("shuffle", SHUFFLE);
  return pipeline;
  // TODO factor security manager into pipeline
  // TODO factor out encode/decode to permit binary shuffle
  // TODO factor out decode of index to permit alt. models
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:ShuffleHandler.java

示例4: channelConnected

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
@Override
public void channelConnected(ChannelHandlerContext ctx,
        ChannelStateEvent e) throws Exception
{
    if (LOG.isTraceEnabled()) {
        LOG.trace("Channel connected " + e);
    }

    NettyServerCnxn cnxn = new NettyServerCnxn(ctx.getChannel(),
            zkServer, NettyServerCnxnFactory.this);
    ctx.setAttachment(cnxn);

    //SECUREKEEPER: Enable ssl only if specified
    //if (secure) {
    if(encryption.equals("ssl")){
        SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
        ChannelFuture handshakeFuture = sslHandler.handshake();
        handshakeFuture.addListener(new CertificateVerifier(sslHandler, cnxn));
    } else {
        allChannels.add(ctx.getChannel());
        addCnxn(cnxn);
    }
}
 
開發者ID:sereca,項目名稱:SecureKeeper,代碼行數:24,代碼來源:NettyServerCnxnFactory.java

示例5: getPipeline

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
@Override
public ChannelPipeline getPipeline() throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline pipeline = Channels.pipeline();

    SslHandler sslHandler = configureServerSSLOnDemand();
    if (sslHandler != null) {
        LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
        pipeline.addLast("ssl", sslHandler);
    }

    pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
    if (configuration.isChunked()) {
        pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
    }
    pipeline.addLast("encoder", new HttpResponseEncoder());
    if (configuration.isCompression()) {
        pipeline.addLast("deflater", new HttpContentCompressor());
    }

    pipeline.addLast("handler", channelFactory.getChannelHandler());

    return pipeline;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:25,代碼來源:HttpServerSharedPipelineFactory.java

示例6: configureServerSSLOnDemand

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
private SslHandler configureServerSSLOnDemand() throws Exception {
    if (!configuration.isSsl()) {
        return null;
    }

    if (configuration.getSslHandler() != null) {
        return configuration.getSslHandler();
    } else if (sslContext != null) {
        SSLEngine engine = sslContext.createSSLEngine();
        engine.setUseClientMode(false);
        engine.setNeedClientAuth(configuration.isNeedClientAuth());
        if (configuration.getSslContextParameters() == null) {
            // just set the enabledProtocols if the SslContextParameter doesn't set
            engine.setEnabledProtocols(configuration.getEnabledProtocols().split(","));
        }
        return new SslHandler(engine);
    }

    return null;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:HttpServerSharedPipelineFactory.java

示例7: configureServerSSLOnDemand

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
private SslHandler configureServerSSLOnDemand() throws Exception {
    if (!consumer.getConfiguration().isSsl()) {
        return null;
    }

    if (consumer.getConfiguration().getSslHandler() != null) {
        return consumer.getConfiguration().getSslHandler();
    } else if (sslContext != null) {
        SSLEngine engine = sslContext.createSSLEngine();
        engine.setUseClientMode(false);
        engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
        if (consumer.getConfiguration().getSslContextParameters() == null) {
            // just set the enabledProtocols if the SslContextParameter doesn't set
            engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
        }
        return new SslHandler(engine);
    }

    return null;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:HttpServerPipelineFactory.java

示例8: configureClientSSLOnDemand

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
private SslHandler configureClientSSLOnDemand() throws Exception {
    if (!producer.getConfiguration().isSsl()) {
        return null;
    }

    if (producer.getConfiguration().getSslHandler() != null) {
        return producer.getConfiguration().getSslHandler();
    } else if (sslContext != null) {
        SSLEngine engine = sslContext.createSSLEngine();
        engine.setUseClientMode(true);
        if (producer.getConfiguration().getSslContextParameters() == null) {
            // just set the enabledProtocols if the SslContextParameter doesn't set
            engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
        }
        return new SslHandler(engine);
    }

    return null;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:HttpClientPipelineFactory.java

示例9: configureClientSSLOnDemand

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
private SslHandler configureClientSSLOnDemand() throws Exception {
    if (!producer.getConfiguration().isSsl()) {
        return null;
    }

    if (producer.getConfiguration().getSslHandler() != null) {
        return producer.getConfiguration().getSslHandler();
    } else if (sslContext != null) {
        SSLEngine engine = sslContext.createSSLEngine();
        if (producer.getConfiguration().getSslContextParameters() == null) {
            // just set the enabledProtocols if the SslContextParameter doesn't set
            engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));
        }
        engine.setUseClientMode(true);
        return new SslHandler(engine);
    }

    return null;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:DefaultClientPipelineFactory.java

示例10: configureServerSSLOnDemand

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
private SslHandler configureServerSSLOnDemand() throws Exception {
    if (!consumer.getConfiguration().isSsl()) {
        return null;
    }

    if (consumer.getConfiguration().getSslHandler() != null) {
        return consumer.getConfiguration().getSslHandler();
    } else if (sslContext != null) {
        SSLEngine engine = sslContext.createSSLEngine();
        engine.setUseClientMode(false);            
        engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
        if (consumer.getConfiguration().getSslContextParameters() == null) {
            // just set the enabledProtocols if the SslContextParameter doesn't set
            engine.setEnabledProtocols(consumer.getConfiguration().getEnabledProtocols().split(","));
        }
        return new SslHandler(engine);
    }

    return null;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:DefaultServerPipelineFactory.java

示例11: start

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
public void start() {
    bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
            Executors.newFixedThreadPool(1),
            Executors.newCachedThreadPool()
    ));

    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = new DefaultChannelPipeline();
            pipeline.addLast("ssl", new SslHandler(getSSLEngine()));
            pipeline.addLast("decoder", new LumberjackDecoder());
            pipeline.addLast("logHandler", new LogEventHandler(eventListener));
            return pipeline;
        }
    });
    bootstrap.bind(new InetSocketAddress(configuration.getIpAddress(), configuration.getPort()));
}
 
開發者ID:sivasamyk,項目名稱:graylog2-input-lumberjack,代碼行數:18,代碼來源:LumberjackServer.java

示例12: messageReceived

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
@Override
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception {
    final Object o = e.getMessage();
    if (o instanceof DefaultHttpRequest) {

        final SslHandler sslhandler = (SslHandler) e.getChannel().getPipeline().get("ssl_http");
        final Principal principal = sslhandler.getEngine().getSession().getPeerCertificateChain()[0].getSubjectDN();
        final DefaultHttpRequest request = (DefaultHttpRequest) o;
        final DefaultHttpsRequest httpsRequest = new DefaultHttpsRequest(request, principal);
        final MessageEventFacade facade = new MessageEventFacade(e, httpsRequest);
        super.messageReceived(ctx, facade);

    } else {

        super.messageReceived(ctx, e);

    }
}
 
開發者ID:petalmd,項目名稱:armor,代碼行數:19,代碼來源:MutualSSLHandler.java

示例13: channelConnected

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
@Override
public void channelConnected(final ChannelHandlerContext ctx, final ChannelStateEvent e) {
    //prevent javax.net.ssl.SSLException: Received close_notify during handshake
    final SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);

    if (sslHandler == null) {
        return;
    }

    final ChannelFuture handshakeFuture = sslHandler.handshake();
    handshakeFuture.addListener(new ChannelFutureListener() {

        @Override
        public void operationComplete(final ChannelFuture future) throws Exception {
            if (logger.isTraceEnabled()) {
                logger.trace("Node to Node encryption cipher is {}/{}", sslHandler.getEngine().getSession().getProtocol(), sslHandler
                        .getEngine().getSession().getCipherSuite());
            }
            ctx.sendUpstream(e);
        }
    });
}
 
開發者ID:petalmd,項目名稱:armor,代碼行數:23,代碼來源:ArmorMessageChannelHandler.java

示例14: start

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
public void start() {
    bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
            Executors.newFixedThreadPool(1),
            Executors.newCachedThreadPool()
    ));

    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = new DefaultChannelPipeline();
            if(configuration.isSslEnabled()) {
                pipeline.addLast("ssl", new SslHandler(getSSLEngine()));
            }
            pipeline.addLast("decoder", new LumberjackDecoder());
            pipeline.addLast("logHandler", new EventHandler(eventListener));
            return pipeline;
        }
    });
    bootstrap.bind(new InetSocketAddress(configuration.getIpAddress(), configuration.getPort()));
}
 
開發者ID:sivasamyk,項目名稱:graylog-beats-plugin,代碼行數:20,代碼來源:LumberjackServer.java

示例15: channelConnected

import org.jboss.netty.handler.ssl.SslHandler; //導入依賴的package包/類
@Override
public void channelConnected(ChannelHandlerContext ctx,
		final ChannelStateEvent e) throws Exception {
	ChannelListener listener = this.listenerFactory.createChannelListener(new ObjectChannelImpl(e.getChannel()));
	this.listeners.put(e.getChannel(), listener);
	maxChannels = Math.max(maxChannels, this.listeners.size());
	SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
	if (sslHandler != null) {
        sslHandler.handshake().addListener(new ChannelFutureListener() {
        	public void operationComplete(ChannelFuture arg0)
        			throws Exception {
        		onConnection(e.getChannel());
        	}
        });
	} else {
		onConnection(e.getChannel());
	}
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:19,代碼來源:SSLAwareChannelHandler.java


注:本文中的org.jboss.netty.handler.ssl.SslHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。