Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

[ENHANCEMENT] enhancement for setting up auth parameters #380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ public FlinkPulsarSinkBase(
if (this.clientConfigurationData.getServiceUrl() == null) {
throw new IllegalArgumentException("ServiceUrl must be supplied in the client configuration");
}

// setup auth parameters based on ClientConfigurationData and Properties
PulsarClientUtils.setupAuthIfNeed(clientConfigurationData, properties);
}

public FlinkPulsarSinkBase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ public FlinkPulsarSource(
throw new IllegalArgumentException("ServiceUrl must be supplied in the client configuration");
}
this.oldStateVersion = SourceSinkUtils.getOldStateVersion(caseInsensitiveParams, oldStateVersion);

// setup auth parameters based on ClientConfigurationData and Properties
PulsarClientUtils.setupAuthIfNeed(clientConfigurationData, properties);
}

public FlinkPulsarSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,20 @@ public static ClientConfigurationData newClientConf(String serviceUrl, Propertie
return clientConf;
}

public static void setupAuthIfNeed(ClientConfigurationData conf, Properties properties) {
if (!StringUtils.isBlank(conf.getAuthPluginClassName())
&& (!StringUtils.isBlank(conf.getAuthParams()) || conf.getAuthParamMap() != null)) {
// User has set up auth with ClientConfigurationData, which has the highest priority.
} else {
if (properties != null
&& !StringUtils.isBlank(properties.getProperty(PulsarOptions.AUTH_PLUGIN_CLASSNAME_KEY))
&& !StringUtils.isBlank(properties.getProperty(PulsarOptions.AUTH_PARAMS_KEY))) {
// User only set up auth with Properties. Copy the properties to ClientConfigurationData.
conf.setAuthParams(properties.getProperty(PulsarOptions.AUTH_PARAMS_KEY));
conf.setAuthPluginClassName(properties.getProperty(PulsarOptions.AUTH_PLUGIN_CLASSNAME_KEY));
} else {
// User does not enable authentication.
}
}
}
}