Search in sources :

Example 1 with KeyProviderException

use of org.apache.hadoop.fs.azure.KeyProviderException in project kylo by Teradata.

the class AzureNativeFileSystemProvider method getCredentials.

@Nullable
private StorageCredentials getCredentials(@Nonnull final URI uri, @Nonnull final Configuration conf) {
    // Find account name
    final String accountName = uri.getHost();
    if (StringUtils.isEmpty(accountName)) {
        throw new CatalogException("catalog.fs.azure.missingAccountName");
    }
    // Find account key
    final String accountKey;
    try {
        accountKey = AzureNativeFileSystemStore.getAccountKeyFromConfiguration(accountName, conf);
    } catch (final KeyProviderException e) {
        throw new CatalogException("catalog.fs.azure.invalidAccountKey");
    }
    // Create credentials
    if (StringUtils.isNotEmpty(accountKey)) {
        final String rawAccountName = accountName.split("\\.")[0];
        return new StorageCredentialsAccountAndKey(rawAccountName, accountKey);
    } else {
        return null;
    }
}
Also used : CatalogException(com.thinkbiganalytics.kylo.catalog.CatalogException) StorageCredentialsAccountAndKey(com.microsoft.azure.storage.StorageCredentialsAccountAndKey) KeyProviderException(org.apache.hadoop.fs.azure.KeyProviderException) Nullable(javax.annotation.Nullable)

Aggregations

StorageCredentialsAccountAndKey (com.microsoft.azure.storage.StorageCredentialsAccountAndKey)1 CatalogException (com.thinkbiganalytics.kylo.catalog.CatalogException)1 Nullable (javax.annotation.Nullable)1 KeyProviderException (org.apache.hadoop.fs.azure.KeyProviderException)1