public final class AccountSasSignatureValues extends Object
generateSASQueryParameters(StorageSharedKeyCredential) to
obtain a representation of the SAS which can actually be applied to container, file, queue, and tables.
Generating an account SAS
The snippet below generates an account SAS that lasts for two days and gives the user read and list access to blob containers and file shares.
StorageSharedKeyCredentialcredential = newStorageSharedKeyCredential("my-account", "my-key");AccountSasPermissionpermissions = newAccountSasPermission() .setListPermission(true) .setReadPermission(true);StringresourceTypes = newAccountSasResourceType().setContainer(true).toString();Stringservices = newAccountSasService().setBlobAccess(true).setFileAccess(true).toString(); // Creates an account SAS that can read and list from blob containers and file shares. // The following are required: permissions, resourceTypes, services, and expiry date.AccountSasQueryParameterssasQueryParameters = newAccountSasSignatureValues() .setPermissions(permissions) .setResourceTypes(resourceTypes) .setServices(services) .setExpiryTime(OffsetDateTime.now().plus(Duration.ofDays(2))) .generateSasQueryParameters(credential);
| Constructor and Description |
|---|
AccountSasSignatureValues()
Initializes a new
AccountSasSignatureValues object. |
| Modifier and Type | Method and Description |
|---|---|
AccountSasQueryParameters |
generateSasQueryParameters(StorageSharedKeyCredential storageSharedKeyCredentials)
Generates a
AccountSasQueryParameters object which contains all SAS query parameters for authenticating
requests. |
OffsetDateTime |
getExpiryTime() |
String |
getPermissions()
Gets the operations the SAS user may perform.
|
SasProtocol |
getProtocol() |
String |
getResourceTypes() |
SasIpRange |
getSasIpRange() |
String |
getServices() |
OffsetDateTime |
getStartTime() |
String |
getVersion() |
AccountSasSignatureValues |
setExpiryTime(OffsetDateTime expiryTime)
Sets the time after which the SAS will no longer work.
|
AccountSasSignatureValues |
setPermissions(AccountSasPermission permissions)
Sets the operations the account SAS user may perform.
|
AccountSasSignatureValues |
setProtocol(SasProtocol protocol)
Sets the
SasProtocol which determines the HTTP protocol that will be used. |
AccountSasSignatureValues |
setResourceTypes(String resourceTypes)
Sets the resource types accessible with this SAS.
|
AccountSasSignatureValues |
setSasIpRange(SasIpRange sasIpRange)
Sets the
SasIpRange which determines the IP ranges that are allowed to use the SAS. |
AccountSasSignatureValues |
setServices(String services)
Sets the services accessible with this SAS.
|
AccountSasSignatureValues |
setStartTime(OffsetDateTime startTime)
Sets when the SAS will take effect.
|
AccountSasSignatureValues |
setVersion(String version)
Sets the service version that is targeted.
|
public AccountSasSignatureValues()
AccountSasSignatureValues object.public String getVersion()
null or empty the latest service version targeted by the
library will be used.public AccountSasSignatureValues setVersion(String version)
null or empty to target the version used by the
library.version - Target version to setpublic SasProtocol getProtocol()
SasProtocol which determines the HTTP protocol that will be used.public AccountSasSignatureValues setProtocol(SasProtocol protocol)
SasProtocol which determines the HTTP protocol that will be used.protocol - Protocol to setpublic OffsetDateTime getStartTime()
public AccountSasSignatureValues setStartTime(OffsetDateTime startTime)
startTime - Start time to setpublic OffsetDateTime getExpiryTime()
public AccountSasSignatureValues setExpiryTime(OffsetDateTime expiryTime)
expiryTime - Expiry time to setpublic String getPermissions()
AccountSasPermission to help determine
which permissions are allowed.public AccountSasSignatureValues setPermissions(AccountSasPermission permissions)
AccountSasPermission for help
constructing the permissions string.permissions - Permissions to set.NullPointerException - if permissions is null.public SasIpRange getSasIpRange()
SasIpRange which determines the IP ranges that are allowed to use the SAS.public AccountSasSignatureValues setSasIpRange(SasIpRange sasIpRange)
SasIpRange which determines the IP ranges that are allowed to use the SAS.sasIpRange - Allowed IP range to setpublic String getServices()
AccountSasService to help determine which
services are accessible.public AccountSasSignatureValues setServices(String services)
AccountSasService to construct this value.services - Allowed services string to setpublic String getResourceTypes()
AccountSasResourceType to help
determine the resource types that are accessible.public AccountSasSignatureValues setResourceTypes(String resourceTypes)
AccountSasResourceType to construct
this value.resourceTypes - Allowed resource types string to setpublic AccountSasQueryParameters generateSasQueryParameters(StorageSharedKeyCredential storageSharedKeyCredentials)
AccountSasQueryParameters object which contains all SAS query parameters for authenticating
requests.
Notes on SAS generation
version is not set, the latest service version is used.For samples, see class level JavaDocs.
storageSharedKeyCredentials - Credentials for the storage account.AccountSasQueryParameters used for authenticating requests.RuntimeException - If the HMAC-SHA256 signature for storageSharedKeyCredentials fails to generate.NullPointerException - If any of storageSharedKeyCredentials, services,
resourceTypes, expiryTime, or permissions is null.Copyright © 2019 Microsoft Corporation. All rights reserved.