use of com.azure.storage.blob.sas.BlobContainerSasPermission in project azure-iot-sdk-java by Azure.
the class ExportImportTests method getContainerSasUri.
private static String getContainerSasUri(BlobContainerClient blobContainerClient) {
OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(1);
BlobContainerSasPermission permission = new BlobContainerSasPermission().setReadPermission(true).setAddPermission(true).setCreatePermission(true).setDeletePermission(true).setListPermission(true);
BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(expiryTime, permission).setStartTime(OffsetDateTime.now());
return blobContainerClient.generateSas(values);
}
use of com.azure.storage.blob.sas.BlobContainerSasPermission in project DataSpaceConnector by eclipse-dataspaceconnector.
the class AzureDataFactoryCopyIntegrationTest method setSecret.
private void setSecret(Account account, Vault vault, String secretName) {
// ADF SLA to start an activity is 4 minutes.
var expiryTime = OffsetDateTime.now().plusMinutes(8);
var permission = new BlobContainerSasPermission().setWritePermission(true);
var sasSignatureValues = new BlobServiceSasSignatureValues(expiryTime, permission).setStartTime(OffsetDateTime.now());
var sasToken = account.client.getBlobContainerClient(account.containerName).generateSas(sasSignatureValues);
var edcAzureSas = new AzureSasToken(sasToken, expiryTime.toEpochSecond());
// Set Secret
vault.secretClient().setSecret(secretName, typeManager.writeValueAsString(edcAzureSas)).block(Duration.ofMinutes(1));
// Add for clean up test data
secretCleanup.add(() -> vault.secretClient().beginDeleteSecret(secretName).blockLast(Duration.ofMinutes(1)));
secretCleanup.add(() -> vault.secretClient().purgeDeletedSecret(secretName).block(Duration.ofMinutes(1)));
}
use of com.azure.storage.blob.sas.BlobContainerSasPermission in project DataSpaceConnector by eclipse-dataspaceconnector.
the class BlobStoreApiImpl method createContainerSasToken.
@Override
public String createContainerSasToken(String accountName, String containerName, String permissionSpec, OffsetDateTime expiry) {
BlobContainerSasPermission permissions = BlobContainerSasPermission.parse(permissionSpec);
BlobServiceSasSignatureValues vals = new BlobServiceSasSignatureValues(expiry, permissions);
return getBlobServiceClient(accountName).getBlobContainerClient(containerName).generateSas(vals);
}
use of com.azure.storage.blob.sas.BlobContainerSasPermission in project bulk-scan-processor by hmcts.
the class BlobManager method copyToRejectedContainer.
private void copyToRejectedContainer(BlobClient sourceBlob, BlobClient targetBlob) {
String sasToken = sourceBlob.generateSas(new BlobServiceSasSignatureValues(OffsetDateTime.of(LocalDateTime.now().plus(5, ChronoUnit.MINUTES), ZoneOffset.UTC), new BlobContainerSasPermission().setReadPermission(true)));
var start = System.nanoTime();
SyncPoller<BlobCopyInfo, Void> poller = null;
try {
poller = targetBlob.beginCopy(sourceBlob.getBlobUrl() + "?" + sasToken, META_DATA_MAP, null, null, null, null, Duration.ofSeconds(2));
PollResponse<BlobCopyInfo> pollResponse = poller.waitForCompletion(Duration.ofMinutes(5));
targetBlob.setMetadata(null);
log.info("Moved to rejected container from {}. Poll response: {}, Copy status: {} ,Takes {} second", sourceBlob.getBlobUrl(), pollResponse.getStatus(), pollResponse.getValue().getCopyStatus(), TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - start));
} catch (Exception ex) {
log.error("Copy Error, for {} to rejected container", sourceBlob.getBlobUrl(), ex);
if (poller != null) {
try {
targetBlob.abortCopyFromUrl(poller.poll().getValue().getCopyId());
} catch (Exception exc) {
log.error("Abort Copy From Url got Error, From {} to rejected container", sourceBlob.getBlobUrl(), exc);
}
}
throw ex;
}
}
Aggregations