ScramSessions.
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 java.util.Random marks it as thread-safe, so inherited classes are also expected
to maintain it.
Builder#setup()} method, can serve for multiple users and
authentications.
| Modifier and Type | Class and Description |
|---|---|
| public static class | ScramClient.Builder
This class is not meant to be used directly. |
| public static enum | ScramClient.ChannelBinding
Select whether this client will support channel binding or not |
| public static class | ScramClient.PreBuilder1
This class is not meant to be used directly. |
| public static class | ScramClient.PreBuilder2
This class is not meant to be used directly. |
| Modifier and Type | Field and Description |
|---|---|
| private final ScramClient. | |
| public static final int | DEFAULT_NONCE_LENGTH
Length (in characters, bytes) of the nonce generated by default (if no nonce supplier is provided) |
| private final NonceSupplier | |
| private final ScramMechanism | |
| private final SecureRandom | |
| private final StringPreparation |
| Access | Constructor and Description |
|---|---|
| private | ScramClient(ScramClient.
|
| Modifier and Type | Method and Description |
|---|---|
| public static ScramClient. | Returns: The next step in the chain (PreBuilder1).The channel binding setting channelBindingSelects for the client whether to use channel binding. |
| public ScramMechanism | |
| public StringPreparation | |
| public ScramSession | Returns: The ScramSession instanceThe username of the authentication exchange user)Instantiates a |
| public static List | Returns: A list of the IANA-registered, SCRAM supported mechanismsList all the supported SCRAM mechanisms by this client implementation |
| channelBinding | back to summary |
|---|---|
| private final ScramClient. | |
| DEFAULT_NONCE_LENGTH | back to summary |
|---|---|
| public static final int DEFAULT_NONCE_LENGTH Length (in characters, bytes) of the nonce generated by default (if no nonce supplier is provided) | |
| nonceSupplier | back to summary |
|---|---|
| private final NonceSupplier nonceSupplier | |
| scramMechanism | back to summary |
|---|---|
| private final ScramMechanism scramMechanism | |
| secureRandom | back to summary |
|---|---|
| private final SecureRandom secureRandom | |
| stringPreparation | back to summary |
|---|---|
| private final StringPreparation stringPreparation | |
| ScramClient | back to summary |
|---|---|
| private ScramClient(ScramClient. | |
| channelBinding | back to summary |
|---|---|
| public static ScramClient. Selects for the client whether to use channel binding.
Refer to
| |
| getScramMechanism | back to summary |
|---|---|
| public ScramMechanism getScramMechanism() | |
| getStringPreparation | back to summary |
|---|---|
| public StringPreparation getStringPreparation() | |
| scramSession | back to summary |
|---|---|
| public ScramSession scramSession(String user) Instantiates a
| |
| supportedMechanisms | back to summary |
|---|---|
| public static List List all the supported SCRAM mechanisms by this client implementation | |
ScramClient#channelBinding(ChannelBinding) and chained methods.
| Modifier and Type | Field and Description |
|---|---|
| private final ScramMechanism | |
| private int | |
| private NonceSupplier | |
| private final ScramMechanism | |
| private SecureRandom |
| Access | Constructor and Description |
|---|---|
| private | Builder(ScramClient.
|
| Modifier and Type | Method and Description |
|---|---|
| public ScramClient. | Returns: The same classThe length of the nonce. Must be positive and greater than 0 length)Sets a non-default ( |
| public ScramClient. | Returns: The same classA 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. nonceSupplier)Optional call. |
| public ScramClient. | Returns: The same classThe name of the algorithm to use. algorithm, String The name of the provider of SecureRandom. Might be null. provider)Optional call. |
| public ScramClient | Returns: The fully built instance.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. |
| channelBindingMechanism | back to summary |
|---|---|
| private final ScramMechanism channelBindingMechanism Hides com. | |
| nonceLength | back to summary |
|---|---|
| private int nonceLength | |
| nonceSupplier | back to summary |
|---|---|
| private NonceSupplier nonceSupplier | |
| nonChannelBindingMechanism | back to summary |
|---|---|
| private final ScramMechanism nonChannelBindingMechanism Hides com. | |
| secureRandom | back to summary |
|---|---|
| private SecureRandom secureRandom | |
| Builder | back to summary |
|---|---|
| private Builder(ScramClient. | |
| nonceLength | back to summary |
|---|---|
| public ScramClient. Sets a non-default (
| |
| nonceSupplier | back to summary |
|---|---|
| public ScramClient. Optional call. The client will use a default nonce generator, unless an external one is provided by this method. *
| |
| secureRandomAlgorithmProvider | back to summary |
|---|---|
| public ScramClient. 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
| |
| setup | back to summary |
|---|---|
| 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
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Gs2CbindFlag | |
| public static final ScramClient. | IF_SERVER_SUPPORTS_IT
Channel binding is preferred. |
| public static final ScramClient. | NO
Don't use channel binding. |
| public static final ScramClient. | YES
Force use of channel binding. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Gs2CbindFlag | |
| public static ScramClient. | |
| public static ScramClient. |
| gs2CbindFlag | back to summary |
|---|---|
| private final Gs2CbindFlag gs2CbindFlag | |
| IF_SERVER_SUPPORTS_IT | back to summary |
|---|---|
| public static final ScramClient. Channel binding is preferred. Non-channel binding mechanisms will be used if either the server does not support channel binding, or no channel binding data is provided as part of the ClientFirstMessage | |
| NO | back to summary |
|---|---|
| public static final ScramClient. Don't use channel binding. Server must support at least one non-channel binding mechanism. | |
| YES | back to summary |
|---|---|
| public static final ScramClient. Force use of channel binding. Server must support at least one channel binding mechanism. Channel binding data will need to be provided as part of the ClientFirstMessage. | |
| ChannelBinding | back to summary |
|---|---|
| private ChannelBinding(Gs2CbindFlag gs2CbindFlag) | |
| gs2CbindFlag | back to summary |
|---|---|
| public Gs2CbindFlag gs2CbindFlag() | |
| valueOf | back to summary |
|---|---|
| public static ScramClient. | |
| values | back to summary |
|---|---|
| public static ScramClient. | |
ScramClient#channelBinding(ChannelBinding) instead.
| Modifier and Type | Field and Description |
|---|---|
| protected final ScramClient. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public ScramClient. | stringPreparation(StringPreparation
The string preparation algorithm stringPreparation)Selects the string preparation algorithm to use by the client. |
| channelBinding | back to summary |
|---|---|
| protected final ScramClient. | |
| PreBuilder1 | back to summary |
|---|---|
| private PreBuilder1(ScramClient. | |
| stringPreparation | back to summary |
|---|---|
| public ScramClient. Selects the string preparation algorithm to use by the client.
| |
ScramClient#channelBinding(ChannelBinding).{#stringPreparation(StringPreparation)} instead.
| Modifier and Type | Field and Description |
|---|---|
| protected ScramMechanism | |
| protected ScramMechanism | |
| protected final StringPreparation |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public ScramClient. | selectClientMechanism(ScramMechanism
The selected scram mechanism scramMechanism)Select a fixed client mechanism. |
| public ScramClient. | selectMechanismBasedOnServerAdvertised(String...
One or more IANA-registered SCRAM mechanism names, as advertised by the server serverMechanisms)Inform the client of the SCRAM mechanisms supported by the server. |
| public ScramClient. | selectMechanismBasedOnServerAdvertisedCsv(String
A CSV (Comma-Separated Values) String, containining all the SCRAM mechanisms
supported by the server serverMechanismsCsv)Inform the client of the SCRAM mechanisms supported by the server. |
| channelBindingMechanism | back to summary |
|---|---|
| protected ScramMechanism channelBindingMechanism | |
| nonChannelBindingMechanism | back to summary |
|---|---|
| protected ScramMechanism nonChannelBindingMechanism | |
| stringPreparation | back to summary |
|---|---|
| protected final StringPreparation stringPreparation | |
| PreBuilder2 | back to summary |
|---|---|
| private PreBuilder2(ScramClient. | |
| selectClientMechanism | back to summary |
|---|---|
| public ScramClient. Select a fixed client mechanism. It must be compatible with the channel binding selection previously
performed. If automatic selection based on server advertised mechanisms is preferred, please use methods
| |
| selectMechanismBasedOnServerAdvertised | back to summary |
|---|---|
| public ScramClient. Inform the client of the SCRAM mechanisms supported by the server. Based on this list, the channel binding settings previously specified, and the relative strength of the supported SCRAM mechanisms for this client, the client will have enough data to select which mechanism to use for future interactions with the server. All names provided here need to be standar IANA Registry names for SCRAM mechanisms, or will be ignored.
| |
| selectMechanismBasedOnServerAdvertisedCsv | back to summary |
|---|---|
| public ScramClient. Inform the client of the SCRAM mechanisms supported by the server.
Calls
| |