Package com.ongres.scram.client
Class ScramClient
java.lang.Object
com.ongres.scram.client.ScramClient
A class that can be parametrized to generate
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:
- The SecureRandom used (
SecureRandomby default) are thread-safe too. The contract ofRandommarks it as thread-safe, so inherited classes are also expected to maintain it. - No external nonceSupplier is provided; or if provided, it is thread-safe.
ScramClient.Builder.setup()} method, can serve for multiple users and
authentications.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class is not meant to be used directly.static enumSelect whether this client will support channel binding or notstatic classThis class is not meant to be used directly.static classThis class is not meant to be used directly. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ScramClient.ChannelBindingstatic final intLength (in characters, bytes) of the nonce generated by default (if no nonce supplier is provided)private final NonceSupplierprivate final ScramMechanismprivate final SecureRandomprivate final StringPreparation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateScramClient(ScramClient.ChannelBinding channelBinding, StringPreparation stringPreparation, ScramMechanism nonChannelBindingMechanism, ScramMechanism channelBindingMechanism, SecureRandom secureRandom, NonceSupplier nonceSupplier) -
Method Summary
Modifier and TypeMethodDescriptionstatic ScramClient.PreBuilder1channelBinding(ScramClient.ChannelBinding channelBinding) Selects for the client whether to use channel binding.scramSession(String user) Instantiates aScramSessionfor the specified user and this parametrized generator.List all the supported SCRAM mechanisms by this client implementation
-
Field Details
-
DEFAULT_NONCE_LENGTH
public static final int DEFAULT_NONCE_LENGTHLength (in characters, bytes) of the nonce generated by default (if no nonce supplier is provided)- See Also:
-
channelBinding
-
stringPreparation
-
scramMechanism
-
secureRandom
-
nonceSupplier
-
-
Constructor Details
-
ScramClient
private ScramClient(ScramClient.ChannelBinding channelBinding, StringPreparation stringPreparation, ScramMechanism nonChannelBindingMechanism, ScramMechanism channelBindingMechanism, SecureRandom secureRandom, NonceSupplier nonceSupplier)
-
-
Method Details
-
channelBinding
public static ScramClient.PreBuilder1 channelBinding(ScramClient.ChannelBinding channelBinding) throws IllegalArgumentException Selects for the client whether to use channel binding. Refer toScramClient.ChannelBindingdocumentation for the description of the possible values.- Parameters:
channelBinding- The channel binding setting- Returns:
- The next step in the chain (PreBuilder1).
- Throws:
IllegalArgumentException- If channelBinding is null
-
getStringPreparation
-
getScramMechanism
-
supportedMechanisms
List all the supported SCRAM mechanisms by this client implementation- Returns:
- A list of the IANA-registered, SCRAM supported mechanisms
-
scramSession
Instantiates aScramSessionfor the specified user and this parametrized generator.- Parameters:
user- The username of the authentication exchange- Returns:
- The ScramSession instance
-