EasySign BETA
Digital Signing Tool
Loading...
Searching...
No Matches
SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration > Class Template Referenceabstract

Provides command definitions and handlers for the EasySign command line interface. More...

Public Member Functions

RootCommand GetRootCommand ()
 Gets the root command for the command line interface.
 
virtual void RunSelfSign (bool force, string? commonName, string? email, string? organization, string? organizationalUnit, string? locality, string? state, string? country)
 Runs the self-sign command to create a self-signed root CA certificate.
 

Protected Member Functions

void InitializeBundle (string bundlePath)
 Initializes the bundle.
 
bool LoadBundle (bool readOnly=true)
 Loads the bundle from file and handles load errors.
 
virtual void RunAdd (StatusContext statusContext, string[] files, bool replace, bool recursive, bool continueOnError, bool force)
 Runs the add command.
 
virtual void RunInfo (StatusContext statusContext)
 Runs the info command.
 
virtual void RunSign (StatusContext statusContext, X509Certificate2Collection certificates, bool skipVerify)
 Runs the sign command.
 
virtual bool RunVerify (StatusContext statusContext, bool ignoreTime)
 Runs the verify command.
 
bool VerifyCertificate (X509Certificate2 certificate, bool ignoreTime)
 Verifies the validity of a certificate.
 
bool VerifyCertificateImpl (X509Certificate2 certificate, bool ignoreTime, out X509ChainStatus[] chainStatuses)
 Verifies the certificate using the configured trust stores.
 
 CommandProvider (TConfiguration? configuration, ILogger? logger)
 Initializes a new instance of the CommandProvider<TBundle, TConfiguration> class.
 
X509Certificate2? GetSelfSigningRootCA ()
 Gets the self-signed root CA.
 

Properties

TBundle? Bundle [get, protected set]
 Gets or sets the bundle.
 
ILogger Logger [get, set]
 Gets or sets the logger to use for logging.
 
TConfiguration Configuration [get]
 Gets the application configurations.
 
Argument< string > BundlePath [get]
 Gets the common argument for the bundle path.
 
Command Add [get]
 Gets the command for creating a new bundle or updating an existing one.
 
Command Info [get]
 Gets the command for Showing bundle information.
 
Command Sign [get]
 Gets the command for signing bundle with one or more certificate.
 
Command Verify [get]
 Gets the command for verifying bundle.
 
Command SelfSign [get]
 Gets the command for generating a self-signed root CA certificate.
 
Command?? Trust [get]
 Gets the command for managing trusted root CAs and intermediate CAs.
 
Command Config [get]
 Gets the command for managing configuration settings.
 

Detailed Description

Provides command definitions and handlers for the EasySign command line interface.

Template Parameters
TBundleThe type of the bundle.
TConfigurationThe type of the command provider configuration.
Type Constraints
TBundle :Bundle 
TConfiguration :CommandProviderConfiguration 
TConfiguration :new() 

Definition at line 21 of file CommandProvider.cs.

Constructor & Destructor Documentation

◆ CommandProvider()

SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.CommandProvider ( TConfiguration? configuration,
ILogger? logger )
protected

Initializes a new instance of the CommandProvider<TBundle, TConfiguration> class.

Parameters
configurationThe configuration for the command provider. If null, a default configuration will be used.
loggerThe logger to use for logging. If null, a default null logger will be used.
Exceptions
ArgumentNullException

Definition at line 45 of file CommandProvider.cs.

References SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Configuration, and SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Logger.

Member Function Documentation

◆ GetRootCommand()

RootCommand SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.GetRootCommand ( )
abstract

Gets the root command for the command line interface.

Returns
The root command.

◆ GetSelfSigningRootCA()

X509Certificate2? SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.GetSelfSigningRootCA ( )
protected

Gets the self-signed root CA.

Returns
The self-signed root CA certificate, or null if it does not exist.

Definition at line 600 of file CommandProvider.cs.

References SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Configuration.

◆ InitializeBundle()

void SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.InitializeBundle ( string bundlePath)
abstractprotected

Initializes the bundle.

Parameters
bundlePathPath of the bundle.

◆ LoadBundle()

◆ RunAdd()

virtual void SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.RunAdd ( StatusContext statusContext,
string[] files,
bool replace,
bool recursive,
bool continueOnError,
bool force )
protectedvirtual

Runs the add command.

Parameters
statusContextThe status context for interacting with AnsiConsole.Status.
filesThe files to add to the bundle.
replaceA value indicating whether to replace existing entries.
recursiveA value indicating whether to add files recursively.
continueOnErrorA value indicating whether to continue adding files if an error occurs.
forceA value indicating whether to force the addition of files to a signed bundle.

Definition at line 83 of file BundleWorker.cs.

References SAPTeam.EasySign.Bundle.AddEntry(), SAPTeam.EasySign.Bundle.BundlePath, SAPTeam.EasySign.Bundle.DeleteEntry(), SAPTeam.EasySign.Manifest.Entries, SAPTeam.EasySign.Signatures.Entries, SAPTeam.EasySign.Manifest.GetNormalizedEntryName(), SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.LoadBundle(), SAPTeam.EasySign.Bundle.Loaded, SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Logger, SAPTeam.EasySign.Bundle.Manifest, SAPTeam.EasySign.Bundle.RootPath, SAPTeam.EasySign.Bundle.Signatures, and SAPTeam.EasySign.Bundle.Update().

