Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public Builder withClientSecret(String clientSecret) {

public Builder initializeWithProperties(Properties properties) {
withAzureConnectionString(properties.getProperty(AzureConstants.AZURE_CONNECTION_STRING, ""));
withAccountName(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, ""));
withAccountName(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, ""));
withBlobEndpoint(properties.getProperty(AzureConstants.AZURE_BLOB_ENDPOINT, ""));
withSasToken(properties.getProperty(AzureConstants.AZURE_SAS, ""));
withAccountKey(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public void init() throws DataStoreException {
private void initAzureDSConfig() {
AzureBlobContainerProvider.Builder builder = AzureBlobContainerProvider.Builder.builder(properties.getProperty(AzureConstants.AZURE_BLOB_CONTAINER_NAME))
.withAzureConnectionString(properties.getProperty(AzureConstants.AZURE_CONNECTION_STRING, ""))
.withAccountName(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, ""))
.withAccountName(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, ""))
.withBlobEndpoint(properties.getProperty(AzureConstants.AZURE_BLOB_ENDPOINT, ""))
.withSasToken(properties.getProperty(AzureConstants.AZURE_SAS, ""))
.withAccountKey(properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, ""))
Expand Down Expand Up @@ -1105,7 +1105,7 @@ record = new AzureBlobStoreDataRecord(
}

