Class ScramClient.Builder

    • Field Detail

      • nonChannelBindingMechanism

        private final java.util.Optional<ScramMechanism> nonChannelBindingMechanism
      • channelBindingMechanism

        private final java.util.Optional<ScramMechanism> channelBindingMechanism
      • secureRandom

        private java.security.SecureRandom secureRandom
      • nonceSupplier

        private java.util.function.Supplier<java.lang.String> nonceSupplier
      • nonceLength

        private int nonceLength
    • Method Detail

      • secureRandomAlgorithmProvider

        public ScramClient.Builder secureRandomAlgorithmProvider​(java.lang.String algorithm,
                                                                 java.lang.String provider)
                                                          throws java.lang.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(Supplier)). 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:
        java.lang.IllegalArgumentException - If algorithm is null, or either the algorithm or provider are not supported
      • nonceSupplier

        public ScramClient.Builder nonceSupplier​(java.util.function.Supplier<java.lang.String> nonceSupplier)
                                          throws java.lang.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:
        java.lang.IllegalArgumentException - If nonceSupplier is null
      • nonceLength

        public ScramClient.Builder nonceLength​(int length)
                                        throws java.lang.IllegalArgumentException
        Sets a non-default (ScramClient.DEFAULT_NONCE_LENGTH) length for the nonce generation, if no alternate nonceSupplier is provided via nonceSupplier(Supplier).
        Parameters:
        length - The length of the nonce. Must be positive and greater than 0
        Returns:
        The same class
        Throws:
        java.lang.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.