@@ -201,6 +201,67 @@ protected virtual void RunAdd(StatusContext statusContext, string[] files, bool
201201 }
202202 }
203203
204+ protected virtual void RunInfo ( StatusContext statusContext )
205+ {
206+ Logger . LogInformation ( "Running info command" ) ;
207+
208+ if ( Bundle == null )
209+ {
210+ throw new ApplicationException ( "Bundle is not initialized" ) ;
211+ }
212+
213+ Logger . LogDebug ( "Loading bundle" ) ;
214+ statusContext . Status ( "[yellow]Loading Bundle[/]" ) ;
215+ if ( ! LoadBundle ( ) ) return ;
216+
217+ Grid bundleGrid = new Grid ( ) ;
218+ bundleGrid . AddColumn ( new GridColumn ( ) . NoWrap ( ) ) ;
219+ bundleGrid . AddColumn ( new GridColumn ( ) . PadLeft ( 2 ) ) ;
220+
221+ bundleGrid . AddRow ( "Bundle Info:" ) ;
222+ bundleGrid . AddRow ( " Full Path:" , Bundle . BundlePath ) ;
223+ bundleGrid . AddRow ( " Updated By:" , Bundle . Manifest . UpdatedBy ?? "N/A" ) ;
224+ bundleGrid . AddRow ( " Protected Entry Names:" , Bundle . Manifest . ProtectedEntryNames . Count . ToString ( ) ) ;
225+ bundleGrid . AddRow ( " Store Files In Bundle:" , Bundle . Manifest . StoreOriginalFiles ? "Yes" : "No" ) ;
226+ bundleGrid . AddRow ( " Manifest Entries:" , Bundle . Manifest . Entries . Count . ToString ( ) ) ;
227+ bundleGrid . AddRow ( " Manifest Is Signed:" , Bundle . Signatures . Entries . Count > 0 ? "Yes" : "No" ) ;
228+ bundleGrid . AddRow ( " Signature Count:" , Bundle . Signatures . Entries . Count . ToString ( ) ) ;
229+
230+ AnsiConsole . Write ( bundleGrid ) ;
231+ AnsiConsole . WriteLine ( ) ;
232+
233+ Grid protectedEntries = new Grid ( ) ;
234+ protectedEntries . AddColumn ( new GridColumn ( ) . NoWrap ( ) ) ;
235+
236+ protectedEntries . AddRow ( "Protected Entry Names:" ) ;
237+
238+ foreach ( var entryName in Bundle . Manifest . ProtectedEntryNames )
239+ {
240+ protectedEntries . AddRow ( $ " { entryName } ") ;
241+ }
242+
243+ AnsiConsole . Write ( protectedEntries ) ;
244+ AnsiConsole . WriteLine ( ) ;
245+
246+ Grid manifestEntries = new Grid ( ) ;
247+ manifestEntries . AddColumn ( new GridColumn ( ) ) ;
248+ manifestEntries . AddColumn ( new GridColumn ( ) . PadLeft ( 2 ) . Width ( 18 ) ) ;
249+
250+ manifestEntries . AddRow ( "Manifest Entries:" ) ;
251+ manifestEntries . AddRow ( " Entry Name" , "Hash" ) ;
252+
253+ foreach ( var entry in Bundle . Manifest . Entries )
254+ {
255+ var entryHash = BitConverter . ToString ( entry . Value ) . Replace ( "-" , "" ) ;
256+ manifestEntries . AddRow ( $ " { entry . Key } ", $ "{ entryHash [ 0 ..8 ] } ..{ entryHash . Substring ( entryHash . Length - 8 ) } ") ;
257+ }
258+
259+ AnsiConsole . Write ( manifestEntries ) ;
260+ AnsiConsole . WriteLine ( ) ;
261+
262+ CertificateUtilities . DisplayCertificate ( Bundle . Signatures . Entries . Keys . Select ( Bundle . GetCertificate ) . ToArray ( ) ) ;
263+ }
264+
204265 /// <summary>
205266 /// Runs the sign command.
206267 /// </summary>
@@ -236,19 +297,7 @@ protected virtual void RunSign(StatusContext statusContext, X509Certificate2Coll
236297 Logger . LogDebug ( "Loading certificate information for {Cert}" , cert ) ;
237298 statusContext . Status ( "[yellow]Loading certificate informations[/]" ) ;
238299
239- Grid grid = new Grid ( ) ;
240- grid . AddColumn ( new GridColumn ( ) . NoWrap ( ) ) ;
241- grid . AddColumn ( new GridColumn ( ) . PadLeft ( 2 ) ) ;
242- grid . AddRow ( "Certificate Info:" ) ;
243- grid . AddRow ( " Common Name" , cert . GetNameInfo ( X509NameType . SimpleName , false ) ) ;
244- grid . AddRow ( " Issuer Name" , cert . GetNameInfo ( X509NameType . SimpleName , true ) ) ;
245- grid . AddRow ( " Holder Email" , cert . GetNameInfo ( X509NameType . EmailName , false ) ) ;
246- grid . AddRow ( " Valid From" , cert . GetEffectiveDateString ( ) ) ;
247- grid . AddRow ( " Valid To" , cert . GetExpirationDateString ( ) ) ;
248- grid . AddRow ( " Thumbprint" , cert . Thumbprint ) ;
249-
250- AnsiConsole . Write ( grid ) ;
251- AnsiConsole . WriteLine ( ) ;
300+ CertificateUtilities . DisplayCertificate ( cert ) ;
252301
253302 Logger . LogDebug ( "Verifying certificate {cert}" , cert ) ;
254303 statusContext . Status ( "[yellow]Verifying Certificate[/]" ) ;
0 commit comments