*
* @param uac
* @return A clone or the remote target object.
*/
private URI findRemoteTarget(UA uac) {
URI remoteTarget;
remoteTarget = uac.getRemoteTarget();
if (remoteTarget == null) {
try {
Address contact = getAddressHeaderImpl(Header.CONTACT);
if (contact != null) {
remoteTarget = getAddressHeaderImpl(Header.CONTACT).getURI();
if (remoteTarget == null) {
throw new IllegalStateException(
"Unable to fetch remote target from Contact header");
}
} else {
throw new IllegalStateException(
"Missing Contact header field");
}
} catch (ServletParseException e) {
throw new IllegalStateException(e);
}
}
return (URI) remoteTarget.clone();
}