Class ScramClient.Builder

Enclosing class:
ScramClient

public static class ScramClient.Builder extends ScramClient.PreBuilder2
This class is not meant to be used directly. Use instead ScramClient.channelBinding(ChannelBinding) and chained methods.
  • Field Details

    • nonChannelBindingMechanism

      private final ScramMechanism nonChannelBindingMechanism
    • channelBindingMechanism

      private final ScramMechanism channelBindingMechanism
    • secureRandom

      private SecureRandom secureRandom
    • nonceSupplier

      private NonceSupplier nonceSupplier
    • nonceLength

      private int nonceLength
  • Constructor Details

  • Method Details

    • secureRandomAlgorithmProvider

      public ScramClient.Builder secureRandomAlgorithmProvider(String algorithm, String provider) throws IllegalArgumentException
      Optional call. Selects a non-default SecureRandom instance, based on the given algorithm and optionally provider. This SecureRandom instance will be used to generate secure random values, like the ones required to generate the nonce (unless an external nonce provider is given via nonceSupplier(NonceSupplier)). Algorithm and provider names are those supported by the SecureRandom class.
      Parameters:
      algorithm - The name of the algorithm to use.
      provider - The name of the provider of SecureRandom. Might be null.
      Returns:
      The same class
      Throws:
      IllegalArgumentException - If algorithm is null, or either the algorithm or provider are not supported
    • nonceSupplier

      public ScramClient.Builder nonceSupplier(NonceSupplier nonceSupplier) throws IllegalArgumentException
      Optional call. The client will use a default nonce generator, unless an external one is provided by this method. *
      Parameters:
      nonceSupplier - A supplier of valid nonce Strings. Please note that according to the SCRAM RFC only ASCII printable characters (except the comma, ',') are permitted on a nonce. Length is not limited.
      Returns:
      The same class
      Throws:
      IllegalArgumentException - If nonceSupplier is null
    • nonceLength

      public ScramClient.Builder nonceLength(int length) throws IllegalArgumentException
      Sets a non-default (ScramClient.DEFAULT_NONCE_LENGTH) length for the nonce generation, if no alternate nonceSupplier is provided via nonceSupplier(NonceSupplier).
      Parameters:
      length - The length of the nonce. Must be positive and greater than 0
      Returns:
      The same class
      Throws:
      IllegalArgumentException - If length is less than 1
    • setup

      public ScramClient setup()
      Gets the client, fully constructed and configured, with the provided channel binding, string preparation properties, and the selected SCRAM mechanism based on server supported mechanisms. If no SecureRandom algorithm and provider were provided, a default one would be used. If no nonceSupplier was provided, a default nonce generator would be used, of the ScramClient.DEFAULT_NONCE_LENGTH length, unless nonceLength(int) is called.
      Returns:
      The fully built instance.