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


Java SslHandshakeCompletionEvent类代码示例

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


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

示例1: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
		throws Exception {
	if (evt instanceof SslHandshakeCompletionEvent) {
		handshakeDone = true;
		if(ctx.pipeline().context(this) != null){
			ctx.pipeline().remove(this);
		}
		SslHandshakeCompletionEvent handshake = (SslHandshakeCompletionEvent) evt;
		if (handshake.isSuccess()) {
			ctx.fireChannelActive();
		}
		else {
			sink.fireContextError(handshake.cause());
		}
	}
	super.userEventTriggered(ctx, evt);
}
 
开发者ID:reactor,项目名称:reactor-netty,代码行数:19,代码来源:SslReadHandler.java

示例2: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
        throws Exception {
    LOG.info(">>> userEventTriggered " + evt);
    if (evt instanceof SslHandshakeCompletionEvent) {
        SslHandshakeCompletionEvent hce = (SslHandshakeCompletionEvent) evt;
        if (!hce.isSuccess()
                && hce.cause().getMessage().contains("unrecognized_name")) {
            LOG.info(">>> unrecognized_name");
            ctx.close();
            unrecognizedName = true;
            return;
        }
    }
    super.userEventTriggered(ctx, evt);
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:17,代码来源:RetryClient.java

示例3: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
        throws Exception {
    LOG.info(">>> userEventTriggered " + evt);
    if (evt instanceof SslHandshakeCompletionEvent) {
        SslHandshakeCompletionEvent hce = (SslHandshakeCompletionEvent) evt;
        if (!hce.isSuccess()
                && hce.cause().getMessage()
                        .contains("unrecognized_name")) {
            LOG.info(">>> unrecognized_name");
            ctx.close();
            unrecognizedName = true;
            return;
        }
    }
    super.userEventTriggered(ctx, evt);
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:18,代码来源:RestartClient.java

示例4: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
  if (evt instanceof SslHandshakeCompletionEvent) {
    ctx.pipeline().remove(this);

    SslHandshakeCompletionEvent handshakeEvent = (SslHandshakeCompletionEvent) evt;
    String peerIdentity = TlsAuthState.UNAUTHENTICATED;
    if (handshakeEvent.isSuccess()) {
      SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
      if (sslHandler == null) {
        throw new IllegalStateException(
            "cannot find a SslHandler in the pipeline (required for MutualAuthHandler)");
      }
      peerIdentity = getPeerIdentity(sslHandler.engine());
    }
    TlsAuthState.setPeerIdentity(ctx, peerIdentity);
    peerIdentityEstablished(ctx, peerIdentity);
  }

  ctx.fireUserEventTriggered(evt);
}
 
开发者ID:xjdr,项目名称:xio,代码行数:22,代码来源:MutualAuthHandler.java

示例5: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
  if (evt instanceof SslHandshakeCompletionEvent) {
    SslHandshakeCompletionEvent handshakeEvent = (SslHandshakeCompletionEvent) evt;
    if (handshakeEvent.isSuccess()) {
      if (NEXT_PROTOCOL_VERSIONS.contains(sslHandler(ctx.pipeline()).applicationProtocol())) {
        // Successfully negotiated the protocol.
        // Notify about completion and pass down SSLSession in attributes.
        grpcHandler.handleProtocolNegotiationCompleted(
            Attributes.newBuilder()
                .set(Grpc.TRANSPORT_ATTR_SSL_SESSION,
                    sslHandler(ctx.pipeline()).engine().getSession())
                .set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
                .build());
        // Replace this handler with the GRPC handler.
        ctx.pipeline().replace(this, null, grpcHandler);
      } else {
        fail(ctx, new Exception(
            "Failed protocol negotiation: Unable to find compatible protocol."));
      }
    } else {
      fail(ctx, handshakeEvent.cause());
    }
  }
  super.userEventTriggered(ctx, evt);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:27,代码来源:ProtocolNegotiators.java

示例6: tlsHandler_userEventTriggeredSslEvent_unsupportedProtocol

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Test
public void tlsHandler_userEventTriggeredSslEvent_unsupportedProtocol() throws Exception {
  SslHandler badSslHandler = new SslHandler(engine, false) {
    @Override
    public String applicationProtocol() {
      return "badprotocol";
    }
  };

  ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
  pipeline.addLast(handler);

  pipeline.replace(SslHandler.class, null, badSslHandler);
  channelHandlerCtx = pipeline.context(handler);
  Object sslEvent = SslHandshakeCompletionEvent.SUCCESS;

  pipeline.fireUserEventTriggered(sslEvent);

  // No h2 protocol was specified, so this should be closed.
  assertFalse(channel.isOpen());
  ChannelHandlerContext grpcHandlerCtx = pipeline.context(grpcHandler);
  assertNull(grpcHandlerCtx);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:24,代码来源:ProtocolNegotiatorsTest.java

示例7: tlsHandler_userEventTriggeredSslEvent_supportedProtocolH2

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Test
public void tlsHandler_userEventTriggeredSslEvent_supportedProtocolH2() throws Exception {
  SslHandler goodSslHandler = new SslHandler(engine, false) {
    @Override
    public String applicationProtocol() {
      return "h2";
    }
  };

  ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
  pipeline.addLast(handler);

  pipeline.replace(SslHandler.class, null, goodSslHandler);
  channelHandlerCtx = pipeline.context(handler);
  Object sslEvent = SslHandshakeCompletionEvent.SUCCESS;

  pipeline.fireUserEventTriggered(sslEvent);

  assertTrue(channel.isOpen());
  ChannelHandlerContext grpcHandlerCtx = pipeline.context(grpcHandler);
  assertNotNull(grpcHandlerCtx);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:23,代码来源:ProtocolNegotiatorsTest.java

示例8: tlsHandler_userEventTriggeredSslEvent_supportedProtocolGrpcExp

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Test
public void tlsHandler_userEventTriggeredSslEvent_supportedProtocolGrpcExp() throws Exception {
  SslHandler goodSslHandler = new SslHandler(engine, false) {
    @Override
    public String applicationProtocol() {
      return "grpc-exp";
    }
  };

  ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
  pipeline.addLast(handler);

  pipeline.replace(SslHandler.class, null, goodSslHandler);
  channelHandlerCtx = pipeline.context(handler);
  Object sslEvent = SslHandshakeCompletionEvent.SUCCESS;

  pipeline.fireUserEventTriggered(sslEvent);

  assertTrue(channel.isOpen());
  ChannelHandlerContext grpcHandlerCtx = pipeline.context(grpcHandler);
  assertNotNull(grpcHandlerCtx);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:23,代码来源:ProtocolNegotiatorsTest.java

示例9: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
        throws Exception {

    LOGGER.trace("userEventTriggered: {}", evt.getClass().getName());

    // if the channel has been idle, close it
    if (evt == IdleStateEvent.FIRST_READER_IDLE_STATE_EVENT) {
        LOGGER.warn("No data received on channel, closing");
        ctx.close();
        return;
    } else if (evt == SslHandshakeCompletionEvent.SUCCESS) {
        // If we require mutual authentication, extract the principal from
        // the client certificate and store it in the channel attributes.
        if (clientAuth) {
            final SSLSession session = ctx.pipeline().get(SslHandler.class)
                    .engine().getSession();

            final Optional<String> customerId = getCustomerId(
                    session.getPeerPrincipal());

            if (!customerId.isPresent()) {
                LOGGER.error(
                        "No customer ID found in certificate, closing");
                ctx.close();
                return;
            }

            ctx.channel().attr(CUSTOMER_KEY).set(customerId.get());

            // notify the BatchHandler that the channel is ready and to
            // create the empty batch
            ctx.fireChannelActive();
        }
    }
}
 
开发者ID:smoketurner,项目名称:uploader,代码行数:37,代码来源:AuthHandler.java

示例10: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public final void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
    if (evt instanceof SslHandshakeCompletionEvent) {
        SslHandshakeCompletionEvent handshakeEvt = (SslHandshakeCompletionEvent) evt;
        if (handshakeEvt.cause() != null) {
            logger.warn("Handshake failed:", handshakeEvt.cause());
        }
        assertSame(SslHandshakeCompletionEvent.SUCCESS, evt);
        negoCounter.incrementAndGet();
        logStats("HANDSHAKEN");
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:13,代码来源:SocketSslEchoTest.java

示例11: tlsHandler_userEventTriggeredSslEvent_handshakeFailure

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Test
public void tlsHandler_userEventTriggeredSslEvent_handshakeFailure() throws Exception {
  ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
  pipeline.addLast(handler);
  channelHandlerCtx = pipeline.context(handler);
  Object sslEvent = new SslHandshakeCompletionEvent(new RuntimeException("bad"));

  pipeline.fireUserEventTriggered(sslEvent);

  // No h2 protocol was specified, so this should be closed.
  assertFalse(channel.isOpen());
  ChannelHandlerContext grpcHandlerCtx = pipeline.context(grpcHandler);
  assertNull(grpcHandlerCtx);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:15,代码来源:ProtocolNegotiatorsTest.java

示例12: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public void userEventTriggered(final ChannelHandlerContext ctx, Object evt) throws Exception {
    if (evt instanceof SslHandshakeCompletionEvent) {
        logger.trace(format(ctx, "SslHandshakeCompletionEvent: "), ((SslHandshakeCompletionEvent) evt).cause());
    } else if (evt instanceof Exception) {
        logger.trace(format(ctx, "Exception: "), (Exception) evt);
    } else {
        logger.trace(format(ctx, "USER_EVENT: " + evt));
    }
    super.userEventTriggered(ctx, evt);
}
 
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:12,代码来源:LoggingHandler.java

示例13: userEventTriggered

import io.netty.handler.ssl.SslHandshakeCompletionEvent; //导入依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
    if (evt instanceof SslHandshakeCompletionEvent) {
        if (((SslHandshakeCompletionEvent)evt).isSuccess()) {
            if (debug) {
                log.debug("SSL connection established [to={}]", id);
            }

            handshake(ctx);
        }

        super.userEventTriggered(ctx, evt);
    } else if (evt instanceof AutoReadChangeEvent) {
        if (evt == AutoReadChangeEvent.PAUSE) {
            // Completely ignore read timeouts.
            ignoreTimeouts = -1;
        } else {
            // Ignore next timeout.
            ignoreTimeouts = 1;
        }
    } else if (evt instanceof IdleStateEvent) {
        if (state == CONNECTING || state == CONNECTED) {
            IdleStateEvent idle = (IdleStateEvent)evt;

            if (idle.state() == IdleState.WRITER_IDLE) {
                if (hbFlushed) {
                    // Make sure that we don't push multiple heartbeats to the network buffer simultaneously.
                    // Need to perform this check since remote peer can hang and stop reading
                    // while this channel will still be trying to put more and more heartbeats on its send buffer.
                    hbFlushed = false;

                    ctx.writeAndFlush(Heartbeat.INSTANCE).addListener(hbOnFlush);
                }
            } else {
                // Reader idle.
                // Ignore if auto-reading was disabled since in such case we will not read any heartbeats.
                if (ignoreTimeouts != -1 && ctx.channel().config().isAutoRead()) {
                    // Check if timeout should be ignored.
                    if (ignoreTimeouts > 0) {
                        // Decrement the counter of ignored timeouts.
                        ignoreTimeouts--;
                    } else {
                        if (state == CONNECTING) {
                            ctx.fireExceptionCaught(new ConnectTimeoutException("Timeout while connecting to " + id));
                        } else if (state == CONNECTED) {
                            ctx.fireExceptionCaught(new SocketTimeoutException("Timeout while reading data from " + id));
                        }
                    }
                }
            }
        }
    } else {
        super.userEventTriggered(ctx, evt);
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:56,代码来源:NettyClientHandler.java


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