From b4579547da5697b5c75880a33dc3884432659189 Mon Sep 17 00:00:00 2001 From: "lubomir.marinov" Date: Tue, 29 Jun 2010 09:53:08 +0000 Subject: [PATCH] Mostly, applies formatting. Fixes an instance of using String#getBytes without an encoding which is discouraged (and hasn't come up as a problem during testing yet). --- src/org/ice4j/attribute/AttributeFactory.java | 19 ++++++++++++++----- .../attribute/MessageIntegrityAttribute.java | 5 ++--- src/org/ice4j/ice/Candidate.java | 8 ++++---- src/org/ice4j/ice/CandidatePair.java | 4 ++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/org/ice4j/attribute/AttributeFactory.java b/src/org/ice4j/attribute/AttributeFactory.java index 39b145f..11a605d 100644 --- a/src/org/ice4j/attribute/AttributeFactory.java +++ b/src/org/ice4j/attribute/AttributeFactory.java @@ -6,6 +6,9 @@ */ package org.ice4j.attribute; +import java.io.*; +import java.lang.reflect.*; + import org.ice4j.*; /** @@ -315,17 +318,23 @@ public class AttributeFactory } /** - * Create a UsernameAttribute. + * Creates a new UsernameAttribute instance. * * @param username the String value of the username - * - * @return newly created UsernameAttribute + * @return a new UsernameAttribute instance */ public static UsernameAttribute createUsernameAttribute(String username) { UsernameAttribute attribute = new UsernameAttribute(); - attribute.setUsername(username.getBytes()); + try + { + attribute.setUsername(username.getBytes("UTF-8")); + } + catch (UnsupportedEncodingException ueex) + { + throw new UndeclaredThrowableException(ueex); + } return attribute; } @@ -345,8 +354,8 @@ public class AttributeFactory String username) { MessageIntegrityAttribute attribute = new MessageIntegrityAttribute(); - attribute.setUsername(username); + attribute.setUsername(username); return attribute; }; diff --git a/src/org/ice4j/attribute/MessageIntegrityAttribute.java b/src/org/ice4j/attribute/MessageIntegrityAttribute.java index 76e2823..3a2743b 100644 --- a/src/org/ice4j/attribute/MessageIntegrityAttribute.java +++ b/src/org/ice4j/attribute/MessageIntegrityAttribute.java @@ -162,14 +162,15 @@ public class MessageIntegrityAttribute throws IllegalArgumentException { byte[] hmac; + try { // get an HMAC-SHA1 key from the raw key bytes SecretKeySpec signingKey = new SecretKeySpec(key, HMAC_SHA1_ALGORITHM); - // get an HMAC-SHA1 Mac instance and initialize it with the key Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM); + mac.init(signingKey); // compute the hmac on input data bytes @@ -179,7 +180,6 @@ public class MessageIntegrityAttribute //so we'd need to create an array that only contains what we //actually need to work with. System.arraycopy(message, offset, macInput, 0, length); - hmac = mac.doFinal(macInput); } catch (Exception exc) @@ -187,7 +187,6 @@ public class MessageIntegrityAttribute throw new IllegalArgumentException( "Could not create HMAC-SHA1 request encoding: ", exc); } - return hmac; } diff --git a/src/org/ice4j/ice/Candidate.java b/src/org/ice4j/ice/Candidate.java index 3dd29a7..674d3cd 100644 --- a/src/org/ice4j/ice/Candidate.java +++ b/src/org/ice4j/ice/Candidate.java @@ -74,7 +74,7 @@ public abstract class Candidate * however (that is when running a more recent JVM) we will reflect it in * this property. */ - private boolean isVirtual = false; + private boolean virtual = false; /** * The component that this candidate was created for. Every candidate is @@ -461,7 +461,7 @@ public abstract class Candidate */ public boolean isVirtual() { - return isVirtual; + return virtual; } /** @@ -478,9 +478,9 @@ public abstract class Candidate * address associated with this Candidate comes from a virtual * interface and false if otherwise. */ - public void setVirtual(boolean isVirtual) + public void setVirtual(boolean virtual) { - this.isVirtual = isVirtual; + this.virtual = virtual; } /** diff --git a/src/org/ice4j/ice/CandidatePair.java b/src/org/ice4j/ice/CandidatePair.java index fd3d77a..9e0ea33 100644 --- a/src/org/ice4j/ice/CandidatePair.java +++ b/src/org/ice4j/ice/CandidatePair.java @@ -135,7 +135,7 @@ public class CandidatePair */ protected void setLocalCandidate( LocalCandidate localCnd) { - this.localCandidate = localCnd;; + this.localCandidate = localCnd; } /** @@ -156,7 +156,7 @@ public class CandidatePair */ protected void setRemoteCandidate( Candidate remoteCnd) { - this.remoteCandidate = remoteCnd;; + this.remoteCandidate = remoteCnd; } /**