This is an automated email from the ASF dual-hosted git repository.

stevel pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new 1b59e3123bb HADOOP-18705. ABFS should exclude incompatible credential 
providers. (#5560)
1b59e3123bb is described below

commit 1b59e3123bb5fb7cc95ee85e148389d61336b6b7
Author: Tamas Domok <tdo...@cloudera.com>
AuthorDate: Mon Apr 24 16:46:40 2023 +0200

    HADOOP-18705. ABFS should exclude incompatible credential providers. (#5560)
    
    Contributed by Tamas Domok.
---
 .../hadoop/fs/azurebfs/AzureBlobFileSystem.java    |  3 ++
 .../fs/azurebfs/ITestABFSJceksFiltering.java       | 43 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git 
a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
 
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
index 9c9d6f561d7..bb9ecdd51a6 100644
--- 
a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
+++ 
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
@@ -46,6 +46,7 @@ import java.util.concurrent.Future;
 import javax.annotation.Nullable;
 
 import org.apache.hadoop.classification.VisibleForTesting;
+import org.apache.hadoop.security.ProviderUtils;
 import org.apache.hadoop.util.Preconditions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -157,6 +158,8 @@ public class AzureBlobFileSystem extends FileSystem
   @Override
   public void initialize(URI uri, Configuration configuration)
       throws IOException {
+    configuration = ProviderUtils.excludeIncompatibleCredentialProviders(
+        configuration, AzureBlobFileSystem.class);
     uri = ensureAuthority(uri, configuration);
     super.initialize(uri, configuration);
     setConf(configuration);
diff --git 
a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestABFSJceksFiltering.java
 
b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestABFSJceksFiltering.java
new file mode 100644
index 00000000000..e1b6b39521a
--- /dev/null
+++ 
b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestABFSJceksFiltering.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.hadoop.fs.azurebfs;
+
+import org.junit.Test;
+
+import org.apache.hadoop.security.alias.CredentialProviderFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+
+public class ITestABFSJceksFiltering extends AbstractAbfsIntegrationTest {
+
+  public ITestABFSJceksFiltering() throws Exception {
+  }
+
+  @Test
+  public void testIncompatibleCredentialProviderIsExcluded() throws Exception {
+    Configuration rawConfig = getRawConfiguration();
+    rawConfig.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
+        "jceks://abfs@a@b.c.d/tmp/a.jceks,jceks://file/tmp/secret.jceks");
+    try (AzureBlobFileSystem fs = (AzureBlobFileSystem) 
FileSystem.get(rawConfig)) {
+      assertNotNull("filesystem", fs);
+      String providers = 
fs.getConf().get(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH);
+      assertEquals("jceks://file/tmp/secret.jceks", providers);
+    }
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to