Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Lib
cloud
azure
OS Core Lib Azure
Commits
ec06e610
Commit
ec06e610
authored
Nov 25, 2020
by
Kishore Battula
Browse files
Merge branch 'container-sas-url' into 'master'
Container sas url See merge request
!50
parents
be7c9317
58abf2be
Pipeline
#17207
passed with stages
in 8 minutes and 13 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
pom.xml
View file @
ec06e610
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<groupId>
org.opengroup.osdu
</groupId>
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
core-lib-azure
</artifactId>
<artifactId>
core-lib-azure
</artifactId>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<version>
0.0.4
5
</version>
<version>
0.0.4
6
</version>
<name>
core-lib-azure
</name>
<name>
core-lib-azure
</name>
<properties>
<properties>
...
...
src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java
View file @
ec06e610
...
@@ -20,6 +20,7 @@ import com.azure.storage.blob.BlobServiceClient;
...
@@ -20,6 +20,7 @@ import com.azure.storage.blob.BlobServiceClient;
import
com.azure.storage.blob.models.BlobCopyInfo
;
import
com.azure.storage.blob.models.BlobCopyInfo
;
import
com.azure.storage.blob.models.BlobErrorCode
;
import
com.azure.storage.blob.models.BlobErrorCode
;
import
com.azure.storage.blob.models.BlobStorageException
;
import
com.azure.storage.blob.models.BlobStorageException
;
import
com.azure.storage.blob.sas.BlobContainerSasPermission
;
import
com.azure.storage.blob.sas.BlobSasPermission
;
import
com.azure.storage.blob.sas.BlobSasPermission
;
import
com.azure.storage.blob.sas.BlobServiceSasSignatureValues
;
import
com.azure.storage.blob.sas.BlobServiceSasSignatureValues
;
import
com.azure.storage.blob.specialized.BlockBlobClient
;
import
com.azure.storage.blob.specialized.BlockBlobClient
;
...
@@ -195,6 +196,19 @@ public class BlobStore {
...
@@ -195,6 +196,19 @@ public class BlobStore {
return
blockBlobClient
.
getBlobUrl
()
+
"?"
+
generateSASToken
(
blockBlobClient
,
expiryTime
,
permissions
);
return
blockBlobClient
.
getBlobUrl
()
+
"?"
+
generateSASToken
(
blockBlobClient
,
expiryTime
,
permissions
);
}
}
/**
* Generates pre-signed url to a blob container.
* @param dataPartitionId data partition id
* @param containerName Name of the storage container
* @param expiryTime Time after which the token expires
* @param permissions permissions for the given container
* @return Generates pre-signed url for a given container
*/
public
String
generatePreSignedURL
(
final
String
dataPartitionId
,
final
String
containerName
,
final
OffsetDateTime
expiryTime
,
final
BlobContainerSasPermission
permissions
)
{
BlobContainerClient
blobContainerClient
=
getBlobContainerClient
(
dataPartitionId
,
containerName
);
return
blobContainerClient
.
getBlobContainerUrl
()
+
"?"
+
generateSASToken
(
blobContainerClient
,
expiryTime
,
permissions
);
}
/**
/**
* Method is used to copy a file specified at Source URL to the provided destination.
* Method is used to copy a file specified at Source URL to the provided destination.
* @param dataPartitionId Data partition id
* @param dataPartitionId Data partition id
...
@@ -223,6 +237,17 @@ public class BlobStore {
...
@@ -223,6 +237,17 @@ public class BlobStore {
return
blockBlobClient
.
generateSas
(
blobServiceSasSignatureValues
);
return
blockBlobClient
.
generateSas
(
blobServiceSasSignatureValues
);
}
}
/**
* @param client Container client
* @param expiryTime Time after which SAS Token expires
* @param permissions Permissions for the given container
* @return Generates SAS Token.
*/
private
String
generateSASToken
(
final
BlobContainerClient
client
,
final
OffsetDateTime
expiryTime
,
final
BlobContainerSasPermission
permissions
)
{
BlobServiceSasSignatureValues
blobServiceSasSignatureValues
=
new
BlobServiceSasSignatureValues
(
expiryTime
,
permissions
);
return
client
.
generateSas
(
blobServiceSasSignatureValues
);
}
/**
/**
* @param dataPartitionId Data partition id.
* @param dataPartitionId Data partition id.
* @param containerName Name of storage container.
* @param containerName Name of storage container.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment