Package com.azure.storage.file.share.sas
Class ShareServiceSasSignatureValues
- java.lang.Object
-
- com.azure.storage.file.share.sas.ShareServiceSasSignatureValues
-
public final class ShareServiceSasSignatureValues extends Object
Used to initialize parameters for a Shared Access Signature (SAS) for an Azure File Storage service. Once all the values here are set, use the appropriate SAS generation method on the desired share/file/directory client to obtain a representation of the SAS which can then be applied to a new client using the .sasToken(String) method on the desired client builder.- See Also:
- Storage SAS overview, Constructing a Service SAS
-
-
Constructor Summary
Constructors Constructor Description ShareServiceSasSignatureValues()ShareServiceSasSignatureValues(String identifier)Creates an object with the specified identifier.ShareServiceSasSignatureValues(OffsetDateTime expiryTime, ShareFileSasPermission permissions)Creates an object with the specified expiry time and permissionsShareServiceSasSignatureValues(OffsetDateTime expiryTime, ShareSasPermission permissions)Creates an object with the specified expiry time and permissions
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ShareServiceSasQueryParametersgenerateSasQueryParameters(StorageSharedKeyCredential storageSharedKeyCredentials)Deprecated.Please use the generateSas(ShareServiceSasSignatureValues) method on the desired share/file/directory client after initializingShareServiceSasSignatureValues.StringgetCacheControl()StringgetContentDisposition()StringgetContentEncoding()StringgetContentLanguage()StringgetContentType()OffsetDateTimegetExpiryTime()StringgetFilePath()Deprecated.File path is now auto-populated by the SAS generation methods provided on the desired file/directory client.StringgetIdentifier()StringgetPermissions()SasProtocolgetProtocol()SasIpRangegetSasIpRange()StringgetShareName()Deprecated.Share name is now auto-populated by the SAS generation methods provided on the desired share/file/directory client.OffsetDateTimegetStartTime()StringgetVersion()ShareServiceSasSignatureValuessetCacheControl(String cacheControl)Sets the cache-control header for the SAS.ShareServiceSasSignatureValuessetContentDisposition(String contentDisposition)Sets the content-disposition header for the SAS.ShareServiceSasSignatureValuessetContentEncoding(String contentEncoding)Sets the content-encoding header for the SAS.ShareServiceSasSignatureValuessetContentLanguage(String contentLanguage)Sets the content-language header for the SAS.ShareServiceSasSignatureValuessetContentType(String contentType)Sets the content-type header for the SAS.ShareServiceSasSignatureValuessetExpiryTime(OffsetDateTime expiryTime)Sets the time after which the SAS will no longer work.ShareServiceSasSignatureValuessetFilePath(String filePath)Deprecated.Please use the generateSas methods provided on the desired file/directory client that will auto-populate the file path.ShareServiceSasSignatureValuessetIdentifier(String identifier)Sets the name of the access policy on the share this SAS references if any.ShareServiceSasSignatureValuessetPermissions(ShareFileSasPermission permissions)Sets the permissions allowed by the SAS.ShareServiceSasSignatureValuessetPermissions(ShareSasPermission permissions)Sets the permissions allowed by the SAS.ShareServiceSasSignatureValuessetProtocol(SasProtocol protocol)Sets theSasProtocolwhich determines the protocols allowed by the SAS.ShareServiceSasSignatureValuessetSasIpRange(SasIpRange sasIpRange)Sets theSasIpRangewhich determines the IP ranges that are allowed to use the SAS.ShareServiceSasSignatureValuessetShareName(String shareName)Deprecated.Please use the generateSas methods provided on the desired share/file/directory client that will auto-populate the share name.ShareServiceSasSignatureValuessetStartTime(OffsetDateTime startTime)Sets when the SAS will take effect.ShareServiceSasSignatureValuessetVersion(String version)Deprecated.The version is set to the latest version of sas.
-
-
-
Constructor Detail
-
ShareServiceSasSignatureValues
@Deprecated public ShareServiceSasSignatureValues()
Deprecated.Creates an object with empty values for all fields.
-
ShareServiceSasSignatureValues
public ShareServiceSasSignatureValues(OffsetDateTime expiryTime, ShareSasPermission permissions)
Creates an object with the specified expiry time and permissions- Parameters:
expiryTime- The time after which the SAS will no longer work.permissions-ShareSasPermissionallowed by the SAS.
-
ShareServiceSasSignatureValues
public ShareServiceSasSignatureValues(OffsetDateTime expiryTime, ShareFileSasPermission permissions)
Creates an object with the specified expiry time and permissions- Parameters:
expiryTime- The time after which the SAS will no longer work.permissions-ShareFileSasPermissionallowed by the SAS.
-
ShareServiceSasSignatureValues
public ShareServiceSasSignatureValues(String identifier)
Creates an object with the specified identifier.- Parameters:
identifier- Name of the access policy.
-
-
Method Detail
-
getVersion
public String getVersion()
- Returns:
- the version of the service this SAS will target. If not specified, it will default to the version targeted by the library.
-
setVersion
@Deprecated public ShareServiceSasSignatureValues setVersion(String version)
Deprecated.The version is set to the latest version of sas. Users should stop calling this API as it is now treated as a no-op.Sets the version of the service this SAS will target. If not specified, it will default to the version targeted by the library.- Parameters:
version- Version to target- Returns:
- the updated FileServiceSasSignatureValues object
-
getProtocol
public SasProtocol getProtocol()
- Returns:
- the
SasProtocolwhich determines the protocols allowed by the SAS.
-
setProtocol
public ShareServiceSasSignatureValues setProtocol(SasProtocol protocol)
Sets theSasProtocolwhich determines the protocols allowed by the SAS.- Parameters:
protocol- Protocol for the SAS- Returns:
- the updated FileServiceSasSignatureValues object
-
getStartTime
public OffsetDateTime getStartTime()
- Returns:
- when the SAS will take effect.
-
setStartTime
public ShareServiceSasSignatureValues setStartTime(OffsetDateTime startTime)
Sets when the SAS will take effect.- Parameters:
startTime- When the SAS takes effect- Returns:
- the updated FileServiceSasSignatureValues object
-
getExpiryTime
public OffsetDateTime getExpiryTime()
- Returns:
- the time after which the SAS will no longer work.
-
setExpiryTime
public ShareServiceSasSignatureValues setExpiryTime(OffsetDateTime expiryTime)
Sets the time after which the SAS will no longer work.- Parameters:
expiryTime- When the SAS will no longer work- Returns:
- the updated FileServiceSasSignatureValues object
-
getPermissions
public String getPermissions()
- Returns:
- the permissions string allowed by the SAS. Please refer to either
ShareSasPermissionorShareFileSasPermissiondepending on the resource being accessed for help determining the permissions allowed.
-
setPermissions
public ShareServiceSasSignatureValues setPermissions(ShareSasPermission permissions)
Sets the permissions allowed by the SAS. Share SASs are created when onlyshare nameis set on the builder.- Parameters:
permissions- Permissions for the share SAS.- Returns:
- the updated FileServiceSasSignatureValues object.
-
setPermissions
public ShareServiceSasSignatureValues setPermissions(ShareFileSasPermission permissions)
Sets the permissions allowed by the SAS. Share file SASs are created when both ashare nameandfile pathare set on the builder.- Parameters:
permissions- Permissions for the SAS.- Returns:
- the updated FileServiceSasSignatureValues object
-
getSasIpRange
public SasIpRange getSasIpRange()
- Returns:
- the
SasIpRangewhich determines the IP ranges that are allowed to use the SAS.
-
setSasIpRange
public ShareServiceSasSignatureValues setSasIpRange(SasIpRange sasIpRange)
Sets theSasIpRangewhich determines the IP ranges that are allowed to use the SAS.- Parameters:
sasIpRange- Allowed IP range to set- Returns:
- the updated FileServiceSasSignatureValues object
- See Also:
- Specifying IP Address or IP range
-
getShareName
@Deprecated public String getShareName()
Deprecated.Share name is now auto-populated by the SAS generation methods provided on the desired share/file/directory client.Gets the name of the share being made accessible.- Returns:
- The name of the share being made accessible.
-
setShareName
@Deprecated public ShareServiceSasSignatureValues setShareName(String shareName)
Deprecated.Please use the generateSas methods provided on the desired share/file/directory client that will auto-populate the share name.Sets the name of the share being made accessible.- Parameters:
shareName- The name of the share being made accessible.- Returns:
- the updated FileServiceSasSignatureValues object
-
getFilePath
@Deprecated public String getFilePath()
Deprecated.File path is now auto-populated by the SAS generation methods provided on the desired file/directory client.Gets the path of the file or directory being made accessible.nullor an empty string for a share SAS.- Returns:
- The path of the file or directory being made accessible.
nullor an empty string for a share SAS.
-
setFilePath
@Deprecated public ShareServiceSasSignatureValues setFilePath(String filePath)
Deprecated.Please use the generateSas methods provided on the desired file/directory client that will auto-populate the file path.Sets the path of the file or directory being made accessible. Pass innullor an empty string for a share SAS.- Parameters:
filePath- The name of the share being made accessible.- Returns:
- the updated FileServiceSasSignatureValues object
-
getIdentifier
public String getIdentifier()
- Returns:
- the name of the access policy on the share this SAS references if any. Please see Establishing a stored access policy for more information.
-
setIdentifier
public ShareServiceSasSignatureValues setIdentifier(String identifier)
Sets the name of the access policy on the share this SAS references if any. Please see Establishing a stored access policy for more information.- Parameters:
identifier- Name of the stored access policy- Returns:
- the updated FileServiceSasSignatureValues object
-
getCacheControl
public String getCacheControl()
- Returns:
- the cache-control header for the SAS.
-
setCacheControl
public ShareServiceSasSignatureValues setCacheControl(String cacheControl)
Sets the cache-control header for the SAS.- Parameters:
cacheControl- Cache-Control header value- Returns:
- the updated FileServiceSasSignatureValues object
-
getContentDisposition
public String getContentDisposition()
- Returns:
- the content-disposition header for the SAS.
-
setContentDisposition
public ShareServiceSasSignatureValues setContentDisposition(String contentDisposition)
Sets the content-disposition header for the SAS.- Parameters:
contentDisposition- Content-Disposition header value- Returns:
- the updated FileServiceSasSignatureValues object
-
getContentEncoding
public String getContentEncoding()
- Returns:
- the content-encoding header for the SAS.
-
setContentEncoding
public ShareServiceSasSignatureValues setContentEncoding(String contentEncoding)
Sets the content-encoding header for the SAS.- Parameters:
contentEncoding- Content-Encoding header value- Returns:
- the updated FileServiceSasSignatureValues object
-
getContentLanguage
public String getContentLanguage()
- Returns:
- the content-language header for the SAS.
-
setContentLanguage
public ShareServiceSasSignatureValues setContentLanguage(String contentLanguage)
Sets the content-language header for the SAS.- Parameters:
contentLanguage- Content-Language header value- Returns:
- the updated FileServiceSasSignatureValues object
-
getContentType
public String getContentType()
- Returns:
- the content-type header for the SAS.
-
setContentType
public ShareServiceSasSignatureValues setContentType(String contentType)
Sets the content-type header for the SAS.- Parameters:
contentType- Content-Type header value- Returns:
- the updated FileServiceSasSignatureValues object
-
generateSasQueryParameters
@Deprecated public ShareServiceSasQueryParameters generateSasQueryParameters(StorageSharedKeyCredential storageSharedKeyCredentials)
Deprecated.Please use the generateSas(ShareServiceSasSignatureValues) method on the desired share/file/directory client after initializingShareServiceSasSignatureValues.Uses an account's shared key credential to sign these signature values to produce the proper SAS query parameters.Notes on SAS generation
- If
identifieris set,expiryTimeand permissions should not be set. These values are inherited from the stored access policy. - Otherwise,
expiryTimeandpermissionsmust be set.
The type of SAS query parameters returned depends on the following:
- If
getFilePath()is not set, query parameters for a share SAS are returned. - Otherwise,
getShareName()andgetFilePath()are used to create query parameters for a file SAS.
See class level JavaDocs for code snippets.
- Parameters:
storageSharedKeyCredentials- AStorageSharedKeyCredentialobject used to sign the SAS values.- Returns:
ShareServiceSasQueryParameters- Throws:
IllegalStateException- If the HMAC-SHA256 algorithm isn't supported, if the key isn't a valid Base64 encoded string, or the UTF-8 charset isn't supported.IllegalArgumentException- ifgetPermissions()contains an invalid character for the SAS resource.NullPointerException- IfstorageSharedKeyCredentialsis null.
- If
-
-