Search in sources :

Example 1 with StorageCredentialsSharedAccessSignature

use of com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature in project hadoop by apache.

the class LocalSASKeyGeneratorImpl method getSASKeyBasedStorageAccountInstance.

/**
   * Helper method that creates a CloudStorageAccount instance based on
   *  SAS key for accountName
   *
   * @param accountName Storage Account Name
   * @return CloudStorageAccount instance created using SAS key for
   *   the Storage Account.
   * @throws SASKeyGenerationException
   */
private CloudStorageAccount getSASKeyBasedStorageAccountInstance(String accountName) throws SASKeyGenerationException {
    try {
        String accountNameWithoutDomain = getAccountNameWithoutDomain(accountName);
        CloudStorageAccount account = getStorageAccountInstance(accountNameWithoutDomain, AzureNativeFileSystemStore.getAccountKeyFromConfiguration(accountName, getConf()));
        return new CloudStorageAccount(new StorageCredentialsSharedAccessSignature(account.generateSharedAccessSignature(getDefaultAccountAccessPolicy())), false, account.getEndpointSuffix(), accountNameWithoutDomain);
    } catch (KeyProviderException keyProviderEx) {
        throw new SASKeyGenerationException("Encountered KeyProviderException" + " while retrieving Storage key from configuration for account " + accountName, keyProviderEx);
    } catch (InvalidKeyException invalidKeyEx) {
        throw new SASKeyGenerationException("Encoutered InvalidKeyException " + "while generating Account level SAS key for account" + accountName, invalidKeyEx);
    } catch (StorageException storeEx) {
        throw new SASKeyGenerationException("Encoutered StorageException while " + "generating Account level SAS key for account" + accountName, storeEx);
    } catch (URISyntaxException uriSyntaxEx) {
        throw new SASKeyGenerationException("Encountered URISyntaxException for" + " account " + accountName, uriSyntaxEx);
    }
}
Also used : StorageCredentialsSharedAccessSignature(com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) URISyntaxException(java.net.URISyntaxException) InvalidKeyException(java.security.InvalidKeyException) StorageException(com.microsoft.azure.storage.StorageException)

Example 2 with StorageCredentialsSharedAccessSignature

use of com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature in project hadoop by apache.

the class AzureNativeFileSystemStore method connectUsingSASCredentials.

/**
   * Connect to Azure storage using shared access signature credentials.
   */
private void connectUsingSASCredentials(final String accountName, final String containerName, final String sas) throws InvalidKeyException, StorageException, IOException, URISyntaxException {
    StorageCredentials credentials = new StorageCredentialsSharedAccessSignature(sas);
    connectingUsingSAS = true;
    connectUsingCredentials(accountName, credentials, containerName);
}
Also used : StorageCredentialsSharedAccessSignature(com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature) StorageCredentials(com.microsoft.azure.storage.StorageCredentials)

Aggregations

StorageCredentialsSharedAccessSignature (com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature)2 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)1 StorageCredentials (com.microsoft.azure.storage.StorageCredentials)1 StorageException (com.microsoft.azure.storage.StorageException)1 URISyntaxException (java.net.URISyntaxException)1 InvalidKeyException (java.security.InvalidKeyException)1