Class ServerFirstMessage
- java.lang.Object
-
- com.impossibl.postgres.protocol.sasl.scram.message.ServerFirstMessage
-
- All Implemented Interfaces:
StringWritable
public class ServerFirstMessage extends Object implements 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:
- [RFC5802] Section 7
-
-
Field Summary
Fields Modifier and Type Field Description static int
ITERATION_MIN_VALUE
Minimum allowed value for the iteration, as per the RFC.
-
Constructor Summary
Constructors Constructor Description ServerFirstMessage(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getClientNonce()
int
getIteration()
String
getNonce()
String
getSalt()
String
getServerNonce()
static ServerFirstMessage
parseFrom(String serverFirstMessage, String clientNonce)
Parses a server-first-message from a String.String
toString()
StringBuffer
writeTo(StringBuffer sb)
Write the class information to the given StringBuffer.
-
-
-
Field Detail
-
ITERATION_MIN_VALUE
public static final int ITERATION_MIN_VALUE
Minimum allowed value for the iteration, as per the RFC.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
getClientNonce
public String getClientNonce()
-
getServerNonce
public String getServerNonce()
-
getNonce
public String getNonce()
-
getSalt
public String getSalt()
-
getIteration
public int getIteration()
-
writeTo
public StringBuffer writeTo(StringBuffer sb)
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
-
-