public class ScramClient
extends java.lang.Object
ScramSession
s.
This class supports the channel binding and string preparation mechanisms that are provided by module scram-common.
The class is fully configurable, including options to selected the desired channel binding,
automatically pick the best client SCRAM mechanism based on those supported (advertised) by the server,
selecting an externally-provided SecureRandom instance or an external nonceProvider, or choosing the nonce length.
This class is thread-safe if the two following conditions are met:
SecureRandom
by default) are thread-safe too.
The contract of Random
marks it as thread-safe, so inherited classes are also expected
to maintain it.
ScramClient.Builder.setup()
} method, can serve for multiple users and
authentications.Modifier and Type | Class and Description |
---|---|
static class |
ScramClient.Builder
This class is not meant to be used directly.
|
static class |
ScramClient.ChannelBinding
Select whether this client will support channel binding or not
|
static class |
ScramClient.PreBuilder1
This class is not meant to be used directly.
|
static class |
ScramClient.PreBuilder2
This class is not meant to be used directly.
|
Modifier and Type | Field and Description |
---|---|
private ScramClient.ChannelBinding |
channelBinding |
static int |
DEFAULT_NONCE_LENGTH
Length (in characters, bytes) of the nonce generated by default (if no nonce supplier is provided)
|
private java.util.function.Supplier<java.lang.String> |
nonceSupplier |
private ScramMechanism |
scramMechanism |
private java.security.SecureRandom |
secureRandom |
private StringPreparation |
stringPreparation |
Modifier | Constructor and Description |
---|---|
private |
ScramClient(ScramClient.ChannelBinding channelBinding,
StringPreparation stringPreparation,
java.util.Optional<ScramMechanism> nonChannelBindingMechanism,
java.util.Optional<ScramMechanism> channelBindingMechanism,
java.security.SecureRandom secureRandom,
java.util.function.Supplier<java.lang.String> nonceSupplier) |
Modifier and Type | Method and Description |
---|---|
static ScramClient.PreBuilder1 |
channelBinding(ScramClient.ChannelBinding channelBinding)
Selects for the client whether to use channel binding.
|
ScramMechanism |
getScramMechanism() |
StringPreparation |
getStringPreparation() |
ScramSession |
scramSession(java.lang.String user)
Instantiates a
ScramSession for the specified user and this parametrized generator. |
static java.util.List<java.lang.String> |
supportedMechanisms()
List all the supported SCRAM mechanisms by this client implementation
|
public static final int DEFAULT_NONCE_LENGTH
private final ScramClient.ChannelBinding channelBinding
private final StringPreparation stringPreparation
private final ScramMechanism scramMechanism
private final java.security.SecureRandom secureRandom
private final java.util.function.Supplier<java.lang.String> nonceSupplier
private ScramClient(ScramClient.ChannelBinding channelBinding, StringPreparation stringPreparation, java.util.Optional<ScramMechanism> nonChannelBindingMechanism, java.util.Optional<ScramMechanism> channelBindingMechanism, java.security.SecureRandom secureRandom, java.util.function.Supplier<java.lang.String> nonceSupplier)
public static ScramClient.PreBuilder1 channelBinding(ScramClient.ChannelBinding channelBinding) throws java.lang.IllegalArgumentException
ScramClient.ChannelBinding
documentation for the description of the possible values.channelBinding
- The channel binding settingjava.lang.IllegalArgumentException
- If channelBinding is nullpublic StringPreparation getStringPreparation()
public ScramMechanism getScramMechanism()
public static java.util.List<java.lang.String> supportedMechanisms()
public ScramSession scramSession(java.lang.String user)
ScramSession
for the specified user and this parametrized generator.user
- The username of the authentication exchange