-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
AzureSasCredential.cs
67 lines (62 loc) · 2.62 KB
/
AzureSasCredential.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using Azure.Core;
namespace Azure
{
/// <summary>
/// Shared access signature credential used to authenticate to an Azure Service.
/// It provides the ability to update the shared access signature without creating a new client.
/// </summary>
public class AzureSasCredential
{
private string _signature;
/// <summary>
/// Shared access signature used to authenticate to an Azure service.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public string Signature
{
get => Volatile.Read(ref _signature);
private set => Volatile.Write(ref _signature, value);
}
/// <summary>
/// Initializes a new instance of the <see cref="AzureSasCredential"/> class.
/// </summary>
/// <param name="signature">Shared access signature to use to authenticate with the Azure service.</param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when the <paramref name="signature"/> is null.
/// </exception>
/// <exception cref="System.ArgumentException">
/// Thrown when the <paramref name="signature"/> is empty.
/// </exception>
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
public AzureSasCredential(string signature)
{
Argument.AssertNotNullOrWhiteSpace(signature, nameof(signature));
Signature = signature;
}
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
/// <summary>
/// Updates the shared access signature.
/// This is intended to be used when you've regenerated your shared access signature
/// and want to update long lived clients.
/// </summary>
/// <param name="signature">Shared access signature to authenticate the service against.</param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when the <paramref name="signature"/> is null.
/// </exception>
/// <exception cref="System.ArgumentException">
/// Thrown when the <paramref name="signature"/> is empty.
/// </exception>
public void Update(string signature)
{
Argument.AssertNotNullOrWhiteSpace(signature, nameof(signature));
Signature = signature;
}
}
}