Class ScramClient


  • public class ScramClient
    extends Object
    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 (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.
    • No external nonceSupplier is provided; or if provided, it is thread-safe.
    So this class, once instantiated via the ScramClient.Builder.setup()} method, can serve for multiple users and authentications.
    • Field Detail

      • DEFAULT_NONCE_LENGTH

        public static final int DEFAULT_NONCE_LENGTH
        Length (in characters, bytes) of the nonce generated by default (if no nonce supplier is provided)
        See Also:
        Constant Field Values
    • Method Detail

      • supportedMechanisms

        public static List<String> supportedMechanisms()
        List all the supported SCRAM mechanisms by this client implementation
        Returns:
        A list of the IANA-registered, SCRAM supported mechanisms
      • scramSession

        public ScramSession scramSession​(String user)
        Instantiates a ScramSession for the specified user and this parametrized generator.
        Parameters:
        user - The username of the authentication exchange
        Returns:
        The ScramSession instance