Fixes use of local credentials authority (now that was some tricky stuff to find).

This commit is contained in:
emcho 2010-04-27 23:32:34 +00:00
parent 75231a7e3e
commit 21cd44045f
5 changed files with 19 additions and 17 deletions

View File

@ -255,7 +255,7 @@ public class MessageIntegrityAttribute
binValue[3] = (byte)(getDataLength()&0x00FF);
byte[] key = StunStack.getInstance().getCredentialsManager()
.getLocalKey(username);
.getRemoteKey(username);
//now calculate the HMAC-SHA1
this.hmacSha1Content = calculateHmacSha1(content, offset, length, key);

View File

@ -406,17 +406,18 @@ public class Agent
}
/**
* Returns the user name that we should tell a peer <tt>Agent</tt> to use
* in connectivity checks for outgoing Binding Requests. According to RFC
* 5245, a Binding Request serving as a connectivity check MUST utilize the
* STUN short term credential mechanism. The username for the credential is
* formed by concatenating the username fragment provided by the peer with
* the username fragment of the agent sending the request, separated by a
* colon (":"). The password is equal to the password provided by the peer.
* For example, consider the case where agent L is the offerer, and agent R
* is the answerer. Agent L included a username fragment of LFRAG for its
* candidates, and a password of LPASS. Agent R provided a username
* fragment of RFRAG and a password of RPASS. A connectivity check from L
* Returns the user name that we should expect a peer <tt>Agent</tt> to use
* in connectivity checks for Binding Requests its sending our way.
* According to RFC 5245, a Binding Request serving as a connectivity check
* MUST utilize the STUN short term credential mechanism. The username for
* the credential is formed by concatenating the username fragment provided
* by the peer with the username fragment of the agent sending the request,
* separated by a colon (":"). The password is equal to the password
* provided by the peer. For example, consider the case where agent
* L is the offerer, and agent R is the answerer. Agent L
* included a username fragment of LFRAG for its candidates,
* and a password of LPASS. Agent R provided a username fragment
* of RFRAG and a password of RPASS. A connectivity check from L
* to R (and its response of course) utilize the username RFRAG:LFRAG and a
* password of RPASS. A connectivity check from R to L (and its response)
* utilize the username LFRAG:RFRAG and a password of LPASS.

View File

@ -89,8 +89,9 @@ public class ConnectivityCheckClient
}
//credentials
String localUserName = parentAgent.generateLocalUserName();
UsernameAttribute unameAttr = AttributeFactory.createUsernameAttribute(
parentAgent.generateLocalUserName());
localUserName);
request.addAttribute(unameAttr);
@ -99,8 +100,7 @@ public class ConnectivityCheckClient
//for example.
//todo: also implement SASL prepare
MessageIntegrityAttribute msgIntegrity = AttributeFactory
.createMessageIntegrityAttribute(parentAgent
.generateRemoteUserName());
.createMessageIntegrityAttribute(localUserName);
request.addAttribute(msgIntegrity);

View File

@ -136,7 +136,7 @@ public class ConnectivityCheckServer
else
{
//caller gave us the entire username.
if (username.equals(parentAgent.generateRemoteUserName()))
if(username.substring(0, colon).equals(parentAgent.getLocalUfrag()))
return parentAgent.getLocalPassword().getBytes();
}

View File

@ -384,7 +384,8 @@ public class StunCandidateHarvester
Level.INFO,
"Failed to send "
+ request
+ " through " + hostCand.getTransportAddress(),
+ " through " + hostCand.getTransportAddress()
+ " to " + stunServer,
exception);
return;
}