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 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.
-
Constructor Details
-
DummyLicenseHandler
public DummyLicenseHandler()Default constructor.
-
-
Method Details
-
runsOnDesktop
public void runsOnDesktop(boolean desktop) Description copied from interface:LicenseHandler
Initialize this handler for running on desktop (desktop = true) or within server or console (desktop = false).- Specified by:
runsOnDesktop
in interfaceLicenseHandler
- Parameters:
desktop
- true, if environmnt is a desktop
-
runsInServerOrConsole
public void runsInServerOrConsole(boolean serverOrConsole) Description copied from interface:LicenseHandler
Initialize this handler for running within server or console (serverOrConsole = true) or on desktop (serverOrConsole = false).- Specified by:
runsInServerOrConsole
in interfaceLicenseHandler
- Parameters:
serverOrConsole
- true, if environemnt is a server or console
-
register
public void register()Description copied from interface:LicenseHandler
Set register flag when application is registered.- Specified by:
register
in interfaceLicenseHandler
-
isRegistered
public boolean isRegistered()Description copied from interface:LicenseHandler
Get registration flag for application.- Specified by:
isRegistered
in interfaceLicenseHandler
- Returns:
- true when registered successfully
-
unregister
public void unregister()Description copied from interface:LicenseHandler
Unregister this application.- Specified by:
unregister
in interfaceLicenseHandler
-
checkRuntimeLicense
public boolean checkRuntimeLicense(LicensedApplication app, Properties baseProps, String baseFile) throws Exception Description copied from interface:LicenseHandler
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!- Specified by:
checkRuntimeLicense
in 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:LicenseHandler
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 callLicenseHandler.checkRuntimeLicense(LicensedApplication, Properties, String)
before.- Specified by:
checkRegistration
in interfaceLicenseHandler
- Parameters:
app
- licensed application- Returns:
- lic license state (INV|INIT|CHCK) or null
-
getLicenseKey
Description copied from interface:LicenseHandler
Get license key and state from key file. Should be a synchronized implementation.- Specified by:
getLicenseKey
in 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:LicenseHandler
Validate a license key given.- Specified by:
validateLicenseKey
in 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:LicenseHandler
Load license info from license.info.- Specified by:
loadLicenseInfo
in 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:LicenseHandler
Store license info as license.info.- Specified by:
storeLicenseInfo
in 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:LicenseHandler
Create a register key that can be converted to a license key.- Specified by:
createRegKey
in 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:LicenseHandler
Make a license key with given registration key and state!- Specified by:
makeLicenseKeyFile
in interfaceLicenseHandler
- Parameters:
app
- licensed applicationfname
- first namelname
- last namecity
- citycompany
- companycountry
- countryemail
- emaillicState
- license state
-
updateLicenseKeyFile
Description copied from interface:LicenseHandler
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!- Specified by:
updateLicenseKeyFile
in interfaceLicenseHandler
- Parameters:
app
- licensed applicationlicKey
- license keynewLicState
- new state (INV|INIT|CHCK)
-
checkOnlineLicense
Description copied from interface:LicenseHandler
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!- Specified by:
checkOnlineLicense
in 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:LicenseHandler
Get online license state. Is it still good? - This call increases the license counter for the online license!- Specified by:
getOnlineLicState
in 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:LicenseHandler
Get online license state. Is it still good? - This call increases the license counter for the online license!- Specified by:
getOnlineLicState
in 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:LicenseHandler
Get online license state. Is it still good? - This call increases the license counter for the online license!- Specified by:
getOnlineLicState
in interfaceLicenseHandler
- Parameters:
app
- licensed application- Returns:
- online license state and license type or null if state is not CHCK
-
decreaseOnlineLicense
Description copied from interface:LicenseHandler
Decrease online license count. E.g. when application is un-installed.- Specified by:
decreaseOnlineLicense
in interfaceLicenseHandler
- Parameters:
app
- licensed application- Returns:
- true if successfull
- Throws:
IOException
- if registration server call fails
-