Class ClientConfiguration.Builder

java.lang.Object
no.digipost.signature.client.ClientConfiguration.Builder
Enclosing class:
ClientConfiguration

public static class ClientConfiguration.Builder extends Object
  • Method Details

    • serviceEnvironment

      public ClientConfiguration.Builder serviceEnvironment(ServiceEnvironment other)
    • serviceEnvironment

      public ClientConfiguration.Builder serviceEnvironment(UnaryOperator<ServiceEnvironment> updateServiceEnvironment)
    • httpProxyHost

      public ClientConfiguration.Builder httpProxyHost(String hostname, int port)
      Set the http proxy host used by the client.
      Parameters:
      hostname - the hostname
      port - the port
    • proxyHost

      public ClientConfiguration.Builder proxyHost(URI proxyHostUri)
      Set URI to proxy host to be used by the client. Only the scheme, host, and port of the URI is used, any other parts are ignored.
      Parameters:
      proxyHostUri - the proxy host URI
    • defaultSender

      public ClientConfiguration.Builder defaultSender(Sender sender)
      Set the default Sender to use if not specifying sender per signature job.

      Use PortalJob.Builder.withSender(..) or DirectJob.Builder.withSender(..) 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 the User-Agent header value to include the given string.
      Parameters:
      userAgentCustomPart - The custom part to include in the User-Agent HTTP header.
    • timeouts

      public ClientConfiguration.Builder timeouts(Consumer<? super TimeoutsConfigurer> timeouts)
      Configure timeouts used for integrating with the API.
      Parameters:
      timeouts - the timeouts to set
    • timeoutsForDocumentDownloads

      public ClientConfiguration.Builder timeoutsForDocumentDownloads(Consumer<? super TimeoutsConfigurer> timeouts)
      Configure timeouts used for downloading documents. The values for these timeouts should in general be configured higher than for default timeouts.
      Parameters:
      timeouts - the timeouts to set
    • connectionPool

      public ClientConfiguration.Builder connectionPool(Consumer<? super ConnectionPoolConfigurer> connectionPool)
      Configure the pool used by the client to manage connections used for integrating with the API.
      Parameters:
      connectionPool - the connection pool configuration API
    • connectionPoolForDocumentDownloads

      public ClientConfiguration.Builder connectionPoolForDocumentDownloads(Consumer<? super ConnectionPoolConfigurer> connectionPool)
      Configure the pool used by the client to manage connections used specifically for downloading documents.
      Parameters:
      connectionPool - the connection pool configuration API
    • apacheHttpClient

      public ClientConfiguration.Builder apacheHttpClient(Consumer<? super ApacheHttpClientConfigurer> apacheHttpClientConfigurer)
      This method allows for custom configuration of the created HttpClient if anything is needed that is not already supported by other methods in ClientConfiguration.

      If you still need to use this method, consider requesting first-class support for your requirement on the library's web site on GitHub.

    • apacheHttpClientForDocumentDownloads

      public ClientConfiguration.Builder apacheHttpClientForDocumentDownloads(Consumer<? super ApacheHttpClientConfigurer> apacheHttpClientConfigurer)
      This method allows for custom configuration of the created HttpClient if anything is needed that is not already supported by other methods in ClientConfiguration.

      If you still need to use this method, consider requesting first-class support for your requirement on the library's web site on GitHub.

    • 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

      timestamp-[reference_from_job-]asice.zip
      The timestamp part may use a clock of your choosing, make sure to override the system clock with clock(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(..) or PortalJob.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 a DocumentBundleProcessor which will be passed the generated zipped document bundle together with the job 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 - the DocumentBundleProcessor which will be passed the generated zipped document bundle together with the job it was created for.
    • serverOrganizationNumber

      public ClientConfiguration.Builder serverOrganizationNumber(String serverOrganizationNumber)
      Override which organization number which is expected from the server's certificate. By default, this is the organization number of Posten Bring AS, and should not be overridden unless you have a specific need such as doing testing against your own stubbed implementation of the Posten signering API.
      Parameters:
      serverOrganizationNumber - the organization number expected in the server's enterprise certificate
    • serverCertificateTrustStrategy

      public ClientConfiguration.Builder serverCertificateTrustStrategy(CertificateChainValidation certificateChainValidation)
      Override the validation of the server's certificate. This method is mainly intended for tests if you need to override (or even disable) the default validation that the server identifies itself as "Posten Bring AS". Calling this method for a production deployment is probably not what you intend to do!
      Parameters:
      certificateChainValidation - the validation for the server's certificate
    • clock

      public ClientConfiguration.Builder clock(Clock clock)
      Allows for overriding which Clock is used to convert between Java and XML, may be useful for e.g. automated tests.

      Uses the system clock with default time zone if not specified.

    • build

      public ClientConfiguration build()