diff --git a/docs/schema-registry.rst b/docs/schema-registry.rst index 5b925dc92..369226136 100644 --- a/docs/schema-registry.rst +++ b/docs/schema-registry.rst @@ -129,10 +129,26 @@ Kafka Producer Integration with SchemaRegistry config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()); + +.. code:: java + + config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + config.put(SchemaRegistryClient.Configuration.SCHEMA_REGISTRY_URL.name(), props.get(SCHEMA_REGISTRY_URL)); + config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); + config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()); + config.put(SchemaRegistryClient.Configuration.AUTH_USERNAME, "user1"); + config.put(SchemaRegistryClient.Configuration.AUTH_PASSWORD, "password"); + Important settings from the above are **schema.registry.url**: This should be set to where the registry server is running ex: http://localhost:9090/api/v1 +**schema.registry.auth.username**: + If the schema registry service is behind a proxy that supports Basic Authentication, the user name part of the credentials can be provided here. + +**schema.registry.auth.password**: + If the schema registry service is behind a proxy that supports Basic Authentication, the password part of the credentials can be provided here. + **key.serializer**: *StringSerializer* is used in the above example. @@ -191,11 +207,26 @@ Kafka Consumer Integration with SchemaRegistry config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, KafkaAvroDeserializer.class.getName()); +.. code:: java + + config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + config.put(SchemaRegistryClient.Configuration.SCHEMA_REGISTRY_URL.name(), props.get(SCHEMA_REGISTRY_URL)); + config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); + config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName()); + config.put(SchemaRegistryClient.Configuration.AUTH_USERNAME, "user1"); + config.put(SchemaRegistryClient.Configuration.AUTH_PASSWORD, "password"); + Important settings from the above are **schema.registry.url**: This should be set to where the registry server is running ex: http://localhost:9090/api/v1 +**schema.registry.auth.username**: + If the schema registry service is behind a proxy that supports Basic Authentication, the user name part of the credentials can be provided here. + +**schema.registry.auth.password**: + If the schema registry service is behind a proxy that supports Basic Authentication, the password part of the credentials can be provided here. + **key.deserializer**: *StringDeserializer* is used in the above example. diff --git a/schema-registry/README.md b/schema-registry/README.md index 97c6ae282..a453c59f2 100644 --- a/schema-registry/README.md +++ b/schema-registry/README.md @@ -128,8 +128,8 @@ sslMap.put("trustStoreType", "JKS"); sslMap.put("trustStorePath", "/path/to/truststore/file"); sslMap.put("trustStorePassword", "truststorepassword"); config.put("schema.registry.client.ssl", sslMap); -config.put(SchemaRegistryClient.Configuration.BASIC_AUTH_USERNAME, "knoxproxyusername"); -config.put(SchemaRegistryClient.Configuration.BASIC_AUTH_PASSWORD, "knoxproxypassword"); +config.put(SchemaRegistryClient.Configuration.AUTH_USERNAME, "knoxproxyusername"); +config.put(SchemaRegistryClient.Configuration.AUTH_PASSWORD, "knoxproxypassword"); SchemaRegistryClient schemaRegistryClient = new SchemaRegistryClient(config); ``` ## Using schema related APIs diff --git a/schema-registry/client/src/main/java/com/hortonworks/registries/schemaregistry/client/SchemaRegistryClient.java b/schema-registry/client/src/main/java/com/hortonworks/registries/schemaregistry/client/SchemaRegistryClient.java index 5438254ce..721389357 100644 --- a/schema-registry/client/src/main/java/com/hortonworks/registries/schemaregistry/client/SchemaRegistryClient.java +++ b/schema-registry/client/src/main/java/com/hortonworks/registries/schemaregistry/client/SchemaRegistryClient.java @@ -221,8 +221,8 @@ public SchemaRegistryClient(Map conf) { } client = clientBuilder.build(); client.register(MultiPartFeature.class); - String userName = configuration.getValue(Configuration.BASIC_AUTH_USERNAME.name()); - String password = configuration.getValue(Configuration.BASIC_AUTH_PASSWORD.name()); + String userName = configuration.getValue(Configuration.AUTH_USERNAME.name()); + String password = configuration.getValue(Configuration.AUTH_PASSWORD.name()); if (StringUtils.isNotEmpty(userName) && StringUtils.isNotEmpty(password)){ HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(userName, password); client.register(feature); @@ -1419,21 +1419,23 @@ public static final class Configuration { /** * Username for basic authentication. */ - public static final ConfigEntry BASIC_AUTH_USERNAME = + public static final ConfigEntry AUTH_USERNAME = ConfigEntry.optional("schema.registry.auth.username", String.class, "Username for basic authentication", null, + ConfigEntry.StringConverter.get(), ConfigEntry.NonEmptyStringValidator.get()); /** * Password for basic authentication. */ - public static final ConfigEntry BASIC_AUTH_PASSWORD = + public static final ConfigEntry AUTH_PASSWORD = ConfigEntry.optional("schema.registry.auth.password", String.class, "Password for basic authentication", null, + ConfigEntry.StringConverter.get(), ConfigEntry.NonEmptyStringValidator.get()); private final Map config;