| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Globalization; |
| | 6 | | using System.Net; |
| | 7 | | using System.Text; |
| | 8 | |
|
| | 9 | | namespace Azure.Storage.Sas |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Encapsulates the shared properties used by both |
| | 13 | | /// BlobSasQueryParameters and DataLakeSasQueryParameters. |
| | 14 | | /// </summary> |
| | 15 | | internal class UserDelegationKeyProperties |
| | 16 | | { |
| | 17 | | // skoid |
| 1116 | 18 | | internal string ObjectId { get; set; } |
| | 19 | |
|
| | 20 | | // sktid |
| 1116 | 21 | | internal string TenantId { get; set; } |
| | 22 | |
|
| | 23 | | // skt |
| 1116 | 24 | | internal DateTimeOffset StartsOn { get; set; } |
| | 25 | |
|
| | 26 | | // ske |
| 1116 | 27 | | internal DateTimeOffset ExpiresOn { get; set; } |
| | 28 | |
|
| | 29 | | // sks |
| 1116 | 30 | | internal string Service { get; set; } |
| | 31 | |
|
| | 32 | | // skv |
| 1100 | 33 | | internal string Version { get; set; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// Builds up the UserDelegationKey portion of the SAS query parameter string. |
| | 37 | | /// </summary> |
| | 38 | | public void AppendProperties(StringBuilder stringBuilder) |
| | 39 | | { |
| 640 | 40 | | if (!string.IsNullOrWhiteSpace(ObjectId)) |
| | 41 | | { |
| 224 | 42 | | stringBuilder.AppendQueryParameter(Constants.Sas.Parameters.KeyObjectId, ObjectId); |
| | 43 | | } |
| | 44 | |
|
| 640 | 45 | | if (!string.IsNullOrWhiteSpace(TenantId)) |
| | 46 | | { |
| 224 | 47 | | stringBuilder.AppendQueryParameter(Constants.Sas.Parameters.KeyTenantId, TenantId); |
| | 48 | | } |
| | 49 | |
|
| 640 | 50 | | if (StartsOn != DateTimeOffset.MinValue) |
| | 51 | | { |
| 224 | 52 | | stringBuilder.AppendQueryParameter(Constants.Sas.Parameters.KeyStart, WebUtility.UrlEncode(StartsOn.ToSt |
| | 53 | | } |
| | 54 | |
|
| 640 | 55 | | if (ExpiresOn != DateTimeOffset.MinValue) |
| | 56 | | { |
| 224 | 57 | | stringBuilder.AppendQueryParameter(Constants.Sas.Parameters.KeyExpiry, WebUtility.UrlEncode(ExpiresOn.To |
| | 58 | | } |
| | 59 | |
|
| 640 | 60 | | if (!string.IsNullOrWhiteSpace(Service)) |
| | 61 | | { |
| 224 | 62 | | stringBuilder.AppendQueryParameter(Constants.Sas.Parameters.KeyService, Service); |
| | 63 | | } |
| | 64 | |
|
| 640 | 65 | | if (!string.IsNullOrWhiteSpace(Version)) |
| | 66 | | { |
| 224 | 67 | | stringBuilder.AppendQueryParameter(Constants.Sas.Parameters.KeyVersion, Version); |
| | 68 | | } |
| 640 | 69 | | } |
| | 70 | | } |
| | 71 | | } |