Package com.azure.storage.file.share.sas
Class ShareFileSasPermission
java.lang.Object
com.azure.storage.file.share.sas.ShareFileSasPermission
Constructs a string representing the permissions granted by a Service SAS to a file. Setting a value to true means
that any SAS which uses these permissions will grant permissions for that operation. Once all the values are set,
this should be serialized with
toString()
and set as the permissions field on
ShareServiceSasSignatureValues
.
It is possible to construct the permissions string without this class, but the order of the permissions is particular and this class guarantees correctness.
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes anShareFileSasPermission
object with all fields set to false. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Gets the create permission status.boolean
Gets the delete permission status.boolean
Gets the read permission status.boolean
Gets the write permission status.static ShareFileSasPermission
Creates anShareFileSasPermission
from the specified permissions string.setCreatePermission
(boolean hasCreatePermission) Sets the create permission status.setDeletePermission
(boolean hasDeletePermission) Sets the delete permission status.setReadPermission
(boolean hasReadPermission) Sets the read permission status.setWritePermission
(boolean hasWritePermission) Sets the write permission status.toString()
Converts the given permissions to aString
.
-
Constructor Details
-
ShareFileSasPermission
public ShareFileSasPermission()Initializes anShareFileSasPermission
object with all fields set to false.
-
-
Method Details
-
parse
Creates anShareFileSasPermission
from the specified permissions string. This method will throw anIllegalArgumentException
if it encounters a character that does not correspond to a valid permission.- Parameters:
permissionString
- AString
which represents theShareFileSasPermission
.- Returns:
- A
ShareFileSasPermission
generated from the givenString
. - Throws:
IllegalArgumentException
- IfpermissionString
contains a character other than r, c, w, or d.
-
hasReadPermission
public boolean hasReadPermission()Gets the read permission status.- Returns:
true
if the SAS can read the content, properties, and metadata for a file. Can use the file as the source of a copy operation.false
, otherwise.
-
setReadPermission
Sets the read permission status.- Parameters:
hasReadPermission
-true
if the SAS can read the content, properties, and metadata for a file. Can use the file as the source of a copy operation.false
, otherwise.- Returns:
- the updated ShareFileSasPermission object
-
hasCreatePermission
public boolean hasCreatePermission()Gets the create permission status.- Returns:
true
if SAS can create a new file or copy a file to a new file.false
, otherwise.
-
setCreatePermission
Sets the create permission status.- Parameters:
hasCreatePermission
-true
if SAS can create a new file or copy a file to a new file.false
, otherwise.- Returns:
- the updated ShareFileSasPermission object
-
hasWritePermission
public boolean hasWritePermission()Gets the write permission status.- Returns:
true
if SAS can write content, properties, or metadata to the file. Or, use the file as the destination of a copy operation.false
, otherwise.
-
setWritePermission
Sets the write permission status.- Parameters:
hasWritePermission
-true
if SAS can write content, properties, or metadata to the file. Or, use the file as the destination of a copy operation.false
, otherwise.- Returns:
- the updated ShareFileSasPermission object
-
hasDeletePermission
public boolean hasDeletePermission()Gets the delete permission status.- Returns:
true
if SAS can delete a file.false
, otherwise.
-
setDeletePermission
Sets the delete permission status.- Parameters:
hasDeletePermission
-true
if SAS can delete a file.false
, otherwise.- Returns:
- the updated ShareFileSasPermission object
-
toString
Converts the given permissions to aString
. Using this method will guarantee the permissions are in an order accepted by the service.
-