Re: [PR] Issues/oak 10781 [jackrabbit-oak]

2024-06-18 Thread via GitHub


amit-jain merged PR #1518:
URL: https://github.com/apache/jackrabbit-oak/pull/1518


-- 
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: oak-dev-unsubscr...@jackrabbit.apache.org

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



Re: [PR] Issues/oak 10781 [jackrabbit-oak]

2024-06-18 Thread via GitHub


nit0906 commented on code in PR #1518:
URL: https://github.com/apache/jackrabbit-oak/pull/1518#discussion_r1644093746


##
oak-blob-cloud-azure/src/main/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobContainerProvider.java:
##
@@ -205,19 +212,33 @@ private CloudBlobContainer 
getBlobContainerFromServicePrincipals(@Nullable BlobR
 
 @NotNull
 private StorageCredentialsToken getStorageCredentials() {
-ClientSecretCredential clientSecretCredential = new 
ClientSecretCredentialBuilder()
-.clientId(clientId)
-.clientSecret(clientSecret)
-.tenantId(tenantId)
-.build();
-AccessToken accessToken = clientSecretCredential.getTokenSync(new 
TokenRequestContext().addScopes(AZURE_DEFAULT_SCOPE));
-if (accessToken == null || 
StringUtils.isBlank(accessToken.getToken())) {
-log.error("Access token is null or empty");
-throw new IllegalArgumentException("Could not connect to azure 
storage, access token is null or empty");
+boolean isAccessTokenGenerated = false;
+/* generate access token, the same token will be used for subsequent 
access
+ * generated token is valid for 1 hour only and will be refreshed in 
background
+ * */
+if (accessToken == null) {
+clientSecretCredential = new ClientSecretCredentialBuilder()
+.clientId(clientId)
+.clientSecret(clientSecret)
+.tenantId(tenantId)
+.build();
+accessToken = clientSecretCredential.getTokenSync(new 
TokenRequestContext().addScopes(AZURE_DEFAULT_SCOPE));
+if (accessToken == null || 
StringUtils.isBlank(accessToken.getToken())) {
+log.error("Access token is null or empty");
+throw new IllegalArgumentException("Could not connect to azure 
storage, access token is null or empty");
+}
+storageCredentialsToken = new StorageCredentialsToken(accountName, 
accessToken.getToken());
+isAccessTokenGenerated = true;
+}
+
+Objects.requireNonNull(storageCredentialsToken, "storage credentials 
token cannot be null");
+
+// start refresh token executor only when the access token is first 
generated
+if (isAccessTokenGenerated) {
+log.info("starting refresh token task at: {}", 
OffsetDateTime.now());
+TokenRefresher tokenRefresher = new TokenRefresher();
+executorService.scheduleWithFixedDelay(tokenRefresher, 
TOKEN_REFRESHER_INITIAL_DELAY, TOKEN_REFRESHER_DELAY, TimeUnit.MINUTES);

Review Comment:
   Can you add a comment here describing why the 1 minute delay is needed.



-- 
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: oak-dev-unsubscr...@jackrabbit.apache.org

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



Re: [PR] Issues/oak 10781 [jackrabbit-oak]

2024-06-14 Thread via GitHub


reschke commented on PR #1518:
URL: https://github.com/apache/jackrabbit-oak/pull/1518#issuecomment-2167737652

   when merging please make sure to squash and to have the JIRA ticket properly 
in the commit message


-- 
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: oak-dev-unsubscr...@jackrabbit.apache.org

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