Skip to content

Commit

Permalink
Mark Serilog-related classes and properties [Obsolete]
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Feb 1, 2023
1 parent 2e394b8 commit 776a569
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Intuit.Ipp.OAuth2PlatformClient.Diagnostics
{
[System.Obsolete("Use IOAuthLogger.")]
public interface IOAuthAdvancedLogger
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Intuit.Ipp.OAuth2PlatformClient.Diagnostics
/// <summary>
/// Helper class for advanced logger/serilogger
/// </summary>
[System.Obsolete("Use Logger with TraceLogger or a custom implementation.")]
public static class LogHelper
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace Intuit.Ipp.OAuth2PlatformClient.Diagnostics
/// <summary>
/// Contains properties used to indicate whether request and response messages are to be logged.
/// </summary>
[Obsolete("Serilog configuration for Advanced Logging deprecated.")]
public class OAuthAdvancedLogging : IOAuthAdvancedLogger, IOAuthLogger
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Net;
using System.Reflection;
using System.Linq;
using System.IO;
using System.Globalization;
using Serilog;
using Intuit.Ipp.OAuth2PlatformClient.Diagnostics;
using Serilog;

namespace Intuit.Ipp.OAuth2PlatformClient
{ /// <summary>
Expand All @@ -30,72 +23,54 @@ public class OAuth2Client
/// <summary>
/// Advanced Logger for OAuth2 calls
/// </summary>
[Obsolete("Use Logger.")]
public static OAuthAdvancedLogging AdvancedLogger;

/// <summary>
/// Enable extra field to check if new OAuth2Client is used for OAuth calls and Advanced logging
/// </summary>
[Obsolete("Use Logger.")]
internal static bool AdvancedLoggerEnabled = false;

/// <summary>
/// Internal field to check if OAuth2Client is used for OAuth calls to enable on intuit-tid based logs, no verbose logs will be enabled if this is true
/// </summary>
internal static bool ShowInfoLogs = false;

/// <summary>
/// Enable extra field to check if OAuth2Client is used for OAuth calls to enable on intuit-tid based logs, no verbose logs will be enabled if this is true
/// </summary>
[Obsolete("Use Logger.")]
public bool EnableAdvancedLoggerInfoMode { get; set; } = false;



/// <summary>
/// request logging location.
/// </summary>
private string serviceRequestLoggingLocationForFile;

/// <summary>
/// request Azure Document DB url.
/// </summary>
private Uri serviceRequestAzureDocumentDBUrl;

/// <summary>
/// request Azure Document DB Secure Key
/// </summary>
private string serviceRequestAzureDocumentDBSecureKey;

///// <summary>
///// request TTL-time to live for all logs
///// </summary>
//public double ServiceRequestAzureDocumentDBTTL { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to enable reqeust response logging for Debug logs.
/// </summary>
[Obsolete("Serilog configuration for Advanced Logging deprecated.")]
public bool EnableSerilogRequestResponseLoggingForDebug { get; set; }


/// <summary>
/// Gets or sets a value indicating whether to enable reqeust response logging for Trace logs.
/// </summary>
[Obsolete("Serilog configuration for Advanced Logging deprecated.")]
public bool EnableSerilogRequestResponseLoggingForTrace { get; set; }


/// <summary>
/// Gets or sets a value indicating whether to enable reqeust response logging for Console logs.
/// </summary>
[Obsolete("Serilog configuration for Advanced Logging deprecated.")]
public bool EnableSerilogRequestResponseLoggingForConsole { get; set; }


///// <summary>
///// Gets or sets a value indicating whether to enable reqeust response logging for file logs.
///// </summary>
[Obsolete("Serilog configuration for Advanced Logging deprecated.")]
public bool EnableSerilogRequestResponseLoggingForFile { get; set; }


/// <summary>
/// Gets or sets the service request logging location for File.
/// </summary>
[Obsolete("Serilog configuration for Advanced Logging deprecated.")]
public string ServiceRequestLoggingLocationForFile
{
get
Expand Down Expand Up @@ -155,8 +130,11 @@ public string ServiceRequestLoggingLocationForFile
/// <summary>
/// CustomLogger
/// </summary>
[Obsolete("Use Logger with a custom implementation.")]
public Serilog.ILogger CustomLogger { get; set; }

#pragma warning disable CS0618 // Type or member is obsolete

private OAuthAdvancedLogging InitializeAdvancedLogger()
{
AdvancedLoggerEnabled = true;
Expand All @@ -181,14 +159,15 @@ private OAuthAdvancedLogging InitializeAdvancedLogger()
//Set internal property to track only informational -intuit_tid based logs
if (EnableAdvancedLoggerInfoMode == true)
{
ShowInfoLogs = true;
logger.ShowInfoLogs = true;
}

AdvancedLogger = logger;
return logger;
}

#pragma warning restore CS0618 // Type or member is obsolete

private IOAuthLogger logger;

/// <summary>
Expand Down Expand Up @@ -314,8 +293,6 @@ public string GetAuthorizationURL(List<string> scopes, string CSRFToken)
throw new System.Exception("Discovery Call failed. Authorize Endpoint is empty.");
}

InitializeAdvancedLogger();

string scopeValue = "";
for (var index = 0; index < scopes.Count; index++)
{
Expand Down Expand Up @@ -352,8 +329,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes, string CSRFToken)
throw new System.Exception("Discovery Call failed. Authorize Endpoint is empty.");
}

InitializeAdvancedLogger();

string scopeValue = "";
for (var index = 0; index < scopes.Count; index++)
{
Expand Down Expand Up @@ -388,8 +363,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
throw new System.Exception("Discovery Call failed. Authorize Endpoint is empty.");
}

InitializeAdvancedLogger();

string scopeValue = "";
for (var index = 0; index < scopes.Count; index++)
{
Expand Down Expand Up @@ -540,8 +513,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
/// <returns></returns>
public async Task<TokenResponse> GetBearerTokenAsync(string code, CancellationToken cancellationToken = default(CancellationToken))
{
InitializeAdvancedLogger();

if (string.IsNullOrEmpty(DiscoveryDoc.TokenEndpoint))
{
Logger.Log("Discovery Call failed.BearerToken Endpoint is empty.");
Expand All @@ -562,8 +533,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
/// <returns></returns>
public async Task<TokenResponse> GetBearerTokenAsync(string tokenEndpoint, string code, CancellationToken cancellationToken = default(CancellationToken))
{
InitializeAdvancedLogger();

if (string.IsNullOrEmpty(tokenEndpoint))
{
Logger.Log("BearerToken Endpoint is empty.");
Expand All @@ -583,8 +552,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
/// <returns></returns>
public async Task<TokenResponse> RefreshTokenAsync(string refreshToken, object extra = null, CancellationToken cancellationToken = default(CancellationToken))
{
InitializeAdvancedLogger();

if (string.IsNullOrEmpty(DiscoveryDoc.TokenEndpoint))
{
Logger.Log("Discovery Call failed. RefreshToken Endpoint is empty.");
Expand All @@ -605,8 +572,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
/// <returns></returns>
public async Task<TokenResponse> RefreshTokenAsync(string tokenEndpoint, string refreshToken, object extra = null, CancellationToken cancellationToken = default(CancellationToken))
{
InitializeAdvancedLogger();

if (string.IsNullOrEmpty(tokenEndpoint))
{
Logger.Log("RefreshToken Endpoint is empty.");
Expand All @@ -625,8 +590,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
/// <returns></returns>
public async Task<TokenRevocationResponse> RevokeTokenAsync(string accessOrRefreshToken, CancellationToken cancellationToken = default(CancellationToken))
{
InitializeAdvancedLogger();

if (string.IsNullOrEmpty(DiscoveryDoc.RevocationEndpoint))
{
Logger.Log("Discovery Call failed. RevokeToken Endpoint is empty.");
Expand All @@ -649,8 +612,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
/// <returns></returns>
public async Task<TokenRevocationResponse> RevokeTokenAsync(string revokeTokenEndpoint,string accessOrRefreshToken, CancellationToken cancellationToken = default(CancellationToken))
{
InitializeAdvancedLogger();

if (string.IsNullOrEmpty(revokeTokenEndpoint))
{
Logger.Log("Revoke Token Endpoint is empty.");
Expand All @@ -672,8 +633,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
/// <returns></returns>
public async Task<UserInfoResponse> GetUserInfoAsync(string accessToken, CancellationToken cancellationToken = default(CancellationToken))
{
InitializeAdvancedLogger();

if (string.IsNullOrEmpty(DiscoveryDoc.UserInfoEndpoint))
{
Logger.Log("Discovery Call failed. UserInfo Endpoint is empty.");
Expand All @@ -693,8 +652,6 @@ public string GetAuthorizationURL(List<OidcScopes> scopes)
/// <returns></returns>
public async Task<UserInfoResponse> GetUserInfoAsync(string userInfoEndpoint, string accessToken, CancellationToken cancellationToken = default(CancellationToken))
{
InitializeAdvancedLogger();

if (string.IsNullOrEmpty(userInfoEndpoint))
{
Logger.Log("UserInfo Endpoint is empty.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ public TokenClient(string endpoint)
/// <param name="innerHttpMessageHandler">innerHttpMessageHandler</param>
public TokenClient(string endpoint, HttpMessageHandler innerHttpMessageHandler)
{
if (OAuth2Client.AdvancedLoggerEnabled == false)
{
//Intialize Logger
OAuth2Client.AdvancedLogger = LogHelper.GetAdvancedLogging(enableSerilogRequestResponseLoggingForDebug: false, enableSerilogRequestResponseLoggingForTrace: false, enableSerilogRequestResponseLoggingForConsole: false, enableSerilogRequestResponseLoggingForFile: false, serviceRequestLoggingLocationForFile: System.IO.Path.GetTempPath());
}

if (endpoint == null) throw new ArgumentNullException(nameof(endpoint));
if (innerHttpMessageHandler == null) throw new ArgumentNullException(nameof(innerHttpMessageHandler));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ public class TokenRevocationClient : IDisposable
/// <param name="innerHttpMessageHandler">innerHttpMessageHandler</param>
public TokenRevocationClient(string endpoint, string clientId = "", string clientSecret = "", HttpMessageHandler innerHttpMessageHandler = null)
{
if (OAuth2Client.AdvancedLoggerEnabled == false)
{
//Intialize Logger
OAuth2Client.AdvancedLogger = LogHelper.GetAdvancedLogging(enableSerilogRequestResponseLoggingForDebug: false, enableSerilogRequestResponseLoggingForTrace: false, enableSerilogRequestResponseLoggingForConsole: false, enableSerilogRequestResponseLoggingForFile: false, serviceRequestLoggingLocationForFile: System.IO.Path.GetTempPath());
}

if (endpoint == null) throw new ArgumentNullException(nameof(endpoint));
if (innerHttpMessageHandler == null) innerHttpMessageHandler = new HttpClientHandler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ public UserInfoClient(string endpoint)
/// <param name="innerHttpMessageHandler">innerHttpMessageHandler</param>
public UserInfoClient(string endpoint, HttpMessageHandler innerHttpMessageHandler)
{
if (OAuth2Client.AdvancedLoggerEnabled == false)
{
//Intialize Logger
OAuth2Client.AdvancedLogger = LogHelper.GetAdvancedLogging(enableSerilogRequestResponseLoggingForDebug: false, enableSerilogRequestResponseLoggingForTrace: false, enableSerilogRequestResponseLoggingForConsole: false, enableSerilogRequestResponseLoggingForFile: false, serviceRequestLoggingLocationForFile: System.IO.Path.GetTempPath());
}

if (endpoint == null) throw new ArgumentNullException(nameof(endpoint));
if (innerHttpMessageHandler == null) throw new ArgumentNullException(nameof(innerHttpMessageHandler));

Expand Down

0 comments on commit 776a569

Please sign in to comment.