-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-17912. ABFS: Support for Encryption Context #3440
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 53 commits
9dc24eb
bd579f2
59d171f
538820e
09c0fbb
10adf42
84df4a2
7365d82
ffb4764
31f4c0f
af6cd1d
2ad36d3
0e19fd4
4dc1601
8998bc0
8357830
8035ed7
3bf75c3
fdc3149
a3559a3
99cf2bd
f6bb16f
ae6fce6
04a73e0
d96e08d
fb75454
ac6ff51
3caeb7b
a2fc26e
b840da3
72b5f2f
66eb217
1721d43
15a0ce8
2f2947c
16973d4
c27c28d
0e700ca
4164ee2
6c05dac
cd7d055
926e7d9
af5e90b
9505ed9
f3abbb9
a3d31f1
5842b28
1f1d9d1
4f86224
873b3fe
e8c1fb5
ae2d065
4f1e33b
8806ceb
ef092dd
fec93f4
c2d35d8
1e987a5
6364cfb
a1b1906
d35a276
450324a
183f1bc
d0a16bd
a69ee4a
061930b
00bd8c3
a642ef3
56f3efa
adc82f6
241fb9b
9daea68
2313790
aee1c7b
bb45ae9
3c6eddb
a231592
6ab375c
aaf1582
f9658e0
4002da6
1990a48
a2472d5
95b0f9d
0cd8c8c
b718b3c
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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| .checkstyle | ||
| bin/ | ||
| src/test/resources/combinationConfigFiles | ||
| src/test/resources/accountSettings | ||
| src/test/resources/abfs-combination-test-configs.xml | ||
| dev-support/testlogs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| import java.io.IOException; | ||
| import java.lang.reflect.Field; | ||
|
|
||
| import org.apache.hadoop.fs.azurebfs.extensions.EncryptionContextProvider; | ||
| import org.apache.hadoop.classification.VisibleForTesting; | ||
| import org.apache.hadoop.util.Preconditions; | ||
|
|
||
|
|
@@ -311,6 +312,9 @@ public class AbfsConfiguration{ | |
| FS_AZURE_ENABLE_ABFS_LIST_ITERATOR, DefaultValue = DEFAULT_ENABLE_ABFS_LIST_ITERATOR) | ||
| private boolean enableAbfsListIterator; | ||
|
|
||
| private String clientProvidedEncryptionKey; | ||
| private String clientProvidedEncryptionKeySHA; | ||
|
|
||
| public AbfsConfiguration(final Configuration rawConfig, String accountName) | ||
| throws IllegalAccessException, InvalidConfigurationValueException, IOException { | ||
| this.rawConfig = ProviderUtils.excludeIncompatibleCredentialProviders( | ||
|
|
@@ -915,6 +919,32 @@ public SASTokenProvider getSASTokenProvider() throws AzureBlobFileSystemExceptio | |
| } | ||
| } | ||
|
|
||
| public EncryptionContextProvider createEncryptionContextProvider() { | ||
|
|
||
| try { | ||
| String configKey = FS_AZURE_ENCRYPTION_CONTEXT_PROVIDER_TYPE; | ||
| if (get(configKey) == null) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this config be strictly per account? Else it might cause problems with instantiating a file system with no intend to use encryption. It will try to create a provider for it anyway. Or am I missing something?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, keeping it account-agnostic would cause other accounts to instantiate EncryptionContextProvider (ECP) as well. Have made the provider config account-specific. However, each account that uses ECP will need to have its own account-specific entry in the config file |
||
| return null; | ||
| } | ||
| Class<? extends EncryptionContextProvider> encryptionContextClass = | ||
| getAccountSpecificClass(configKey, null, EncryptionContextProvider.class); | ||
| Preconditions.checkArgument(encryptionContextClass != null, String.format( | ||
| "The configuration value for %s is invalid, or config key is not account-specific", | ||
| configKey)); | ||
|
|
||
| EncryptionContextProvider encryptionContextProvider = | ||
| ReflectionUtils.newInstance(encryptionContextClass, rawConfig); | ||
| Preconditions.checkArgument(encryptionContextProvider != null, | ||
| String.format("Failed to initialize %s", encryptionContextClass)); | ||
|
|
||
| LOG.trace("{} init complete", encryptionContextClass.getName()); | ||
| return encryptionContextProvider; | ||
| } catch (Exception e) { | ||
| throw new IllegalArgumentException("Unable to load encryption context provider class: ", e); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public int getReadAheadRange() { | ||
| return this.readAheadRange; | ||
| } | ||
|
|
@@ -1017,9 +1047,22 @@ public boolean enableAbfsListIterator() { | |
| return this.enableAbfsListIterator; | ||
| } | ||
|
|
||
| public String getClientProvidedEncryptionKey() { | ||
| String accSpecEncKey = accountConf(FS_AZURE_CLIENT_PROVIDED_ENCRYPTION_KEY); | ||
| return rawConfig.get(accSpecEncKey, null); | ||
| public String getEncodedClientProvidedEncryptionKey() { | ||
| if (clientProvidedEncryptionKey == null) { | ||
| String accSpecEncKey = accountConf( | ||
| FS_AZURE_ENCRYPTION_ENCODED_CLIENT_PROVIDED_KEY); | ||
| clientProvidedEncryptionKey = rawConfig.get(accSpecEncKey, null); | ||
| } | ||
| return clientProvidedEncryptionKey; | ||
| } | ||
|
|
||
| public String getEncodedClientProvidedEncryptionKeySHA() { | ||
| if (clientProvidedEncryptionKeySHA == null) { | ||
| String accSpecEncKey = accountConf( | ||
| FS_AZURE_ENCRYPTION_ENCODED_CLIENT_PROVIDED_KEY_SHA); | ||
| clientProvidedEncryptionKeySHA = rawConfig.get(accSpecEncKey, null); | ||
| } | ||
| return clientProvidedEncryptionKeySHA; | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move down to line 46
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have fixed it.