Skip to content

Commit 528da49

Browse files
committed
debezium/dbz#1083: Add Javadoc for PulsarAuthHandler and PulsarAdminProvider interfaces to document authentication configuration and builder abstraction
Signed-off-by: Philippe Camus <pxcamus@pm.me>
1 parent 9fd4376 commit 528da49

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

debezium-platform-conductor/src/main/java/io/debezium/platform/environment/connection/destination/pulsar/PulsarAdminProvider.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
import org.apache.pulsar.client.admin.PulsarAdminBuilder;
44

5+
/**
6+
* Provides configured {@link PulsarAdminBuilder} instances for Pulsar administrative operations.
7+
* <p>
8+
* This abstraction centralizes the creation of {@link PulsarAdminBuilder} objects so that
9+
* callers can start from a common builder setup and then apply connection-specific details
10+
* such as the service URL and authentication options.
11+
* </p>
12+
*
13+
* <p>
14+
* It is primarily used during Pulsar connection validation and other operations that require
15+
* constructing a {@code PulsarAdmin} client.
16+
* </p>
17+
*
18+
* @author Mario Fiore Vitale
19+
*/
520
public interface PulsarAdminProvider {
21+
22+
/**
23+
* Creates or returns a {@link PulsarAdminBuilder} ready for further customization.
24+
*
25+
* @return a Pulsar admin builder instance
26+
*/
627
PulsarAdminBuilder builder();
728
}

debezium-platform-conductor/src/main/java/io/debezium/platform/environment/connection/destination/pulsar/PulsarAuthHandler.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,65 @@
44

55
import org.apache.pulsar.client.admin.PulsarAdminBuilder;
66

7+
/**
8+
* Strategy interface for applying and validating authentication settings used to connect to Apache Pulsar.
9+
* <p>
10+
* Implementations of this interface encapsulate the behavior required for a specific Pulsar
11+
* authentication scheme, such as no authentication, basic authentication, or JWT-based authentication.
12+
* They are responsible for:
13+
* </p>
14+
* <ul>
15+
* <li>validating that all required authentication-related configuration values are present and well-formed, and</li>
16+
* <li>configuring a {@link PulsarAdminBuilder} with the authentication mechanism expected by Pulsar.</li>
17+
* </ul>
18+
*
19+
* <p>
20+
* The {@code config} map contains connection properties associated with a Pulsar destination.
21+
* Implementations may read authentication-specific keys from this map, such as usernames,
22+
* passwords, or tokens.
23+
* </p>
24+
*/
725
public interface PulsarAuthHandler {
26+
27+
/**
28+
* Configures the provided {@link PulsarAdminBuilder} with the authentication settings
29+
* required by this handler.
30+
* <p>
31+
* Implementations may add authentication credentials or other related settings to the builder.
32+
* This method assumes that the supplied configuration has already been validated.
33+
* </p>
34+
*
35+
* @param builder the Pulsar admin builder to configure; must not be {@code null}
36+
* @param config the Pulsar connection configuration containing authentication properties;
37+
* must not be {@code null}
38+
*/
839
void configure(PulsarAdminBuilder builder, Map<String, Object> config);
940

41+
/**
42+
* Validates the authentication-related configuration required by this handler.
43+
* <p>
44+
* Implementations should verify that required configuration keys are present and that their
45+
* values are valid for the corresponding authentication scheme. If validation fails, an
46+
* {@link IllegalArgumentException} should be thrown with a descriptive message.
47+
* </p>
48+
*
49+
* @param config the Pulsar connection configuration to validate; must not be {@code null}
50+
* @throws IllegalArgumentException if required configuration values are missing, blank, or invalid
51+
*/
1052
void validate(Map<String, Object> config) throws IllegalArgumentException;
1153

54+
/**
55+
* Utility method to check whether a configuration value is missing or blank.
56+
* <p>
57+
* A value is considered missing if the map does not contain the key, if the associated value
58+
* is {@code null}, or if the string representation of the value is blank after trimming.
59+
* </p>
60+
*
61+
* @param config the configuration map to inspect; must not be {@code null}
62+
* @param key the configuration key to look up
63+
* @return {@code true} if the key is absent, mapped to {@code null}, or mapped to a blank value;
64+
* {@code false} otherwise
65+
*/
1266
default boolean isConfigValueMissing(Map<String, ?> config, String key) {
1367
return !config.containsKey(key) ||
1468
config.get(key) == null ||

0 commit comments

Comments
 (0)