Tabnine Logo
Authentication
Code IndexAdd Tabnine to your IDE (free)

How to use
Authentication
in
org.apache.pulsar.client.api

Best Java code snippets using org.apache.pulsar.client.api.Authentication (Showing top 20 results out of 315)

origin: apache/pulsar

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);
}
origin: apache/pulsar

public PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup eventLoopGroup, ConnectionPool cnxPool)
    throws PulsarClientException {
  if (conf == null || isBlank(conf.getServiceUrl()) || eventLoopGroup == null) {
    throw new PulsarClientException.InvalidConfigurationException("Invalid client configuration");
  }
  this.eventLoopGroup = eventLoopGroup;
  this.conf = conf;
  conf.getAuthentication().start();
  this.cnxPool = cnxPool;
  externalExecutorProvider = new ExecutorProvider(conf.getNumListenerThreads(), getThreadFactory("pulsar-external-listener"));
  if (conf.getServiceUrl().startsWith("http")) {
    lookup = new HttpLookupService(conf, eventLoopGroup);
  } else {
    lookup = new BinaryProtoLookupService(this, conf.getServiceUrl(), conf.isUseTls(), externalExecutorProvider.getExecutor());
  }
  timer = new HashedWheelTimer(getThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS);
  producers = Maps.newIdentityHashMap();
  consumers = Maps.newIdentityHashMap();
  state.set(State.Open);
}
origin: apache/pulsar

@Override
public void shutdown() throws PulsarClientException {
  try {
    lookup.close();
    cnxPool.close();
    timer.stop();
    externalExecutorProvider.shutdownNow();
    conf.getAuthentication().close();
  } catch (Throwable t) {
    log.warn("Failed to shutdown Pulsar client", t);
    throw new PulsarClientException(t);
  }
}
origin: org.apache.pulsar/pulsar-client-admin-original

this.auth = clientConfigData != null ? clientConfigData.getAuthentication() : new AuthenticationDisabled();
LOG.debug("created: serviceUrl={}, authMethodName={}", serviceUrl,
    auth != null ? auth.getAuthMethodName() : null);
  auth.start();
    AuthenticationDataProvider authData = auth.getAuthData();
    if (authData.hasDataForTls()) {
      sslCtx = SecurityUtility.createSslContext(clientConfigData.isTlsAllowInsecureConnection(),
    try {
      if (auth != null) {
        auth.close();
origin: org.apache.pulsar/pulsar-proxy

auth.start();
    AuthenticationDataProvider authData = auth.getAuthData();
    if (authData.hasDataForTls()) {
      sslCtx = SecurityUtility.createSslContext(
  } catch (Exception e) {
    try {
      auth.close();
    } catch (IOException ioe) {
      LOG.error("Failed to close the authentication service", ioe);
origin: apache/pulsar

  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());
  }
});
origin: org.apache.pulsar/pulsar-testclient

try {
  Authentication auth = AuthenticationFactory.create(authPluginClassName, authParams);
  auth.start();
  AuthenticationDataProvider authData = auth.getAuthData();
  if (authData.hasDataForHttp()) {
    for (Map.Entry<String, String> kv : authData.getHttpHeaders()) {
origin: apache/pulsar

  /**
   * Create an instance of the Authentication-Plugin
   *
   * @param authPluginClassName
   *            name of the Authentication-Plugin you want to use
   * @param authParams
   *            map which represents parameters for the Authentication-Plugin
   * @return instance of the Authentication-Plugin
   * @throws UnsupportedAuthenticationException
   */
  @SuppressWarnings("deprecation")
  public static final Authentication create(String authPluginClassName, Map<String, String> authParams)
      throws UnsupportedAuthenticationException {
    try {
      if (isNotBlank(authPluginClassName)) {
        Class<?> authClass = Class.forName(authPluginClassName);
        Authentication auth = (Authentication) authClass.newInstance();
        auth.configure(authParams);
        return auth;
      } else {
        return new AuthenticationDisabled();
      }
    } catch (Throwable t) {
      throw new UnsupportedAuthenticationException(t);
    }
  }
}
origin: apache/pulsar

try {
  String requestUrl = new URL(serviceNameResolver.resolveHostUri().toURL(), path).toString();
  AuthenticationDataProvider authData = authentication.getAuthData();
  BoundRequestBuilder builder = httpClient.prepareGet(requestUrl);
origin: apache/pulsar

} else {
  auth.configure(configureFromPulsar1AuthParamString(authParamsString));
origin: org.apache.pulsar/pulsar-client-original

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);
}
origin: apache/pulsar

AuthenticationDataProvider authData = authentication.getAuthData();
if (authData.hasDataForTls()) {
  sslCtx = SecurityUtility.createNettySslContextForClient(tlsAllowInsecureConnection, tlsTrustCertsFilePath,
origin: org.apache.pulsar/pulsar-client-original

public PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup eventLoopGroup, ConnectionPool cnxPool)
    throws PulsarClientException {
  if (conf == null || isBlank(conf.getServiceUrl()) || eventLoopGroup == null) {
    throw new PulsarClientException.InvalidConfigurationException("Invalid client configuration");
  }
  this.eventLoopGroup = eventLoopGroup;
  this.conf = conf;
  conf.getAuthentication().start();
  this.cnxPool = cnxPool;
  externalExecutorProvider = new ExecutorProvider(conf.getNumListenerThreads(), getThreadFactory("pulsar-external-listener"));
  if (conf.getServiceUrl().startsWith("http")) {
    lookup = new HttpLookupService(conf, eventLoopGroup);
  } else {
    lookup = new BinaryProtoLookupService(this, conf.getServiceUrl(), conf.isUseTls(), externalExecutorProvider.getExecutor());
  }
  timer = new HashedWheelTimer(getThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS);
  producers = Maps.newIdentityHashMap();
  consumers = Maps.newIdentityHashMap();
  state.set(State.Open);
}
origin: org.apache.pulsar/pulsar-client-admin-original

  /**
   * Close the Pulsar admin client to release all the resources
   */
  @Override
  public void close() {
    try {
      if (auth != null) {
        auth.close();
      }
    } catch (IOException e) {
      LOG.error("Failed to close the authentication service", e);
    }
    client.close();
  }
}
origin: org.apache.pulsar/pulsar-client-original

  /**
   * Create an instance of the Authentication-Plugin
   *
   * @param authPluginClassName name of the Authentication-Plugin you want to use
   * @param authParams          map which represents parameters for the Authentication-Plugin
   * @return instance of the Authentication-Plugin
   * @throws UnsupportedAuthenticationException
   */
  @SuppressWarnings("deprecation")
  public static final Authentication create(String authPluginClassName, Map<String, String> authParams)
      throws UnsupportedAuthenticationException {
    try {
      if (isNotBlank(authPluginClassName)) {
        Class<?> authClass = Class.forName(authPluginClassName);
        Authentication auth = (Authentication) authClass.newInstance();
        auth.configure(authParams);
        return auth;
      } else {
        return new AuthenticationDisabled();
      }
    } catch (Throwable t) {
      throw new UnsupportedAuthenticationException(t);
    }
  }
}
origin: org.apache.pulsar/pulsar-proxy

@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);
}
origin: org.apache.pulsar/pulsar-client-admin-original

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);
  }
}
origin: org.apache.pulsar/pulsar-client-original

