seropian commented on code in PR #2982:
URL: https://github.com/apache/jackrabbit-oak/pull/2982#discussion_r3542950685


##########
oak-blob-cloud-azure/src/main/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/v12/AzureBlobContainerProviderV12.java:
##########
@@ -0,0 +1,329 @@
+/*
+ * 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.jackrabbit.oak.blob.cloud.azure.blobstorage.v12;
+
+import com.azure.core.http.HttpClient;
+import com.azure.core.http.netty.NettyAsyncHttpClientBuilder;
+import com.azure.identity.ClientSecretCredential;
+import com.azure.identity.ClientSecretCredentialBuilder;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.BlobContainerClientBuilder;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.blob.models.UserDelegationKey;
+import com.azure.storage.blob.sas.BlobSasPermission;
+import com.azure.storage.blob.sas.BlobServiceSasSignatureValues;
+import com.azure.storage.blob.specialized.BlockBlobClient;
+import com.azure.storage.common.policy.RequestRetryOptions;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.jackrabbit.oak.spi.blob.data.DataStoreException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URISyntaxException;
+import java.security.InvalidKeyException;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Properties;
+
+class AzureBlobContainerProviderV12 {
+    private static final Logger log = 
LoggerFactory.getLogger(AzureBlobContainerProviderV12.class);
+    private static final String DEFAULT_ENDPOINT_SUFFIX = "core.windows.net";
+    private final String azureConnectionString;
+    private final String accountName;
+    private final String containerName;
+    private final String blobEndpoint;
+    private final String sasToken;
+    private final String accountKey;
+    private final String tenantId;
+    private final String clientId;
+    private final String clientSecret;
+    // Cached credential — token cache is per-instance, recreating on every 
SAS call would
+    // force a new OAuth round-trip each time.
+    private final ClientSecretCredential clientSecretCredential;
+    // Cached service client for user-delegation SAS generation — avoids 
allocating a new Netty
+    // event loop and connection pool on every SAS call.
+    private volatile BlobServiceClient cachedBlobServiceClient;
+
+    private AzureBlobContainerProviderV12(Builder builder) {
+        this.azureConnectionString = builder.azureConnectionString;
+        this.accountName = builder.accountName;
+        this.containerName = builder.containerName;
+        this.blobEndpoint = builder.blobEndpoint;
+        this.sasToken = builder.sasToken;
+        this.accountKey = builder.accountKey;
+        this.tenantId = builder.tenantId;
+        this.clientId = builder.clientId;
+        this.clientSecret = builder.clientSecret;
+        this.clientSecretCredential = 
StringUtils.isNoneBlank(builder.clientId, builder.clientSecret, 
builder.tenantId)
+                ? new ClientSecretCredentialBuilder()
+                .clientId(builder.clientId)
+                .clientSecret(builder.clientSecret)
+                .tenantId(builder.tenantId)
+                .build()
+                : null;
+    }
+
+    /**
+     * Constructs the Azure Storage endpoint URL.
+     * If a custom blobEndpoint is configured, it will be used.
+     * Otherwise, constructs the default endpoint using the account name.
+     *
+     * @param accountName        the storage account name
+     * @param customBlobEndpoint optional custom blob endpoint (can be null or 
empty)
+     * @return the endpoint URL to use
+     */
+    @NotNull
+    private static String getEndpointUrl(String accountName, String 
customBlobEndpoint) {
+        if (StringUtils.isNotBlank(customBlobEndpoint)) {
+            // Use custom endpoint (e.g., for private endpoints)
+            // Ensure it starts with https:// if not already present
+            if (!customBlobEndpoint.startsWith("http://";) && 
!customBlobEndpoint.startsWith("https://";)) {

Review Comment:
   we allow http:// passthrough for azurite tests; in production Azure enforces 
HTTPS at the service level. Moving azurite to https is possible but involves 
some extra work, not sure if it is worth:
   - Mounting TLS certs into the container
   - Configuring Netty to trust the self-signed cert across all test setups
   - Updating all three AzuriteDockerRule variants



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to