Skip to content

Commit 6dc4498

Browse files
committed
OAK-11608 Fix AzureConstants.java
1 parent 01179a5 commit 6dc4498

File tree

11 files changed

+22
-17
lines changed

11 files changed

+22
-17
lines changed

oak-blob-cloud-azure/src/main/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobContainerProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public Builder withClientSecret(String clientSecret) {
152152

153153
public Builder initializeWithProperties(Properties properties) {
154154
withAzureConnectionString(properties.getProperty(AzureConstants.AZURE_CONNECTION_STRING, ""));
155-
withAccountName(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, ""));
155+
withAccountName(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, ""));
156156
withBlobEndpoint(properties.getProperty(AzureConstants.AZURE_BLOB_ENDPOINT, ""));
157157
withSasToken(properties.getProperty(AzureConstants.AZURE_SAS, ""));
158158
withAccountKey(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, ""));

oak-blob-cloud-azure/src/main/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobStoreBackend.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public void init() throws DataStoreException {
260260
private void initAzureDSConfig() {
261261
AzureBlobContainerProvider.Builder builder = AzureBlobContainerProvider.Builder.builder(properties.getProperty(AzureConstants.AZURE_BLOB_CONTAINER_NAME))
262262
.withAzureConnectionString(properties.getProperty(AzureConstants.AZURE_CONNECTION_STRING, ""))
263-
.withAccountName(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, ""))
263+
.withAccountName(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, ""))
264264
.withBlobEndpoint(properties.getProperty(AzureConstants.AZURE_BLOB_ENDPOINT, ""))
265265
.withSasToken(properties.getProperty(AzureConstants.AZURE_SAS, ""))
266266
.withAccountKey(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, ""))
@@ -1105,7 +1105,7 @@ record = new AzureBlobStoreDataRecord(
11051105
}
11061106