private String getDefaultBlobStorageDomain() {
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "");
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "");
if (StringUtils.isEmpty(accountName)) {
LOG.warn("Can't generate presigned URI - Azure account name not found in properties");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
package org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage;

public final class AzureConstants {
/**
* Azure storage access key
*/
public static final String AZURE_STORAGE_ACCESS_KEY = "accessKey";

/**
* Azure storage account name
*/
public static final String AZURE_STORAGE_ACCOUNT_NAME = "accessKey";
public static final String AZURE_STORAGE_ACCOUNT_NAME = "accountName";

/**
* Azure storage account key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static String getConnectionStringFromProperties(Properties properties) {
String sasUri = properties.getProperty(AzureConstants.AZURE_SAS, "");
String blobEndpoint = properties.getProperty(AzureConstants.AZURE_BLOB_ENDPOINT, "");
String connectionString = properties.getProperty(AzureConstants.AZURE_CONNECTION_STRING, "");
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "");
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "");
String accountKey = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, "");

if (!connectionString.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private Properties getPropertiesWithServicePrincipals() {
final String clientSecret = getEnvironmentVariable(AZURE_CLIENT_SECRET);

Properties properties = new Properties();
properties.setProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, accountName);
properties.setProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, accountName);
properties.setProperty(AzureConstants.AZURE_TENANT_ID, tenantId);
properties.setProperty(AzureConstants.AZURE_CLIENT_ID, clientId);
properties.setProperty(AzureConstants.AZURE_CLIENT_SECRET, clientSecret);
Expand Down Expand Up @@ -221,7 +221,7 @@ private static Properties getConfigurationWithConnectionString() {
private static Properties getBasicConfiguration() {
Properties properties = new Properties();
properties.setProperty(AzureConstants.AZURE_BLOB_CONTAINER_NAME, CONTAINER_NAME);
properties.setProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, AzuriteDockerRule.ACCOUNT_NAME);
properties.setProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, AzuriteDockerRule.ACCOUNT_NAME);
properties.setProperty(AzureConstants.AZURE_BLOB_ENDPOINT, azurite.getBlobEndpoint());
properties.setProperty(AzureConstants.AZURE_CREATE_CONTAINER, "");
return properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void testVetoDownloadDomainOverride() throws Exception {
assertNotEquals(DOWNLOAD_URI_DOMAIN, downloadUri.getHost());

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

Properties properties = AzureDataStoreUtils.getDirectAccessDataStoreProperties();
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, null);
String accountName = properties.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY, null);
assertNotNull(accountName);
String defaultDomain = String.format("%s.blob.core.windows.net", accountName);
for (URI uri : upload.getUploadURIs()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public class AzureDataStoreUtils extends DataStoreUtils {
public static boolean isAzureConfigured() {
Properties props = getAzureConfig();
//need either access keys or sas or service principal
if (!props.containsKey(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY) || !props.containsKey(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME)
if (!props.containsKey(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY) || !props.containsKey(AzureConstants.AZURE_STORAGE_ACCESS_KEY)
|| !(props.containsKey(AzureConstants.AZURE_BLOB_CONTAINER_NAME))) {
if (!props.containsKey(AzureConstants.AZURE_SAS) || !props.containsKey(AzureConstants.AZURE_BLOB_ENDPOINT)
|| !(props.containsKey(AzureConstants.AZURE_BLOB_CONTAINER_NAME))) {
// service principal
return props.containsKey(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME) && props.containsKey(AzureConstants.AZURE_TENANT_ID) &&
return props.containsKey(AzureConstants.AZURE_STORAGE_ACCESS_KEY) && props.containsKey(AzureConstants.AZURE_TENANT_ID) &&
props.containsKey(AzureConstants.AZURE_CLIENT_ID) && props.containsKey(AzureConstants.AZURE_CLIENT_SECRET) &&
props.containsKey(AzureConstants.AZURE_BLOB_CONTAINER_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testConnectionStringIsBasedOnSAS() {
public void testConnectionStringIsBasedOnSASWithoutEndpoint() {
Properties properties = new Properties();
properties.put(AzureConstants.AZURE_SAS, "sas");
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "account");
properties.put(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "account");
String connectionString = Utils.getConnectionStringFromProperties(properties);
assertEquals(connectionString,
String.format("AccountName=%s;SharedAccessSignature=%s", "account", "sas"));
Expand All @@ -55,7 +55,7 @@ public void testConnectionStringIsBasedOnSASWithoutEndpoint() {
@Test
public void testConnectionStringIsBasedOnAccessKeyIfSASMissing() {
Properties properties = new Properties();
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "accessKey");
properties.put(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "accessKey");
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, "secretKey");

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

properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, "accessKey");
properties.put(AzureConstants.AZURE_STORAGE_ACCESS_KEY, "accessKey");
properties.put(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, "secretKey");

String connectionString = Utils.getConnectionStringFromProperties(properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private static CloudBlobContainer getCloudBlobContainer(@NotNull Map<String, ?>
final String clientId = (String) config.get(AzureConstants.AZURE_CLIENT_ID);
final String clientSecret = (String) config.get(AzureConstants.AZURE_CLIENT_SECRET);
final String tenantId = (String) config.get(AzureConstants.AZURE_TENANT_ID);
final String accountName = (String) config.get(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME);
final String accountName = (String) config.get(AzureConstants.AZURE_STORAGE_ACCESS_KEY);
final String accountKey = (String) config.get(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY);
final String blobEndpoint = (String) config.get(AzureConstants.AZURE_BLOB_ENDPOINT);
final String sasToken = (String) config.get(AzureConstants.AZURE_SAS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private String getEnvironmentVariable(String variableName) {
String tenantId) {
Map<String, String> config = new HashMap<>();
config.put(AzureConstants.AZURE_CONNECTION_STRING, connectionString);
config.put(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME, accountName);
config.put(AzureConstants.AZURE_STORAGE_ACCESS_KEY, accountName);
config.put(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY, accessKey);
config.put(AzureConstants.AZURE_BLOB_ENDPOINT, blobEndpoint);
config.put(AzureConstants.AZURE_CLIENT_ID, clientId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ class AzureSegmentStoreFixture extends SegmentStoreFixture {

@Override public NodeStore init(DataStoreBlobStore blobStore, File storeFile) throws Exception {
Properties props = AzureDataStoreUtils.getAzureConfig();
String accessKey = props.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME);
String accessKey = props.getProperty(AzureConstants.AZURE_STORAGE_ACCESS_KEY);
String secretKey = props.getProperty(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY);
container = props.getProperty(AzureConstants.AZURE_BLOB_CONTAINER_NAME);
container = container + System.currentTimeMillis();
Expand Down
Loading