internal string SetAzureShareStoredAccessPolicy(IStorageFileManagement localChannel, string shareName, string policyName, DateTime?startTime, DateTime?expiryTime, string permission, bool noStartTime, bool noExpiryTime) { //Get existing permissions CloudFileShare share = localChannel.GetShareReference(shareName); FileSharePermissions permissions = localChannel.GetSharePermissions(share); //Set the policy with new value if (!permissions.SharedAccessPolicies.Keys.Contains(policyName)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName)); } SharedAccessFilePolicy policy = permissions.SharedAccessPolicies[policyName]; AccessPolicyHelper.SetupAccessPolicy <SharedAccessFilePolicy>(policy, startTime, expiryTime, permission, noStartTime, noExpiryTime); permissions.SharedAccessPolicies[policyName] = policy; //Set permission back to share localChannel.SetSharePermissions(share, permissions); WriteObject(AccessPolicyHelper.ConstructPolicyOutputPSObject <SharedAccessFilePolicy>(permissions.SharedAccessPolicies, policyName)); return(policyName); }
internal string SetAzureQueueStoredAccessPolicy(IStorageQueueManagement localChannel, string queueName, string policyName, DateTime?startTime, DateTime?expiryTime, string permission, bool noStartTime, bool noExpiryTime) { //Get existing permissions CloudQueue queue = Channel.GetQueueReference(queueName); QueuePermissions queuePermissions = localChannel.GetPermissions(queue); //Set the policy with new value if (!queuePermissions.SharedAccessPolicies.Keys.Contains(policyName)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName)); } SharedAccessQueuePolicy policy = queuePermissions.SharedAccessPolicies[policyName]; AccessPolicyHelper.SetupAccessPolicy <SharedAccessQueuePolicy>(policy, startTime, expiryTime, permission, noStartTime, noExpiryTime); queuePermissions.SharedAccessPolicies[policyName] = policy; //Set permission back to queue WriteObject(AccessPolicyHelper.ConstructPolicyOutputPSObject <SharedAccessQueuePolicy>(queuePermissions.SharedAccessPolicies, policyName)); localChannel.SetPermissions(queue, queuePermissions); return(policyName); }
internal string SetAzureContainerStoredAccessPolicy(IStorageBlobManagement localChannel, string containerName, string policyName, DateTime?startTime, DateTime?expiryTime, string permission, bool noStartTime, bool noExpiryTime) { //Get existing permissions CloudBlobContainer container = localChannel.GetContainerReference(containerName); BlobContainerPermissions blobContainerPermissions = localChannel.GetContainerPermissions(container); //Set the policy with new value if (!blobContainerPermissions.SharedAccessPolicies.Keys.Contains(policyName)) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName)); } SharedAccessBlobPolicy policy = blobContainerPermissions.SharedAccessPolicies[policyName]; AccessPolicyHelper.SetupAccessPolicy <SharedAccessBlobPolicy>(policy, startTime, expiryTime, permission, noStartTime, noExpiryTime); blobContainerPermissions.SharedAccessPolicies[policyName] = policy; //Set permission back to container localChannel.SetContainerPermissions(container, blobContainerPermissions); WriteObject(AccessPolicyHelper.ConstructPolicyOutputPSObject <SharedAccessBlobPolicy>(blobContainerPermissions.SharedAccessPolicies, policyName)); return(policyName); }
internal async Task GetAzureContainerStoredAccessPolicyAsync(long taskId, IStorageBlobManagement localChannel, string containerName, string policyName) { SharedAccessBlobPolicies shareAccessPolicies = await GetPoliciesAsync(localChannel, containerName, policyName).ConfigureAwait(false); if (!String.IsNullOrEmpty(policyName)) { if (shareAccessPolicies.Keys.Contains(policyName)) { OutputStream.WriteObject(taskId, AccessPolicyHelper.ConstructPolicyOutputPSObject <SharedAccessBlobPolicy>(shareAccessPolicies, policyName)); } else { throw new ResourceNotFoundException(String.Format(CultureInfo.CurrentCulture, Resources.PolicyNotFound, policyName)); } } else { foreach (string key in shareAccessPolicies.Keys) { OutputStream.WriteObject(taskId, AccessPolicyHelper.ConstructPolicyOutputPSObject <SharedAccessBlobPolicy>(shareAccessPolicies, key)); } } }