Package com.ongres.scram.common
Class ServerFirstMessage
java.lang.Object
com.ongres.scram.common.StringWritable
com.ongres.scram.common.AbstractScramMessage
com.ongres.scram.common.ServerFirstMessage
Constructs and parses
server-first-messages
.
nonce | "r=" c-nonce [s-nonce] ;; Second part provided by server. |
salt | "s=" base64 |
server-first-message | [reserved-mext ","] nonce "," salt ", "iteration-count ["," extensions] |
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServerFirstMessage
(String clientNonce, String serverNonce, String salt, int iterationCount) Constructs a server-first-message from a client-first-message and the additional required data. -
Method Summary
Modifier and TypeMethodDescriptionThe client nonce.int
The number of iterations.getNonce()
The concatenation of the client nonce and the server nonce:c-nonce [s-nonce]
.getSalt()
The salt in base64.The server nonce.static ServerFirstMessage
Parses a server-first-message from a String.(package private) StringBuilder
writeTo
(StringBuilder sb) Write the class information to the given StringBuffer.Methods inherited from class com.ongres.scram.common.AbstractScramMessage
toString
-
Field Details
-
clientNonce
-
serverNonce
-
salt
-
iterationCount
private final int iterationCount
-
-
Constructor Details
-
ServerFirstMessage
Constructs a server-first-message from a client-first-message and the additional required data.Formal Syntax: server-error "e=" server-error-value verifier "v=" base64
;; base-64 encoded ServerSignature.server-final-message (server-error / verifier)
["," extensions]- Parameters:
clientNonce
- The c-nonce used in client-first-messageserverNonce
- The s-nonce returned by the serversalt
- The saltiterationCount
- The iteration count (must be positive)- Throws:
IllegalArgumentException
- If clientFirstMessage, serverNonce or salt are null or empty, or iteration < 1
-
-
Method Details
-
getClientNonce
The client nonce.- Returns:
- The client nonce
-
getServerNonce
The server nonce.- Returns:
- The server nonce
-
getNonce
The concatenation of the client nonce and the server nonce:c-nonce [s-nonce]
.- Returns:
- The nonce
-
getSalt
The salt in base64.- Returns:
- The salt in base64.
-
getIterationCount
public int getIterationCount()The number of iterations.- Returns:
- The number of iterations.
-
parseFrom
public static ServerFirstMessage parseFrom(String serverFirstMessage, String clientNonce) throws ScramParseException Parses a server-first-message from a String.- Parameters:
serverFirstMessage
- The string representing the server-first-messageclientNonce
- The clientNonce 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
-
writeTo
Description copied from class:StringWritable
Write the class information to the given StringBuffer.- Specified by:
writeTo
in classStringWritable
- Parameters:
sb
- Where to write the data.- Returns:
- The same StringBuffer.
-