• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ApplicationProtocolNames类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: applicationProtocolConfig

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
private static ApplicationProtocolConfig applicationProtocolConfig(NitmProxyConfig config, boolean http2) {
    if (http2) {
        return new ApplicationProtocolConfig(
                Protocol.ALPN,
                SelectorFailureBehavior.NO_ADVERTISE,
                SelectedListenerFailureBehavior.ACCEPT,
                ApplicationProtocolNames.HTTP_2,
                ApplicationProtocolNames.HTTP_1_1);
    } else {
        return new ApplicationProtocolConfig(
                Protocol.ALPN,
                SelectorFailureBehavior.NO_ADVERTISE,
                SelectedListenerFailureBehavior.ACCEPT,
                ApplicationProtocolNames.HTTP_1_1);
    }
}
 
开发者ID:chhsiao90,项目名称:nitmproxy,代码行数:17,代码来源:TlsUtil.java


示例2: getNettySslContextInner

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
private SslContext getNettySslContextInner(String host, boolean useH2) throws Exception {
        long start = System.currentTimeMillis();
        PrivateKeyAndCertChain keyAndCertChain = keyStoreGenerator.generateCertChain(host, Settings.certValidityDays);
        logger.debug("Create certificate for {}, cost {} ms", host, System.currentTimeMillis() - start);
        SslContextBuilder builder = SslContextBuilder
                .forServer(keyAndCertChain.getPrivateKey(), keyAndCertChain.getCertificateChain());
        if (useH2) {
//                .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
            builder.applicationProtocolConfig(new ApplicationProtocolConfig(
                    ApplicationProtocolConfig.Protocol.ALPN,
                    SelectorFailureBehavior.NO_ADVERTISE,
                    SelectedListenerFailureBehavior.ACCEPT,
                    ApplicationProtocolNames.HTTP_2,
                    ApplicationProtocolNames.HTTP_1_1));
        }
        return builder.build();
    }
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:18,代码来源:ServerSSLContextManager.java


示例3: configurePipeline

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        ctx.pipeline().addLast(new Http2MultiplexCodec(true, new HelloWorldHttp2Handler()));
        return;
    }

    if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        ctx.pipeline().addLast(new HttpServerCodec(),
                               new HttpObjectAggregator(MAX_CONTENT_LENGTH),
                               new HelloWorldHttp1Handler("ALPN Negotiation"));
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:17,代码来源:Http2OrHttpHandler.java


示例4: configureSsl

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
/**
 * Configure the pipeline for TLS NPN negotiation to HTTP/2.
 */
private void configureSsl(SocketChannel ch) {
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast(sslCtx.newHandler(ch.alloc()));
    // We must wait for the handshake to finish and the protocol to be negotiated before configuring
    // the HTTP/2 components of the pipeline.
    pipeline.addLast(new ApplicationProtocolNegotiationHandler("") {
        @Override
        protected void configurePipeline(ChannelHandlerContext ctx, String protocol) {
            if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
                ChannelPipeline p = ctx.pipeline();
                p.addLast(connectionHandler);
                configureEndOfPipeline(p);
                return;
            }
            ctx.close();
            throw new IllegalStateException("unknown protocol: " + protocol);
        }
    });
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:23,代码来源:Http2ClientInitializer.java


示例5: configurePipeline

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        ctx.pipeline().addLast(new HelloWorldHttp2HandlerBuilder().build());
        return;
    }

    if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        ctx.pipeline().addLast(new HttpServerCodec(),
                               new HttpObjectAggregator(MAX_CONTENT_LENGTH),
                               new HelloWorldHttp1Handler("ALPN Negotiation"));
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:17,代码来源:Http2OrHttpHandler.java


示例6: getSslContext

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
private SslContext getSslContext() {
    SslContext sslCtx = null;

    final SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;

    try {
        sslCtx = SslContextBuilder.forClient()
            .sslProvider(provider)
            .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
            .trustManager(InsecureTrustManagerFactory.INSTANCE)
            .applicationProtocolConfig(new ApplicationProtocolConfig(
                Protocol.ALPN,
                SelectorFailureBehavior.NO_ADVERTISE,
                SelectedListenerFailureBehavior.ACCEPT,
                ApplicationProtocolNames.HTTP_2))
            .build();
    } catch(SSLException exception) {
        return null;
    }

    return sslCtx;
}
 
开发者ID:syucream,项目名称:jmeter-http2-plugin,代码行数:23,代码来源:NettyHttp2Client.java


示例7: createHttp2TLSContext

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
/**
 * This method will provide netty ssl context which supports HTTP2 over TLS using
 * Application Layer Protocol Negotiation (ALPN)
 *
 * @return instance of {@link SslContext}
 * @throws SSLException if any error occurred during building SSL context.
 */
