-
Notifications
You must be signed in to change notification settings - Fork 753
/
CustomAuthentication.cs
32 lines (27 loc) · 955 Bytes
/
CustomAuthentication.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
using System.Net;
namespace AutoUpdaterDotNET;
/// <summary>
/// Provides Custom Authentication header for web request.
/// </summary>
public class CustomAuthentication : IAuthentication
{
/// <summary>
/// Initializes authorization header value for Custom Authentication
/// </summary>
/// <param name="httpRequestHeaderAuthorizationValue">Value to use as http request header authorization value</param>
public CustomAuthentication(string httpRequestHeaderAuthorizationValue)
{
HttpRequestHeaderAuthorizationValue = httpRequestHeaderAuthorizationValue;
}
private string HttpRequestHeaderAuthorizationValue { get; }
/// <inheritdoc />
public void Apply(ref MyWebClient webClient)
{
webClient.Headers[HttpRequestHeader.Authorization] = ToString();
}
/// <inheritdoc />
public override string ToString()
{
return HttpRequestHeaderAuthorizationValue;
}
}