Copilot commented on code in PR #9237:
URL: https://github.com/apache/gravitino/pull/9237#discussion_r2559689062
##########
bundles/azure/src/main/java/org/apache/gravitino/abs/credential/ADLSTokenProvider.java:
##########
@@ -69,69 +37,7 @@ public String credentialType() {
}
@Override
- public Credential getCredential(CredentialContext context) {
- if (!(context instanceof PathBasedCredentialContext)) {
- return null;
- }
- PathBasedCredentialContext pathBasedCredentialContext =
(PathBasedCredentialContext) context;
-
- Set<String> writePaths = pathBasedCredentialContext.getWritePaths();
- Set<String> readPaths = pathBasedCredentialContext.getReadPaths();
-
- Set<String> combinedPaths = new HashSet<>(writePaths);
- combinedPaths.addAll(readPaths);
-
- if (combinedPaths.size() != 1) {
- throw new IllegalArgumentException(
- "ADLS should contain exactly one unique path, but found: "
- + combinedPaths.size()
- + " paths: "
- + combinedPaths);
- }
- String uniquePath = combinedPaths.iterator().next();
-
- ClientSecretCredential clientSecretCredential =
- new ClientSecretCredentialBuilder()
- .tenantId(tenantId)
- .clientId(clientId)
- .clientSecret(clientSecret)
- .build();
-
- DataLakeServiceClient dataLakeServiceClient =
- new DataLakeServiceClientBuilder()
- .endpoint(endpoint)
- .credential(clientSecretCredential)
- .buildClient();
-
- OffsetDateTime start = OffsetDateTime.now();
- OffsetDateTime expiry = OffsetDateTime.now().plusSeconds(tokenExpireSecs);
- UserDelegationKey userDelegationKey =
dataLakeServiceClient.getUserDelegationKey(start, expiry);
-
- PathSasPermission pathSasPermission =
- new
PathSasPermission().setReadPermission(true).setListPermission(true);
-
- if (!writePaths.isEmpty()) {
- pathSasPermission
- .setWritePermission(true)
- .setDeletePermission(true)
- .setCreatePermission(true)
- .setAddPermission(true);
- }
-
- DataLakeServiceSasSignatureValues signatureValues =
- new DataLakeServiceSasSignatureValues(expiry, pathSasPermission);
-
- ADLSLocationUtils.ADLSLocationParts locationParts =
ADLSLocationUtils.parseLocation(uniquePath);
- String sasToken =
- new DataLakeSasImplUtil(
- signatureValues,
- locationParts.getContainer(),
- ADLSLocationUtils.trimSlashes(locationParts.getPath()),
- true)
- .generateUserDelegationSas(
- userDelegationKey, locationParts.getAccountName(),
Context.NONE);
-
- return new ADLSTokenCredential(
- locationParts.getAccountName(), sasToken,
expiry.toInstant().toEpochMilli());
+ public String getGeneratorClassName() {
+ return "org.apache.gravitino.abs.credential.ADLSTokenProvider";
Review Comment:
The generator class name should be `ADLSTokenGenerator` (as implemented in
the new file) but it's incorrectly set to `ADLSTokenProvider`. This will cause
a `ClassNotFoundException` when the delegator tries to load the generator via
reflection.
```suggestion
return "org.apache.gravitino.abs.credential.ADLSTokenGenerator";
```
--
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]