Class ServerFirstMessage

  • All Implemented Interfaces:
    StringWritable

    public class ServerFirstMessage
    extends java.lang.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
      private java.lang.String clientNonce  
      private int iteration  
      static int ITERATION_MIN_VALUE
      Minimum allowed value for the iteration, as per the RFC.
      private java.lang.String salt  
      private java.lang.String serverNonce  
    • Constructor Summary

      Constructors 
      Constructor Description
      ServerFirstMessage​(java.lang.String clientNonce, java.lang.String serverNonce, java.lang.String salt, int iteration)
      Constructs a server-first-message from a client-first-message and the additional required data.
    • 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
      • clientNonce

        private final java.lang.String clientNonce
      • serverNonce

        private final java.lang.String serverNonce
      • salt

        private final java.lang.String salt
      • iteration

        private final int iteration
    • Constructor Detail

      • ServerFirstMessage

        public ServerFirstMessage​(java.lang.String clientNonce,
                                  java.lang.String serverNonce,
                                  java.lang.String salt,
                                  int iteration)
                           throws java.lang.IllegalArgumentException
        Constructs a server-first-message from a client-first-message and the additional required data.
        Parameters:
        clientNonce - String representing the client-first-message
        serverNonce - Server serverNonce
        salt - The salt
        iteration - The iteration count (must be <= 4096)
        Throws:
        java.lang.IllegalArgumentException - If clientFirstMessage, serverNonce or salt are null or empty, or iteration < 4096
    • Method Detail

      • getClientNonce

        public java.lang.String getClientNonce()
      • getServerNonce

        public java.lang.String getServerNonce()
      • getNonce

        public java.lang.String getNonce()
      • getSalt

        public java.lang.String getSalt()
      • getIteration

        public int getIteration()
      • writeTo

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

        public static ServerFirstMessage parseFrom​(java.lang.String serverFirstMessage,
                                                   java.lang.String clientNonce)
                                            throws ScramParseException,
                                                   java.lang.IllegalArgumentException
        Parses a server-first-message from a String.
        Parameters:
        serverFirstMessage - The string representing the server-first-message
        clientNonce - 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-message
        java.lang.IllegalArgumentException - If either argument is empty or serverFirstMessage is not a valid message
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object