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
-
public final class ServerFirstMessage extends AbstractScramMessage
Constructs and parsesserver-first-messages.Formal Syntax: 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:
- [RFC5802] Section 7
-
-
Field Summary
Fields Modifier and Type Field Description private @NotNull java.lang.StringclientNonceprivate intiterationCountprivate @NotNull java.lang.Stringsaltprivate @NotNull java.lang.StringserverNonce
-
Constructor Summary
Constructors Constructor Description ServerFirstMessage(@NotNull java.lang.String clientNonce, @NotNull java.lang.String serverNonce, @NotNull java.lang.String salt, int iterationCount)Constructs a server-first-message from a client-first-message and the additional required data.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull java.lang.StringgetClientNonce()The client nonce.intgetIterationCount()The number of iterations.@NotNull java.lang.StringgetNonce()The concatenation of the client nonce and the server nonce:c-nonce [s-nonce].java.lang.StringgetSalt()The salt in base64.@NotNull java.lang.StringgetServerNonce()The server nonce.static @NotNull ServerFirstMessageparseFrom(@NotNull java.lang.String serverFirstMessage, @NotNull java.lang.String clientNonce)Parses a server-first-message from a String.(package private) java.lang.StringBuilderwriteTo(java.lang.StringBuilder sb)Write the class information to the given StringBuffer.-
Methods inherited from class com.ongres.scram.common.AbstractScramMessage
toString
-
-
-
-
Constructor Detail
-
ServerFirstMessage
public ServerFirstMessage(@NotNull @NotNull java.lang.String clientNonce, @NotNull @NotNull java.lang.String serverNonce, @NotNull @NotNull java.lang.String salt, int iterationCount)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:
java.lang.IllegalArgumentException- If clientFirstMessage, serverNonce or salt are null or empty, or iteration < 1
-
-
Method Detail
-
getClientNonce
@NotNull public @NotNull java.lang.String getClientNonce()
The client nonce.- Returns:
- The client nonce
-
getServerNonce
@NotNull public @NotNull java.lang.String getServerNonce()
The server nonce.- Returns:
- The server nonce
-
getNonce
@NotNull public @NotNull java.lang.String getNonce()
The concatenation of the client nonce and the server nonce:c-nonce [s-nonce].- Returns:
- The nonce
-
getSalt
public java.lang.String getSalt()
The salt in base64.- Returns:
- The salt in base64.
-
getIterationCount
public int getIterationCount()
The number of iterations.- Returns:
- The number of iterations.
-
parseFrom
@NotNull public static @NotNull ServerFirstMessage parseFrom(@NotNull @NotNull java.lang.String serverFirstMessage, @NotNull @NotNull java.lang.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-messagejava.lang.IllegalArgumentException- If either argument is empty or serverFirstMessage is not a valid message
-
writeTo
java.lang.StringBuilder writeTo(java.lang.StringBuilder sb)
Description copied from class:StringWritableWrite the class information to the given StringBuffer.- Specified by:
writeToin classStringWritable- Parameters:
sb- Where to write the data.- Returns:
- The same StringBuffer.
-
-