Adds password support for google relayed candidate.
This commit is contained in:
parent
f2529200be
commit
dfcde11376
@ -808,21 +808,7 @@ public class Agent
|
||||
public String generateLocalUserName(RemoteCandidate remoteCandidate,
|
||||
LocalCandidate localCandidate)
|
||||
{
|
||||
String ret = null;
|
||||
String remoteUfrag = remoteCandidate.getUfrag();
|
||||
String localUfrag = localCandidate.getUfrag();
|
||||
|
||||
/* Google Talk specific
|
||||
* each candidate has its own username/password
|
||||
*/
|
||||
if(localUfrag == null || remoteUfrag == null ||
|
||||
compatibilityMode != CompatibilityMode.GTALK)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ret = remoteUfrag + localUfrag;
|
||||
return ret;
|
||||
return generateUserName(remoteCandidate, localCandidate);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -837,22 +823,38 @@ public class Agent
|
||||
*/
|
||||
public String generateRemoteUserName(RemoteCandidate remoteCandidate,
|
||||
LocalCandidate localCandidate)
|
||||
{
|
||||
return generateUserName(localCandidate, remoteCandidate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 in a
|
||||
* Google Talk session.
|
||||
*
|
||||
* @param candidate1 The first candidate of a candidatePair.
|
||||
* @param candidate2 The second candidate of a candidatePair.
|
||||
* @return a user name that a peer <tt>Agent</tt> would use in connectivity
|
||||
* check for outgoing Binding Requests.
|
||||
*/
|
||||
private String generateUserName(
|
||||
Candidate candidate1,
|
||||
Candidate candidate2)
|
||||
{
|
||||
String ret = null;
|
||||
String remoteUfrag = remoteCandidate.getUfrag();
|
||||
String localUfrag = localCandidate.getUfrag();
|
||||
String ufrag1 = candidate1.getUfrag();
|
||||
String ufrag2 = candidate2.getUfrag();
|
||||
|
||||
/* Google Talk specific
|
||||
* each candidate has its own username/password
|
||||
*/
|
||||
if(remoteUfrag == null || localUfrag == null ||
|
||||
compatibilityMode != CompatibilityMode.GTALK)
|
||||
if(ufrag1 != null
|
||||
&& ufrag2 != null
|
||||
&& compatibilityMode == CompatibilityMode.GTALK)
|
||||
{
|
||||
return null;
|
||||
ret = ufrag1 + ufrag2;
|
||||
}
|
||||
|
||||
ret = localUfrag + remoteUfrag;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1258,15 +1260,13 @@ public class Agent
|
||||
String localUFrag,
|
||||
boolean useCandidate)
|
||||
{
|
||||
String ufrag = null;
|
||||
LocalCandidate localCandidate = null;
|
||||
|
||||
if(compatibilityMode == CompatibilityMode.GTALK)
|
||||
if(compatibilityMode == CompatibilityMode.GTALK
|
||||
&& localAddress.getTransport() != Transport.TCP)
|
||||
{
|
||||
if(localAddress.getTransport() == Transport.TCP)
|
||||
localCandidate = findLocalCandidate(localAddress);
|
||||
else
|
||||
localCandidate = findLocalCandidate(localAddress,
|
||||
remoteUFrag);
|
||||
localCandidate = findLocalCandidate(localAddress, remoteUFrag);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1306,23 +1306,15 @@ public class Agent
|
||||
useCandidate = pair2.useCandidateReceived();
|
||||
}
|
||||
|
||||
remoteCandidate = new RemoteCandidate(
|
||||
remoteAddress, parentComponent,
|
||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||
foundationsRegistry.
|
||||
obtainFoundationForPeerReflexiveCandidate(),
|
||||
priority,
|
||||
((RemoteCandidate)pair.getRemoteCandidate()).getUfrag());
|
||||
}
|
||||
else
|
||||
{
|
||||
remoteCandidate = new RemoteCandidate(
|
||||
remoteAddress, parentComponent,
|
||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||
foundationsRegistry.
|
||||
obtainFoundationForPeerReflexiveCandidate(),
|
||||
priority);
|
||||
ufrag = ((RemoteCandidate)pair.getRemoteCandidate()).getUfrag();
|
||||
}
|
||||
remoteCandidate = new RemoteCandidate(
|
||||
remoteAddress,
|
||||
parentComponent,
|
||||
CandidateType.PEER_REFLEXIVE_CANDIDATE,
|
||||
foundationsRegistry.obtainFoundationForPeerReflexiveCandidate(),
|
||||
priority,
|
||||
ufrag);
|
||||
|
||||
CandidatePair triggeredPair
|
||||
= new CandidatePair(localCandidate, remoteCandidate);
|
||||
|
||||
@ -766,4 +766,11 @@ public abstract class Candidate
|
||||
* Component yet.
|
||||
*/
|
||||
public abstract boolean isDefault();
|
||||
|
||||
/**
|
||||
* Get the local ufrag.
|
||||
*
|
||||
* @return local ufrag
|
||||
*/
|
||||
public abstract String getUfrag();
|
||||
}
|
||||
|
||||
@ -378,24 +378,7 @@ class ConnectivityCheckClient
|
||||
|
||||
//If all of the pairs in the check list are now either in the Failed or
|
||||
//Succeeded state:
|
||||
boolean allPairsDone = true;
|
||||
|
||||
synchronized(checkList)
|
||||
{
|
||||
for(CandidatePair pair : checkList)
|
||||
{
|
||||
CandidatePairState pairState = pair.getState();
|
||||
|
||||
if((pairState != CandidatePairState.FAILED)
|
||||
&& (pairState != CandidatePairState.SUCCEEDED))
|
||||
{
|
||||
allPairsDone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allPairsDone)
|
||||
if(checkList.allChecksCompleted())
|
||||
{
|
||||
//If there is not a pair in the valid list for each component of the
|
||||
//media stream, the state of the check list is set to Failed.
|
||||
|
||||
@ -55,6 +55,11 @@ public class GoogleRelayedCandidate
|
||||
*/
|
||||
private final String username;
|
||||
|
||||
/**
|
||||
* Password.
|
||||
*/
|
||||
private final String password;
|
||||
|
||||
/**
|
||||
* Initializes a new <tt>RelayedCandidate</tt> which is to represent a
|
||||
* specific <tt>TransportAddress</tt> harvested through a specific
|
||||
@ -69,13 +74,16 @@ public class GoogleRelayedCandidate
|
||||
* TURN server with the delivery of the replayed <tt>transportAddress</tt>
|
||||
* to be represented by the new instance
|
||||
* @param username username (Send request to the Google relay server need
|
||||
* it
|
||||
* it)
|
||||
* @param password password (used with XMPP gingle candidates).
|
||||
* it)
|
||||
*/
|
||||
public GoogleRelayedCandidate(
|
||||
TransportAddress transportAddress,
|
||||
GoogleTurnCandidateHarvest turnCandidateHarvest,
|
||||
TransportAddress mappedAddress,
|
||||
String username)
|
||||
String username,
|
||||
String password)
|
||||
{
|
||||
super(
|
||||
transportAddress,
|
||||
@ -91,6 +99,7 @@ public class GoogleRelayedCandidate
|
||||
|
||||
this.turnCandidateHarvest = turnCandidateHarvest;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
|
||||
// RFC 5245: The base of a relayed candidate is that candidate itself.
|
||||
setBase(this);
|
||||
@ -197,4 +206,13 @@ public class GoogleRelayedCandidate
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password for this candidate.
|
||||
* @return the password for this candidate.
|
||||
*/
|
||||
public String getPassword()
|
||||
{
|
||||
return this.password;
|
||||
}
|
||||
}
|
||||
|
||||
@ -891,31 +891,6 @@ public class IceMediaStream
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link CandidatePair} from <tt>component</tt> that's
|
||||
* currently first in our valid list and that is therefore with the highest
|
||||
* priority.
|
||||
*
|
||||
* @param component the {@link Component} whose highest priority valid
|
||||
* {@link CandidatePair} we are looking for.
|
||||
*
|
||||
* @return the {@link CandidatePair} with the highest priority in our
|
||||
* valid list or <tt>null</tt> if our valid list is still empty.
|
||||
*/
|
||||
public CandidatePair getFirstValidPair(Component component)
|
||||
{
|
||||
synchronized(validList)
|
||||
{
|
||||
for(CandidatePair pair : validList)
|
||||
{
|
||||
if (pair.getParentComponent() == component)
|
||||
return pair;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the user name that we received from the remote peer.
|
||||
*
|
||||
|
||||
@ -49,9 +49,12 @@ public class RemoteCandidate
|
||||
String foundation,
|
||||
long priority)
|
||||
{
|
||||
super(transportAddress, parentComponent, type);
|
||||
setFoundation(foundation);
|
||||
setPriority(priority);
|
||||
this(transportAddress,
|
||||
parentComponent,
|
||||
type,
|
||||
foundation,
|
||||
priority,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,7 +79,9 @@ public class RemoteCandidate
|
||||
long priority,
|
||||
String ufrag)
|
||||
{
|
||||
this(transportAddress, parentComponent, type, foundation, priority);
|
||||
super(transportAddress, parentComponent, type);
|
||||
setFoundation(foundation);
|
||||
setPriority(priority);
|
||||
this.ufrag = ufrag;
|
||||
}
|
||||
|
||||
|
||||
@ -40,6 +40,11 @@ public class GoogleTurnCandidateHarvest
|
||||
*/
|
||||
private Request requestToStartResolvingCandidate;
|
||||
|
||||
/**
|
||||
* The gingle candidates password necessary to use the TURN server.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Initializes a new <tt>TurnCandidateHarvest</tt> which is to represent the
|
||||
* harvesting of TURN <tt>Candidate</tt>s for a specific
|
||||
@ -50,12 +55,16 @@ public class GoogleTurnCandidateHarvest
|
||||
* the TURN harvesting
|
||||
* @param hostCandidate the <tt>HostCandidate</tt> for which TURN
|
||||
* <tt>Candidate</tt>s are to be harvested
|
||||
* @param password The gingle candidates password necessary to use this TURN
|
||||
* server.
|
||||
*/
|
||||
public GoogleTurnCandidateHarvest(
|
||||
GoogleTurnCandidateHarvester harvester,
|
||||
HostCandidate hostCandidate)
|
||||
HostCandidate hostCandidate,
|
||||
String password)
|
||||
{
|
||||
super(harvester, hostCandidate);
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +153,8 @@ public class GoogleTurnCandidateHarvest
|
||||
transportAddress,
|
||||
this,
|
||||
mappedAddress,
|
||||
harvester.getShortTermCredentialUsername());
|
||||
harvester.getShortTermCredentialUsername(),
|
||||
this.password);
|
||||
|
||||
candidate.setUfrag(harvester.getShortTermCredentialUsername());
|
||||
return candidate;
|
||||
|
||||
@ -19,6 +19,11 @@ import org.ice4j.ice.*;
|
||||
public class GoogleTurnCandidateHarvester
|
||||
extends StunCandidateHarvester
|
||||
{
|
||||
/**
|
||||
* The gingle candidates password necessary to use the TURN server.
|
||||
*/
|
||||
private String password = null;
|
||||
|
||||
/**
|
||||
* Initializes a new <tt>GoogleTurnCandidateHarvester</tt> instance which
|
||||
* is to work with a specific Google TURN server.
|
||||
@ -28,7 +33,7 @@ public class GoogleTurnCandidateHarvester
|
||||
*/
|
||||
public GoogleTurnCandidateHarvester(TransportAddress turnServer)
|
||||
{
|
||||
this(turnServer, null);
|
||||
this(turnServer, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,11 +47,15 @@ public class GoogleTurnCandidateHarvester
|
||||
* instance for the purposes of the STUN short-term credential mechanism or
|
||||
* <tt>null</tt> if the use of the STUN short-term credential mechanism is
|
||||
* not determined at the time of the construction of the new instance
|
||||
* @param password The gingle candidates password necessary to use this TURN
|
||||
* server.
|
||||
*/
|
||||
public GoogleTurnCandidateHarvester(TransportAddress turnServer,
|
||||
String shortTermCredentialUsername)
|
||||
String shortTermCredentialUsername,
|
||||
String password)
|
||||
{
|
||||
super(turnServer, shortTermCredentialUsername);
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,6 +72,18 @@ public class GoogleTurnCandidateHarvester
|
||||
protected GoogleTurnCandidateHarvest createHarvest(
|
||||
HostCandidate hostCandidate)
|
||||
{
|
||||
return new GoogleTurnCandidateHarvest(this, hostCandidate);
|
||||
return new GoogleTurnCandidateHarvest(
|
||||
this,
|
||||
hostCandidate,
|
||||
this.password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password for this candidate.
|
||||
* @return the password for this candidate.
|
||||
*/
|
||||
public String getPassword()
|
||||
{
|
||||
return this.password;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ public class GoogleTurnSSLCandidateHarvester
|
||||
*/
|
||||
public GoogleTurnSSLCandidateHarvester(TransportAddress turnServer)
|
||||
{
|
||||
this(turnServer, null);
|
||||
this(turnServer, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,11 +81,14 @@ public class GoogleTurnSSLCandidateHarvester
|
||||
* instance for the purposes of the STUN short-term credential mechanism or
|
||||
* <tt>null</tt> if the use of the STUN short-term credential mechanism is
|
||||
* not determined at the time of the construction of the new instance
|
||||
* @param password The gingle candidates password necessary to use this TURN
|
||||
* server.
|
||||
*/
|
||||
public GoogleTurnSSLCandidateHarvester(TransportAddress turnServer,
|
||||
String shortTermCredentialUsername)
|
||||
String shortTermCredentialUsername,
|
||||
String password)
|
||||
{
|
||||
super(turnServer, shortTermCredentialUsername);
|
||||
super(turnServer, shortTermCredentialUsername, password);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,7 +105,10 @@ public class GoogleTurnSSLCandidateHarvester
|
||||
protected GoogleTurnCandidateHarvest createHarvest(
|
||||
HostCandidate hostCandidate)
|
||||
{
|
||||
return new GoogleTurnCandidateHarvest(this, hostCandidate);
|
||||
return new GoogleTurnCandidateHarvest(
|
||||
this,
|
||||
hostCandidate,
|
||||
this.getPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user