Class LicenseManager
Utility class for dealing with licenses
Namespace: SuperOffice.License
Assembly: SoDataBase.dll
Syntax
[SoInject("Database")]
public class LicenseManager : Object
Fields
SuperOfficeOwner
Utility class for dealing with licenses
Declaration
public const string SuperOfficeOwner = "superoffice"
Field Value
Type | Description |
---|---|
String |
Properties
AllowAutoUpdate
Utility class for dealing with licenses
Declaration
protected virtual bool AllowAutoUpdate { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsUnitTesting
Turn off some checking to enable unit tests to run
Declaration
[AllowedMultitenantStatic]
public static bool IsUnitTesting { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
ActivateLicenseInfo(ExtendedLicenseInfo, Boolean, Boolean)
Save a new license to the database.
Declaration
public void ActivateLicenseInfo(ExtendedLicenseInfo newLicense, bool checkSerialNumber = true, bool checkUserLicense = true)
Parameters
Type | Name | Description |
---|---|---|
ExtendedLicenseInfo | newLicense | New license to save to the database. |
Boolean | checkSerialNumber | |
Boolean | checkUserLicense |
Remarks
SuperOffice.License.LicenseManager.ValidateNewLicence(SuperOffice.License.ExtendedLicenseInfo,System.Boolean,System.Boolean) is called to validate the license before it is accepted and saved.
Exceptions
Type | Condition |
---|---|
SoException | Thrown if license is not valid. |
ChangeSerialNumber(String, String)
Change the new serial number for the installation.
Declaration
public void ChangeSerialNumber(string newCompanyName, string newSerialNumber)
Parameters
Type | Name | Description |
---|---|---|
String | newCompanyName | The new company name |
String | newSerialNumber | New serial number to change to. |
GetAssociateLicenseUsageCount(AssociateType, Int32[])
Provided an associate type and a list of module id's, count how many times each license is used. Deleted associates are not counted. License assignments with 0 license-numbers are not counted.
Declaration
public Dictionary<int, int> GetAssociateLicenseUsageCount(AssociateType associateType, params int[] associateModules)
Parameters
Type | Name | Description |
---|---|---|
AssociateType | associateType | Associate Type the license is relevant for (employee, external-user, anonymous). |
Int32[] | associateModules | Module License ids to count usage of |
Returns
Type | Description |
---|---|
Dictionary<Int32, Int32> | Dictionary containing module id as a key and how many times a license is used as value. |
GetCurrent()
Get the current LicenseManager. If constructing a new class instance and nextCheckDate is in the past, an automatic update is attempted.
Declaration
public static LicenseManager GetCurrent()
Returns
Type | Description |
---|---|
LicenseManager |
GetCurrentLicense(String, out DateTime)
Get the current license from a module owner.
Declaration
public LicenseInfo GetCurrentLicense(string moduleOwner, out DateTime accumulatedNextCheckDate)
Parameters
Type | Name | Description |
---|---|---|
String | moduleOwner | Name of the module owner |
DateTime | accumulatedNextCheckDate |
Returns
Type | Description |
---|---|
LicenseInfo | License as stored in the database. |
GetGrantedModuleLicenses(Int32)
Get granted module licenses for the provided associate.
Declaration
public GrantedModuleLicense[] GetGrantedModuleLicenses(int associateId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | associateId | Associate id's of the associate to get granted module licenses for. |
Returns
Type | Description |
---|---|
GrantedModuleLicense[] | Granted module licenses |
GetGrantedModuleLicenses(Int32, Int32)
Get granted module licenses for the provided associate.
Declaration
public GrantedModuleLicense[] GetGrantedModuleLicenses(int associateId, int satelliteId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | associateId | Associate id's of the associate to get granted module licenses for. |
Int32 | satelliteId | Satellite id of the satellite the associate is logging on to. |
Returns
Type | Description |
---|---|
GrantedModuleLicense[] | Granted module licenses |
GetLicenseForAllOwnersFromDB()
Get all licenses, with usage, from all module owners as they are stored in the database
Declaration
public ExtendedLicenseInfo[] GetLicenseForAllOwnersFromDB()
Returns
Type | Description |
---|---|
ExtendedLicenseInfo[] | Array of licenses, with usage, as it is stored in the database. |
GetLicenseFromDB(String)
Get license, with usage, as it is stored in the database for one particular module owner.
Declaration
public ExtendedLicenseInfo GetLicenseFromDB(string ownerName)
Parameters
Type | Name | Description |
---|---|---|
String | ownerName | Name of the module owner. |
Returns
Type | Description |
---|---|
ExtendedLicenseInfo | License, with usage, as it is stored in the database. NULL if no license found. |
GetLicenseFromFile(String)
Parse a license from file content for a particular module owner.
Declaration
public ExtendedLicenseInfo GetLicenseFromFile(string fileContent)
Parameters
Type | Name | Description |
---|---|---|
String | fileContent | Content of license file. |
Returns
Type | Description |
---|---|
ExtendedLicenseInfo | License from the database, from file and with usage. |
GetLicenseFromLicenseServer(String, String)
Get License from the license server for a particular module owner.
Declaration
public ExtendedLicenseInfo GetLicenseFromLicenseServer(string ownerName, string additionalInfo = null)
Parameters
Type | Name | Description |
---|---|---|
String | ownerName | Name of the module owner to get license from. |
String | additionalInfo |
Returns
Type | Description |
---|---|
ExtendedLicenseInfo | License from the database, from the license server and with usage. |
GetLicenseFromLicenseServerWithAssignments(String, Boolean, String)
Get License from the license server for a particular module owner. Validates that the license is signed ok.
Declaration
public ExtendedLicenseInfoWithAssignments GetLicenseFromLicenseServerWithAssignments(string ownerName, bool isTestUpgrade = false, string licenseUrl = null)
Parameters
Type | Name | Description |
---|---|---|
String | ownerName | Name of the module owner to get license from. |
Boolean | isTestUpgrade | Is this a test upgrade? Default false. |
String | licenseUrl |
Returns
Type | Description |
---|---|
ExtendedLicenseInfoWithAssignments | License from the database, from the license server and with new license assignments, and possibly new serial number. Possible exception if license server has not implemented method. |
GetLicenseStateFromLicenseServer(String, String)
Ping the license server and get the current state.
Declaration
public CheckLicenseStatusResult GetLicenseStateFromLicenseServer(string ownerName, string additionalInfo = null)
Parameters
Type | Name | Description |
---|---|---|
String | ownerName | Name of the owner to ping. |
String | additionalInfo | Extra info - packed into NetServer version: "TestUpgrade=true" |
Returns
Type | Description |
---|---|
CheckLicenseStatusResult | Result obtained by the license server. |
GetModuleLicenseHistoryFromLicenseServer(ExtendedLicenseInfo, ExtendedModuleLicense)
Get details about a license from the license server.
Declaration
public string GetModuleLicenseHistoryFromLicenseServer(ExtendedLicenseInfo licenseInfo, ExtendedModuleLicense moduleLicense)
Parameters
Type | Name | Description |
---|---|---|
ExtendedLicenseInfo | licenseInfo | Description of the license |
ExtendedModuleLicense | moduleLicense | Information about a particular module to get information for. |
Returns
Type | Description |
---|---|
String | Information about a particular license module. |
GetModuleOwner(String)
Get module owner from the owners name.
Declaration
public ModuleOwnerRow GetModuleOwner(string moduleOwner)
Parameters
Type | Name | Description |
---|---|---|
String | moduleOwner | Name of hte module owner |
Returns
Type | Description |
---|---|
ModuleOwnerRow | Module owner |
GetModuleOwners()
Get all the module owners.
Declaration
public ModuleOwnerRow[] GetModuleOwners()
Returns
Type | Description |
---|---|
ModuleOwnerRow[] | Array of module owners |
GetSatelliteLicenses(Int32, Boolean)
Obtain information about satellite module licenses
Declaration
public SatelliteModuleLicenseOwner[] GetSatelliteLicenses(int satelliteId, bool fetchForCentralIfSatelliteIdIsZero)
Parameters
Type | Name | Description |
---|---|---|
Int32 | satelliteId | Satellite id to check for satellite module licenses. 0 indicates central database |
Boolean | fetchForCentralIfSatelliteIdIsZero |
Returns
Type | Description |
---|---|
SatelliteModuleLicenseOwner[] | Satellite module licenses grouped by owners. |
GetSatelliteLicenseUsageCount(Int32[])
Provided a list of module id's, count how many times each license is used.
Declaration
public Dictionary<int, int> GetSatelliteLicenseUsageCount(params int[] satelliteModules)
Parameters
Type | Name | Description |
---|---|---|
Int32[] | satelliteModules | Module id's to count usage of |
Returns
Type | Description |
---|---|
Dictionary<Int32, Int32> | Dictionary containing module id as a key and how many times a license is used as value. |
GetShopUrl(String, String)
Get the shop url for a module owner, including a context string
Declaration
public string GetShopUrl(string ownerName, string context)
Parameters
Type | Name | Description |
---|---|---|
String | ownerName | |
String | context |
Returns
Type | Description |
---|---|
String |
GetUserLicenses(Int32, UserType)
Obtain information about associate module licenses
Declaration
public AssociateModuleLicenseOwner[] GetUserLicenses(int associateId, UserType allowedType)
Parameters
Type | Name | Description |
---|---|---|
Int32 | associateId | Associate id to check for associate module licenses |
UserType | allowedType |
Returns
Type | Description |
---|---|
AssociateModuleLicenseOwner[] | Associate module licenses grouped by owners. |
LicenseExists(String)
Determine if a license (owner.module) exists at all - regardsless of numbers, assignment etc
Declaration
public bool LicenseExists(string license)
Parameters
Type | Name | Description |
---|---|---|
String | license |
Returns
Type | Description |
---|---|
Boolean |
LoadNewLicenseFromServerIfNeeded()
Check nextCheckDate on all modules, and call server for those that are in the past
Declaration
public void LoadNewLicenseFromServerIfNeeded()
Remarks
The virtual AllowAutoUpdate flag can be used to inhibit auto-updating
MapAndValidateLicenseWithDb(LicenseInfo)
Get the current license from the database, map the incoming one on to it, and validate to see if the result is acceptable (can be Activated)
Declaration
public ExtendedLicenseInfo MapAndValidateLicenseWithDb(LicenseInfo newLicense)
Parameters
Type | Name | Description |
---|---|---|
LicenseInfo | newLicense |
Returns
Type | Description |
---|---|
ExtendedLicenseInfo | License including activation flags and problem tag |
PopulateSignedPublicKey(LicenseInfo, Stream)
Get a SignedPublicKey from a stream
Declaration
public static void PopulateSignedPublicKey(LicenseInfo licenseInfo, Stream publicKeyStream)
Parameters
Type | Name | Description |
---|---|---|
LicenseInfo | licenseInfo | License info object to populate with public key from stream |
Stream | publicKeyStream | Stream to read the signed public key from. |
RemoveLicenseFromDB(String)
Remove all information about a licenses from a module owner from the database
Declaration
public void RemoveLicenseFromDB(string ownerName)
Parameters
Type | Name | Description |
---|---|---|
String | ownerName |
ToInfo(ModuleLicense)
Utility class for dealing with licenses
Declaration
public static string ToInfo(ModuleLicense info)
Parameters
Type | Name | Description |
---|---|---|
ModuleLicense | info |
Returns
Type | Description |
---|---|
String |
ValidateLicenseInfo(ExtendedLicenseInfo)
Validate that a license is consistent.
Declaration
public void ValidateLicenseInfo(ExtendedLicenseInfo licenseInfo)
Parameters
Type | Name | Description |
---|---|---|
ExtendedLicenseInfo | licenseInfo | License to validate consistance for |
Exceptions
Type | Condition |
---|---|
SoException | Thrown if license is not valid. |
ValidateLicenseInfo(LicenseInfo, Boolean)
Validate that a license is consistent.
Declaration
public void ValidateLicenseInfo(LicenseInfo licenseInfo, bool checkSerialNumber = true)
Parameters
Type | Name | Description |
---|---|---|
LicenseInfo | licenseInfo | License to validate consistancy for |
Boolean | checkSerialNumber | Check that Serial Number is consistent. Throws exception if serial number is inconsistent if true. Default = true. |
Exceptions
Type | Condition |
---|---|
SoException | Thrown if license is not valid. |
ValidatePublicKey(SignedPublicKey)
Validate a Public Key
Declaration
public static void ValidatePublicKey(SignedPublicKey publicKey)
Parameters
Type | Name | Description |
---|---|---|
SignedPublicKey | publicKey | Public key to validate |
Exceptions
Type | Condition |
---|---|
SoException | Throw if failed to validate public key. |