@Override
public void shutdown() throws PulsarClientException {
  try {
    lookup.close();
    cnxPool.close();
    timer.stop();
    externalExecutorProvider.shutdownNow();
    conf.getAuthentication().close();
  } catch (Throwable t) {
    log.warn("Failed to shutdown Pulsar client", t);
    throw new PulsarClientException(t);
  }
}
origin: org.apache.pulsar/pulsar-client-original

/**
 * Create an instance of the Authentication-Plugin
 *
 * @param authPluginClassName name of the Authentication-Plugin you want to use
 * @param authParamsString    string which represents parameters for the Authentication-Plugin, e.g., "key1:val1,key2:val2"
 * @return instance of the Authentication-Plugin
 * @throws UnsupportedAuthenticationException
 */
@SuppressWarnings("deprecation")
public static final Authentication create(String authPluginClassName, String authParamsString)
    throws UnsupportedAuthenticationException {
  try {
    if (isNotBlank(authPluginClassName)) {
      Class<?> authClass = Class.forName(authPluginClassName);
      Authentication auth = (Authentication) authClass.newInstance();
      if (auth instanceof EncodedAuthenticationParameterSupport) {
        // Parse parameters on plugin side.
        ((EncodedAuthenticationParameterSupport) auth).configure(authParamsString);
      } else {
        // Parse parameters by default parse logic.
        auth.configure(AuthenticationUtil.configureFromPulsar1AuthParamString(authParamsString));
      }
      return auth;
    } else {
      return new AuthenticationDisabled();
    }
  } catch (Throwable t) {
    throw new UnsupportedAuthenticationException(t);
  }
}
origin: org.apache.pulsar/pulsar-proxy

@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();
}
org.apache.pulsar.client.apiAuthentication

Javadoc

Interface of authentication providers.

Most used methods

  • getAuthData
  • start
    Initialize the authentication provider
  • close
  • getAuthMethodName
  • configure
    Configure the authentication plugins with the supplied parameters

Popular in Java

  • Making http post requests using okhttp
  • setScale (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now