Package org.openbravo.erpCommon.obps
Class ActivationKey
- java.lang.Object
-
- org.openbravo.erpCommon.obps.ActivationKey
-
public class ActivationKey extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ActivationKey.CommercialModuleStatus
static class
ActivationKey.FeatureRestriction
static class
ActivationKey.LicenseClass
static class
ActivationKey.LicenseRestriction
static class
ActivationKey.LicenseType
static class
ActivationKey.SubscriptionStatus
static class
ActivationKey.WSRestriction
-
Constructor Summary
Constructors Constructor Description ActivationKey(String publicKey, String activationKey)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ActivationKey.WSRestriction
checkNewWSCall(boolean updateCounter)
This method checks web service can be called.ActivationKey.LicenseRestriction
checkOPSLimitations()
Deprecated.ActivationKey.LicenseRestriction
checkOPSLimitations(String currentSession)
ActivationKey.LicenseRestriction
checkOPSLimitations(String currentSession, String sessionType)
Checks the current activation keystatic boolean
consumesConcurrentUser(String sessionType)
Returns whether a session type is counted for concurrent usersboolean
forceSysAdminLogin(javax.servlet.http.HttpSession session)
Returns whether only System Admin should be allowed, because it is already set in session or there are license restrictions.ModuleLicenseRestrictions.ActivationMsg
getActivationMessage()
activation message to be displayed in Instance Activation windowint
getActiveSessions(String currentSession)
Returns the number of current active sessionsList<ModuleLicenseRestrictions.AdditionalInfo>
getAdditionalMessageInfo()
get all additional messages to be printed in Instance Activation window.Long
getAllowedPosTerminals()
Date
getEndDate()
String
getErrorMessage()
org.codehaus.jettison.json.JSONObject
getExpirationMessage(String lang)
Returns a JSONObject with a message warning about near expiration or already expired instance to be displayed in Login page.ArrayList<Module>
getExpiredInstalledModules()
Obtains a List of all the modules that are installed in the instance which license has expired.int
getExtraWsExceededDaysAllowed()
Returns the number of days that can exceed the maximum number of ws calls taking into account the ones that exceeded it during last 30 days.static ActivationKey
getInstance()
static ActivationKey
getInstance(boolean refreshIfNeeded)
Obtains the ActivationKey instance.String
getInstanceActivationExtraActionsHtml(XmlEngine xmlEngine)
gets HTML to be injected in Instance Activation window with additional actions to be performedProperties
getInstanceProperties()
ActivationKey.LicenseClass
getLicenseClass()
String
getLicenseExplanation(ConnectionProvider conn, String lang)
Long
getMaxUsers()
String
getMessageType()
int
getNumberOfDaysLeftInPeriod()
Returns the number of days pending till the end of ws calls verification period.int
getNumberWSDayCounter()
String
getOpsLogId()
Returns a CRC hash of the public keyLong
getPendingDays()
String
getPOSTerminalsExplanation()
Returns a message for POS Terminals limitationsLong
getPosTerminalsWarn()
String
getProperty(String propName)
String
getPublicKey()
String
getPurpose(String lang)
Date
getStartDate()
HashMap<String,ActivationKey.CommercialModuleStatus>
getSubscribedModules()
Obtains a list for modules ID the instance is subscribed to and their statusesActivationKey.SubscriptionStatus
getSubscriptionStatus()
Returns current subscription statusint
getWsCallsExceededDays()
Returns the number of days during last 30 days exceeding the maximum allowed number of callsString
getWSExplanation(ConnectionProvider conn, String lang)
Returns a message explaining WS call limitationsboolean
hasActivationKey()
Returns true in case the instance has activation key though it might not be valid or activatedboolean
hasExpirationDate()
boolean
hasExpired()
ActivationKey.FeatureRestriction
hasLicenseAccess(String type, String id)
Checks whether there is access to an artifact because of license restrictions (checking core advance and premium features).boolean
hasUnlimitedWsAccess()
boolean
isActive()
Returns true when the instance currently is OBPS active, this is when it has a valid activation key.static boolean
isActiveInstance()
Returns true when the instance currently is OBPS active.boolean
isGolden()
boolean
isHeartbeatActive()
Checks if heartbeat is active and a beat has been sent during last days.boolean
isModuleEnableable(Module module)
Checks whether a disabled module can be enabled again.ActivationKey.CommercialModuleStatus
isModuleSubscribed(String moduleId)
Returns the status for the commercial module passed as parameter.boolean
isNotActiveYet()
boolean
isOPSInstance()
Returns true when the instance has a activation key and the activation file has been loaded.boolean
isStatelessRequestAllowed()
Returns whether the stateless request is allowed or not due to any license limitation.boolean
isSubscriptionConverted()
boolean
isTrial()
static ActivationKey
reload()
Reloads ActivationKey instance from information in DB.static void
setInstance(ActivationKey ak)
String
verifyInstalledModules()
Verifies all the commercial installed modules are allowed to the instance.
-
-
-
Field Detail
-
NO_LIMIT
public static final Long NO_LIMIT
-
-
Method Detail
-
getInstance
public static ActivationKey getInstance()
- See Also:
getInstance(boolean)
-
getInstance
public static ActivationKey getInstance(boolean refreshIfNeeded)
Obtains the ActivationKey instance. Instances should be get in this way, rather than creating a new one. If refreshIfNeeded parameter is true, license is tried to be refreshed if it is needed to.- Parameters:
refreshIfNeeded
- refresh license if needed to
-
setInstance
public static void setInstance(ActivationKey ak)
-
reload
public static ActivationKey reload()
Reloads ActivationKey instance from information in DB.
-
getLicenseClass
public ActivationKey.LicenseClass getLicenseClass()
-
getOpsLogId
public String getOpsLogId()
Returns a CRC hash of the public key
-
getPublicKey
public String getPublicKey()
-
isActive
public boolean isActive()
Returns true when the instance currently is OBPS active, this is when it has a valid activation key.
-
isActiveInstance
public static boolean isActiveInstance()
Returns true when the instance currently is OBPS active. It is similar asisActive
, but it is static and is initialized whenever the ActivationKey class is instantiated.
-
isOPSInstance
public boolean isOPSInstance()
Returns true when the instance has a activation key and the activation file has been loaded. It doesn't verify is still valid.
-
hasActivationKey
public boolean hasActivationKey()
Returns true in case the instance has activation key though it might not be valid or activated
-
getErrorMessage
public String getErrorMessage()
-
getMessageType
public String getMessageType()
-
getActivationMessage
public ModuleLicenseRestrictions.ActivationMsg getActivationMessage()
activation message to be displayed in Instance Activation window
-
getInstanceActivationExtraActionsHtml
public String getInstanceActivationExtraActionsHtml(XmlEngine xmlEngine)
gets HTML to be injected in Instance Activation window with additional actions to be performed
-
checkOPSLimitations
@Deprecated public ActivationKey.LicenseRestriction checkOPSLimitations()
Deprecated.Deprecated, use insteadcheckOPSLimitations(String)
-
checkOPSLimitations
public ActivationKey.LicenseRestriction checkOPSLimitations(String currentSession)
- See Also:
checkOPSLimitations(String, String)
-
checkOPSLimitations
public ActivationKey.LicenseRestriction checkOPSLimitations(String currentSession, String sessionType)
Checks the current activation key- Parameters:
currentSession
- Current session, used for checking the concurrent users limitation.sessionType
- Successful session type: if the session is finally successful this is the type that will be marked with inAD_Session
, it is used to determine whether it should or not count for CU limitation. In case it isnull
it will be counted.- Returns:
ActivationKey.LicenseRestriction
with the status of the restrictions
-
consumesConcurrentUser
public static boolean consumesConcurrentUser(String sessionType)
Returns whether a session type is counted for concurrent users
-
isHeartbeatActive
public boolean isHeartbeatActive()
Checks if heartbeat is active and a beat has been sent during last days.
-
getLicenseExplanation
public String getLicenseExplanation(ConnectionProvider conn, String lang)
-
getWSExplanation
public String getWSExplanation(ConnectionProvider conn, String lang)
Returns a message explaining WS call limitations
-
getPOSTerminalsExplanation
public String getPOSTerminalsExplanation()
Returns a message for POS Terminals limitations
-
hasExpirationDate
public boolean hasExpirationDate()
-
getPendingDays
public Long getPendingDays()
-
isSubscriptionConverted
public boolean isSubscriptionConverted()
-
hasExpired
public boolean hasExpired()
-
isNotActiveYet
public boolean isNotActiveYet()
-
hasUnlimitedWsAccess
public boolean hasUnlimitedWsAccess()
-
getExpiredInstalledModules
public ArrayList<Module> getExpiredInstalledModules()
Obtains a List of all the modules that are installed in the instance which license has expired.- Returns:
- List of the expired modules
-
getSubscribedModules
public HashMap<String,ActivationKey.CommercialModuleStatus> getSubscribedModules()
Obtains a list for modules ID the instance is subscribed to and their statuses- Returns:
- HashMap<String, CommercialModuleStatus> containing the subscribed modules
-
getAdditionalMessageInfo
public List<ModuleLicenseRestrictions.AdditionalInfo> getAdditionalMessageInfo()
get all additional messages to be printed in Instance Activation window.
-
getActiveSessions
public int getActiveSessions(String currentSession)
Returns the number of current active sessions
-
isModuleEnableable
public boolean isModuleEnableable(Module module)
Checks whether a disabled module can be enabled again. A commercial module cannot be enabled in case its license has expired or the instance is not commercial.- Parameters:
module
-- Returns:
- true in case the module can be enabled
-
isModuleSubscribed
public ActivationKey.CommercialModuleStatus isModuleSubscribed(String moduleId)
Returns the status for the commercial module passed as parameter. Note that module tier is not checked here, this should be correctly handled in the license itself.- Parameters:
moduleId
-- Returns:
- the status for the commercial module passed as parameter
-
hasLicenseAccess
public ActivationKey.FeatureRestriction hasLicenseAccess(String type, String id)
Checks whether there is access to an artifact because of license restrictions (checking core advance and premium features).- Parameters:
type
- Type of artifact (Window, Report, Process...)id
- Id of the Artifact- Returns:
- true in case it has access, false if not
-
verifyInstalledModules
public String verifyInstalledModules()
Verifies all the commercial installed modules are allowed to the instance.- Returns:
- List of non allowed modules
-
getSubscriptionStatus
public ActivationKey.SubscriptionStatus getSubscriptionStatus()
Returns current subscription status
-
isTrial
public boolean isTrial()
-
isGolden
public boolean isGolden()
-
getExpirationMessage
public org.codehaus.jettison.json.JSONObject getExpirationMessage(String lang)
Returns a JSONObject with a message warning about near expiration or already expired instance to be displayed in Login page.
-
checkNewWSCall
public ActivationKey.WSRestriction checkNewWSCall(boolean updateCounter)
This method checks web service can be called. IfupdateCounter
parameter istrue
number of daily calls is increased by one.- Parameters:
updateCounter
- daily calls should be updated
-
getNumberWSDayCounter
public int getNumberWSDayCounter()
-
getWsCallsExceededDays
public int getWsCallsExceededDays()
Returns the number of days during last 30 days exceeding the maximum allowed number of calls
-
getExtraWsExceededDaysAllowed
public int getExtraWsExceededDaysAllowed()
Returns the number of days that can exceed the maximum number of ws calls taking into account the ones that exceeded it during last 30 days.
-
getNumberOfDaysLeftInPeriod
public int getNumberOfDaysLeftInPeriod()
Returns the number of days pending till the end of ws calls verification period.
-
getAllowedPosTerminals
public Long getAllowedPosTerminals()
-
getPosTerminalsWarn
public Long getPosTerminalsWarn()
-
forceSysAdminLogin
public boolean forceSysAdminLogin(javax.servlet.http.HttpSession session)
Returns whether only System Admin should be allowed, because it is already set in session or there are license restrictions.
-
isStatelessRequestAllowed
public boolean isStatelessRequestAllowed()
Returns whether the stateless request is allowed or not due to any license limitation.
-
getInstanceProperties
public Properties getInstanceProperties()
- Returns:
- all license's properties
-
getStartDate
public Date getStartDate()
- Returns:
- starting valid date for license
-
getEndDate
public Date getEndDate()
- Returns:
- license's expiration date
-
getMaxUsers
public Long getMaxUsers()
- Returns:
- maximum allowed concurrent users
-
-