Class LicenseDetailsService
- java.lang.Object
-
- io.jans.ca.plugin.adminui.service.BaseService
-
- io.jans.ca.plugin.adminui.service.license.LicenseDetailsService
-
@Singleton public class LicenseDetailsService extends BaseService
-
-
Field Summary
Fields Modifier and Type Field Description static StringBEARERstatic StringCODEstatic StringHARDWARE_IDstatic StringHTTP_RESPONSE_IS_NULLstatic StringLICENSE_ACTIVATE_ERROR_RESPONSEstatic StringLICENSE_APIS_404static StringLICENSE_APIS_503static StringLICENSE_ISACTIVE_ERROR_RESPONSEstatic StringLICENSE_KEYstatic StringLICENSE_RETRIEVE_ERROR_RESPONSEstatic StringMESSAGEstatic StringTRIAL_GENERATE_ERROR_RESPONSE-
Fields inherited from class io.jans.ca.plugin.adminui.service.BaseService
httpService, mapper, TLS_ALLOWED_CIPHER_SUITES, TLS_ENABLED_PROTOCOLS
-
-
Constructor Summary
Constructors Constructor Description LicenseDetailsService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GenericResponseactivateLicense(LicenseRequest licenseRequest)Activate a license with the configured License API and persist updated license details.GenericResponsecheckLicense()Verify that the stored license configuration is present, current, and not expired.GenericResponsedeleteLicenseConfiguration()Deletes the license-related configuration in both the persistent and in-memory Admin UI configuration.GenericResponsegenerateTrialLicense()Generates a trial license via the configured License API and saves the returned license key to persistence and the in-memory AUI configuration.LicenseResponsegetLicenseDetails()This function is used to get the license details of the admin-uiGenericResponsepostSSA(SSARequest ssaRequest)The function takes an SSA string as input, calls the DCR API to get the scan hostname and OIDC client settings, and saves the SSA string and the scan hostname and OIDC client settings in the Admin UI configurationGenericResponseretrieveLicense()Retrieve license details from the configured License API.GenericResponsevalidateLicenseConfiguration()Validates the license configuration by checking for the presence of required parameters.-
Methods inherited from class io.jans.ca.plugin.adminui.service.BaseService
executeDCR, getToken, getToken, introspectToken
-
-
-
-
Field Detail
-
LICENSE_KEY
public static final String LICENSE_KEY
- See Also:
- Constant Field Values
-
HARDWARE_ID
public static final String HARDWARE_ID
- See Also:
- Constant Field Values
-
BEARER
public static final String BEARER
- See Also:
- Constant Field Values
-
MESSAGE
public static final String MESSAGE
- See Also:
- Constant Field Values
-
CODE
public static final String CODE
- See Also:
- Constant Field Values
-
LICENSE_ISACTIVE_ERROR_RESPONSE
public static final String LICENSE_ISACTIVE_ERROR_RESPONSE
- See Also:
- Constant Field Values
-
LICENSE_RETRIEVE_ERROR_RESPONSE
public static final String LICENSE_RETRIEVE_ERROR_RESPONSE
- See Also:
- Constant Field Values
-
LICENSE_ACTIVATE_ERROR_RESPONSE
public static final String LICENSE_ACTIVATE_ERROR_RESPONSE
- See Also:
- Constant Field Values
-
LICENSE_APIS_404
public static final String LICENSE_APIS_404
- See Also:
- Constant Field Values
-
LICENSE_APIS_503
public static final String LICENSE_APIS_503
- See Also:
- Constant Field Values
-
TRIAL_GENERATE_ERROR_RESPONSE
public static final String TRIAL_GENERATE_ERROR_RESPONSE
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_IS_NULL
public static final String HTTP_RESPONSE_IS_NULL
- See Also:
- Constant Field Values
-
-
Method Detail
-
validateLicenseConfiguration
public GenericResponse validateLicenseConfiguration()
Validates the license configuration by checking for the presence of required parameters.This method retrieves the license configuration from the persistence layer and checks the following: 1. The existence of the license hardware key. 2. The presence and validity of OIDC client details (OP host, client ID, client secret). 3. The presence of the SSA (Software Statement Assertion). 4. The existence of the license key. 5. The presence of the scan license API hostname. 6. The last updated date of the license details. If missing, it triggers synchronization of OIDC client details. 7. The time elapsed since the last license details update, comparing it with the configured synchronization interval. If the interval has passed, it initiates synchronization of OIDC client details.
- Returns:
- A GenericResponse object indicating the validity of the license configuration. - Returns a successful response (true, 200) if all required parameters are present and valid. - Returns an error response (false, various error codes) if any required parameter is missing or invalid.
-
deleteLicenseConfiguration
public GenericResponse deleteLicenseConfiguration()
Deletes the license-related configuration in both the persistent and in-memory Admin UI configuration.
-
checkLicense
public GenericResponse checkLicense()
Verify that the stored license configuration is present, current, and not expired.If the configuration is missing, incomplete, expired, or due for refresh, the method initiates synchronization with the license service and returns the corresponding error response. When the license is valid and up-to-date, the response contains custom attributes (including the `mau_threshold`) describing license limits.
- Returns:
- a `GenericResponse` with `true` and HTTP 200 containing license custom attributes (including `mau_threshold`) when the license is valid; otherwise `false` with an appropriate HTTP error code and diagnostic message.
-
retrieveLicense
public GenericResponse retrieveLicense()
Retrieve license details from the configured License API.Validates that the local license configuration contains a hardware ID and scan API hostname, obtains an access token, and queries the remote retrieve endpoint. On success returns a response containing `licenseKey` and `mauThreshold` in the response payload.
- Returns:
- GenericResponse containing `licenseKey` and `mauThreshold` on success (HTTP 200); otherwise a GenericResponse with an appropriate error code and message (for example, 402 for payment required, 404/503 when the license API is inaccessible, or 500 for other server-side errors).
-
activateLicense
public GenericResponse activateLicense(LicenseRequest licenseRequest)
Activate a license with the configured License API and persist updated license details.- Parameters:
licenseRequest- request containing the license key to activate- Returns:
- a GenericResponse indicating success or failure; on success (HTTP 200) the response contains a message and the license's updated custom_fields, on failure the response contains an error message and an appropriate HTTP status code
-
generateTrialLicense
public GenericResponse generateTrialLicense()
Generates a trial license via the configured License API and saves the returned license key to persistence and the in-memory AUI configuration.On success returns a response containing a JSON object with the `license-key`. On failure returns a response with an appropriate error code and message reflecting token generation failures, HTTP errors from the License API, missing fields in the API response, or internal server errors.
- Returns:
- GenericResponse with status `true` and a JSON payload containing `license-key` on success; `false` with an error code and message otherwise.
-
getLicenseDetails
public LicenseResponse getLicenseDetails()
This function is used to get the license details of the admin-ui- Returns:
- A LicenseResponse object
-
postSSA
public GenericResponse postSSA(SSARequest ssaRequest)
The function takes an SSA string as input, calls the DCR API to get the scan hostname and OIDC client settings, and saves the SSA string and the scan hostname and OIDC client settings in the Admin UI configuration- Parameters:
ssaRequest- The SSA request object.- Returns:
- A LicenseApiResponse object.
-
-