Package com.ongres.scram.client
Class ScramSession
java.lang.Object
com.ongres.scram.client.ScramSession
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Processor that allows to generate the client-final-message, as well as process the server-final-message and verify server's signature.class
Process a received server-first-message. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ClientFirstMessage
private final String
private final ScramMechanism
private String
private final StringPreparation
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionScramSession
(ScramMechanism scramMechanism, StringPreparation stringPreparation, String user, String nonce) Constructs a SCRAM client, to perform an authentication for a given user. -
Method Summary
Modifier and TypeMethodDescriptionReturns the text representation of a SCRAM client-first-message, with no channel binding nor authzid.clientFirstMessage
(Gs2CbindFlag gs2CbindFlag, String cbindName, String authzid) Returns the text representation of a SCRAM client-first-message, with the GSS-API header values indicated.receiveServerFirstMessage
(String serverFirstMessage) Constructs a handler for the server-first-message, from its String representation.private String
setAndReturnClientFirstMessage
(ClientFirstMessage clientFirstMessage)
-
Field Details
-
scramMechanism
-
stringPreparation
-
user
-
nonce
-
clientFirstMessage
-
serverFirstMessageString
-
-
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 aScramClient
is used instead.- Parameters:
scramMechanism
- The SCRAM mechanism that will be using this clientstringPreparation
-user
-nonce
-
-
-
Method Details
-
setAndReturnClientFirstMessage
-
clientFirstMessage
Returns the text representation of a SCRAM client-first-message, with the GSS-API header values indicated.- Parameters:
gs2CbindFlag
- The channel binding flagcbindName
- The channel binding algorithm name, if channel binding is supported, or nullauthzid
- The optional- Returns:
- The message
-
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-messageIllegalArgumentException
- If the message is null or empty
-