Package com.ongres.scram.client
Class ScramClient.Builder
- java.lang.Object
-
- com.ongres.scram.client.ScramClient.PreBuilder1
-
- com.ongres.scram.client.ScramClient.PreBuilder2
-
- com.ongres.scram.client.ScramClient.Builder
-
- Enclosing class:
- ScramClient
public static class ScramClient.Builder extends ScramClient.PreBuilder2
This class is not meant to be used directly. Use insteadScramClient.channelBinding(ChannelBinding)
and chained methods.
-
-
Field Summary
-
Fields inherited from class com.ongres.scram.client.ScramClient.PreBuilder2
stringPreparation
-
Fields inherited from class com.ongres.scram.client.ScramClient.PreBuilder1
channelBinding
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScramClient.Builder
nonceLength(int length)
Sets a non-default (ScramClient.DEFAULT_NONCE_LENGTH
) length for the nonce generation, if no alternate nonceSupplier is provided vianonceSupplier(Supplier)
.ScramClient.Builder
nonceSupplier(Supplier<String> nonceSupplier)
Optional call.ScramClient.Builder
secureRandomAlgorithmProvider(String algorithm, String provider)
Optional call.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.-
Methods inherited from class com.ongres.scram.client.ScramClient.PreBuilder2
selectClientMechanism, selectMechanismBasedOnServerAdvertised, selectMechanismBasedOnServerAdvertisedCsv
-
Methods inherited from class com.ongres.scram.client.ScramClient.PreBuilder1
stringPreparation
-
-
-
-
Method Detail
-
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 vianonceSupplier(Supplier)
). Algorithm and provider names are those supported by theSecureRandom
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(Supplier<String> 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 vianonceSupplier(Supplier)
.- 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 theScramClient.DEFAULT_NONCE_LENGTH
length, unlessnonceLength(int)
is called.- Returns:
- The fully built instance.
-
-