◆ RunInfo()

◆ RunSelfSign()

virtual void SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.RunSelfSign ( bool force,
string? commonName,
string? email,
string? organization,
string? organizationalUnit,
string? locality,
string? state,
string? country )
virtual

Runs the self-sign command to create a self-signed root CA certificate.

Parameters
forceA value indicating whether to force the creation of a new self-signed root CA certificate even if one already exists.
commonNameCommon Name (CN) - required. if not specified, will prompt for user input.
emailEmail (E) - optional.
organizationOrganization (O) - optional.
organizationalUnitOrganizational Unit (OU) - optional.
localityLocality (L) - optional.
stateState or Province (ST) - optional.
countryCountry (C) - optional.

Definition at line 543 of file CommandProvider.cs.

References SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Configuration, SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Logger, and SAPTeam.EasySign.CommandLine.CertificateSubject.ToString().

◆ RunSign()

virtual void SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.RunSign ( StatusContext statusContext,
X509Certificate2Collection certificates,
bool skipVerify )
protectedvirtual

Runs the sign command.

Parameters
statusContextThe status context for interacting with AnsiConsole.Status.
certificatesThe certificates.
skipVerifyA value indicating whether to skip certificate verification.

Definition at line 293 of file BundleWorker.cs.

References SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.LoadBundle(), SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Logger, SAPTeam.EasySign.Bundle.Sign(), SAPTeam.EasySign.Bundle.Update(), and SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.VerifyCertificate().

◆ RunVerify()

virtual bool SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.RunVerify ( StatusContext statusContext,
bool ignoreTime )
protectedvirtual

Runs the verify command.

Parameters
statusContextThe status context for interacting with AnsiConsole.Status.
ignoreTimeA value indicating whether to ignore time validity checks for certificate verification.
Returns
true

if the verification was successful; otherwise, false

Definition at line 380 of file BundleWorker.cs.

References SAPTeam.EasySign.Manifest.Entries, SAPTeam.EasySign.Signatures.Entries, SAPTeam.EasySign.Bundle.GetCertificate(), SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.LoadBundle(), SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Logger, SAPTeam.EasySign.Bundle.Manifest, SAPTeam.EasySign.Bundle.Signatures, SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.VerifyCertificate(), and SAPTeam.EasySign.Bundle.VerifySignature().

◆ VerifyCertificate()

bool SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.VerifyCertificate ( X509Certificate2 certificate,
bool ignoreTime )
protected

Verifies the validity of a certificate.

This method has console output. For internal usages, call VerifyCertificateImpl(X509Certificate2, bool, out X509ChainStatus[]) instead.

Parameters
certificateThe certificate to verify.
ignoreTimeA value indicating whether to ignore time validity checks.
Returns
true if the certificate is valid; otherwise, false.

Definition at line 555 of file BundleWorker.cs.

Referenced by SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.RunSign(), and SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.RunVerify().

◆ VerifyCertificateImpl()

bool SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.VerifyCertificateImpl ( X509Certificate2 certificate,
bool ignoreTime,
out X509ChainStatus[] chainStatuses )
protected

Verifies the certificate using the configured trust stores.

Parameters
certificateThe certificate to verify.
ignoreTimeA value indicating whether to ignore time validity checks.
chainStatusesThe chain statuses of the verification.
Returns
true if the certificate is valid; otherwise, false.
Exceptions
ApplicationException

Definition at line 584 of file BundleWorker.cs.

References SAPTeam.EasySign.Bundle.VerifyCertificate().

Property Documentation

◆ Add

Command SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Add
get

Gets the command for creating a new bundle or updating an existing one.

Definition at line 66 of file CommandProvider.cs.

◆ Bundle

TBundle? SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Bundle
getprotected set

Gets or sets the bundle.

Definition at line 14 of file BundleWorker.cs.

◆ BundlePath

Argument<string> SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.BundlePath
getprotected
Initial value:
= new Argument<string>("bundle", "Bundle path or directory containing the bundle\n" +
"if the bundle name is not specified, a default name will be used")

Gets the common argument for the bundle path.

Definition at line 54 of file CommandProvider.cs.

◆ Config

Command SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Config
get

Gets the command for managing configuration settings.

Definition at line 467 of file CommandProvider.cs.

◆ Configuration

◆ Info

Command SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Info
get

Gets the command for Showing bundle information.

Definition at line 120 of file CommandProvider.cs.

◆ Logger

◆ SelfSign

Command SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.SelfSign
get

Gets the command for generating a self-signed root CA certificate.

Definition at line 282 of file CommandProvider.cs.

◆ Sign

Command SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Sign
get

Gets the command for signing bundle with one or more certificate.

Definition at line 142 of file CommandProvider.cs.

◆ Trust

Command?? SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Trust
get

Gets the command for managing trusted root CAs and intermediate CAs.

Definition at line 339 of file CommandProvider.cs.

◆ Verify

Command SAPTeam.EasySign.CommandLine.CommandProvider< TBundle, TConfiguration >.Verify
get

Gets the command for verifying bundle.

Definition at line 256 of file CommandProvider.cs.


The documentation for this class was generated from the following files: