-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-17129. Validating storage keys in ABFS correctly #2141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,13 +20,15 @@ | |
|
|
||
| import java.io.IOException; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.azurebfs.AbfsConfiguration; | ||
| import org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.KeyProviderException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidConfigurationValueException; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.apache.hadoop.fs.azurebfs.diagnostics.Base64StringConfigurationBasicValidator; | ||
|
|
||
| /** | ||
| * Key provider that simply returns the storage account key from the | ||
|
|
@@ -49,6 +51,27 @@ public String getStorageAccountKey(String accountName, Configuration rawConfig) | |
| LOG.warn("Unable to get key from credential providers. {}", ioe); | ||
| } | ||
|
|
||
| // Validating the key. | ||
| try { | ||
| validateStorageAccountKey(key); | ||
| } catch (InvalidConfigurationValueException e) { | ||
| e.printStackTrace(); | ||
|
||
| } | ||
|
|
||
| return key; | ||
| } | ||
|
|
||
| /** | ||
| * A method to validate the storage key. | ||
| * | ||
| * @param key the key to be validated. | ||
| * @throws InvalidConfigurationValueException | ||
| */ | ||
| private void validateStorageAccountKey(String key) | ||
| throws InvalidConfigurationValueException { | ||
| Base64StringConfigurationBasicValidator validator = new Base64StringConfigurationBasicValidator( | ||
| ConfigurationKeys.FS_AZURE_ACCOUNT_KEY_PROPERTY_NAME, "", true); | ||
|
|
||
| validator.validate(key); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.