Class LicenseDetailsService


  • @Singleton
    public class LicenseDetailsService
    extends BaseService
    • Constructor Detail

      • LicenseDetailsService

        public LicenseDetailsService()
    • 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.