1111using Newtonsoft . Json ;
1212using System ;
1313using System . Collections . Generic ;
14+ using Keyfactor . Logging ;
1415
1516namespace Keyfactor . Extensions . Orchestrator . RemoteFile
1617{
@@ -35,6 +36,8 @@ public abstract class RemoteFileJobTypeBase
3536
3637 internal void SetJobProperties ( JobConfiguration config , CertificateStore certificateStoreDetails , ILogger logger )
3738 {
39+ logger . MethodEntry ( LogLevel . Debug ) ;
40+
3841 logger . LogDebug ( $ "Begin { config . Capability } for job id { config . JobId } ...") ;
3942 logger . LogDebug ( $ "Server: { certificateStoreDetails . ClientMachine } ") ;
4043 logger . LogDebug ( $ "Store Path: { certificateStoreDetails . StorePath } ") ;
@@ -73,17 +76,43 @@ internal void SetJobProperties(JobConfiguration config, CertificateStore certifi
7376 FileTransferProtocol = ApplicationSettings . FileTransferProtocol ;
7477 if ( properties . FileTransferProtocol != null && ! string . IsNullOrEmpty ( properties . FileTransferProtocol . Value ) )
7578 {
79+ logger . LogDebug ( $ "Attempting to map file transfer protocol from properties. Current Value: { FileTransferProtocol } , Property Value: { properties . FileTransferProtocol . Value } ") ;
7680 ApplicationSettings . FileTransferProtocolEnum fileTransferProtocol ;
7781 if ( Enum . TryParse ( properties . FileTransferProtocol . Value , out fileTransferProtocol ) )
82+ {
83+ logger . LogDebug ( "Successfully mapped file transfer protocol from properties" ) ;
7884 FileTransferProtocol = fileTransferProtocol ;
85+ }
86+
7987 }
8088
8189 if ( config . JobProperties != null )
8290 {
8391 KeyType = ! config . JobProperties . ContainsKey ( "keyType" ) || config . JobProperties [ "keyType" ] == null || string . IsNullOrEmpty ( config . JobProperties [ "keyType" ] . ToString ( ) ) ? string . Empty : config . JobProperties [ "keyType" ] . ToString ( ) ;
8492 KeySize = ! config . JobProperties . ContainsKey ( "keySize" ) || config . JobProperties [ "keySize" ] == null || string . IsNullOrEmpty ( config . JobProperties [ "keySize" ] . ToString ( ) ) || ! int . TryParse ( config . JobProperties [ "keySize" ] . ToString ( ) , out int notUsed2 ) ? 2048 : Convert . ToInt32 ( config . JobProperties [ "keySize" ] ) ;
8593 SubjectText = ! config . JobProperties . ContainsKey ( "subjectText" ) || config . JobProperties [ "subjectText" ] == null || string . IsNullOrEmpty ( config . JobProperties [ "subjectText" ] . ToString ( ) ) ? string . Empty : config . JobProperties [ "subjectText" ] . ToString ( ) ;
86- }
94+ }
95+
96+ logger . LogDebug ( "Store properties have been configured successfully. Property values:" ) ;
97+ logger . LogDebug ( $ "UserName: { UserName } ") ;
98+ logger . LogDebug ( $ "UserPassword: { LogSensitiveField ( UserPassword ) } ") ;
99+ logger . LogDebug ( $ "StorePassword: { LogSensitiveField ( StorePassword ) } ") ;
100+ logger . LogDebug ( $ "SudoImpersonatedUser: { SudoImpersonatedUser } ") ;
101+ logger . LogDebug ( $ "RemoveRootCertificate: { RemoveRootCertificate } ") ;
102+ logger . LogDebug ( $ "SSHPort: { SSHPort } ") ;
103+ logger . LogDebug ( $ "IncludePortInSPN: { IncludePortInSPN } ") ;
104+ logger . LogDebug ( $ "FileTransferProtocol: { FileTransferProtocol } ") ;
105+ logger . LogDebug ( $ "CreateCSROnDevice: { CreateCSROnDevice } ") ;
106+ logger . LogDebug ( $ "KeyType: { KeyType } ") ;
107+ logger . LogDebug ( $ "KeySize: { KeySize } ") ;
108+ logger . LogDebug ( $ "SubjectText: { SubjectText } ") ;
109+
110+ logger . MethodExit ( LogLevel . Debug ) ;
111+ }
112+
113+ private string LogSensitiveField ( string input )
114+ {
115+ return string . IsNullOrWhiteSpace ( input ) ? "" : "(hidden)" ;
87116 }
88117 }
89118}
0 commit comments