當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。