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,7 +382,10 @@ class ConnectivityCheckServer
|
|||||||
{
|
{
|
||||||
//caller gave us the entire username.
|
//caller gave us the entire username.
|
||||||
if (username.equals(parentAgent.generateLocalUserName()))
|
if (username.equals(parentAgent.generateLocalUserName()))
|
||||||
return parentAgent.getRemotePassword().getBytes();
|
{
|
||||||
|
if(parentAgent.getRemotePassword() != null)
|
||||||
|
return parentAgent.getRemotePassword().getBytes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -872,7 +872,7 @@ public class StunStack
|
|||||||
* supposed to have been built for.
|
* supposed to have been built for.
|
||||||
* @param shortTermCredentialMechanism <tt>true</tt> if <tt>msgInt</tt> is
|
* @param shortTermCredentialMechanism <tt>true</tt> if <tt>msgInt</tt> is
|
||||||
* to be validated as part of the STUN short-term credential mechanism or
|
* to be validated as part of the STUN short-term credential mechanism or
|
||||||
* <tt>false</tt> for the STUN long-term credential mechanism
|
* <tt>false</tt> for the STUN long-term credential mechanism
|
||||||
* @param message the message whose SHA1 checksum we'd need to recalculate.
|
* @param message the message whose SHA1 checksum we'd need to recalculate.
|
||||||
*
|
*
|
||||||
* @return <tt>true</tt> if <tt>msgInt</tt> contains a valid SHA1 value and
|
* @return <tt>true</tt> if <tt>msgInt</tt> contains a valid SHA1 value and
|
||||||
@ -972,7 +972,7 @@ public class StunStack
|
|||||||
/**
|
/**
|
||||||
* Returns a <tt>String</tt> representation of a specific <tt>byte</tt>
|
* Returns a <tt>String</tt> representation of a specific <tt>byte</tt>
|
||||||
* array as an unsigned integer in base 16.
|
* array as an unsigned integer in base 16.
|
||||||
*
|
*
|
||||||
* @param bytes the <tt>byte</tt> to get the <tt>String</tt> representation
|
* @param bytes the <tt>byte</tt> to get the <tt>String</tt> representation
|
||||||
* of as an unsigned integer in base 16
|
* of as an unsigned integer in base 16
|
||||||
* @return a <tt>String</tt> representation of the specified <tt>byte</tt>
|
* @return a <tt>String</tt> representation of the specified <tt>byte</tt>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user