Adds generation of agent-level user name and password values
This commit is contained in:
parent
00bf037003
commit
152eb6282b
@ -8,7 +8,9 @@
|
|||||||
package org.ice4j.ice;
|
package org.ice4j.ice;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.math.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
import java.security.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
@ -63,11 +65,25 @@ public class Agent
|
|||||||
*/
|
*/
|
||||||
private FoundationsRegistry foundationsRegistry = new FoundationsRegistry();
|
private FoundationsRegistry foundationsRegistry = new FoundationsRegistry();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user fragment that we should use for the ice-ufrag attribute.
|
||||||
|
*/
|
||||||
|
private final String ufrag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The password that we should use for the ice-pwd attribute.
|
||||||
|
*/
|
||||||
|
private final String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty <tt>Agent</tt> with no streams, and no address
|
* Creates an empty <tt>Agent</tt> with no streams, and no address
|
||||||
*/
|
*/
|
||||||
public Agent()
|
public Agent()
|
||||||
{
|
{
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
|
||||||
|
ufrag = new BigInteger(24, random).toString(32);
|
||||||
|
password = new BigInteger(128, random).toString(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -216,4 +232,29 @@ public class Agent
|
|||||||
harvesters.add(harvester);
|
harvesters.add(harvester);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns that user name that should be advertised in session descriptions
|
||||||
|
* containing ICE data from this agent.
|
||||||
|
*
|
||||||
|
* @return that user name that should be advertised in session descriptions
|
||||||
|
* containing ICE data from this agent.
|
||||||
|
*/
|
||||||
|
public String getUserName()
|
||||||
|
{
|
||||||
|
return ufrag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns that password that should be advertised in session descriptions
|
||||||
|
* containing ICE data from this agent.
|
||||||
|
*
|
||||||
|
* @return that password that should be advertised in session descriptions
|
||||||
|
* containing ICE data from this agent.
|
||||||
|
*/
|
||||||
|
public String getPassword()
|
||||||
|
{
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,9 @@ public class Ice
|
|||||||
{
|
{
|
||||||
Agent agent = new Agent();
|
Agent agent = new Agent();
|
||||||
|
|
||||||
|
System.out.println("ice-pwd:"+ agent.getPassword());
|
||||||
|
System.out.println("ice-ufrag:" + agent.getUserName() + "\n");
|
||||||
|
|
||||||
StunCandidateHarvester stunHarv = new StunCandidateHarvester(
|
StunCandidateHarvester stunHarv = new StunCandidateHarvester(
|
||||||
new TransportAddress("sip-communicator.net", 3478, Transport.UDP));
|
new TransportAddress("sip-communicator.net", 3478, Transport.UDP));
|
||||||
StunCandidateHarvester stun6Harv = new StunCandidateHarvester(
|
StunCandidateHarvester stun6Harv = new StunCandidateHarvester(
|
||||||
@ -49,8 +52,8 @@ public class Ice
|
|||||||
stream, Transport.UDP, 9090, 9090, 10000);
|
stream, Transport.UDP, 9090, 9090, 10000);
|
||||||
System.out.println("rtpComp:" + rtpComp);
|
System.out.println("rtpComp:" + rtpComp);
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
System.out.println("Componente created in "
|
System.out.println("Component created in "
|
||||||
+ (endTime - startTime) +" ms");
|
+ (endTime - startTime) +" ms\n");
|
||||||
startTime = endTime;
|
startTime = endTime;
|
||||||
//rtcpComp
|
//rtcpComp
|
||||||
Component rtcpComp = agent.createComponent(
|
Component rtcpComp = agent.createComponent(
|
||||||
@ -58,8 +61,8 @@ public class Ice
|
|||||||
|
|
||||||
System.out.println("rtcpComp:" + rtcpComp);
|
System.out.println("rtcpComp:" + rtcpComp);
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
System.out.println("Componente created in "
|
System.out.println("Component created in "
|
||||||
+ (endTime - startTime) +" ms");
|
+ (endTime - startTime) +" ms\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user