Skip to content

Commit

Permalink
Created CustomAuthentication. This resolves #319. (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
jay1891 authored and ravibpatel committed Sep 25, 2019
1 parent e173b51 commit 9ef1de7
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions AutoUpdater.NET/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ public static class AutoUpdater
/// <summary>
/// Set Basic Authentication credentials required to download the file.
/// </summary>
public static BasicAuthentication BasicAuthDownload;
public static IAuthentication BasicAuthDownload;

/// <summary>
/// Set Basic Authentication credentials required to download the XML file.
/// </summary>
public static BasicAuthentication BasicAuthXML;
public static IAuthentication BasicAuthXML;

/// <summary>
/// Set Basic Authentication credentials to navigate to the change log URL.
/// </summary>
public static BasicAuthentication BasicAuthChangeLog;
public static IAuthentication BasicAuthChangeLog;

/// <summary>
/// Set the User-Agent string to be used for HTTP web requests.
Expand Down Expand Up @@ -854,10 +854,18 @@ public ParseUpdateInfoEventArgs(string remoteData)
}
}


/// <summary>
/// Interface for authentication
/// </summary>
public interface IAuthentication
{
}

/// <summary>
/// Provides Basic Authentication header for web request.
/// </summary>
public class BasicAuthentication
public class BasicAuthentication : IAuthentication
{
private string Username { get; }

Expand All @@ -881,4 +889,27 @@ public override string ToString()
return $"Basic {token}";
}
}

/// <summary>
/// Provides Custom Authentication header for web request.
/// </summary>
public class CustomAuthentication : IAuthentication
{
private string HttpRequestHeaderAuthorizationValue { get; }

/// <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;
}

/// <inheritdoc />
public override string ToString()
{
return HttpRequestHeaderAuthorizationValue;
}
}
}

0 comments on commit 9ef1de7

Please sign in to comment.