Java Code Examples for io.netty.handler.ssl.ClientAuth#values()
The following examples show how to use
io.netty.handler.ssl.ClientAuth#values() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TlsHelper.java From DDMQ with Apache License 2.0 | 5 votes |
private static ClientAuth parseClientAuthMode(String authMode) { if (null == authMode || authMode.trim().isEmpty()) { return ClientAuth.NONE; } for (ClientAuth clientAuth : ClientAuth.values()) { if (clientAuth.name().equals(authMode.toUpperCase())) { return clientAuth; } } return ClientAuth.NONE; }
Example 2
Source File: TlsHelper.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
private static ClientAuth parseClientAuthMode(String authMode) { if (null == authMode || authMode.trim().isEmpty()) { return ClientAuth.NONE; } for (ClientAuth clientAuth : ClientAuth.values()) { if (clientAuth.name().equals(authMode.toUpperCase())) { return clientAuth; } } return ClientAuth.NONE; }
Example 3
Source File: TlsHelper.java From rocketmq-read with Apache License 2.0 | 5 votes |
private static ClientAuth parseClientAuthMode(String authMode) { if (null == authMode || authMode.trim().isEmpty()) { return ClientAuth.NONE; } for (ClientAuth clientAuth : ClientAuth.values()) { if (clientAuth.name().equals(authMode.toUpperCase())) { return clientAuth; } } return ClientAuth.NONE; }
Example 4
Source File: TlsHelper.java From DDMQ with Apache License 2.0 | 5 votes |
private static ClientAuth parseClientAuthMode(String authMode) { if (null == authMode || authMode.trim().isEmpty()) { return ClientAuth.NONE; } for (ClientAuth clientAuth : ClientAuth.values()) { if (clientAuth.name().equals(authMode.toUpperCase())) { return clientAuth; } } return ClientAuth.NONE; }
Example 5
Source File: TlsHelper.java From rocketmq with Apache License 2.0 | 5 votes |
private static ClientAuth parseClientAuthMode(String authMode) { if (null == authMode || authMode.trim().isEmpty()) { return ClientAuth.NONE; } for (ClientAuth clientAuth : ClientAuth.values()) { if (clientAuth.name().equals(authMode.toUpperCase())) { return clientAuth; } } return ClientAuth.NONE; }
Example 6
Source File: NettyServerEndpoint.java From jlibs with Apache License 2.0 | 4 votes |
@Override public void bind(final URI uri, final String subProtocols[], final AcceptListener listener){ final SslContext sslContext; if("wss".equals(uri.getScheme())){ try{ if(sslSettings==null){ SelfSignedCertificate ssc = new SelfSignedCertificate(); sslSettings = new SSLSettings().keyFile(ssc.privateKey()).certificateFile(ssc.certificate()); } ClientAuth clientAuth = ClientAuth.values()[sslSettings.clientAuthentication.ordinal()]; sslContext = SslContextBuilder.forServer(sslSettings.certificateFile, sslSettings.keyFile, sslSettings.keyPassword) .clientAuth(clientAuth) .trustManager(sslSettings.trustCertChainFile) .build(); }catch(Throwable thr){ listener.onError(thr); return; } }else if("ws".equals(uri.getScheme())) sslContext = null; else throw new IllegalArgumentException("invalid protocol: "+uri.getScheme()); int port = uri.getPort(); if(port==-1) port = sslContext==null ? 80 : 443; ServerBootstrap bootstrap = new ServerBootstrap() .group(eventLoopGroup) .channel(NioServerSocketChannel.class) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.MAX_MESSAGES_PER_READ, 50000) .childOption(ChannelOption.WRITE_SPIN_COUNT, 50000) .childHandler(new ChannelInitializer<SocketChannel>(){ @Override protected void initChannel(SocketChannel ch) throws Exception{ if(sslContext!=null) ch.pipeline().addLast(sslContext.newHandler(ch.alloc())); ch.pipeline().addLast( new HttpServerCodec(), new HttpObjectAggregator(65536), new Handshaker(uri, listener, subProtocols) ); } }); bootstrap.bind(uri.getHost(), port).addListener(new ChannelFutureListener(){ @Override public void operationComplete(ChannelFuture future) throws Exception{ if(future.isSuccess()){ channel = future.channel(); channel.attr(ACCEPT_LISTENER).set(listener); listener.onBind(NettyServerEndpoint.this); }else listener.onError(future.cause()); } }); }