C# 클래스 ComponentFactory.Krypton.Ribbon.EncryptedLicenseProvider

Defines a .NET LicenseProvider that uses encrypted licenses generated by the Infralution Licensing System.

The Infralution Licensing System provides a secure way of licensing .NET controls, components and applications. Licenses are protected using public key encryption to minimize possibility of cracking.

Components or controls use the LicenseProviderAttribute to specify this class as the LicenseProvider

상속: System.ComponentModel.LicenseProvider
파일 보기 프로젝트 열기: ComponentFactory/Krypton 1 사용 예제들

Private Properties

프로퍼티 타입 설명
ArrayEqual bool
ArraySize int
FromHex byte[]
GetEncryptionKey byte[]
GetLicense EncryptedLicense
LoadLicense EncryptedLicense
Strip string
ToHex string

공개 메소드들

메소드 설명
GenerateKey ( string password, string productInfo, UInt16 serialNo ) : string

Generate a new encrypted license using the given password

If there is no installed license for the Infralution Licensing System then the only allowed password is "TEST" and the only allowed serial numbers are 1 or 0. To use the licensed version of this method ensure that the file Infralution.Licensing.EncryptedLicenseProvider.lic exists in the same directory as the Infralution.Licensing.dll and contains a valid license key for the Licensing System.

GenerateLicenseParameters ( string password ) : string

Generate the XML license parameter string that is used to validate licenses generated using the given password

GetLicense ( System.ComponentModel.LicenseContext context, Type type, object instance, bool allowExceptions ) : License

Get a license (if installed) for the given context, type and instance

InstallLicense ( Type type, string licenseKey ) : EncryptedLicense

Install a license for the given type.

This method is used by client applications to allow customers to register license for components. The generic Infralution.Licensing.LicenseInstallForm uses this method to install licenses. Client components may implement their own registration forms that call this method. You must call SetParameters before using this method.

SetParameters ( string licenseParameters ) : void

Set the parameters used to validate licenses created by this provider.

This must be called by the client software prior to obtaining licenses using the EncryptedLicenseProvider. The parameters are generated using the Infralution License Key Generator and pasted into the calling client code.

ValidateLicenseKey ( string licenseKey ) : EncryptedLicense

Validate that the given license key is valid for the current licensing parameters

This method provides a mechanism to validate that a given license key is valid prior to attempting to install it. This can be useful if you want to check the EncryptedLicense.ProductInfo before installing the license. You must call SetParameters before using this method.

보호된 메소드들

메소드 설명
GetLicenseDirectory ( System.ComponentModel.LicenseContext context, Type type ) : string

Return the directory used to store license files

GetLicenseFilePath ( System.ComponentModel.LicenseContext context, Type type ) : string

Called by GetLicenseKey to get the file path to obtain the license from (if there is no runtime license saved in the context)

This can be overridden to change the file used to store the design time license for the provider. By default the the license file is stored in the same directory as the component executable with the name based on the fully qualified type name eg MyNamespace.MyControl.lic

GetLicenseKey ( System.ComponentModel.LicenseContext context, Type type ) : string

Return the license key for the given context and type

This can be overridden to change where the license key is stored by the provider. For instance a derived class could override this method to store the key in the Registry.

ReadKeyFromFile ( string licenseFile ) : string

Read a license key from the given file

ReadKeyFromRegistry ( ) : string

Grab the key from the registry.

비공개 메소드들

메소드 설명
ArrayEqual ( byte a1, byte a2 ) : bool

Are the contents of the two byte arrays equal

ArraySize ( int length ) : int

Return the array size to use when declaring an array of the given length.

This is used to account for the difference between declaring VB and C# arrays and permit automatic conversion of the code to VB

FromHex ( string hex ) : byte[]

Converts a hexadecimal string into a byte array.

GetEncryptionKey ( string password ) : byte[]

Generate an 8 byte DES encryption key using the given password

Only the first 7 bytes of the key returned are used. This enables us to reduce the size of the final license keys by 8 bytes.

GetLicense ( string licenseKey, string password ) : EncryptedLicense

Return the license information from the given license key

LoadLicense ( System.ComponentModel.LicenseContext context, Type type, string licenseKey ) : EncryptedLicense