public SslContext createHttp2TLSContext() throws SSLException {

    // If listener configuration does not include cipher suites , default ciphers required by the HTTP/2
    // specification will be added.
    List<String> ciphers = sslConfig.getCipherSuites() != null && sslConfig.getCipherSuites().length > 0 ? Arrays
            .asList(sslConfig.getCipherSuites()) : Http2SecurityUtil.CIPHERS;
    SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
    return SslContextBuilder.forServer(this.getKeyManagerFactory())
            .trustManager(this.getTrustStoreFactory())
            .sslProvider(provider)
            .ciphers(ciphers,
                    SupportedCipherSuiteFilter.INSTANCE)
            .clientAuth(needClientAuth ? ClientAuth.REQUIRE : ClientAuth.NONE)
            .applicationProtocolConfig(new ApplicationProtocolConfig(
                    ApplicationProtocolConfig.Protocol.ALPN,
                    // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
                    ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE,
                    // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
                    ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT,
                    ApplicationProtocolNames.HTTP_2,
                    ApplicationProtocolNames.HTTP_1_1)).build();
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:30,代码来源:SSLHandlerFactory.java


示例8: build

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
static SslContext build(final Config conf) throws IOException, CertificateException {
  String tmpdir = conf.getString("application.tmpdir");
  boolean http2 = conf.getBoolean("server.http2.enabled");
  File keyStoreCert = toFile(conf.getString("ssl.keystore.cert"), tmpdir);
  File keyStoreKey = toFile(conf.getString("ssl.keystore.key"), tmpdir);
  String keyStorePass = conf.hasPath("ssl.keystore.password")
      ? conf.getString("ssl.keystore.password") : null;
  SslContextBuilder scb = SslContextBuilder.forServer(keyStoreCert, keyStoreKey, keyStorePass);
  if (conf.hasPath("ssl.trust.cert")) {
    scb.trustManager(toFile(conf.getString("ssl.trust.cert"), tmpdir))
       .clientAuth(ClientAuth.REQUIRE);
  }
  if (http2) {
    SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
    return scb.sslProvider(provider)
        .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
        .applicationProtocolConfig(new ApplicationProtocolConfig(
            Protocol.ALPN,
            SelectorFailureBehavior.NO_ADVERTISE,
            SelectedListenerFailureBehavior.ACCEPT,
            Arrays.asList(ApplicationProtocolNames.HTTP_2, ApplicationProtocolNames.HTTP_1_1)))
        .build();
  }
  return scb.build();
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:NettySslContext.java


示例9: alpn

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
private Block alpn(final SslProvider provider) {
  return unit -> {
    SslContextBuilder scb = unit.get(SslContextBuilder.class);
    expect(scb.sslProvider(provider)).andReturn(scb);
    expect(scb.ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE))
        .andReturn(scb);

    ApplicationProtocolConfig apc = unit.constructor(ApplicationProtocolConfig.class)
        .args(Protocol.class, SelectorFailureBehavior.class,
            SelectedListenerFailureBehavior.class, List.class)
        .build(Protocol.ALPN,
            SelectorFailureBehavior.NO_ADVERTISE,
            SelectedListenerFailureBehavior.ACCEPT,
            Arrays.asList(ApplicationProtocolNames.HTTP_2,
                ApplicationProtocolNames.HTTP_1_1));
    expect(scb.applicationProtocolConfig(apc)).andReturn(scb);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:19,代码来源:NettySslContextTest.java


示例10: configurePipeline

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        configHttp2(tlsCtx);
    } else if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        configHttp1(tlsCtx);
    } else {
        throw new IllegalStateException("unknown protocol: " + protocol);
    }
}
 
开发者ID:chhsiao90,项目名称:nitmproxy,代码行数:11,代码来源:TlsHandler.java


