From 2a13730d4e7c07e5391198f5aebc9d2aabade5c8 Mon Sep 17 00:00:00 2001 From: emcho Date: Sun, 25 Apr 2010 14:44:53 +0000 Subject: [PATCH] Improves handling of MessageIntegrity, Fingerprint, and Software attributes --- src/org/ice4j/message/Message.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/org/ice4j/message/Message.java b/src/org/ice4j/message/Message.java index 79c30ef..5823db7 100644 --- a/src/org/ice4j/message/Message.java +++ b/src/org/ice4j/message/Message.java @@ -12,6 +12,8 @@ import org.ice4j.*; import org.ice4j.attribute.*; import org.ice4j.stack.*; +import sun.tools.tree.*; + /** * This class represents a STUN message. STUN messages are TLV (type-length-value) * 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 //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); //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())); } + //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); + } }