Extract the license for the given type from the given licenseKey

Strip ( string value, string characters ) : string

Return the given input string stripped of the given characters

ToHex ( byte data ) : string

Converts a byte array into a hexadecimal representation.

메소드 상세

GenerateKey() 공개 메소드

Generate a new encrypted license using the given password
If there is no installed license for the Infralution Licensing System then the only allowed password is "TEST" and the only allowed serial numbers are 1 or 0. To use the licensed version of this method ensure that the file Infralution.Licensing.EncryptedLicenseProvider.lic exists in the same directory as the Infralution.Licensing.dll and contains a valid license key for the Licensing System.
public GenerateKey ( string password, string productInfo, UInt16 serialNo ) : string
password string The password used to encrypted the license data
productInfo string User defined data about the product being licensed
serialNo System.UInt16 The unique license serial number
리턴 string

GenerateLicenseParameters() 공개 메소드

Generate the XML license parameter string that is used to validate licenses generated using the given password
public GenerateLicenseParameters ( string password ) : string
password string The password used to encrypted the license data
리턴 string

GetLicense() 공개 메소드

Get a license (if installed) for the given context, type and instance
public GetLicense ( System.ComponentModel.LicenseContext context, Type type, object instance, bool allowExceptions ) : License
context System.ComponentModel.LicenseContext The context (design or runtime)
type System.Type The type to get the license for
instance object
allowExceptions bool If true LicenseException is thrown if a valid license cannot be loaded
리턴 License

GetLicenseDirectory() 보호된 메소드

Return the directory used to store license files
protected GetLicenseDirectory ( System.ComponentModel.LicenseContext context, Type type ) : string
context System.ComponentModel.LicenseContext The licence context
type System.Type The type being licensed
리턴 string

GetLicenseFilePath() 보호된 메소드

Called by GetLicenseKey to get the file path to obtain the license from (if there is no runtime license saved in the context)
This can be overridden to change the file used to store the design time license for the provider. By default the the license file is stored in the same directory as the component executable with the name based on the fully qualified type name eg MyNamespace.MyControl.lic
protected GetLicenseFilePath ( System.ComponentModel.LicenseContext context, Type type ) : string
context System.ComponentModel.LicenseContext The licence context
type System.Type The type to get the license for
리턴 string

GetLicenseKey() 보호된 메소드

Return the license key for the given context and type
This can be overridden to change where the license key is stored by the provider. For instance a derived class could override this method to store the key in the Registry.
protected GetLicenseKey ( System.ComponentModel.LicenseContext context, Type type ) : string
context System.ComponentModel.LicenseContext The license context
type System.Type The type to get the key for
리턴 string

InstallLicense() 공개 메소드

Install a license for the given type.
This method is used by client applications to allow customers to register license for components. The generic Infralution.Licensing.LicenseInstallForm uses this method to install licenses. Client components may implement their own registration forms that call this method. You must call SetParameters before using this method.
public InstallLicense ( Type type, string licenseKey ) : EncryptedLicense
type System.Type The type to install the license for
licenseKey string The license key to install
리턴 EncryptedLicense

ReadKeyFromFile() 보호된 메소드

Read a license key from the given file
protected ReadKeyFromFile ( string licenseFile ) : string
licenseFile string The path to the license file to read the key from
리턴 string

ReadKeyFromRegistry() 보호된 메소드

Grab the key from the registry.
protected ReadKeyFromRegistry ( ) : string
리턴 string

SetParameters() 공개 정적인 메소드

Set the parameters used to validate licenses created by this provider.
This must be called by the client software prior to obtaining licenses using the EncryptedLicenseProvider. The parameters are generated using the Infralution License Key Generator and pasted into the calling client code.
public static SetParameters ( string licenseParameters ) : void
licenseParameters string An XML string containing parameters used to validate licenses
리턴 void

ValidateLicenseKey() 공개 메소드

Validate that the given license key is valid for the current licensing parameters
This method provides a mechanism to validate that a given license key is valid prior to attempting to install it. This can be useful if you want to check the EncryptedLicense.ProductInfo before installing the license. You must call SetParameters before using this method.
public ValidateLicenseKey ( string licenseKey ) : EncryptedLicense
licenseKey string The license key to validate
리턴 EncryptedLicense