-
- 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.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringNAMEpublic final static charTRY_ALTERNATEpublic final static charBAD_REQUESTpublic final static charUNAUTHORIZEDpublic final static charFORBIDDENpublic final static charUNKNOWN_ATTRIBUTEpublic final static charSTALE_CREDENTIALSpublic final static charINTEGRITY_CHECK_FAILUREpublic final static charMISSING_USERNAMEpublic final static charUSE_TLSpublic final static charALLOCATION_MISMATCHpublic final static charSTALE_NONCEpublic final static charADDRESS_FAMILY_NOT_SUPPORTEDpublic final static charWRONG_CREDENTIALSpublic final static charUNSUPPORTED_TRANSPORT_PROTOCOLpublic final static charPEER_ADDRESS_FAMILY_MISMATCHpublic final static charCONNECTION_ALREADY_EXISTSpublic final static charCONNECTION_TIMEOUT_OR_FAILUREpublic final static charALLOCATION_QUOTA_REACHEDpublic final static charROLE_CONFLICTpublic final static charSERVER_ERRORpublic final static charINSUFFICIENT_CAPACITYpublic final static charGLOBAL_FAILUREprivate byteerrorClassprivate byteerrorNumberprivate Array<byte>reasonPhrase
-
Method Summary
Modifier and Type Method Description bytegetErrorClass()Returns this error's error class. voidsetErrorClass(byte errorClass)Sets this error's error class. bytegetErrorNumber()Returns this attribute's error number. voidsetErrorNumber(byte errorNumber)Sets this attribute's error number. voidsetReasonPhrase(String reasonPhrase)Set's a reason phrase. voidsetErrorCode(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. chargetErrorCode()A convenience method that constructs an error code from this Attribute's class and number. static StringgetDefaultReasonPhrase(char errorCode)Returns a default reason phrase corresponding to the specified error code, as described by rfc 3489. StringgetName()Returns the human readable name of this attribute. chargetDataLength()Returns the length of this attribute's body. Array<byte>encode()Returns a binary representation of this attribute. booleanequals(Object obj)Compares two STUN Attributes. -
-
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.
-
-
-
-