diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index 6fd48f3..efb719f 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -8,7 +8,9 @@ package org.ice4j.ice; import java.io.*; +import java.math.*; import java.net.*; +import java.security.*; import java.util.*; import java.util.logging.*; @@ -63,11 +65,25 @@ public class Agent */ 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 Agent with no streams, and no address */ 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); } } + + /** + * 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; + } + } diff --git a/test/test/Ice.java b/test/test/Ice.java index ac70fbb..dffe741 100644 --- a/test/test/Ice.java +++ b/test/test/Ice.java @@ -32,6 +32,9 @@ public class Ice { Agent agent = new Agent(); + System.out.println("ice-pwd:"+ agent.getPassword()); + System.out.println("ice-ufrag:" + agent.getUserName() + "\n"); + StunCandidateHarvester stunHarv = new StunCandidateHarvester( new TransportAddress("sip-communicator.net", 3478, Transport.UDP)); StunCandidateHarvester stun6Harv = new StunCandidateHarvester( @@ -49,8 +52,8 @@ public class Ice stream, Transport.UDP, 9090, 9090, 10000); System.out.println("rtpComp:" + rtpComp); long endTime = System.currentTimeMillis(); - System.out.println("Componente created in " - + (endTime - startTime) +" ms"); + System.out.println("Component created in " + + (endTime - startTime) +" ms\n"); startTime = endTime; //rtcpComp Component rtcpComp = agent.createComponent( @@ -58,8 +61,8 @@ public class Ice System.out.println("rtcpComp:" + rtcpComp); endTime = System.currentTimeMillis(); - System.out.println("Componente created in " - + (endTime - startTime) +" ms"); + System.out.println("Component created in " + + (endTime - startTime) +" ms\n"); } /**