Package 

Class FingerprintAttribute

  • All Implemented Interfaces:
    org.ice4j.attribute.ContentDependentAttribute

    
    public class FingerprintAttribute
    extends Attribute implements ContentDependentAttribute
                        

    The FINGERPRINT attribute is used to distinguish STUN packets from packets of other protocols. It MAY be present in all STUN messages. The value of the attribute is computed as the CRC-32 of the STUN message up to (but excluding) the FINGERPRINT attribute itself, XOR'ed with the 32-bit value 0x5354554e (the XOR helps in cases where an application packet is also using CRC-32 in it). The 32-bit CRC is the one defined in ITU V.42 [ITU.V42.2002], which has a generator polynomial of x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1. When present, the FINGERPRINT attribute MUST be the last attribute in the message, and thus will appear after MESSAGE-INTEGRITY.

    The FINGERPRINT attribute can aid in distinguishing STUN packets from packets of other protocols. See Section 8.

    As with MESSAGE-INTEGRITY, the CRC used in the FINGERPRINT attribute covers the length field from the STUN message header. Therefore, this value must be correct and include the CRC attribute as part of the message length, prior to computation of the CRC. When using the FINGERPRINT attribute in a message, the attribute is first placed into the message with a dummy value, then the CRC is computed, and then the value of the attribute is updated. If the MESSAGE-INTEGRITY attribute is also present, then it must be present with the correct message-integrity value before the CRC is computed, since the CRC is done over the value of the MESSAGE-INTEGRITY attribute as well.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static String NAME
      public final static Array<byte> XOR_MASK
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Array<byte> getChecksum() Returns the CRC32 checksum that this attribute is carrying.
      char getDataLength() Returns the length of this attribute's body.
      String getName() Returns the human readable name of this attribute.
      boolean equals(Object obj) Compares two STUN Attributes.
      Array<byte> encode() Returns a binary representation of this attribute.
      Array<byte> encode(StunStack stunStack, Array<byte> content, int offset, int length) Returns a binary representation of this attribute.
      void decodeAttributeBody(Array<byte> attributeValue, char offset, char length) Sets this attribute's fields according to the message and attributeValue arrays.
      static Array<byte> calculateXorCRC32(Array<byte> message, int offset, int len) Calculates and returns the CRC32 checksum for message after applying the XOR_MASK specified by RFC 5389.
      • Methods inherited from class org.ice4j.attribute.Attribute

        getAttributeType, getLocationInMessage, setLocationInMessage
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getChecksum

         Array<byte> getChecksum()

        Returns the CRC32 checksum that this attribute is carrying. Only makes sense for incoming messages and hence only set for them.

      • getDataLength

         char getDataLength()

        Returns the length of this attribute's body.

      • getName

         String getName()

        Returns the human readable name of this attribute.

      • equals

         boolean equals(Object obj)

        Compares two STUN Attributes. Two attributes are considered equal when they have the same type length and value.

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

         Array<byte> encode()

        Returns a binary representation of this attribute.

      • encode

         Array<byte> encode(StunStack stunStack, Array<byte> content, int offset, int length)

        Returns a binary representation of this attribute.

        Parameters:
        stunStack - the StunStack in the context of which the request to encode this ContentDependentAttribute is being made
        content - the content of the message that this attribute will be transported in
        offset - the content-related offset where the actual content starts.
        length - the length of the content in the content array.
      • decodeAttributeBody

         void decodeAttributeBody(Array<byte> attributeValue, char offset, char length)

        Sets this attribute's fields according to the message and attributeValue arrays.

        Parameters:
        attributeValue - a binary array containing this attribute's field values and NOT containing the attribute header.
        offset - the position where attribute values begin (most often offset is equal to the index of the first byte after length)
        length - the length of the binary array.
      • calculateXorCRC32

         static Array<byte> calculateXorCRC32(Array<byte> message, int offset, int len)

        Calculates and returns the CRC32 checksum for message after applying the XOR_MASK specified by RFC 5389.

        Parameters:
        message - the message whose checksum we'd like to have
        offset - the location in message where the actual message starts.
        len - the number of message bytes in message