Package no.digipost.signature.client
Class ClientConfiguration.Builder
- java.lang.Object
-
- no.digipost.signature.client.ClientConfiguration.Builder
-
- Enclosing class:
- ClientConfiguration
public static class ClientConfiguration.Builder extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientConfiguration.Builder
addDocumentBundleProcessor(DocumentBundleProcessor processor)
Add aDocumentBundleProcessor
which will be passed the generated zipped document bundle together with thejob
it was created for.ClientConfiguration
build()
ClientConfiguration.Builder
connectTimeoutMillis(int millis)
Override thedefault connect timeout value
.ClientConfiguration.Builder
customizeJaxRs(Consumer<? super javax.ws.rs.core.Configurable<? extends javax.ws.rs.core.Configuration>> customizer)
This methods allows for custom configuration of JAX-RS (i.e.ClientConfiguration.Builder
enableDocumentBundleDiskDump(Path directory)
Have the library dump the generated document bundle zip files to disk before they are sent to the service to create signature jobs.ClientConfiguration.Builder
enableRequestAndResponseLogging()
Makes the client log the sent requests and received responses to the logger namedClientConfiguration.HTTP_REQUEST_RESPONSE_LOGGER_NAME
.ClientConfiguration.Builder
globalSender(Sender sender)
Set the sender used globally for every signature job.ClientConfiguration.Builder
includeInUserAgent(String userAgentCustomPart)
Customize theUser-Agent
header value to include the given string.ClientConfiguration.Builder
serviceUri(URI uri)
Override the service endpoint URI to a custom environment.ClientConfiguration.Builder
serviceUri(ServiceUri environment)
Set the service URI to one of the predefined environments.ClientConfiguration.Builder
socketTimeoutMillis(int millis)
Override thedefault socket timeout value
.ClientConfiguration.Builder
trustStore(Iterable<String> certificatePaths)
Override the trust store configuration to load DER-encoded certificates from the given folder(s).ClientConfiguration.Builder
trustStore(String... certificatePaths)
Override the trust store configuration to load DER-encoded certificates from the given folder(s).ClientConfiguration.Builder
trustStore(Certificates certificates)
ClientConfiguration.Builder
usingClock(Clock clock)
Allows for overriding whichClock
is used to convert between Java and XML, may be useful for e.g.
-
-
-
Method Detail
-
serviceUri
public ClientConfiguration.Builder serviceUri(ServiceUri environment)
Set the service URI to one of the predefined environments.
-
serviceUri
public ClientConfiguration.Builder serviceUri(URI uri)
Override the service endpoint URI to a custom environment.
-
socketTimeoutMillis
public ClientConfiguration.Builder socketTimeoutMillis(int millis)
Override thedefault socket timeout value
.
-
connectTimeoutMillis
public ClientConfiguration.Builder connectTimeoutMillis(int millis)
Override thedefault connect timeout value
.
-
trustStore
public ClientConfiguration.Builder trustStore(Certificates certificates)
-
trustStore
public ClientConfiguration.Builder trustStore(String... certificatePaths)
Override the trust store configuration to load DER-encoded certificates from the given folder(s).
-
trustStore
public ClientConfiguration.Builder trustStore(Iterable<String> certificatePaths)
Override the trust store configuration to load DER-encoded certificates from the given folder(s).
-
globalSender
public ClientConfiguration.Builder globalSender(Sender sender)
Set the sender used globally for every signature job.Use
PortalJob.Builder.withSender(Sender)
orDirectJob.Builder.withSender(Sender)
if you need to specify different senders per signature job (typically when acting as a broker on behalf of multiple other organizations)
-
includeInUserAgent
public ClientConfiguration.Builder includeInUserAgent(String userAgentCustomPart)
Customize theUser-Agent
header value to include the given string.- Parameters:
userAgentCustomPart
- The custom part to include in the User-Agent HTTP header.
-
enableRequestAndResponseLogging
public ClientConfiguration.Builder enableRequestAndResponseLogging()
Makes the client log the sent requests and received responses to the logger namedClientConfiguration.HTTP_REQUEST_RESPONSE_LOGGER_NAME
.
-
enableDocumentBundleDiskDump
public ClientConfiguration.Builder enableDocumentBundleDiskDump(Path directory)
Have the library dump the generated document bundle zip files to disk before they are sent to the service to create signature jobs.The files will be given names on the format
The timestamp part may use a clock of your choosing, make sure to override the system clock withtimestamp-[reference_from_job-]asice.zip
usingClock(Clock)
before calling this method if that is desired.The reference_from_job part is only included if the job is given such a reference using
DirectJob.Builder.withReference(..)
orPortalJob.Builder.withReference(..)
.- Parameters:
directory
- the directory to dump to. This directory must already exist, or creating new signature jobs will fail. Miserably.
-
addDocumentBundleProcessor
public ClientConfiguration.Builder addDocumentBundleProcessor(DocumentBundleProcessor processor)
Add aDocumentBundleProcessor
which will be passed the generated zipped document bundle together with thejob
it was created for. The processor is not responsible for closing the stream, as this is handled by the library itself.A note on performance
The processor is free to do what it want with the passed stream, but bear in mind that the time used by a processor adds to the processing time to create signature jobs.- Parameters:
processor
- theDocumentBundleProcessor
which will be passed the generated zipped document bundle together with thejob
it was created for.
-
customizeJaxRs
public ClientConfiguration.Builder customizeJaxRs(Consumer<? super javax.ws.rs.core.Configurable<? extends javax.ws.rs.core.Configuration>> customizer)
This methods allows for custom configuration of JAX-RS (i.e. Jersey) if anything is needed that is not already supported by theClientConfiguration.Builder
. This method should not be used to configure anything that is already directly supported by theClientConfiguration.Builder
API.If you still need to use this method, consider requesting first-class support for your requirement on the library's web site on GitHub.
- Parameters:
customizer
- The operations to do on the JAX-RSConfigurable
, e.g.registering components
.
-
usingClock
public ClientConfiguration.Builder usingClock(Clock clock)
Allows for overriding whichClock
is used to convert between Java and XML, may be useful for e.g. automated tests.Uses
the best available system clock
if not specified.
-
build
public ClientConfiguration build()
-
-