Class LotlService
- All Implemented Interfaces:
-
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionLotlService
(LotlFetchingProperties lotlFetchingProperties) Creates a new instance ofLotlService
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Cancels timer, if it was already set up.void
close()
.static LotlService
Gets global static instance ofLotlService
.void
Initializes the cache with the latest Lotl data and related resources.static void
initializeGlobalCache
(LotlFetchingProperties lotlFetchingProperties) Initializes the global cache with the provided LotlFetchingProperties.protected void
Sets up a timer to periodically refresh the LOTL cache.protected void
This method is intended to refresh the cache, it will try to download the latest LOTL data and update the cache accordingly.withCountrySpecificLotlFetcher
(CountrySpecificLotlFetcher countrySpecificLotlFetcher) Sets the country-specific Lotl fetcher for the Lotl service.final LotlService
withCustomResourceRetriever
(IResourceRetriever resourceRetriever) Sets a custom resource retriever for fetching resources.Sets the European List of Trusted Lists (Lotl) byte fetcher for the Lotl service.withEuropeanResourceFetcher
(EuropeanResourceFetcher europeanResourceFetcher) Sets the European Resource Fetcher for the LotlService.Sets the cache for the LotlService.withLotlValidator
(Supplier<LotlValidator> lotlValidatorFactory) Sets up factory which is responsible forLotlValidator
creation.withPivotFetcher
(PivotFetcher pivotFetcher) Sets the pivot fetcher for the Lotl service.withXmlSignatureValidator
(Function<TrustedCertificatesStore, XmlSignatureValidator> xmlSignatureValidatorFactory) Sets up factory which is responsible forXmlSignatureValidator
creation.
-
Constructor Details
-
LotlService
Creates a new instance ofLotlService
.- Parameters:
-
lotlFetchingProperties
-LotlFetchingProperties
to configure the way in which LOTL will be fetched
-
-
Method Details
-
initializeGlobalCache
Initializes the global cache with the provided LotlFetchingProperties. This method must be called before using the LotlService to ensure that the cache is set up.If you are using a custom implementation of
LotlService
you can use the instance method.- Parameters:
-
lotlFetchingProperties
- the LotlFetchingProperties to use for initializing the cache
-
getGlobalService
Gets global static instance ofLotlService
.- Returns:
-
global static instance of
LotlService
-
withLotlServiceCache
Sets the cache for the LotlService.This method allows you to provide a custom implementation of
LotlServiceCache
to be used for caching Lotl data, pivot files, and country-specific Lotls.- Parameters:
-
cache
- the custom cache to be used for caching Lotl data - Returns:
-
the current instance of
LotlService
for method chaining
-
withCustomResourceRetriever
Sets a custom resource retriever for fetching resources.This method allows you to provide a custom implementation of
IResourceRetriever
to be used for fetching resources such as the Lotl XML, pivot files, and country-specific Lotls.- Parameters:
-
resourceRetriever
- the custom resource retriever to be used for fetching resources - Returns:
-
the current instance of
LotlService
for method chaining
-
initializeCache
public void initializeCache()Initializes the cache with the latest Lotl data and related resources. -
withPivotFetcher
Sets the pivot fetcher for the Lotl service.- Parameters:
-
pivotFetcher
- the pivot fetcher to be used for fetching and validating pivot files - Returns:
-
the current instance of
LotlService
for method chaining
-
withCountrySpecificLotlFetcher
public LotlService withCountrySpecificLotlFetcher(CountrySpecificLotlFetcher countrySpecificLotlFetcher) Sets the country-specific Lotl fetcher for the Lotl service.- Parameters:
-
countrySpecificLotlFetcher
- the country-specific Lotl fetcher to be used for fetching and validating country-specific Lotls - Returns:
-
the current instance of
LotlService
for method chaining
-
withEuropeanLotlFetcher
Sets the European List of Trusted Lists (Lotl) byte fetcher for the Lotl service.- Parameters:
-
fetcher
- the fetcher to be used for fetching the Lotl XML data - Returns:
-
the current instance of
LotlService
for method chaining
-
withXmlSignatureValidator
public LotlService withXmlSignatureValidator(Function<TrustedCertificatesStore, XmlSignatureValidator> xmlSignatureValidatorFactory) Sets up factory which is responsible forXmlSignatureValidator
creation.- Parameters:
-
xmlSignatureValidatorFactory
- factory responsible forXmlSignatureValidator
creation - Returns:
-
the current instance of
LotlService
for method chaining
-
withLotlValidator
Sets up factory which is responsible forLotlValidator
creation.- Parameters:
-
lotlValidatorFactory
- factory responsible forLotlValidator
creation - Returns:
-
this same instance of
LotlService
-
withEuropeanResourceFetcher
Sets the European Resource Fetcher for the LotlService.- Parameters:
-
europeanResourceFetcher
- the European Resource Fetcher to be used for fetching EU journal certificates - Returns:
-
the current instance of
LotlService
for method chaining
-
close
public void close().- Specified by:
-
close
in interfaceAutoCloseable
-
setupTimer
protected void setupTimer()Sets up a timer to periodically refresh the LOTL cache.The timer will use the refresh interval calculated based on the stale-ness of the cache. If the cache is null, it will create a new instance of
InMemoryLotlServiceCache
. -
cancelTimer
protected void cancelTimer()Cancels timer, if it was already set up. -
tryAndRefreshCache
protected void tryAndRefreshCache()This method is intended to refresh the cache, it will try to download the latest LOTL data and update the cache accordingly.The rules taken into account are: Country specific LOTL files will be fetched, validated and updated per country. If country fails to fetch,
LotlFetchingProperties.getOnCountryFetchFailureStrategy()
will be used to perform corresponding action.For the main LOTL file, if the fetch fails, the cache will not be updated. Also, we will NOT proceed to update the pivot files. If the main LOTL file is fetched successfully, the pivot files will be fetched, validated and stored in the cache.
-