protected ByteBuf newConnectCommand() throws PulsarClientException { String authData = ""; if (authentication.getAuthData().hasDataFromCommand()) { authData = authentication.getAuthData().getCommandData(); } return Commands.newConnect(authentication.getAuthMethodName(), authData, this.protocolVersion, getPulsarClientVersion(), proxyToTargetBrokerAddress, null, null, null); }
public void initChannel(SocketChannel ch) throws Exception { if (conf.isUseTls()) { SslContext sslCtx; // Set client certificate if available AuthenticationDataProvider authData = conf.getAuthentication().getAuthData(); if (authData.hasDataForTls()) { sslCtx = SecurityUtility.createNettySslContextForClient(conf.isTlsAllowInsecureConnection(), conf.getTlsTrustCertsFilePath(), (X509Certificate[]) authData.getTlsCertificates(), authData.getTlsPrivateKey()); } else { sslCtx = SecurityUtility.createNettySslContextForClient(conf.isTlsAllowInsecureConnection(), conf.getTlsTrustCertsFilePath()); } ch.pipeline().addLast(TLS_HANDLER, sslCtx.newHandler(ch.alloc())); ch.pipeline().addLast("ByteBufPairEncoder", ByteBufPair.COPYING_ENCODER); } else { ch.pipeline().addLast("ByteBufPairEncoder", ByteBufPair.ENCODER); } ch.pipeline().addLast("frameDecoder", new LengthFieldBasedFrameDecoder(MaxMessageSize, 0, 4, 0, 4)); ch.pipeline().addLast("handler", clientCnxSupplier.get()); } });
try { String requestUrl = new URL(serviceNameResolver.resolveHostUri().toURL(), path).toString(); AuthenticationDataProvider authData = authentication.getAuthData(); BoundRequestBuilder builder = httpClient.prepareGet(requestUrl);
AuthenticationDataProvider authData = authentication.getAuthData(); if (authData.hasDataForTls()) { sslCtx = SecurityUtility.createNettySslContextForClient(tlsAllowInsecureConnection, tlsTrustCertsFilePath,
public Builder request(final WebTarget target) throws PulsarAdminException { try { Builder builder = target.request(MediaType.APPLICATION_JSON); // Add headers for authentication if any if (auth != null && auth.getAuthData().hasDataForHttp()) { for (Map.Entry<String, String> header : auth.getAuthData().getHttpHeaders()) { builder.header(header.getKey(), header.getValue()); } } return builder; } catch (Throwable t) { throw new GettingAuthenticationDataException(t); } }
@Override protected ByteBuf newConnectCommand() throws PulsarClientException { if (log.isDebugEnabled()) { log.debug( "New Connection opened via ProxyClientCnx with params clientAuthRole = {}, clientAuthData = {}, clientAuthMethod = {}", clientAuthRole, clientAuthData, clientAuthMethod); } String authData = null; if (authentication.getAuthData().hasDataFromCommand()) { authData = authentication.getAuthData().getCommandData(); } return Commands.newConnect(authentication.getAuthMethodName(), authData, protocolVersion, getPulsarClientVersion(), proxyToTargetBrokerAddress, clientAuthRole, clientAuthData, clientAuthMethod); }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { this.ctx = ctx; // Send the Connect command to broker String authData = ""; if (authentication.getAuthData().hasDataFromCommand()) { authData = authentication.getAuthData().getCommandData(); } ByteBuf command = null; command = Commands.newConnect(authentication.getAuthMethodName(), authData, protocolVersion, "Pulsar proxy", null /* target broker */, originalPrincipal, clientAuthData, clientAuthMethod); outboundChannel.writeAndFlush(command); outboundChannel.read(); }
protected ByteBuf newConnectCommand() throws PulsarClientException { String authData = ""; if (authentication.getAuthData().hasDataFromCommand()) { authData = authentication.getAuthData().getCommandData(); } return Commands.newConnect(authentication.getAuthMethodName(), authData, this.protocolVersion, getPulsarClientVersion(), proxyToTargetBrokerAddress, null, null, null); }
public void initChannel(SocketChannel ch) throws Exception { if (conf.isUseTls()) { SslContext sslCtx; // Set client certificate if available AuthenticationDataProvider authData = conf.getAuthentication().getAuthData(); if (authData.hasDataForTls()) { sslCtx = SecurityUtility.createNettySslContextForClient(conf.isTlsAllowInsecureConnection(), conf.getTlsTrustCertsFilePath(), (X509Certificate[]) authData.getTlsCertificates(), authData.getTlsPrivateKey()); } else { sslCtx = SecurityUtility.createNettySslContextForClient(conf.isTlsAllowInsecureConnection(), conf.getTlsTrustCertsFilePath()); } ch.pipeline().addLast(TLS_HANDLER, sslCtx.newHandler(ch.alloc())); ch.pipeline().addLast("ByteBufPairEncoder", ByteBufPair.COPYING_ENCODER); } else { ch.pipeline().addLast("ByteBufPairEncoder", ByteBufPair.ENCODER); } ch.pipeline().addLast("frameDecoder", new LengthFieldBasedFrameDecoder(MaxMessageSize, 0, 4, 0, 4)); ch.pipeline().addLast("handler", clientCnxSupplier.get()); } });
@Override protected void initChannel(SocketChannel ch) throws Exception { if (config.isTlsEnabledWithBroker()) { SslContext sslCtx; // Set client certificate if available AuthenticationDataProvider authData = authentication.getAuthData(); if (authData.hasDataForTls()) { sslCtx = SecurityUtility.createNettySslContextForClient(config.isTlsAllowInsecureConnection(), config.getBrokerClientTrustCertsFilePath(), (X509Certificate[]) authData.getTlsCertificates(), authData.getTlsPrivateKey()); } else { sslCtx = SecurityUtility.createNettySslContextForClient(config.isTlsAllowInsecureConnection(), config.getBrokerClientTrustCertsFilePath()); } ch.pipeline().addLast(TLS_HANDLER, sslCtx.newHandler(ch.alloc())); } ch.pipeline().addLast("frameDecoder", new LengthFieldBasedFrameDecoder(PulsarDecoder.MaxFrameSize, 0, 4, 0, 4)); ch.pipeline().addLast("proxyOutboundHandler", new ProxyBackendHandler(config, protocolVersion)); } });
Authentication auth = AuthenticationFactory.create(authPluginClassName, authParams); auth.start(); AuthenticationDataProvider authData = auth.getAuthData(); if (authData.hasDataForHttp()) { for (Map.Entry<String, String> kv : authData.getHttpHeaders()) {
try { String requestUrl = new URL(url, path).toString(); AuthenticationDataProvider authData = authentication.getAuthData(); BoundRequestBuilder builder = httpClient.prepareGet(requestUrl);
AuthenticationDataProvider authData = auth.getAuthData(); if (authData.hasDataForTls()) { sslCtx = SecurityUtility.createSslContext(
AuthenticationDataProvider authData = authentication.getAuthData(); if (authData.hasDataForTls()) { sslCtx = SecurityUtility.createNettySslContextForClient(tlsAllowInsecureConnection, tlsTrustCertsFilePath,
AuthenticationDataProvider authData = auth.getAuthData(); if (authData.hasDataForTls()) { sslCtx = SecurityUtility.createSslContext(clientConfigData.isTlsAllowInsecureConnection(),