11071107
private String getDefaultBlobStorageDomain() {
1108-
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "");
1108+
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "");
11091109
if (StringUtils.isEmpty(accountName)) {
11101110
LOG.warn("Can't generate presigned URI - Azure account name not found in properties");
11111111
return null;

oak-blob-cloud-azure/src/main/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureConstants.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@
2020
package org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage;
2121

2222
public final class AzureConstants {
23+
/**
24+
* Azure storage access key
25+
*/
26+
public static final String AZURE_STORAGE_ACCESS_KEY = "accessKey";
27+
2328
/**
2429
* Azure storage account name
2530
*/
26-
public static final String AZURE_STORAGE_ACCOUNT_NAME = "accessKey";
31+
public static final String AZURE_STORAGE_ACCOUNT_NAME = "accountName";
2732

2833
/**
2934
* Azure storage account key

oak-blob-cloud-azure/src/main/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static String getConnectionStringFromProperties(Properties properties) {
127127
String sasUri = properties.getProperty(AzureConstants.AZURE_SAS, "");
128128
String blobEndpoint = properties.getProperty(AzureConstants.AZURE_BLOB_ENDPOINT, "");
129129
String connectionString = properties.getProperty(AzureConstants.AZURE_CONNECTION_STRING, "");
130-
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "");
130+
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "");
131131
String accountKey = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, "");
132132

133133
if (!connectionString.isEmpty()) {

oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureBlobStoreBackendTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private Properties getPropertiesWithServicePrincipals() {
176176
final String clientSecret = getEnvironmentVariable(AZURE_CLIENT_SECRET);
177177

178178
Properties properties = new Properties();
179-
properties.setProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, accountName);
179+
properties.setProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, accountName);
180180
properties.setProperty(AzureConstants.AZURE_TENANT_ID, tenantId);
181181
properties.setProperty(AzureConstants.AZURE_CLIENT_ID, clientId);
182182
properties.setProperty(AzureConstants.AZURE_CLIENT_SECRET, clientSecret);
@@ -221,7 +221,7 @@ private static Properties getConfigurationWithConnectionString() {
221221
private static Properties getBasicConfiguration() {
222222
Properties properties = new Properties();
223223
properties.setProperty(AzureConstants.AZURE_BLOB_CONTAINER_NAME, CONTAINER_NAME);
224-
properties.setProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, AzuriteDockerRule.ACCOUNT_NAME);
224+
properties.setProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, AzuriteDockerRule.ACCOUNT_NAME);
225225
properties.setProperty(AzureConstants.AZURE_BLOB_ENDPOINT, azurite.getBlobEndpoint());
226226
properties.setProperty(AzureConstants.AZURE_CREATE_CONTAINER, "");
227227
return properties;

oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureDataRecordAccessProviderCDNTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void testVetoDownloadDomainOverride() throws Exception {
137137
assertNotEquals(DOWNLOAD_URI_DOMAIN, downloadUri.getHost());
138138

139139
Properties properties = AzureDataStoreUtils.getDirectAccessDataStoreProperties();
140-
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, null);
140+
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, null);
141141
assertNotNull(accountName);
142142
assertEquals(String.format("%s.blob.core.windows.net", accountName), downloadUri.getHost());
143143
}
@@ -151,7 +151,7 @@ public void testVetoUploadDomainOverride() throws Exception {
151151
assertTrue(upload.getUploadURIs().size() > 0);
152152

153153
Properties properties = AzureDataStoreUtils.getDirectAccessDataStoreProperties();
154-
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, null);
154+
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, null);
155155
assertNotNull(accountName);
156156
String defaultDomain = String.format("%s.blob.core.windows.net", accountName);
157157
for (URI uri : upload.getUploadURIs()) {

oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/AzureDataStoreUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ public class AzureDataStoreUtils extends DataStoreUtils {
6565
public static boolean isAzureConfigured() {
6666
Properties props = getAzureConfig();
6767
//need either access keys or sas or service principal
68-
if (!props.containsKey(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY) || !props.containsKey(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME)
68+
if (!props.containsKey(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY) || !props.containsKey(AzureConstants.AZURE_STORAGE_ACCESS_KEY)
6969
|| !(props.containsKey(AzureConstants.AZURE_BLOB_CONTAINER_NAME))) {
7070
if (!props.containsKey(AzureConstants.AZURE_SAS) || !props.containsKey(AzureConstants.AZURE_BLOB_ENDPOINT)
7171
|| !(props.containsKey(AzureConstants.AZURE_BLOB_CONTAINER_NAME))) {
7272
// service principal
73-
return props.containsKey(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME) && props.containsKey(AzureConstants.AZURE_TENANT_ID) &&
73+
return props.containsKey(AzureConstants.AZURE_STORAGE_ACCESS_KEY) && props.containsKey(AzureConstants.AZURE_TENANT_ID) &&
7474
props.containsKey(AzureConstants.AZURE_CLIENT_ID) && props.containsKey(AzureConstants.AZURE_CLIENT_SECRET) &&
7575
props.containsKey(AzureConstants.AZURE_BLOB_CONTAINER_NAME);
7676
}

oak-blob-cloud-azure/src/test/java/org/apache/jackrabbit/oak/blob/cloud/azure/blobstorage/UtilsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void testConnectionStringIsBasedOnSAS() {
4646
public void testConnectionStringIsBasedOnSASWithoutEndpoint() {
4747
Properties properties = new Properties();
4848
properties.put(AzureConstants.AZURE_SAS, "sas");
49-
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "account");
49+
properties.put(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "account");
5050
String connectionString = Utils.getConnectionStringFromProperties(properties);
5151
assertEquals(connectionString,
5252
String.format("AccountName=%s;SharedAccessSignature=%s", "account", "sas"));
@@ -55,7 +55,7 @@ public void testConnectionStringIsBasedOnSASWithoutEndpoint() {
5555
@Test
5656
public void testConnectionStringIsBasedOnAccessKeyIfSASMissing() {
5757
Properties properties = new Properties();
58-
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "accessKey");
58+
properties.put(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "accessKey");
5959
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, "secretKey");
6060

6161
String connectionString = Utils.getConnectionStringFromProperties(properties);
@@ -69,7 +69,7 @@ public void testConnectionStringSASIsPriority() {
6969
properties.put(AzureConstants.AZURE_SAS, "sas");
7070
properties.put(AzureConstants.AZURE_BLOB_ENDPOINT, "endpoint");
7171

72-
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "accessKey");
72+
properties.put(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "accessKey");
7373
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, "secretKey");
7474

7575
String connectionString = Utils.getConnectionStringFromProperties(properties);

oak-run-commons/src/main/java/org/apache/jackrabbit/oak/fixture/DataStoreUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private static CloudBlobContainer getCloudBlobContainer(@NotNull Map<String, ?>
177177
final String clientId = (String) config.get(AzureConstants.AZURE_CLIENT_ID);
178178
final String clientSecret = (String) config.get(AzureConstants.AZURE_CLIENT_SECRET);
179179
final String tenantId = (String) config.get(AzureConstants.AZURE_TENANT_ID);
180-
final String accountName = (String) config.get(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME);
180+
final String accountName = (String) config.get(AzureConstants.AZURE_STORAGE_ACCESS_KEY);
181181
final String accountKey = (String) config.get(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY);
182182
final String blobEndpoint = (String) config.get(AzureConstants.AZURE_BLOB_ENDPOINT);
183183
final String sasToken = (String) config.get(AzureConstants.AZURE_SAS);

oak-run-commons/src/test/java/org/apache/jackrabbit/oak/fixture/DataStoreUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private String getEnvironmentVariable(String variableName) {
233233
String tenantId) {
234234
Map<String, String> config = new HashMap<>();
235235
config.put(AzureConstants.AZURE_CONNECTION_STRING, connectionString);
236-
config.put(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, accountName);
236+
config.put(AzureConstants.AZURE_STORAGE_ACCESS_KEY, accountName);
237237
config.put(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, accessKey);
238238
config.put(AzureConstants.AZURE_BLOB_ENDPOINT, blobEndpoint);
239239
config.put(AzureConstants.AZURE_CLIENT_ID, clientId);

0 commit comments

Comments
 (0)