Class ServerFinalMessage
- java.lang.Object
-
- com.impossibl.postgres.protocol.sasl.scram.message.ServerFinalMessage
-
- All Implemented Interfaces:
StringWritable
public class ServerFinalMessage extends Object implements StringWritable
Constructs and parses server-final-messages. Formal syntax is:server-error = "e=" server-error-value server-error-value = "invalid-encoding" / "extensions-not-supported" / ; unrecognized 'm' value "invalid-proof" / "channel-bindings-dont-match" / "server-does-support-channel-binding" / ; server does not support channel binding "channel-binding-not-supported" / "unsupported-channel-binding-type" / "unknown-user" / "invalid-username-encoding" / ; invalid username encoding (invalid UTF-8 or ; SASLprep failed) "no-resources" / "other-error" / server-error-value-ext ; Unrecognized errors should be treated as "other-error". ; In order to prevent information disclosure, the server ; may substitute the real reason with "other-error". server-error-value-ext = value ; Additional error reasons added by extensions ; to this document. verifier = "v=" base64 ;; base-64 encoded ServerSignature. server-final-errorMessage = (server-error / verifier) ["," extensions]
Note that extensions are not supported (and, consequently, error message extensions).- See Also:
- [RFC5802] Section 7
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ServerFinalMessage.Error
Possible error messages sent on a server-final-message.
-
Constructor Summary
Constructors Constructor Description ServerFinalMessage(byte[] verifier)
Constructs a server-final-message with no errors, and the provided server verifierServerFinalMessage(ServerFinalMessage.Error error)
Constructs a server-final-message which represents a SCRAM error.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ServerFinalMessage.Error
getError()
byte[]
getVerifier()
boolean
isError()
Whether this server-final-message contains an errorstatic ServerFinalMessage
parseFrom(String serverFinalMessage)
Parses a server-final-message from a String.String
toString()
StringBuffer
writeTo(StringBuffer sb)
Write the class information to the given StringBuffer.
-
-
-
Constructor Detail
-
ServerFinalMessage
public ServerFinalMessage(byte[] verifier) throws IllegalArgumentException
Constructs a server-final-message with no errors, and the provided server verifier- Parameters:
verifier
- The bytes of the computed signature- Throws:
IllegalArgumentException
- If the verifier is null
-
ServerFinalMessage
public ServerFinalMessage(ServerFinalMessage.Error error) throws IllegalArgumentException
Constructs a server-final-message which represents a SCRAM error.- Parameters:
error
- The error- Throws:
IllegalArgumentException
- If the error is null
-
-
Method Detail
-
isError
public boolean isError()
Whether this server-final-message contains an error- Returns:
- True if it contains an error, false if it contains a verifier
-
getVerifier
public byte[] getVerifier()
-
getError
public ServerFinalMessage.Error getError()
-
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 ServerFinalMessage parseFrom(String serverFinalMessage) throws ScramParseException, IllegalArgumentException
Parses a server-final-message from a String.- Parameters:
serverFinalMessage
- The message- Returns:
- A constructed server-final-message instance
- Throws:
ScramParseException
- If the argument is not a valid server-final-messageIllegalArgumentException
- If the message is null or empty
-
-