Initialize the Binding Response's MESSAGE-INTEGRITY attribute with the same username as the request. Now ice4j should correctly work with Empathy.
This commit is contained in:
parent
a16b8afe12
commit
fc3e411657
@ -11,6 +11,7 @@ import java.util.*;
|
|||||||
import javax.crypto.*;
|
import javax.crypto.*;
|
||||||
import javax.crypto.spec.*;
|
import javax.crypto.spec.*;
|
||||||
|
|
||||||
|
import org.ice4j.message.*;
|
||||||
import org.ice4j.stack.*;
|
import org.ice4j.stack.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -254,7 +255,20 @@ public class MessageIntegrityAttribute
|
|||||||
binValue[2] = (byte)(getDataLength()>>8);
|
binValue[2] = (byte)(getDataLength()>>8);
|
||||||
binValue[3] = (byte)(getDataLength()&0x00FF);
|
binValue[3] = (byte)(getDataLength()&0x00FF);
|
||||||
|
|
||||||
byte[] key = stunStack.getCredentialsManager().getRemoteKey(username);
|
byte[] key = null;
|
||||||
|
char msgType = (char)((content[0] << 8) + content[1]);
|
||||||
|
|
||||||
|
if(Message.isRequestType(msgType))
|
||||||
|
{
|
||||||
|
/* attribute part of a request, use the remote key */
|
||||||
|
key = stunStack.getCredentialsManager().getRemoteKey(username);
|
||||||
|
}
|
||||||
|
else if(Message.isSuccessResponseType(msgType) ||
|
||||||
|
Message.isErrorResponseType(msgType))
|
||||||
|
{
|
||||||
|
/* attribute part of a response, use the local key */
|
||||||
|
key = stunStack.getCredentialsManager().getLocalKey(username);
|
||||||
|
}
|
||||||
|
|
||||||
//now calculate the HMAC-SHA1
|
//now calculate the HMAC-SHA1
|
||||||
this.hmacSha1Content = calculateHmacSha1(content, offset, length, key);
|
this.hmacSha1Content = calculateHmacSha1(content, offset, length, key);
|
||||||
|
|||||||
@ -128,9 +128,12 @@ class ConnectivityCheckServer
|
|||||||
Attribute usernameAttribute = AttributeFactory.createUsernameAttribute(
|
Attribute usernameAttribute = AttributeFactory.createUsernameAttribute(
|
||||||
parentAgent.generateLocalUserName());
|
parentAgent.generateLocalUserName());
|
||||||
|
|
||||||
|
/* The responses utilize the same usernames and passwords as the
|
||||||
|
* requests
|
||||||
|
*/
|
||||||
Attribute messageIntegrityAttribute =
|
Attribute messageIntegrityAttribute =
|
||||||
AttributeFactory.createMessageIntegrityAttribute(
|
AttributeFactory.createMessageIntegrityAttribute(
|
||||||
parentAgent.generateLocalUserName());
|
new String(uname.getUsername()));
|
||||||
|
|
||||||
response.addAttribute(usernameAttribute);
|
response.addAttribute(usernameAttribute);
|
||||||
response.addAttribute(messageIntegrityAttribute);
|
response.addAttribute(messageIntegrityAttribute);
|
||||||
@ -334,8 +337,8 @@ class ConnectivityCheckServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the {@link CredentialsAuthority#getLocalKey(String)} method in a
|
* Implements the {@link CredentialsAuthority#getLocalKey(String)} method in
|
||||||
* way that would return this handler's parent agent password if
|
* a way that would return this handler's parent agent password if
|
||||||
* <tt>username</tt> is either the local ufrag or the username that the
|
* <tt>username</tt> is either the local ufrag or the username that the
|
||||||
* agent's remote peer was expected to use.
|
* agent's remote peer was expected to use.
|
||||||
*
|
*
|
||||||
@ -379,8 +382,11 @@ class ConnectivityCheckServer
|
|||||||
{
|
{
|
||||||
//caller gave us the entire username.
|
//caller gave us the entire username.
|
||||||
if (username.equals(parentAgent.generateLocalUserName()))
|
if (username.equals(parentAgent.generateLocalUserName()))
|
||||||
|
{
|
||||||
|
if(parentAgent.getRemotePassword() != null)
|
||||||
return parentAgent.getRemotePassword().getBytes();
|
return parentAgent.getRemotePassword().getBytes();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user