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
This class is not meant to be used directly.
Use instead
ScramClient.channelBinding(ChannelBinding) and chained methods.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ScramMechanismprivate intprivate NonceSupplierprivate final ScramMechanismprivate SecureRandomFields inherited from class com.ongres.scram.client.ScramClient.PreBuilder2
stringPreparationFields inherited from class com.ongres.scram.client.ScramClient.PreBuilder1
channelBinding -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateBuilder(ScramClient.ChannelBinding channelBinding, StringPreparation stringPreparation, ScramMechanism nonChannelBindingMechanism, ScramMechanism channelBindingMechanism) -
Method Summary
Modifier and TypeMethodDescriptionnonceLength(int length) Sets a non-default (ScramClient.DEFAULT_NONCE_LENGTH) length for the nonce generation, if no alternate nonceSupplier is provided vianonceSupplier(NonceSupplier).nonceSupplier(NonceSupplier nonceSupplier) Optional call.secureRandomAlgorithmProvider(String algorithm, String provider) Optional call.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, selectMechanismBasedOnServerAdvertisedCsvMethods inherited from class com.ongres.scram.client.ScramClient.PreBuilder1
stringPreparation
-
Field Details
-
nonChannelBindingMechanism
-
channelBindingMechanism
-
secureRandom
-
nonceSupplier
-
nonceLength
private int nonceLength
-
-
Constructor Details
-
Builder
private Builder(ScramClient.ChannelBinding channelBinding, StringPreparation stringPreparation, ScramMechanism nonChannelBindingMechanism, ScramMechanism channelBindingMechanism)
-
-
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 vianonceSupplier(NonceSupplier)). Algorithm and provider names are those supported by theSecureRandomclass.- 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
Sets a non-default (ScramClient.DEFAULT_NONCE_LENGTH) length for the nonce generation, if no alternate nonceSupplier is provided vianonceSupplier(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
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_LENGTHlength, unlessnonceLength(int)is called.- Returns:
- The fully built instance.
-