io.axual.connect.plugins.adls.gen2.authentication.ClientSecretClientProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of adls-gen2-sink Show documentation
Show all versions of adls-gen2-sink Show documentation
Collect the records from topics in an Azure Data Lake Storage Gen2
package io.axual.connect.plugins.adls.gen2.authentication;
/*-
* ========================LICENSE_START=================================
* Azure Data Lake Storage Gen2 Sink Connector for Kafka Connect
* %%
* Copyright (C) 2021 Axual B.V.
* %%
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =========================LICENSE_END==================================
*/
import com.azure.identity.ClientSecretCredentialBuilder;
import com.azure.storage.file.datalake.DataLakeServiceClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.axual.connect.plugins.adls.gen2.AdlsGen2SinkConfig;
/**
* Use the Azure AD Client Secret authentication method to access the Azure DataLake Storage account
* and container.
*
* Create a client secret for a user or application registration in Azure AD and make sure the
* application can list filesystems and read/write/create/delete directories in the correct containers.
*/
public class ClientSecretClientProvider extends ServiceClientProvider {
private static final Logger LOG = LoggerFactory.getLogger(ClientSecretClientProvider.class);
public ClientSecretClientProvider(AdlsGen2SinkConfig config) {
super(config);
}
// Used for testing
ClientSecretClientProvider(AdlsGen2SinkConfig config, DataLakeServiceClientBuilder serviceClientBuilder) {
super(config, serviceClientBuilder);
}
@Override
public DataLakeServiceClientBuilder addCredentials(DataLakeServiceClientBuilder builder) {
LOG.debug("Authenticating using ClientSecretCredential");
return builder.credential(new ClientSecretCredentialBuilder()
.tenantId(config.getTenantId())
.clientId(config.getClientId())
.clientSecret(config.getClientSecret().value())
.build());
}
}