|
@@ -71,6 +71,13 @@ public class SecureStorageInterfaceImpl extends StorageInterface {
|
|
private String storageAccount;
|
|
private String storageAccount;
|
|
private RetryPolicyFactory retryPolicy;
|
|
private RetryPolicyFactory retryPolicy;
|
|
private int timeoutIntervalInMs;
|
|
private int timeoutIntervalInMs;
|
|
|
|
+ private boolean useContainerSasKeyForAllAccess;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Configuration key to specify if containerSasKey should be used for all accesses
|
|
|
|
+ */
|
|
|
|
+ public static final String KEY_USE_CONTAINER_SASKEY_FOR_ALL_ACCESS =
|
|
|
|
+ "fs.azure.saskey.usecontainersaskeyforallaccess";
|
|
|
|
|
|
public SecureStorageInterfaceImpl(boolean useLocalSASKeyMode,
|
|
public SecureStorageInterfaceImpl(boolean useLocalSASKeyMode,
|
|
Configuration conf) throws SecureModeException {
|
|
Configuration conf) throws SecureModeException {
|
|
@@ -88,6 +95,7 @@ public class SecureStorageInterfaceImpl extends StorageInterface {
|
|
}
|
|
}
|
|
this.sasKeyGenerator = remoteSasKeyGenerator;
|
|
this.sasKeyGenerator = remoteSasKeyGenerator;
|
|
}
|
|
}
|
|
|
|
+ this.useContainerSasKeyForAllAccess = conf.getBoolean(KEY_USE_CONTAINER_SASKEY_FOR_ALL_ACCESS, true);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -145,7 +153,9 @@ public class SecureStorageInterfaceImpl extends StorageInterface {
|
|
if (timeoutIntervalInMs > 0) {
|
|
if (timeoutIntervalInMs > 0) {
|
|
container.getServiceClient().getDefaultRequestOptions().setTimeoutIntervalInMs(timeoutIntervalInMs);
|
|
container.getServiceClient().getDefaultRequestOptions().setTimeoutIntervalInMs(timeoutIntervalInMs);
|
|
}
|
|
}
|
|
- return new SASCloudBlobContainerWrapperImpl(storageAccount, container, sasKeyGenerator);
|
|
|
|
|
|
+ return (useContainerSasKeyForAllAccess)
|
|
|
|
+ ? new SASCloudBlobContainerWrapperImpl(storageAccount, container, null)
|
|
|
|
+ : new SASCloudBlobContainerWrapperImpl(storageAccount, container, sasKeyGenerator);
|
|
} catch (SASKeyGenerationException sasEx) {
|
|
} catch (SASKeyGenerationException sasEx) {
|
|
String errorMsg = "Encountered SASKeyGeneration exception while "
|
|
String errorMsg = "Encountered SASKeyGeneration exception while "
|
|
+ "generating SAS Key for container : " + name
|
|
+ "generating SAS Key for container : " + name
|
|
@@ -226,12 +236,12 @@ public class SecureStorageInterfaceImpl extends StorageInterface {
|
|
public CloudBlobWrapper getBlockBlobReference(String relativePath)
|
|
public CloudBlobWrapper getBlockBlobReference(String relativePath)
|
|
throws URISyntaxException, StorageException {
|
|
throws URISyntaxException, StorageException {
|
|
try {
|
|
try {
|
|
- CloudBlockBlob blob = new CloudBlockBlob(sasKeyGenerator.getRelativeBlobSASUri(
|
|
|
|
- storageAccount, getName(), relativePath));
|
|
|
|
|
|
+ CloudBlockBlob blob = (sasKeyGenerator!=null)
|
|
|
|
+ ? new CloudBlockBlob(sasKeyGenerator.getRelativeBlobSASUri(storageAccount, getName(), relativePath))
|
|
|
|
+ : container.getBlockBlobReference(relativePath);
|
|
blob.getServiceClient().setDefaultRequestOptions(
|
|
blob.getServiceClient().setDefaultRequestOptions(
|
|
container.getServiceClient().getDefaultRequestOptions());
|
|
container.getServiceClient().getDefaultRequestOptions());
|
|
- return new SASCloudBlockBlobWrapperImpl(
|
|
|
|
- blob);
|
|
|
|
|
|
+ return new SASCloudBlockBlobWrapperImpl(blob);
|
|
} catch (SASKeyGenerationException sasEx) {
|
|
} catch (SASKeyGenerationException sasEx) {
|
|
String errorMsg = "Encountered SASKeyGeneration exception while "
|
|
String errorMsg = "Encountered SASKeyGeneration exception while "
|
|
+ "generating SAS Key for relativePath : " + relativePath
|
|
+ "generating SAS Key for relativePath : " + relativePath
|
|
@@ -245,12 +255,13 @@ public class SecureStorageInterfaceImpl extends StorageInterface {
|
|
public CloudBlobWrapper getPageBlobReference(String relativePath)
|
|
public CloudBlobWrapper getPageBlobReference(String relativePath)
|
|
throws URISyntaxException, StorageException {
|
|
throws URISyntaxException, StorageException {
|
|
try {
|
|
try {
|
|
- CloudPageBlob blob = new CloudPageBlob(sasKeyGenerator.getRelativeBlobSASUri(
|
|
|
|
- storageAccount, getName(), relativePath));
|
|
|
|
|
|
+ CloudPageBlob blob = (sasKeyGenerator!=null)
|
|
|
|
+ ? new CloudPageBlob(sasKeyGenerator.getRelativeBlobSASUri(storageAccount, getName(), relativePath))
|
|
|
|
+ : container.getPageBlobReference(relativePath);
|
|
|
|
+
|
|
blob.getServiceClient().setDefaultRequestOptions(
|
|
blob.getServiceClient().setDefaultRequestOptions(
|
|
container.getServiceClient().getDefaultRequestOptions());
|
|
container.getServiceClient().getDefaultRequestOptions());
|
|
- return new SASCloudPageBlobWrapperImpl(
|
|
|
|
- blob);
|
|
|
|
|
|
+ return new SASCloudPageBlobWrapperImpl(blob);
|
|
} catch (SASKeyGenerationException sasEx) {
|
|
} catch (SASKeyGenerationException sasEx) {
|
|
String errorMsg = "Encountered SASKeyGeneration exception while "
|
|
String errorMsg = "Encountered SASKeyGeneration exception while "
|
|
+ "generating SAS Key for relativePath : " + relativePath
|
|
+ "generating SAS Key for relativePath : " + relativePath
|