Skip to content

Commit

Permalink
HADOOP-18516. Style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sreeb-msft committed Dec 8, 2022
1 parent d523e50 commit 6fff60f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,13 @@ public AccessTokenProvider getTokenProvider() throws TokenAccessProviderExceptio
* depending on which one is available. In case a user SASTokenProvider implementation is not present, and a fixed token is configured,
* it simply returns null, to set the sasTokenProvider object for current configuration instance to null.
* The fixed token is read and used later. This is done to:
* 1. check for cases where both are not set, while initializing AbfsConfiguration, to not proceed further than thi stage itself when none of the options are available.
* 2. avoid using similar tokenProvider implementation to just read the configured fixed token, as this could create confusion. The configuration is introduced
* 1. check for cases where both are not set, while initializing AbfsConfiguration,
* to not proceed further than thi stage itself when none of the options are available.
* 2. avoid using similar tokenProvider implementation to just read the configured fixed token,
* as this could create confusion. The configuration is introduced
* primarily to avoid using any tokenProvider class/interface. Also,implementing the SASTokenProvider requires relying on the raw configurations.
* It is more stable to depend on the AbfsConfiguration with which a filesystem is initialized, and eliminate chances of dynamic modifications and spurious situations.
* It is more stable to depend on the AbfsConfiguration with which a filesystem is initialized,
* and eliminate chances of dynamic modifications and spurious situations.
*/

public SASTokenProvider getSASTokenProvider() throws AzureBlobFileSystemException {
Expand All @@ -911,7 +914,7 @@ public SASTokenProvider getSASTokenProvider() throws AzureBlobFileSystemExceptio
String configuredFixedToken = this.rawConfig.get(FS_AZURE_SAS_FIXED_TOKEN, null);

Preconditions.checkArgument(sasTokenProviderImplementation != null || configuredFixedToken != null,
String.format("The configuration value for both \"%s\" and \"%s\" cannot be invalid.", FS_AZURE_SAS_TOKEN_PROVIDER_TYPE, FS_AZURE_SAS_FIXED_TOKEN));
String.format("The value for both \"%s\" and \"%s\" cannot be invalid.", FS_AZURE_SAS_TOKEN_PROVIDER_TYPE, FS_AZURE_SAS_FIXED_TOKEN));

if (sasTokenProviderImplementation != null) {
LOG.trace("Using SASTokenProvider class instead of config although both are available for use");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public void testBothProviderFixedTokenConfigured() throws Exception {
AbfsConfiguration testAbfsConfig = getConfiguration();

// configuring a SASTokenProvider class: this provides a user delegation SAS
// user delegation SAS Provider is set to easily distinguish between results of filesystem level and blob level operations to ensure correct SAS is chosen,
// user delegation SAS Provider is set
// This easily distinguishes between results of filesystem level and blob level operations to ensure correct SAS is chosen,
// when both a provider class and fixed token is configured.
testAbfsConfig.set(FS_AZURE_SAS_TOKEN_PROVIDER_TYPE, "org.apache.hadoop.fs.azurebfs.extensions.MockDelegationSASTokenProvider");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public class AccountSASGenerator extends SASGenerator {
* https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas
* @param accountKey: the storage account key
*/
public AccountSASGenerator(byte[] accountKey) { super(accountKey); }
public AccountSASGenerator(byte[] accountKey) {
super(accountKey);
}

public String getAccountSAS(String accountName) throws AzureBlobFileSystemException {
// retaining only the account name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@
import java.time.Duration;
import java.time.format.DateTimeFormatter;
import java.time.ZoneId;
import java.util.Base64;
import java.util.Locale;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

import org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants;
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidConfigurationValueException;
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidUriException;
import org.apache.hadoop.fs.azurebfs.services.SharedKeyCredentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
Expand Down

0 comments on commit 6fff60f

Please sign in to comment.