Commit 34ae8143 authored by Erik Leckner's avatar Erik Leckner
Browse files

file-azure

parent 00772def
......@@ -58,7 +58,7 @@ public class FileLocationRepository implements IFileLocationRepository {
log.info("Saving file location : {}", fileLocation);
FileLocationEntity saved = fileLocationEntityRepository
.save(fileLocationMapper.toEntity(fileLocation));
log.info("Fetch saved file location : {}", saved);
log.debug("Fetch saved file location : {}", saved);
return fileLocationMapper.toFileLocation(saved);
}
......
......@@ -42,7 +42,7 @@ import javax.inject.Inject;
public class StorageRepository implements IStorageRepository {
@Inject
final Storage storage;
private Storage storage;
private String storageAccount = getStorageAccount();
......@@ -59,7 +59,6 @@ public class StorageRepository implements IStorageRepository {
.build();
Blob blob = storage.create(blobInfo, ArrayUtils.EMPTY_BYTE_ARRAY);
log.debug("Created the blob in container {} for path {}", containerName, filepath);
System.out.println(String.format("Created the blob in container %s for path %s", containerName, filepath));
URL signedUrl = storage.signUrl(blobInfo, 7L, TimeUnit.DAYS);
log.debug("Signed URL for created storage object. Object ID : {} , Signed URL : {}",
blob.getGeneratedId(), signedUrl);
......
......@@ -37,26 +37,20 @@ public class AzureTokenServiceImpl {
public String signContainer(String containerUrl, long duration, TimeUnit timeUnit) {
BlobUrlParts parts = BlobUrlParts.parse(containerUrl);
String endpoint = calcBlobAccountUrl(parts);
BlobServiceClient rbacKeySource = new BlobServiceClientBuilder()
.endpoint(endpoint)
.credential(defaultCredential)
.buildClient();
BlobContainerClient blobContainerClient = new BlobContainerClientBuilder()
.credential(defaultCredential)
.endpoint(containerUrl)
.containerName(parts.getBlobContainerName())
.buildClient();
OffsetDateTime expires = calcTokenExpirationDate(duration, timeUnit);
UserDelegationKey key = rbacKeySource.getUserDelegationKey(null, expires);
BlobSasPermission readOnlyPerms = BlobSasPermission.parse("r");
BlobServiceSasSignatureValues tokenProps = new BlobServiceSasSignatureValues(expires, readOnlyPerms);
String sasToken = blobContainerClient.generateUserDelegationSas(tokenProps, key);
String sasUri = String.format("%s?%s", containerUrl, sasToken);
return sasUri;
}
......
......@@ -23,7 +23,7 @@ import java.net.URL;
import java.util.concurrent.TimeUnit;
public class Blob extends BlobInfo {
private static final long serialVersionUID = -6806832496717441434L;
private static final long serialVersionUID = -6806832496757441434L;
private transient Storage storage;
Blob(Storage storage, BlobInfo.BuilderImpl infoBuilder) {
......
......@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
import java.io.Serializable;
public final class BlobId implements Serializable {
private static final long serialVersionUID = -6156002883225601925L;
private static final long serialVersionUID = -6156002883225601325L;
private final String container;
private final String name;
private final Long generation;
......
......@@ -103,9 +103,7 @@ public class StorageImpl implements Storage {
public URL signUrl(BlobInfo blobInfo, long duration, TimeUnit timeUnit) {
try {
log.debug("Signing the blob in container {} for path {}", blobInfo.getContainer(), blobInfo.getName());
System.out.println(String.format("Signing the blob in container %s for path %s", blobInfo.getContainer(), blobInfo.getName()));
String blobURL = generateBlobPath(storageAccount, blobInfo.getContainer(), blobInfo.getName());
System.out.println(String.format("Signing the blob %s", blobURL));
log.debug("Signing the blob {}", blobURL);
String signedUrl = token.sign(blobURL, duration, timeUnit);
return new URL(signedUrl);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment