use of com.microsoft.azure.management.datalake.store.DataLakeStoreAccountManagementClient in project cloudbreak by hortonworks.
the class AzureSetup method validateAdlsFileSystem.
private void validateAdlsFileSystem(CloudCredential credential, FileSystem fileSystem) {
Map<String, Object> credentialAttributes = credential.getParameters();
String clientSecret = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.CREDENTIAL_SECRET_KEY));
String subscriptionId = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.SUBSCRIPTION_ID));
String clientId = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.ACCESS_KEY));
String tenantId = fileSystem.getStringParameter(AdlsFileSystemConfiguration.TENANT_ID);
String accountName = fileSystem.getStringParameter(FileSystemConfiguration.ACCOUNT_NAME);
ApplicationTokenCredentials creds = new ApplicationTokenCredentials(clientId, tenantId, clientSecret, AzureEnvironment.AZURE);
DataLakeStoreAccountManagementClient adlsClient = new DataLakeStoreAccountManagementClientImpl(creds);
adlsClient.withSubscriptionId(subscriptionId);
List<DataLakeStoreAccount> dataLakeStoreAccounts = adlsClient.accounts().list();
boolean validAccountname = false;
for (DataLakeStoreAccount account : dataLakeStoreAccounts) {
if (account.name().equalsIgnoreCase(accountName)) {
validAccountname = true;
break;
}
}
if (!validAccountname) {
throw new CloudConnectorException("The provided file system account name does not belong to a valid ADLS account");
}
}
Aggregations