Package com.ongres.scram.client
Class ScramSession
- java.lang.Object
-
- com.ongres.scram.client.ScramSession
-
public class ScramSession extends java.lang.ObjectA 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 Classes Modifier and Type Class Description classScramSession.ClientFinalProcessorProcessor that allows to generate the client-final-message, as well as process the server-final-message and verify server's signature.classScramSession.ServerFirstProcessorProcess a received server-first-message.
-
Field Summary
Fields Modifier and Type Field Description private ClientFirstMessageclientFirstMessageprivate java.lang.Stringnonceprivate ScramMechanismscramMechanismprivate java.lang.StringserverFirstMessageStringprivate StringPreparationstringPreparationprivate java.lang.Stringuser
-
Constructor Summary
Constructors Constructor Description ScramSession(ScramMechanism scramMechanism, StringPreparation stringPreparation, java.lang.String user, java.lang.String nonce)Constructs a SCRAM client, to perform an authentication for a given user.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringclientFirstMessage()Returns the text representation of a SCRAM client-first-message, with no channel binding nor authzid.java.lang.StringclientFirstMessage(Gs2CbindFlag gs2CbindFlag, java.lang.String cbindName, java.lang.String authzid)Returns the text representation of a SCRAM client-first-message, with the GSS-API header values indicated.ScramSession.ServerFirstProcessorreceiveServerFirstMessage(java.lang.String serverFirstMessage)Constructs a handler for the server-first-message, from its String representation.private java.lang.StringsetAndReturnClientFirstMessage(ClientFirstMessage clientFirstMessage)
-
-
-
Field Detail
-
scramMechanism
private final ScramMechanism scramMechanism
-
stringPreparation
private final StringPreparation stringPreparation
-
user
private final java.lang.String user
-
nonce
private final java.lang.String nonce
-
clientFirstMessage
private ClientFirstMessage clientFirstMessage
-
serverFirstMessageString
private java.lang.String serverFirstMessageString
-
-
Constructor Detail
-
ScramSession
public ScramSession(ScramMechanism scramMechanism, StringPreparation stringPreparation, java.lang.String user, java.lang.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 aScramClientis used instead.- Parameters:
scramMechanism- The SCRAM mechanism that will be using this clientstringPreparation-user-nonce-
-
-
Method Detail
-
setAndReturnClientFirstMessage
private java.lang.String setAndReturnClientFirstMessage(ClientFirstMessage clientFirstMessage)
-
clientFirstMessage
public java.lang.String clientFirstMessage(Gs2CbindFlag gs2CbindFlag, java.lang.String cbindName, java.lang.String authzid)
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
public java.lang.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(java.lang.String serverFirstMessage) throws ScramParseException, java.lang.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-messagejava.lang.IllegalArgumentException- If the message is null or empty
-
-