Package 

Class ErrorCodeAttribute

  • All Implemented Interfaces:

    
    public class ErrorCodeAttribute
    extends Attribute
                        

    The ERROR-CODE attribute is present in the Binding Error Response and Shared Secret Error Response. It is a numeric value in the range of 100 to 699 plus a textual reason phrase encoded in UTF-8, and is consistent in its code assignments and semantics with SIP [10] and HTTP [15]. The reason phrase is meant for user consumption, and can be anything appropriate for the response code. The lengths of the reason phrases MUST be a multiple of 4 (measured in bytes). This can be accomplished by added spaces to the end of the text, if necessary. Recommended reason phrases for the defined response codes are presented below. To facilitate processing, the class of the error code (the hundreds digit) is encoded separately from the rest of the code. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0 |Class| Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Reason Phrase (variable) .. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The class represents the hundreds digit of the response code. The value MUST be between 1 and 6. The number represents the response code modulo 100, and its value MUST be between 0 and 99. The following response codes, along with their recommended reason phrases (in brackets) are defined at this time: 400 (Bad Request): The request was malformed. The client should not retry the request without modification from the previous attempt. 401 (Unauthorized): The Binding Request did not contain a MESSAGE- INTEGRITY attribute. 420 (Unknown Attribute): The server did not understand a mandatory attribute in the request. 430 (Stale Credentials): The Binding Request did contain a MESSAGE- INTEGRITY attribute, but it used a shared secret that has expired. The client should obtain a new shared secret and try again. 431 (Integrity Check Failure): The Binding Request contained a MESSAGE-INTEGRITY attribute, but the HMAC failed verification. This could be a sign of a potential attack, or client implementation error. 432 (Missing Username): The Binding Request contained a MESSAGE- INTEGRITY attribute, but not a USERNAME attribute. Both must be present for integrity checks. 433 (Use TLS): The Shared Secret request has to be sent over TLS, but was not received over TLS. 500 (Server Error): The server has suffered a temporary error. The client should try again. 600 (Global Failure:) The server is refusing to fulfill the request. The client should not retry.

    • Constructor Detail

    • Method Detail

      • getErrorClass

         byte getErrorClass()

        Returns this error's error class.

      • setErrorClass

         void setErrorClass(byte errorClass)

        Sets this error's error class.

        Parameters:
        errorClass - this error's error class.
      • getErrorNumber

         byte getErrorNumber()

        Returns this attribute's error number.

      • setErrorNumber

         void setErrorNumber(byte errorNumber)

        Sets this attribute's error number.

        Parameters:
        errorNumber - the error number to assign this attribute.
      • setReasonPhrase

         void setReasonPhrase(String reasonPhrase)

        Set's a reason phrase. The reason phrase is meant for user consumption, and can be anything appropriate for the response code. The lengths of the reason phrases MUST be a multiple of 4 (measured in bytes).

        Parameters:
        reasonPhrase - a reason phrase that describes this error.
      • setErrorCode

         void setErrorCode(char errorCode)

        A convenience method that sets error class and number according to the specified errorCode.The class represents the hundreds digit of the error code. The value MUST be between 1 and 6. The number represents the response code modulo 100, and its value MUST be between 0 and 99.

        Parameters:
        errorCode - the errorCode that this class encapsulates.
      • getErrorCode

         char getErrorCode()

        A convenience method that constructs an error code from this Attribute's class and number.

      • getDefaultReasonPhrase

         static String getDefaultReasonPhrase(char errorCode)

        Returns a default reason phrase corresponding to the specified error code, as described by rfc 3489.

        Parameters:
        errorCode - the code of the error that the reason phrase must describe.
      • getName

         String getName()

        Returns the human readable name of this attribute. Attribute names do not really matter from the protocol point of view. They are only used for debugging and readability.

      • getDataLength

         char getDataLength()

        Returns the length of this attribute's body.

      • encode

         Array<byte> encode()

        Returns a binary representation of this attribute.

      • equals

         boolean equals(Object obj)

        Compares two STUN Attributes. Attributes are considered equal when their type, length, and all data are the same.

        Parameters:
        obj - the object to compare this attribute with.