| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Text; |
| | 7 | | using Azure.Core; |
| | 8 | | using Azure.Core.Pipeline; |
| | 9 | |
|
| | 10 | | namespace Azure.Messaging.EventGrid |
| | 11 | | { |
| | 12 | | internal class EventGridSharedAccessSignatureCredentialPolicy : HttpPipelineSynchronousPolicy |
| | 13 | | { |
| | 14 | | private readonly EventGridSharedAccessSignatureCredential _credential; |
| | 15 | |
|
| | 16 | | /// <summary> |
| | 17 | | /// Initializes a new instance of the <see cref="EventGridSharedAccessSignatureCredentialPolicy"/> class. |
| | 18 | | /// </summary> |
| | 19 | | /// <param name="credential">The <see cref="EventGridSharedAccessSignatureCredential"/> used to authenticate req |
| 4 | 20 | | public EventGridSharedAccessSignatureCredentialPolicy(EventGridSharedAccessSignatureCredential credential) |
| | 21 | | { |
| 4 | 22 | | Argument.AssertNotNull(credential, nameof(credential)); |
| 4 | 23 | | _credential = credential; |
| 4 | 24 | | } |
| | 25 | |
|
| | 26 | | /// <inheritdoc/> |
| | 27 | | public override void OnSendingRequest(HttpMessage message) |
| | 28 | | { |
| 4 | 29 | | base.OnSendingRequest(message); |
| 4 | 30 | | message.Request.Headers.SetValue(Constants.SasTokenName, _credential.Signature); |
| 4 | 31 | | } |
| | 32 | | } |
| | 33 | | } |