public class LotlService extends Object implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
protected LotlFetchingProperties |
lotlFetchingProperties |
| Constructor and Description |
|---|
LotlService(LotlFetchingProperties lotlFetchingProperties)
Creates a new instance of
LotlService. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cancelTimer()
Cancels timer, if it was already set up.
|
void |
close() |
static LotlService |
getGlobalService()
Gets global static instance of
LotlService. |
List<IServiceContext> |
getNationalTrustedCertificates()
Retrieves national trusted certificates.
|
ValidationReport |
getValidationResult()
Get the validation results for the List of Trusted Lists (LOTL).
|
void |
initializeCache()
Initializes the cache with the latest LOTL data and related resources.
|
void |
initializeCache(InputStream stream)
Initializes the cache with the latest LOTL data and related resources.
|
static void |
initializeGlobalCache(LotlFetchingProperties lotlFetchingProperties)
Initializes the global service with the provided
LotlFetchingProperties. |
void |
loadFromCache(InputStream stream)
Loads the cache from the provided input stream.
|
protected void |
loadFromNetwork()
Loads the cache from the network by fetching the latest LOTL data and related resources.
|
void |
serializeCache(OutputStream outputStream)
Serializes the current state of the cache to the provided output stream.
|
protected void |
setupTimer()
Sets up a timer to periodically refresh the LOTL cache.
|
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.
|
LotlService |
withCountrySpecificLotlFetcher(CountrySpecificLotlFetcher countrySpecificLotlFetcher)
Sets the country-specific LOTL fetcher for the LOTL service.
|
LotlService |
withCustomResourceRetriever(com.itextpdf.io.resolver.resource.IResourceRetriever resourceRetriever)
Sets a custom resource retriever for fetching resources.
|
LotlService |
withEuropeanLotlFetcher(EuropeanLotlFetcher fetcher)
Sets the European List of Trusted Lists (LOTL) byte fetcher for the LOTL service.
|
LotlService |
withEuropeanResourceFetcher(EuropeanResourceFetcher europeanResourceFetcher)
Sets the European Resource Fetcher for the
LotlService. |
LotlService |
withLotlServiceCache(LotlServiceCache cache)
Sets the cache for the
LotlService. |
LotlService |
withLotlValidator(Supplier<LotlValidator> lotlValidatorFactory)
Sets up factory which is responsible for
LotlValidator creation. |
LotlService |
withPivotFetcher(PivotFetcher pivotFetcher)
Sets the pivot fetcher for the LOTL service.
|
LotlService |
withXmlSignatureValidator(Function<TrustedCertificatesStore,XmlSignatureValidator> xmlSignatureValidatorFactory)
Sets up factory which is responsible for
XmlSignatureValidator creation. |
protected final LotlFetchingProperties lotlFetchingProperties
public LotlService(LotlFetchingProperties lotlFetchingProperties)
LotlService.lotlFetchingProperties - LotlFetchingProperties to configure the way in which LOTL will be fetchedpublic static void initializeGlobalCache(LotlFetchingProperties lotlFetchingProperties)
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.
lotlFetchingProperties - the LotlFetchingProperties to use for initializing the cachepublic static LotlService getGlobalService()
LotlService.LotlServicepublic LotlService withLotlServiceCache(LotlServiceCache cache)
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.
cache - the custom cache to be used for caching LOTL dataLotlService for method chainingpublic final LotlService withCustomResourceRetriever(com.itextpdf.io.resolver.resource.IResourceRetriever resourceRetriever)
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.
Multiple LOTL endpoints require a userAgent header to be sent. This should be taken into account
when providing a custom IResourceRetriever.
resourceRetriever - the custom resource retriever to be used for fetching resourcesLotlService for method chainingpublic void initializeCache()
public void loadFromCache(InputStream stream)
The input stream should contain serialized cache data, which can be created using the
serializeCache(OutputStream) method.
stream - the input stream to read the cached data frompublic ValidationReport getValidationResult()
ValidationReport containing the results of the LOTL validationpublic List<IServiceContext> getNationalTrustedCertificates()
public void initializeCache(InputStream stream)
Important: By default when providing a stream, we will still set up a timer to refresh the cache periodically.
If you don't want this behavior, please set
LotlFetchingProperties.setRefreshIntervalCalculator(LongUnaryOperator) to int.Max.
stream - InputStream to read the cached data from. If null, the data will be fetched from the network.
The data can be serialized using serializeCache(OutputStream) method.public LotlService withPivotFetcher(PivotFetcher pivotFetcher)
pivotFetcher - the pivot fetcher to be used for fetching and validating pivot filesLotlService for method chainingpublic LotlService withCountrySpecificLotlFetcher(CountrySpecificLotlFetcher countrySpecificLotlFetcher)
countrySpecificLotlFetcher - the country-specific LOTL fetcher to be used for fetching and validating
country-specific LOTLsLotlService for method chainingpublic LotlService withEuropeanLotlFetcher(EuropeanLotlFetcher fetcher)
fetcher - the fetcher to be used for fetching the LOTL XML dataLotlService for method chainingpublic LotlService withXmlSignatureValidator(Function<TrustedCertificatesStore,XmlSignatureValidator> xmlSignatureValidatorFactory)
XmlSignatureValidator creation.xmlSignatureValidatorFactory - factory responsible for XmlSignatureValidator creationLotlService for method chainingpublic LotlService withLotlValidator(Supplier<LotlValidator> lotlValidatorFactory)
LotlValidator creation.lotlValidatorFactory - factory responsible for LotlValidator creationLotlServicepublic LotlService withEuropeanResourceFetcher(EuropeanResourceFetcher europeanResourceFetcher)
LotlService.europeanResourceFetcher - the European Resource Fetcher to be used for fetching EU journal certificatesLotlService for method chainingpublic void close()
close in interface AutoCloseablepublic void serializeCache(OutputStream outputStream) throws IOException
outputStream - the output stream to which the cache will be serializedIOException - if an I/O error occurs during serializationprotected void loadFromNetwork()
This method fetches the main LOTL file, EU journal certificates, pivot files, and country-specific LOTLs, validates them, and stores them in the cache.
Note: This method is called during cache initialization and should not be called directly in normal operation.
protected void tryAndRefreshCache()
protected void setupTimer()
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.
protected void cancelTimer()
Copyright © 1998–2026 Apryse Group NV. All rights reserved.