Improves handling of MessageIntegrity, Fingerprint, and Software attributes

This commit is contained in:
emcho 2010-04-25 14:44:53 +00:00
parent 87326fb70c
commit 2a13730d4e

View File

@ -12,6 +12,8 @@ import org.ice4j.*;
import org.ice4j.attribute.*; import org.ice4j.attribute.*;
import org.ice4j.stack.*; import org.ice4j.stack.*;
import sun.tools.tree.*;
/** /**
* This class represents a STUN message. STUN messages are TLV (type-length-value) * This class represents a STUN message. STUN messages are TLV (type-length-value)
* encoded using big endian (network ordered) binary. All STUN messages start * encoded using big endian (network ordered) binary. All STUN messages start
@ -568,7 +570,7 @@ public abstract class Message
{ {
//remove MESSAGE-INTEGRITY and FINGERPRINT attributes so that we can //remove MESSAGE-INTEGRITY and FINGERPRINT attributes so that we can
//make sure they are added at the end. //make sure they are added at the end.
Attribute msgIntegrity = removeAttribute(Attribute.MESSAGE_INTEGRITY); Attribute msgIntAttr = removeAttribute(Attribute.MESSAGE_INTEGRITY);
Attribute fingerprint = removeAttribute(Attribute.FINGERPRINT); Attribute fingerprint = removeAttribute(Attribute.FINGERPRINT);
//add a SOFTWARE attribute if the user said so, and unless they did it //add a SOFTWARE attribute if the user said so, and unless they did it
@ -582,7 +584,24 @@ public abstract class Message
.createSoftwareAttribute(software.getBytes())); .createSoftwareAttribute(software.getBytes()));
} }
//re-add MESSAGE-INTEGRITY if there was one.
if (msgIntAttr != null)
{
addAttribute(msgIntAttr);
}
//add FINGERPRINT if there was one or if user told us to add it
//everywhere.
if (fingerprint == null
&& Boolean.getBoolean(StackProperties.ALWAYS_SIGN));
{
fingerprint = AttributeFactory.createFingerprintAttribute();
}
if (fingerprint != null)
{
addAttribute(fingerprint);
}
} }