Class ScramSession

java.lang.Object
com.ongres.scram.client.ScramSession

public class ScramSession extends Object
A class that represents a SCRAM client. Use this class to perform a SCRAM negotiation with a SCRAM server. This class performs an authentication execution for a given user, and has state related to it. Thus, it cannot be shared across users or authentication executions.
  • Field Details

  • Constructor Details

    • ScramSession

      public ScramSession(ScramMechanism scramMechanism, StringPreparation stringPreparation, String user, String nonce)
      Constructs a SCRAM client, to perform an authentication for a given user. This class can be instantiated directly, but it is recommended that a ScramClient is used instead.
      Parameters:
      scramMechanism - The SCRAM mechanism that will be using this client
      stringPreparation -
      user -
      nonce -
  • Method Details

    • setAndReturnClientFirstMessage

      private String setAndReturnClientFirstMessage(ClientFirstMessage clientFirstMessage)
    • clientFirstMessage

      public String clientFirstMessage(Gs2CbindFlag gs2CbindFlag, String cbindName, String authzid)
      Returns the text representation of a SCRAM client-first-message, with the GSS-API header values indicated.
      Parameters:
      gs2CbindFlag - The channel binding flag
      cbindName - The channel binding algorithm name, if channel binding is supported, or null
      authzid - The optional
      Returns:
      The message
    • clientFirstMessage

      public String clientFirstMessage()
      Returns the text representation of a SCRAM client-first-message, with no channel binding nor authzid.
      Returns:
      The message
    • receiveServerFirstMessage

      public ScramSession.ServerFirstProcessor receiveServerFirstMessage(String serverFirstMessage) throws ScramParseException, IllegalArgumentException
      Constructs a handler for the server-first-message, from its String representation.
      Parameters:
      serverFirstMessage - The message
      Returns:
      The handler
      Throws:
      ScramParseException - If the message is not a valid server-first-message
      IllegalArgumentException - If the message is null or empty