use of com.azure.storage.common.StorageSharedKeyCredential in project samza by apache.
the class AzureBlobClientBuilder method getBlobServiceAsyncClient.
/**
* method creates BlobServiceAsyncClient using the configs provided earlier.
* if the authentication method is set to {@link TokenCredential} then a {@link com.azure.identity.ClientSecretCredential}
* is created and used for the Blob client. Else authentication is done via account name and key using the
* {@link StorageSharedKeyCredential}.
* The config used to determine which authentication is systems.%s.azureblob.useTokenCredentialAuthentication = true
* for using TokenCredential.
* @return BlobServiceAsyncClient
*/
public BlobServiceAsyncClient getBlobServiceAsyncClient() {
BlobServiceClientBuilder blobServiceClientBuilder = getBlobServiceClientBuilder();
if (azureBlobConfig.getUseTokenCredentialAuthentication(systemName)) {
// Use your Azure Blob Storage account's name and client details to create a token credential object to access your account.
TokenCredential tokenCredential = getTokenCredential();
return blobServiceClientBuilder.credential(tokenCredential).buildAsyncClient();
}
// Use your Azure Blob Storage account's name and key to create a credential object to access your account.
StorageSharedKeyCredential storageSharedKeyCredential = getStorageSharedKeyCredential();
return blobServiceClientBuilder.credential(storageSharedKeyCredential).buildAsyncClient();
}
use of com.azure.storage.common.StorageSharedKeyCredential in project beam by apache.
the class DefaultBlobstoreClientBuilderFactory method createBuilder.
@Override
public BlobServiceClientBuilder createBuilder(BlobstoreOptions blobstoreOptions) {
BlobServiceClientBuilder builder = new BlobServiceClientBuilder();
if (!Strings.isNullOrEmpty(blobstoreOptions.getAzureConnectionString())) {
builder = builder.connectionString(blobstoreOptions.getAzureConnectionString());
}
if (blobstoreOptions.getAzureCredentialsProvider() != null) {
builder = builder.credential(blobstoreOptions.getAzureCredentialsProvider());
}
if (!Strings.isNullOrEmpty(blobstoreOptions.getSasToken())) {
builder = builder.sasToken(blobstoreOptions.getSasToken());
}
if (!Strings.isNullOrEmpty(blobstoreOptions.getAccountName()) && !Strings.isNullOrEmpty(blobstoreOptions.getAccessKey())) {
StorageSharedKeyCredential credential = new StorageSharedKeyCredential(blobstoreOptions.getAccountName(), blobstoreOptions.getAccessKey());
builder = builder.credential(credential);
}
if (!Strings.isNullOrEmpty(blobstoreOptions.getBlobServiceEndpoint())) {
builder = builder.endpoint(blobstoreOptions.getBlobServiceEndpoint());
}
if (blobstoreOptions.getCustomerProvidedKey() != null) {
builder = builder.customerProvidedKey(blobstoreOptions.getCustomerProvidedKey());
}
if (blobstoreOptions.getPipelinePolicy() != null) {
builder = builder.addPolicy(blobstoreOptions.getPipelinePolicy());
}
if (blobstoreOptions.getHttpClient() != null) {
builder = builder.httpClient(blobstoreOptions.getHttpClient());
}
if (blobstoreOptions.getHttpPipeline() != null) {
builder = builder.pipeline(blobstoreOptions.getHttpPipeline());
}
return builder;
}
use of com.azure.storage.common.StorageSharedKeyCredential in project carina by qaprosoft.
the class AzureManager method getInstance.
public static synchronized AzureManager getInstance() {
if (instance == null) {
instance = new AzureManager();
CryptoTool cryptoTool = new CryptoTool(Configuration.get(Configuration.Parameter.CRYPTO_KEY_PATH));
Pattern CRYPTO_PATTERN = Pattern.compile(SpecialKeywords.CRYPT);
String accountName = Configuration.get(Configuration.Parameter.AZURE_ACCOUNT_NAME);
String endpoint = cryptoTool.decryptByPattern(Configuration.get(Configuration.Parameter.AZURE_BLOB_URL), CRYPTO_PATTERN);
String secretKey = cryptoTool.decryptByPattern(Configuration.get(Configuration.Parameter.AZURE_ACCESS_KEY_TOKEN), CRYPTO_PATTERN);
// Create a SharedKeyCredential
StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, secretKey);
// Create a blobServiceClient
blobServiceClient = new BlobServiceClientBuilder().endpoint(endpoint).credential(credential).buildClient();
}
return instance;
}
Aggregations