Package com.ongres.scram.common.message
Class ServerFirstMessage
java.lang.Object
com.ongres.scram.common.message.ServerFirstMessage
- All Implemented Interfaces:
StringWritable
Constructs and parses server-first-messages. Formal syntax is:
server-first-message = [reserved-mext ","] nonce "," salt ","
iteration-count ["," extensions]
Note that extensions are not supported.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServerFirstMessage
(String clientNonce, String serverNonce, String salt, int iteration) Constructs a server-first-message from a client-first-message and the additional required data. -
Method Summary
Modifier and TypeMethodDescriptionint
getNonce()
getSalt()
static ServerFirstMessage
Parses a server-first-message from a String.toString()
writeTo
(StringBuffer sb) Write the class information to the given StringBuffer.
-
Field Details
-
ITERATION_MIN_VALUE
public static final int ITERATION_MIN_VALUEMinimum allowed value for the iteration, as per the RFC.- See Also:
-
clientNonce
-
serverNonce
-
salt
-
iteration
private final int iteration
-
-
Constructor Details
-
ServerFirstMessage
public ServerFirstMessage(String clientNonce, String serverNonce, String salt, int iteration) throws IllegalArgumentException Constructs a server-first-message from a client-first-message and the additional required data.- Parameters:
clientNonce
- String representing the client-first-messageserverNonce
- Server serverNoncesalt
- The saltiteration
- The iteration count (must be <= 4096)- Throws:
IllegalArgumentException
- If clientFirstMessage, serverNonce or salt are null or empty, or iteration < 4096
-
-
Method Details
-
getClientNonce
-
getServerNonce
-
getNonce
-
getSalt
-
getIteration
public int getIteration() -
writeTo
Description copied from interface:StringWritable
Write the class information to the given StringBuffer.- Specified by:
writeTo
in interfaceStringWritable
- Parameters:
sb
- Where to write the data.- Returns:
- The same StringBuffer.
-
parseFrom
public static ServerFirstMessage parseFrom(String serverFirstMessage, String clientNonce) throws ScramParseException, IllegalArgumentException Parses a server-first-message from a String.- Parameters:
serverFirstMessage
- The string representing the server-first-messageclientNonce
- The serverNonce that is present in the client-first-message- Returns:
- The parsed instance
- Throws:
ScramParseException
- If the argument is not a valid server-first-messageIllegalArgumentException
- If either argument is empty or serverFirstMessage is not a valid message
-
toString
-