Package ch.autumo.commons.utils.license
Interface LicenseHandler
- All Known Implementing Classes:
DummyLicenseHandler
public interface LicenseHandler
License Handler Interface.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Base configuration, usually within app-'cfg/' path.static final String
License path, usually within app-'cfg/' path.static final String
Registration information city property key.static final String
Registration information company property key.static final String
Registration information country property key.static final String
Registration information email property key.static final String
Registration information first name property key.static final String
Registration information last name property key.static final String
License state: Checked & valid.static final String
License state: Initialize - Not registered and not invalidated.static final String
License state: Invalidated! -
Method Summary
Modifier and TypeMethodDescriptionboolean
Read license key file and unregister if invalid.Check registration state and set application to registered or unregistered.boolean
checkRuntimeLicense
(LicensedApplication app, Properties baseProps, String baseFile) Check runtime license, is it a limited or unlimited version.createRegKey
(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Create a register key that can be converted to a license key.boolean
Decrease online license count.String[]
Get license key and state from key file.String[]
Get online license state.String[]
getOnlineLicState
(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Get online license state.String[]
getOnlineLicState
(LicensedApplication app, Properties userInfo) Get online license state.boolean
Get registration flag for application.Load license info from license.info.void
makeLicenseKeyFile
(LicensedApplication app, String fname, String lname, String city, String company, String country, String email, String licState) Make a license key with given registration key and state!void
register()
Set register flag when application is registered.void
runsInServerOrConsole
(boolean serverOrConsole) Initialize this handler for running within server or console (serverOrConsole = true) or on desktop (serverOrConsole = false).void
runsOnDesktop
(boolean desktop) Initialize this handler for running on desktop (desktop = true) or within server or console (desktop = false).void
storeLicenseInfo
(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Store license info as license.info.void
Unregister this application.void
updateLicenseKeyFile
(LicensedApplication app, String licKey, String newLicState) Update license key with new state.boolean
validateLicenseKey
(LicensedApplication app, String fname, String lname, String city, String company, String country, String email, String licKey) Validate a license key given.
-
Field Details
-
BASE_CFG
Base configuration, usually within app-'cfg/' path.- See Also:
-
LIC_PATH
License path, usually within app-'cfg/' path.- See Also:
-
REG_STATE_INIT
License state: Initialize - Not registered and not invalidated.- See Also:
-
REG_STATE_INV
License state: Invalidated!- See Also:
-
REG_STATE_CHCK
License state: Checked & valid.- See Also:
-
REG_ENTRY_FNAME
Registration information first name property key.- See Also:
-
REG_ENTRY_LNAME
Registration information last name property key.- See Also:
-
REG_ENTRY_CITY
Registration information city property key.- See Also:
-
REG_ENTRY_COMP
Registration information company property key.- See Also:
-
REG_ENTRY_COUNTRY
Registration information country property key.- See Also:
-
REG_ENTRY_EMAIL
Registration information email property key.- See Also:
-
-
Method Details
-
runsOnDesktop
void runsOnDesktop(boolean desktop) Initialize this handler for running on desktop (desktop = true) or within server or console (desktop = false).- Parameters:
desktop
- true, if environmnt is a desktop
-
runsInServerOrConsole
void runsInServerOrConsole(boolean serverOrConsole) Initialize this handler for running within server or console (serverOrConsole = true) or on desktop (serverOrConsole = false).- Parameters:
serverOrConsole
- true, if environemnt is a server or console
-
register
void register()Set register flag when application is registered. -
isRegistered
boolean isRegistered()Get registration flag for application.- Returns:
- true when registered successfully
-
unregister
void unregister()Unregister this application. -
checkRuntimeLicense
boolean checkRuntimeLicense(LicensedApplication app, Properties baseProps, String baseFile) throws Exception Check runtime license, is it a limited or unlimited version.
Also see 'rt_type' in decrypted 'cfg/base.cfg' (in production encrypted version 'cfg/base.ifc' is used):
rtType:date:internalSecKey
Possible values:
limited|unlimited|numberOfDays:dd.MM.yyyy:internalSecKeyInHex
Examples:
'unlimited:01.01.2199:abcdabcdabcdabcdabcdabcdabcdabcd'
--> Usually a full version
'30:14.02.1975:abcdabcdabcdabcdabcdabcdabcdabcd'
--> Usually a trial version; the first value will be replaced with 'limited' and the second with a real date in future calculated on the days specified after calling this method!- Parameters:
app
- applicationbaseProps
- the loaded base configuration file propertiesbaseFile
- the base configuration file ('cfg/base.ifc')- Returns:
- true, if runtime license is good, otherwise false
- Throws:
Exception
- if runtime cannot be checked
-
checkRegistration
Check registration state and set application to registered or unregistered.
NOTE: This should be called first after creating a handler, this checks the license! But you can callcheckRuntimeLicense(LicensedApplication, Properties, String)
before.- Parameters:
app
- licensed application- Returns:
- lic license state (INV|INIT|CHCK) or null
-
getLicenseKey
Get license key and state from key file. Should be a synchronized implementation.- Parameters:
app
- licensed application- Returns:
- key & state [key,state(INV|INIT|CHCK)]
-
validateLicenseKey
boolean validateLicenseKey(LicensedApplication app, String fname, String lname, String city, String company, String country, String email, String licKey) Validate a license key given.- Parameters:
app
- licensed appfname
- first namelname
- last namecity
- citycompany
- companycountry
- countryemail
- emaillicKey
- license key- Returns:
- true, if license key is valid
-
loadLicenseInfo
Load license info from license.info.- Parameters:
app
- licensed application- Returns:
- lic info as props
-
storeLicenseInfo
void storeLicenseInfo(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Store license info as license.info.- Parameters:
app
- licensed applicationfname
- first namelname
- last namecity
- citycompany
- companycountry
- countryemail
- email
-
createRegKey
String createRegKey(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Create a register key that can be converted to a license key.- Parameters:
app
- licensed applicationfname
- first namelname
- last namecity
- citycompany
- companycountry
- countryemail
- email- Returns:
- registration key
-
makeLicenseKeyFile
void makeLicenseKeyFile(LicensedApplication app, String fname, String lname, String city, String company, String country, String email, String licState) Make a license key with given registration key and state!- Parameters:
app
- licensed applicationfname
- first namelname
- last namecity
- citycompany
- companycountry
- countryemail
- emaillicState
- license state
-
updateLicenseKeyFile
Update license key with new state. This is necessary if we have a software that can or must be licensed. If the license check somehow fails for that software, we can update the license and invalidate it for example; the software will never be valid again after that!- Parameters:
app
- licensed applicationlicKey
- license keynewLicState
- new state (INV|INIT|CHCK)
-
checkOnlineLicense
Read license key file and unregister if invalid. If state = CHCK all good, if state = INIT we call the online check! If online check is bad, we invalidate. - This call increases the license counter for the online license! - This call manipulates the local license!- Parameters:
app
- licensed application- Returns:
- true if an online call has been made, not the result!
-
getOnlineLicState
String[] getOnlineLicState(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Get online license state. Is it still good? - This call increases the license counter for the online license!- Parameters:
app
- licensed applicationfname
- first namelname
- last namecity
- citycompany
- companycountry
- countryemail
- email- Returns:
- online license state and license type or null if state is not CHCK
-
getOnlineLicState
Get online license state. Is it still good? - This call increases the license counter for the online license!- Parameters:
app
- licensed applicationuserInfo
- license user info properties- Returns:
- online license state and license type or null if state is not CHCK
-
getOnlineLicState
Get online license state. Is it still good? - This call increases the license counter for the online license!- Parameters:
app
- licensed application- Returns:
- online license state and license type or null if state is not CHCK
-
decreaseOnlineLicense
Decrease online license count. E.g. when application is un-installed.- Parameters:
app
- licensed application- Returns:
- true if successfull
- Throws:
IOException
- if registration server call fails
-