Package ch.autumo.commons.utils.license
Class DummyLicenseHandler
java.lang.Object
ch.autumo.commons.utils.license.DummyLicenseHandler
- All Implemented Interfaces:
LicenseHandler
Dummy license handler implementation.
-
Field Summary
Fields inherited from interface ch.autumo.commons.utils.license.LicenseHandler
BASE_CFG, LIC_PATH, REG_ENTRY_CITY, REG_ENTRY_COMP, REG_ENTRY_COUNTRY, REG_ENTRY_EMAIL, REG_ENTRY_FNAME, REG_ENTRY_LNAME, REG_STATE_CHCK, REG_STATE_INIT, REG_STATE_INV -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanRead license key file and unregister if invalid.Check registration state and set application to registered or unregistered.booleancheckRuntimeLicense(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.booleanDecrease 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.booleanGet registration flag for application.Load license info from license.info.voidmakeLicenseKeyFile(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!voidregister()Set register flag when application is registered.voidrunsInServerOrConsole(boolean serverOrConsole) Initialize this handler for running within server or console (serverOrConsole = true) or on desktop (serverOrConsole = false).voidrunsOnDesktop(boolean desktop) Initialize this handler for running on desktop (desktop = true) or within server or console (desktop = false).voidstoreLicenseInfo(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Store license info as license.info.voidUnregister this application.voidupdateLicenseKeyFile(LicensedApplication app, String licKey, String newLicState) Update license key with new state.booleanvalidateLicenseKey(LicensedApplication app, String fname, String lname, String city, String company, String country, String email, String licKey) Validate a license key given.
-
Constructor Details
-
DummyLicenseHandler
public DummyLicenseHandler()Default constructor.
-
-
Method Details
-
runsOnDesktop
public void runsOnDesktop(boolean desktop) Description copied from interface:LicenseHandlerInitialize this handler for running on desktop (desktop = true) or within server or console (desktop = false).- Specified by:
runsOnDesktopin interfaceLicenseHandler- Parameters:
desktop- true, if environmnt is a desktop
-
runsInServerOrConsole
public void runsInServerOrConsole(boolean serverOrConsole) Description copied from interface:LicenseHandlerInitialize this handler for running within server or console (serverOrConsole = true) or on desktop (serverOrConsole = false).- Specified by:
runsInServerOrConsolein interfaceLicenseHandler- Parameters:
serverOrConsole- true, if environemnt is a server or console
-
register
public void register()Description copied from interface:LicenseHandlerSet register flag when application is registered.- Specified by:
registerin interfaceLicenseHandler
-
isRegistered
public boolean isRegistered()Description copied from interface:LicenseHandlerGet registration flag for application.- Specified by:
isRegisteredin interfaceLicenseHandler- Returns:
- true when registered successfully
-
unregister
public void unregister()Description copied from interface:LicenseHandlerUnregister this application.- Specified by:
unregisterin interfaceLicenseHandler
-
checkRuntimeLicense
public boolean checkRuntimeLicense(LicensedApplication app, Properties baseProps, String baseFile) throws Exception Description copied from interface:LicenseHandlerCheck 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!- Specified by:
checkRuntimeLicensein interfaceLicenseHandler- 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
Description copied from interface:LicenseHandlerCheck 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 callLicenseHandler.checkRuntimeLicense(LicensedApplication, Properties, String)before.- Specified by:
checkRegistrationin interfaceLicenseHandler- Parameters:
app- licensed application- Returns:
- lic license state (INV|INIT|CHCK) or null
-
getLicenseKey
Description copied from interface:LicenseHandlerGet license key and state from key file. Should be a synchronized implementation.- Specified by:
getLicenseKeyin interfaceLicenseHandler- Parameters:
app- licensed application- Returns:
- key & state [key,state(INV|INIT|CHCK)]
-
validateLicenseKey
public boolean validateLicenseKey(LicensedApplication app, String fname, String lname, String city, String company, String country, String email, String licKey) Description copied from interface:LicenseHandlerValidate a license key given.- Specified by:
validateLicenseKeyin interfaceLicenseHandler- Parameters:
app- licensed appfname- first namelname- last namecity- citycompany- companycountry- countryemail- emaillicKey- license key- Returns:
- true, if license key is valid
-
loadLicenseInfo
Description copied from interface:LicenseHandlerLoad license info from license.info.- Specified by:
loadLicenseInfoin interfaceLicenseHandler- Parameters:
app- licensed application- Returns:
- lic info as props
-
storeLicenseInfo
public void storeLicenseInfo(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Description copied from interface:LicenseHandlerStore license info as license.info.- Specified by:
storeLicenseInfoin interfaceLicenseHandler- Parameters:
app- licensed applicationfname- first namelname- last namecity- citycompany- companycountry- countryemail- email
-
createRegKey
public String createRegKey(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Description copied from interface:LicenseHandlerCreate a register key that can be converted to a license key.- Specified by:
createRegKeyin interfaceLicenseHandler- Parameters:
app- licensed applicationfname- first namelname- last namecity- citycompany- companycountry- countryemail- email- Returns:
- registration key
-
makeLicenseKeyFile
public void makeLicenseKeyFile(LicensedApplication app, String fname, String lname, String city, String company, String country, String email, String licState) Description copied from interface:LicenseHandlerMake a license key with given registration key and state!- Specified by:
makeLicenseKeyFilein interfaceLicenseHandler- Parameters:
app- licensed applicationfname- first namelname- last namecity- citycompany- companycountry- countryemail- emaillicState- license state
-
updateLicenseKeyFile
Description copied from interface:LicenseHandlerUpdate 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!- Specified by:
updateLicenseKeyFilein interfaceLicenseHandler- Parameters:
app- licensed applicationlicKey- license keynewLicState- new state (INV|INIT|CHCK)
-
checkOnlineLicense
Description copied from interface:LicenseHandlerRead 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!- Specified by:
checkOnlineLicensein interfaceLicenseHandler- Parameters:
app- licensed application- Returns:
- true if an online call has been made, not the result!
-
getOnlineLicState
public String[] getOnlineLicState(LicensedApplication app, String fname, String lname, String city, String company, String country, String email) Description copied from interface:LicenseHandlerGet online license state. Is it still good? - This call increases the license counter for the online license!- Specified by:
getOnlineLicStatein interfaceLicenseHandler- 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
Description copied from interface:LicenseHandlerGet online license state. Is it still good? - This call increases the license counter for the online license!- Specified by:
getOnlineLicStatein interfaceLicenseHandler- Parameters:
app- licensed applicationuserInfo- license user info properties- Returns:
- online license state and license type or null if state is not CHCK
-
getOnlineLicState
Description copied from interface:LicenseHandlerGet online license state. Is it still good? - This call increases the license counter for the online license!- Specified by:
getOnlineLicStatein interfaceLicenseHandler- Parameters:
app- licensed application- Returns:
- online license state and license type or null if state is not CHCK
-
decreaseOnlineLicense
Description copied from interface:LicenseHandlerDecrease online license count. E.g. when application is un-installed.- Specified by:
decreaseOnlineLicensein interfaceLicenseHandler- Parameters:
app- licensed application- Returns:
- true if successfull
- Throws:
IOException- if registration server call fails
-