当前位置: 首页>>代码示例>>Java>>正文


Java SslHandler.handshakeFuture方法代码示例

本文整理汇总了Java中io.netty.handler.ssl.SslHandler.handshakeFuture方法的典型用法代码示例。如果您正苦于以下问题:Java SslHandler.handshakeFuture方法的具体用法?Java SslHandler.handshakeFuture怎么用?Java SslHandler.handshakeFuture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.handler.ssl.SslHandler的用法示例。


在下文中一共展示了SslHandler.handshakeFuture方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encrypt

import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
/**
 * Encrypts traffic on this connection with SSL/TLS.
 * 
 * @param pipeline
 *            the ChannelPipeline on which to enable encryption
 * @param sslEngine
 *            the {@link SSLEngine} for doing the encryption
 * @param authenticateClients
 *            determines whether to authenticate clients or not
 * @return a Future for when the SSL handshake has completed
 */
protected Future<Channel> encrypt(ChannelPipeline pipeline,
        SSLEngine sslEngine,
        boolean authenticateClients) {
    LOG.debug("Enabling encryption with SSLEngine: {}",
            sslEngine);
    this.sslEngine = sslEngine;
    sslEngine.setUseClientMode(runsAsSslClient);
    sslEngine.setNeedClientAuth(authenticateClients);
    if (null != channel) {
        channel.config().setAutoRead(true);
    }
    SslHandler handler = new SslHandler(sslEngine);
    if(pipeline.get("ssl") == null) {
        pipeline.addFirst("ssl", handler);
    } else {
        // The second SSL handler is added to handle the case
        // where the proxy (running as MITM) has to chain with
        // another SSL enabled proxy. The second SSL handler
        // is to perform SSL with the server.
        pipeline.addAfter("ssl", "sslWithServer", handler);
    }
    return handler.handshakeFuture();
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:35,代码来源:ProxyConnection.java

示例2: encrypt

import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
/**
 * Encrypts traffic on this connection with SSL/TLS.
 * 
 * @param pipeline
 *            the ChannelPipeline on which to enable encryption
 * @param sslEngine
 *            the {@link SSLEngine} for doing the encryption
 * @param authenticateClients
 *            determines whether to authenticate clients or not
 * @return a Future for when the SSL handshake has completed
 */
protected Future<Channel> encrypt(ChannelPipeline pipeline,
        SSLEngine sslEngine,
        boolean authenticateClients) {
    LOG.debug("Enabling encryption with SSLEngine: {}",
            sslEngine);
    this.sslEngine = sslEngine;
    sslEngine.setUseClientMode(runsAsSslClient);
    sslEngine.setNeedClientAuth(authenticateClients);
    if (null != channel) {
        channel.config().setAutoRead(true);
    }
    SslHandler handler = new SslHandler(sslEngine);
    pipeline.addFirst("ssl", handler);
    return handler.handshakeFuture();
}
 
开发者ID:Elitward,项目名称:LittleProxy,代码行数:27,代码来源:ProxyConnection.java

示例3: handshake

import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
/**
 * Create {@link io.netty.handler.ssl.SslHandler} and send TCP handshaking using
 * {@link javax.net.ssl.SSLEngine}
 * After add ssl handler to the end of {@link io.netty.channel.ChannelPipeline}, it enable
 * secure communications over SSL/TLS
 *
 * @param isSslClient true if the channel start handshaking or false if accept handshaking
 * @param channel the channel to start handshaking
 * */
private Future<Channel> handshake(SSLEngine sslEngine, boolean isSslClient, Channel channel) {
  sslEngine.setUseClientMode(isSslClient);
  if (channel != null) {
    channel.config().setAutoRead(true);
  }
  SslHandler handler = new SslHandler(sslEngine);
  channel.pipeline().addFirst("ssl", handler);
  LOG.debug("About to start handshaking...");
  return handler.handshakeFuture();
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:20,代码来源:ChannelMediator.java

示例4: channelRead0

import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
    byte[] actual = new byte[in.readableBytes()];
    in.readBytes(actual);

    int lastIdx = recvCounter.get();
    for (int i = 0; i < actual.length; i ++) {
        assertEquals(data[i + lastIdx], actual[i]);
    }

    ByteBuf buf = Unpooled.wrappedBuffer(actual);
    if (useCompositeByteBuf) {
        buf = Unpooled.compositeBuffer().addComponent(buf).writerIndex(buf.writerIndex());
    }
    ctx.write(buf);

    recvCounter.addAndGet(actual.length);

    // Perform server-initiated renegotiation if necessary.
    if (renegotiation.type == RenegotiationType.SERVER_INITIATED &&
        recvCounter.get() > data.length / 2 && renegoFuture == null) {

        SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);

        Future<Channel> hf = sslHandler.handshakeFuture();
        assertThat(hf.isDone(), is(true));

        sslHandler.engine().setEnabledCipherSuites(new String[] { renegotiation.cipherSuite });
        logStats("SERVER RENEGOTIATES");
        renegoFuture = sslHandler.renegotiate();
        assertThat(renegoFuture, is(not(sameInstance(hf))));
        assertThat(renegoFuture, is(sameInstance(sslHandler.handshakeFuture())));
        assertThat(renegoFuture.isDone(), is(false));
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:36,代码来源:SocketSslEchoTest.java

示例5: encrypt

import io.netty.handler.ssl.SslHandler; //导入方法依赖的package包/类
/**
 * Encrypts traffic on this connection with SSL/TLS.
 * 
 * @param pipeline
 *            the ChannelPipeline on which to enable encryption
 * @param sslEngine
 *            the {@link SSLEngine} for doing the encryption
 * @param authenticateClients
 *            determines whether to authenticate clients or not
 * @return a Future for when the SSL handshake has completed
 */
protected Future<Channel> encrypt(ChannelPipeline pipeline,
        SSLEngine sslEngine,
        boolean authenticateClients) {
    LOG.debug("Enabling encryption with SSLEngine: {}",
            sslEngine);
    this.sslEngine = sslEngine;
    sslEngine.setUseClientMode(runsAsSslClient);
    sslEngine.setNeedClientAuth(authenticateClients);
    SslHandler handler = new SslHandler(sslEngine);
    pipeline.addFirst("ssl", handler);
    return handler.handshakeFuture();
}
 
开发者ID:Mobideck,项目名称:appdeck-android,代码行数:24,代码来源:ProxyConnection.java


注:本文中的io.netty.handler.ssl.SslHandler.handshakeFuture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。