Skip to content

Commit

Permalink
ServiceProvider registration for Confluent Schema Registry basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
michalszynkiewicz committed Mar 9, 2021
1 parent ee25c48 commit 6d06f4f
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import javax.security.auth.spi.LoginModule;

import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import org.apache.kafka.clients.consumer.ConsumerInterceptor;
import org.apache.kafka.clients.consumer.ConsumerPartitionAssignor;
import org.apache.kafka.clients.consumer.RangeAssignor;
Expand Down Expand Up @@ -117,6 +118,7 @@ void contributeClassesToIndex(BuildProducer<AdditionalIndexedClassesBuildItem> a
public void build(
KafkaBuildTimeConfig config,
CombinedIndexBuildItem indexBuildItem, BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<ServiceProviderBuildItem> serviceProviders,
BuildProducer<NativeImageProxyDefinitionBuildItem> proxies,
Capabilities capabilities, BuildProducer<UnremovableBeanBuildItem> beans,
BuildProducer<NativeImageResourceBuildItem> nativeLibs, NativeConfig nativeConfig) {
Expand Down Expand Up @@ -172,7 +174,7 @@ public void build(
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, "java.nio.DirectByteBuffer"));
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, "sun.misc.Cleaner"));

handleAvro(reflectiveClass, proxies);
handleAvro(reflectiveClass, proxies, serviceProviders);
handleOpenTracing(reflectiveClass, capabilities);
handleStrimziOAuth(reflectiveClass);
if (config.snappyEnabled) {
Expand Down Expand Up @@ -253,7 +255,8 @@ private void handleStrimziOAuth(BuildProducer<ReflectiveClassBuildItem> reflecti
}

private void handleAvro(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
BuildProducer<NativeImageProxyDefinitionBuildItem> proxies) {
BuildProducer<NativeImageProxyDefinitionBuildItem> proxies,
BuildProducer<ServiceProviderBuildItem> serviceProviders) {
// Avro - for both Confluent and Apicurio
try {
Class.forName("io.confluent.kafka.serializers.KafkaAvroDeserializer", false,
Expand Down Expand Up @@ -292,6 +295,18 @@ private void handleAvro(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
//ignore, Confluent Avro is not in the classpath
}

try {
Class.forName("io.confluent.kafka.schemaregistry.client.security.basicauth.BasicAuthCredentialProvider", false,
Thread.currentThread().getContextClassLoader());
serviceProviders
.produce(new ServiceProviderBuildItem(
"io.confluent.kafka.schemaregistry.client.security.basicauth.BasicAuthCredentialProvider",
"io.confluent.kafka.schemaregistry.client.security.basicauth.SaslBasicAuthCredentialProvider",
"io.confluent.kafka.schemaregistry.client.security.basicauth.UrlBasicAuthCredentialProvider",
"io.confluent.kafka.schemaregistry.client.security.basicauth.UserInfoCredentialProvider"));
} catch (ClassNotFoundException e) {
// ignore, Confluent schema registry client not in the classpath
}
try {
Class.forName("io.apicurio.registry.utils.serde.AvroKafkaDeserializer", false,
Thread.currentThread().getContextClassLoader());
Expand Down

0 comments on commit 6d06f4f

Please sign in to comment.