Class ServerFinalMessage


  • public final class ServerFinalMessage
    extends AbstractScramMessage
    Constructs and parses server-final-messages.
    Formal Syntax:
    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"

    ; Unrecognized errors should be treated as "other-error".
    ; In order to prevent information disclosure, the server
    ; may substitute the real reason with "other-error".
    verifier "v=" base64
    ;; base-64 encoded ServerSignature.
    server-final-message (server-error / verifier)
    ["," extensions]
    See Also:
    [RFC5802] Section 7
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private @Nullable java.lang.String serverError  
      private byte @Nullable [] verifier  
    • Constructor Summary

      Constructors 
      Constructor Description
      ServerFinalMessage​(byte @NotNull [] verifier)
      Constructs a server-final-message with no errors, and the provided server verifier.
      ServerFinalMessage​(@NotNull java.lang.String serverError)
      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
      @Nullable java.lang.String getServerError()
      Get the server-error-value from the "e=" server-final-message.
      byte @Nullable [] getVerifier()
      Get the verifier value from the "v=" server-final-message.
      boolean isError()
      Whether this server-final-message contains an error.
      static @NotNull ServerFinalMessage parseFrom​(@NotNull java.lang.String serverFinalMessage)
      Parses a server-final-message from a String.
      private static java.lang.String validateServerErrorType​(@NotNull java.lang.String serverError)  
      (package private) java.lang.StringBuilder writeTo​(java.lang.StringBuilder sb)
      Write the class information to the given StringBuffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • verifier

        private final byte @Nullable [] verifier
      • serverError

        @Nullable
        private final @Nullable java.lang.String serverError
    • Constructor Detail

      • ServerFinalMessage

        public ServerFinalMessage​(byte @NotNull [] verifier)
        Constructs a server-final-message with no errors, and the provided server verifier.
        Parameters:
        verifier - The bytes of the computed signature
        Throws:
        java.lang.IllegalArgumentException - If the verifier is null
      • ServerFinalMessage

        public ServerFinalMessage​(@NotNull
                                  @NotNull java.lang.String serverError)
        Constructs a server-final-message which represents a SCRAM error.
        Parameters:
        serverError - The error message
        Throws:
        java.lang.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 @Nullable [] getVerifier()
        Get the verifier value from the "v=" server-final-message.
        Returns:
        the verifier
      • getServerError

        @Nullable
        public @Nullable java.lang.String getServerError()
        Get the server-error-value from the "e=" server-final-message.
        Returns:
        the server-error-value
      • parseFrom

        @NotNull
        public static @NotNull ServerFinalMessage parseFrom​(@NotNull
                                                            @NotNull java.lang.String serverFinalMessage)
                                                     throws ScramParseException
        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-message
        java.lang.IllegalArgumentException - If the message is null or empty
      • writeTo

        java.lang.StringBuilder writeTo​(java.lang.StringBuilder sb)
        Description copied from class: StringWritable
        Write the class information to the given StringBuffer.
        Specified by:
        writeTo in class StringWritable
        Parameters:
        sb - Where to write the data.
        Returns:
        The same StringBuffer.
      • validateServerErrorType

        private static java.lang.String validateServerErrorType​(@NotNull
                                                                @NotNull java.lang.String serverError)