Class LotlService
- All Implemented Interfaces:
-
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionLotlService(LotlFetchingProperties lotlFetchingProperties) Creates a new instance ofLotlService. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCancels timer, if it was already set up.voidclose().static LotlServiceGets global static instance ofLotlService.voidInitializes the cache with the latest Lotl data and related resources.static voidinitializeGlobalCache(LotlFetchingProperties lotlFetchingProperties) Initializes the global cache with the provided LotlFetchingProperties.protected voidSets up a timer to periodically refresh the LOTL cache.protected voidThis 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 LotlServicewithCustomResourceRetriever(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 forLotlValidatorcreation.withPivotFetcher(PivotFetcher pivotFetcher) Sets the pivot fetcher for the Lotl service.withXmlSignatureValidator(Function<TrustedCertificatesStore, XmlSignatureValidator> xmlSignatureValidatorFactory) Sets up factory which is responsible forXmlSignatureValidatorcreation.
-
Constructor Details
-
LotlService
Creates a new instance ofLotlService.- Parameters:
-
lotlFetchingProperties-LotlFetchingPropertiesto 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
LotlServiceyou 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
LotlServiceCacheto 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
LotlServicefor method chaining
-
withCustomResourceRetriever
Sets a custom resource retriever for fetching resources.This method allows you to provide a custom implementation of
IResourceRetrieverto 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
LotlServicefor 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
LotlServicefor 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
LotlServicefor 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
LotlServicefor method chaining
-
withXmlSignatureValidator
public LotlService withXmlSignatureValidator(Function<TrustedCertificatesStore, XmlSignatureValidator> xmlSignatureValidatorFactory) Sets up factory which is responsible forXmlSignatureValidatorcreation.- Parameters:
-
xmlSignatureValidatorFactory- factory responsible forXmlSignatureValidatorcreation - Returns:
-
the current instance of
LotlServicefor method chaining
-
withLotlValidator
Sets up factory which is responsible forLotlValidatorcreation.- Parameters:
-
lotlValidatorFactory- factory responsible forLotlValidatorcreation - 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
LotlServicefor method chaining
-
close
public void close().- Specified by:
-
closein 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.
-