Class ScramSessionFactory.Builder
- java.lang.Object
-
- com.impossibl.postgres.protocol.sasl.scram.client.ScramSessionFactory.Builder
-
- Enclosing class:
- ScramSessionFactory
public static class ScramSessionFactory.Builder extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScramSessionFactory
build()
ScramSessionFactory.Builder
channelBindMethod(String channelBindMethod)
The selected/supported channel-bind method the client plans to use.ScramSessionFactory.Builder
nonceLength(int nonceLength)
Optional call.ScramSessionFactory.Builder
preferChannelBindingMechanism(boolean preferChannelBinding)
Determine whether the selection process should favor selecting a mechanism that requires channel binding over a method that has a stronger algorithm.ScramSessionFactory.Builder
secureRandomAlgorithmProvider(String algorithm, String provider)
Optional call.ScramSessionFactory.Builder
serverAdvertisedMechanisms(Collection<String> serverAdvertisedMechanisms)
Provide the list of mechanism names advertised by the server.ScramSessionFactory.Builder
stringPreparation(StringPreparation stringPreparation)
Optional call.
-
-
-
Method Detail
-
serverAdvertisedMechanisms
public ScramSessionFactory.Builder serverAdvertisedMechanisms(Collection<String> serverAdvertisedMechanisms)
Provide the list of mechanism names advertised by the server. The method will filter out mechanisms unsupported by the current implementation.- Parameters:
serverAdvertisedMechanisms
- Names of advertised mechanisms
-
preferChannelBindingMechanism
public ScramSessionFactory.Builder preferChannelBindingMechanism(boolean preferChannelBinding)
Determine whether the selection process should favor selecting a mechanism that requires channel binding over a method that has a stronger algorithm. For example, if 'SCRAM-SHA1-PLUS' and 'SCRAM-SHA256' are the available methods should it favor the `SCRAM-SHA1-PLUS` because it requires channel binding.- Parameters:
preferChannelBinding
- Should selection prefer a channel binding mechanism
-
channelBindMethod
public ScramSessionFactory.Builder channelBindMethod(String channelBindMethod)
The selected/supported channel-bind method the client plans to use. If the client does not support any channel binding methods it can passnull
.- Parameters:
channelBindMethod
- Selected/supported channel-bind method.
-
stringPreparation
public ScramSessionFactory.Builder stringPreparation(StringPreparation stringPreparation)
Optional call. The string preparation method that should be performed on the user's name and password. The default is to useStringPreparations.SASL_PREPARATION
.- Parameters:
stringPreparation
- Selected string preparation method.
-
nonceLength
public ScramSessionFactory.Builder nonceLength(int nonceLength)
Optional call. The length of randomly generated nonce that should be used. Only required if a specific non-default nonce length is required otherwise an implementation defined default length is used.- Parameters:
nonceLength
- Length of randomly generated nonce.
-
secureRandomAlgorithmProvider
public ScramSessionFactory.Builder secureRandomAlgorithmProvider(String algorithm, String provider) throws IllegalArgumentException
Optional call. Selects a non-default SecureRandom instance, based on the given algorithm and optionally a specific security provider. This selectedSecureRandom
instance will be used to generate secure random values (e.g. nonces). 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
-
build
public ScramSessionFactory build() throws ScramException
- Throws:
ScramException
-
-