nastra commented on code in PR #11577:
URL: https://github.com/apache/iceberg/pull/11577#discussion_r2016106249


##########
azure/src/main/java/org/apache/iceberg/azure/adlsv2/VendedAdlsCredentialProvider.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.iceberg.azure.adlsv2;
+
+import com.azure.core.credential.AccessToken;
+import com.azure.core.credential.SimpleTokenCache;
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.UncheckedIOException;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.iceberg.azure.AzureProperties;
+import org.apache.iceberg.io.CloseableGroup;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.iceberg.rest.ErrorHandlers;
+import org.apache.iceberg.rest.HTTPClient;
+import org.apache.iceberg.rest.RESTClient;
+import org.apache.iceberg.rest.auth.AuthManager;
+import org.apache.iceberg.rest.auth.AuthManagers;
+import org.apache.iceberg.rest.auth.AuthSession;
+import org.apache.iceberg.rest.credentials.Credential;
+import org.apache.iceberg.rest.responses.LoadCredentialsResponse;
+import org.apache.iceberg.util.SerializableMap;
+import reactor.core.publisher.Mono;
+
+public class VendedAdlsCredentialProvider implements Serializable, 
AutoCloseable {
+
+  public static final String URI = "credentials.uri";
+
+  private final SerializableMap<String, String> properties;
+  private transient volatile Map<String, SimpleTokenCache> 
sasCredentialByAccount;
+  private transient volatile HTTPClient client;
+  private transient AuthManager authManager;
+  private transient AuthSession authSession;
+
+  public VendedAdlsCredentialProvider(Map<String, String> properties) {
+    Preconditions.checkArgument(null != properties, "Invalid properties: 
null");
+    Preconditions.checkArgument(null != properties.get(URI), "Invalid URI: 
null");

Review Comment:
   can you please apply the below diff to this class?
   ```
   --- 
a/azure/src/main/java/org/apache/iceberg/azure/adlsv2/VendedAdlsCredentialProvider.java
   +++ 
b/azure/src/main/java/org/apache/iceberg/azure/adlsv2/VendedAdlsCredentialProvider.java
   @@ -28,6 +28,7 @@ import java.time.ZoneOffset;
    import java.util.List;
    import java.util.Map;
    import java.util.stream.Collectors;
   +import org.apache.iceberg.CatalogProperties;
    import org.apache.iceberg.azure.AzureProperties;
    import org.apache.iceberg.io.CloseableGroup;
    import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
   @@ -48,6 +49,8 @@ public class VendedAdlsCredentialProvider implements 
Serializable, AutoCloseable
      public static final String URI = "credentials.uri";
   
      private final SerializableMap<String, String> properties;
   +  private final String credentialsEndpoint;
   +  private final String catalogEndpoint;
      private transient volatile Map<String, SimpleTokenCache> 
sasCredentialByAccount;
      private transient volatile HTTPClient client;
      private transient AuthManager authManager;
   @@ -55,8 +58,12 @@ public class VendedAdlsCredentialProvider implements 
Serializable, AutoCloseable
   
      public VendedAdlsCredentialProvider(Map<String, String> properties) {
        Preconditions.checkArgument(null != properties, "Invalid properties: 
null");
   -    Preconditions.checkArgument(null != properties.get(URI), "Invalid URI: 
null");
   +    Preconditions.checkArgument(null != properties.get(URI), "Invalid 
credentials endpoint: null");
   +    Preconditions.checkArgument(
   +        null != properties.get(CatalogProperties.URI), "Invalid catalog 
endpoint: null");
        this.properties = SerializableMap.copyOf(properties);
   +    this.credentialsEndpoint = properties.get(URI);
   +    this.catalogEndpoint = properties.get(CatalogProperties.URI);
      }
   
      String credentialForAccount(String storageAccount) {
   @@ -117,7 +124,7 @@ public class VendedAdlsCredentialProvider implements 
Serializable, AutoCloseable
          synchronized (this) {
            if (null == client) {
              authManager = 
AuthManagers.loadAuthManager("adls-credentials-refresh", properties);
   -          HTTPClient httpClient = 
HTTPClient.builder(properties).uri(properties.get(URI)).build();
   +          HTTPClient httpClient = 
HTTPClient.builder(properties).uri(catalogEndpoint).build();
              authSession = authManager.catalogSession(httpClient, properties);
              client = httpClient.withAuthSession(authSession);
            }
   @@ -130,7 +137,7 @@ public class VendedAdlsCredentialProvider implements 
Serializable, AutoCloseable
      private LoadCredentialsResponse fetchCredentials() {
        return httpClient()
            .get(
   -            properties.get(URI),
   +            credentialsEndpoint,
                null,
   ```
   This is fixing an issue that we're currently also fixing for S3 / GCP in 
#12612 / #12638. You will also have to update the tests in a similar way as in 
those PRs



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to