示例11: Http2TestServerRunnable

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
Http2TestServerRunnable(File certFile, File keyFile) throws Exception {
    ApplicationProtocolConfig applicationProtocolConfig = new ApplicationProtocolConfig(
            Protocol.ALPN, SelectorFailureBehavior.NO_ADVERTISE,
            SelectedListenerFailureBehavior.ACCEPT, ApplicationProtocolNames.HTTP_2);

    mSslCtx = new OpenSslServerContext(certFile, keyFile, null, null,
            Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE,
            applicationProtocolConfig, 0, 0);
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:10,代码来源:Http2TestServer.java


示例12: configurePipeline

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol)
        throws Exception {
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        ctx.pipeline().addLast(new Http2TestHandler.Builder().build());
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:11,代码来源:Http2TestServer.java


示例13: newClientEngine

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
@Override
public SSLEngine newClientEngine(String cipher, boolean useAlpn) {
    SSLEngine engine = initEngine(clientContext.createSSLEngine(), cipher, true);
    if (useAlpn) {
        Conscrypt.setApplicationProtocols(engine, new String[] {ApplicationProtocolNames.HTTP_2});
    }
    return engine;
}
 
开发者ID:google,项目名称:conscrypt,代码行数:9,代码来源:OpenJdkEngineFactory.java


示例14: newServerEngine

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
@Override
public SSLEngine newServerEngine(String cipher, boolean useAlpn) {
    SSLEngine engine = initEngine(serverContext.createSSLEngine(), cipher, false);
    if (useAlpn) {
        Conscrypt.setApplicationProtocols(engine, new String[] {ApplicationProtocolNames.HTTP_2});
    }
    return engine;
}
 
开发者ID:google,项目名称:conscrypt,代码行数:9,代码来源:OpenJdkEngineFactory.java


示例15: createNettyClientSSlContext

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
private static SslContext createNettyClientSSlContext() {
    try {
        return SslContextBuilder.forClient()
                .trustManager(InsecureTrustManagerFactory.INSTANCE)
                .applicationProtocolConfig(new ApplicationProtocolConfig(
                        ApplicationProtocolConfig.Protocol.ALPN,
                        SelectorFailureBehavior.NO_ADVERTISE,
                        SelectedListenerFailureBehavior.ACCEPT,
                        ApplicationProtocolNames.HTTP_2,
                        ApplicationProtocolNames.HTTP_1_1))
                .build();
    } catch (SSLException e) {
        throw new SSLContextException(e);
    }
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:16,代码来源:ClientSSLContextManager.java


示例16: configurePipeline

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        configureHttp2(ctx);
        return;
    }

    if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        configureHttp1(ctx);
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:15,代码来源:Http2OrHttpHandler.java


示例17: configureTLS

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
private static SslContext configureTLS() throws CertificateException, SSLException {
    SelfSignedCertificate ssc = new SelfSignedCertificate();
    ApplicationProtocolConfig apn = new ApplicationProtocolConfig(
            Protocol.ALPN,
            // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
            SelectorFailureBehavior.NO_ADVERTISE,
            // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
            SelectedListenerFailureBehavior.ACCEPT,
            ApplicationProtocolNames.HTTP_2,
            ApplicationProtocolNames.HTTP_1_1);

    return SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey(), null)
                            .ciphers(CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
                            .applicationProtocolConfig(apn).build();
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:16,代码来源:Http2Server.java


示例18: main

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Configure SSL.
    SelfSignedCertificate ssc = new SelfSignedCertificate();
    SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
        .applicationProtocolConfig(new ApplicationProtocolConfig(
                    Protocol.NPN,
                    // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
                    SelectorFailureBehavior.NO_ADVERTISE,
                    // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
                    SelectedListenerFailureBehavior.ACCEPT,
                    ApplicationProtocolNames.SPDY_3_1,
                    ApplicationProtocolNames.HTTP_1_1))
        .build();

    // Configure the server.
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.option(ChannelOption.SO_BACKLOG, 1024);
        b.group(bossGroup, workerGroup)
         .channel(NioServerSocketChannel.class)
         .handler(new LoggingHandler(LogLevel.INFO))
         .childHandler(new SpdyServerInitializer(sslCtx));

        Channel ch = b.bind(PORT).sync().channel();

        System.err.println("Open your SPDY-enabled web browser and navigate to https://127.0.0.1:" + PORT + '/');
        System.err.println("If using Chrome browser, check your SPDY sessions at chrome://net-internals/#spdy");

        ch.closeFuture().sync();
    } finally {
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:37,代码来源:SpdyServer.java


示例19: configurePipeline

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    if (ApplicationProtocolNames.SPDY_3_1.equals(protocol)) {
        configureSpdy(ctx, SpdyVersion.SPDY_3_1);
        return;
    }

    if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        configureHttp1(ctx);
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}
 
开发者ID:cowthan,项目名称:JavaAyo,代码行数:15,代码来源:SpdyOrHttpHandler.java


示例20: configureTLS

import io.netty.handler.ssl.ApplicationProtocolNames; //导入依赖的package包/类
private static SslContext configureTLS() throws CertificateException, SSLException {
	SelfSignedCertificate ssc = new SelfSignedCertificate();
	ApplicationProtocolConfig apn = new ApplicationProtocolConfig(Protocol.ALPN,
			// NO_ADVERTISE is currently the only mode supported by both
			// OpenSsl and JDK providers.
			SelectorFailureBehavior.NO_ADVERTISE,
			// ACCEPT is currently the only mode supported by both OpenSsl
			// and JDK providers.
			SelectedListenerFailureBehavior.ACCEPT, ApplicationProtocolNames.HTTP_2,
			ApplicationProtocolNames.HTTP_1_1);

	return SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey(), null)
			.ciphers(CIPHERS, SupportedCipherSuiteFilter.INSTANCE).applicationProtocolConfig(apn).build();
}
 
开发者ID:leogomes,项目名称:http2-netty,代码行数:15,代码来源:Http2Server.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultErrorAttributes类代码示例发布时间:2022-05-21
下一篇:
Java GraphQLOutputType类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap