/// <summary>
        /// Ensure the <see cref="BlobSasBuilder"/>'s properties are in a
        /// consistent state.
        /// </summary>
        private void EnsureState()
        {
            // Container
            if (String.IsNullOrEmpty(BlobName))
            {
                // Make sure the permission characters are in the correct order
                Permissions = BlobContainerSasPermissions.Parse(Permissions).ToString();
                Resource    = Constants.Sas.Resource.Container;
            }

            // Blob or Snapshot
            else
            {
                // Blob
                if (String.IsNullOrEmpty(Snapshot))
                {
                    // Make sure the permission characters are in the correct order
                    Permissions = BlobSasPermissions.Parse(Permissions).ToString();
                    Resource    = Constants.Sas.Resource.Blob;
                }
                // Snapshot
                else
                {
                    // Make sure the permission characters are in the correct order
                    Permissions = SnapshotSasPermissions.Parse(Permissions).ToString();
                    Resource    = Constants.Sas.Resource.BlobSnapshot;
                }
            }
            if (String.IsNullOrEmpty(Version))
            {
                Version = SasQueryParameters.DefaultSasVersion;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Sets the permissions for a blob container SAS.
 /// </summary>
 /// <param name="permissions">
 /// <see cref="BlobContainerSasPermissions"/> containing the allowed permissions.
 /// </param>
 public void SetPermissions(BlobContainerSasPermissions permissions)
 {
     Permissions = permissions.ToPermissionsString();
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlobSasBuilder"/>
 /// class to create a Blob Container Service Sas.
 /// </summary>
 /// <param name="permissions">
 /// The time at which the shared access signature becomes invalid.
 /// This field must be omitted if it has been specified in an
 /// associated stored access policy.
 /// </param>
 /// <param name="expiresOn">
 /// The time at which the shared access signature becomes invalid.
 /// This field must be omitted if it has been specified in an
 /// associated stored access policy.
 /// </param>
 public BlobSasBuilder(BlobContainerSasPermissions permissions, DateTimeOffset expiresOn)
 {
     ExpiresOn = expiresOn;
     SetPermissions(permissions);
 }