public class StunCandidateHarvester extends AbstractCandidateHarvester
Component
using STUN as defined in RFC 5389 "Session
Traversal Utilities for NAT (STUN)" only.Modifier and Type | Field and Description |
---|---|
private List<StunCandidateHarvest> |
completedHarvests
The list of StunCandidateHarvests which have been successfully
completed i.e.
|
private static Logger |
logger
The Logger used by the StunCandidateHarvester class and
its instances for logging output.
|
private String |
shortTermCredentialUsername
The username used by this StunCandidateHarvester for the
purposes of the STUN short-term credential mechanism.
|
private List<StunCandidateHarvest> |
startedHarvests
The list of StunCandidateHarvests which have been started to
harvest Candidates for HostCandidates and which have
not completed yet so
harvest(Component) has to wait for them. |
TransportAddress |
stunServer
The address of the STUN server that we will be sending our requests to.
|
private StunStack |
stunStack
The StunStack used by this instance for the purposes of STUN
communication.
|
Constructor and Description |
---|
StunCandidateHarvester(TransportAddress stunServer)
Creates a new STUN harvester that will be running against the specified
stunServer using a specific username for the purposes of the
STUN short-term credential mechanism.
|
StunCandidateHarvester(TransportAddress stunServer,
String shortTermCredentialUsername)
Creates a new STUN harvester that will be running against the specified
stunServer using a specific username for the purposes of the
STUN short-term credential mechanism.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
completedResolvingCandidate(StunCandidateHarvest harvest)
Notifies this StunCandidateHarvester that a specific
StunCandidateHarvest has been completed.
|
protected StunCandidateHarvest |
createHarvest(HostCandidate hostCandidate)
Creates a new StunCandidateHarvest instance which is to perform
STUN harvesting of a specific HostCandidate.
|
protected LongTermCredential |
createLongTermCredential(StunCandidateHarvest harvest,
byte[] realm)
Creates a LongTermCredential to be used by a specific
StunCandidateHarvest for the purposes of the long-term
credential mechanism in a specific realm of the STUN server
associated with this StunCandidateHarvester.
|
protected HostCandidate |
getHostCandidate(HostCandidate hostCand)
Returns the host candidate.
|
protected String |
getShortTermCredentialUsername()
Gets the username to be used by this StunCandidateHarvester for
the purposes of the STUN short-term credential mechanism.
|
StunStack |
getStunStack()
Gets the StunStack used by this CandidateHarvester for
the purposes of STUN communication.
|
Collection<LocalCandidate> |
harvest(Component component)
Gathers STUN candidates for all host Candidates that are already
present in the specified component.
|
private String |
listCandidates(Collection<? extends Candidate<?>> candidates) |
private void |
startResolvingCandidate(HostCandidate hostCand)
Sends a binding request to our stun server through the specified
hostCand candidate and adds it to the list of addresses still
waiting for resolution.
|
String |
toString()
Returns a String representation of this harvester containing its
type and server address.
|
private void |
waitForResolutionEnd()
Blocks the current thread until all resolutions in this harvester
have terminated one way or another.
|
getHarvestStatistics, isHostHarvester
private static final Logger logger
private final List<StunCandidateHarvest> completedHarvests
private final String shortTermCredentialUsername
private final List<StunCandidateHarvest> startedHarvests
harvest(Component)
has to wait for them.public final TransportAddress stunServer
private StunStack stunStack
public StunCandidateHarvester(TransportAddress stunServer)
stunServer
- the address of the STUN server that we will be querying
for our public bindingspublic StunCandidateHarvester(TransportAddress stunServer, String shortTermCredentialUsername)
stunServer
- the address of the STUN server that we will be querying
for our public bindingsshortTermCredentialUsername
- the username to be used by the new
instance for the purposes of the STUN short-term credential mechanism or
null if the use of the STUN short-term credential mechanism is
not determined at the time of the construction of the new instancevoid completedResolvingCandidate(StunCandidateHarvest harvest)
startedHarvests
to completedHarvests
. Otherwise, it is
just removed from startedHarvests
.harvest
- the StunCandidateHarvest which has been completedprotected StunCandidateHarvest createHarvest(HostCandidate hostCandidate)
hostCandidate
- the HostCandidate for which harvesting is
to be performed by the new StunCandidateHarvest instanceprotected LongTermCredential createLongTermCredential(StunCandidateHarvest harvest, byte[] realm)
harvest
- the StunCandidateHarvest which asks for the
LongTermCredentialrealm
- the realm of the STUN server associated with this
StunCandidateHarvester in which harvest will use the
returned LongTermCredentialprotected String getShortTermCredentialUsername()
public StunStack getStunStack()
CandidateHarvester.harvest(Component)
.CandidateHarvester.harvest(Component)
public Collection<LocalCandidate> harvest(Component component)
component
- the Component
that we'd like to gather candidate
STUN Candidates forprivate String listCandidates(Collection<? extends Candidate<?>> candidates)
private void startResolvingCandidate(HostCandidate hostCand)
hostCand
- the HostCandidate that we'd like to resolve.private void waitForResolutionEnd()
public String toString()
protected HostCandidate getHostCandidate(HostCandidate hostCand)
hostCand
- HostCandidateCopyright © 2018. All rights reserved.