Last active
December 28, 2018 21:45
-
-
Save cbanner/62a88bf4b3e8029561652a1be45b47e4 to your computer and use it in GitHub Desktop.
Part 1: Pseudo code demonstrating the pervasiveness of logging components when allowed to infiltrate classes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SignatureAuthenticationProcedure : IAuthenticationProcedure | |
{ | |
private readonly ILogger logger; | |
public SignatureAuthenticationProcedure(ILogger logger) | |
{ | |
this.logger = logger; | |
} | |
public AuthenticationResult Authenticate(HttpRequest request) | |
{ | |
this.logger.Trace("Beginning signature authentication procedure."); | |
AuthenticationResult result = AuthenticationResult.Failed; | |
try | |
{ | |
this.logger.Trace("Validating timestamp."); | |
if(IsTimestampValid(request)) | |
{ | |
this.logger.Trace("Timestamp valid."); | |
this.logger.Trace("Validating signature."); | |
if(IsSignatureValid(request)) | |
{ | |
result = AuthenticationResult.Success; | |
this.logger.Information("Authentication successful.") | |
} | |
} | |
} | |
catch(Exception ex) | |
{ | |
this.logger.Error(ex); | |
throw; | |
} | |
finally | |
{ | |
this.logger.Trace("Completed signature authentication procedure."); | |
} | |
return result; | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment