throws ResourceException {
ManagedConnection result = null;
if (info instanceof SocketRequestInfo) {
SocketRequestInfo requestInfo = (SocketRequestInfo) info;
URI uri = URIHelper.convertHostToAddress(requestInfo.getURI());
URI altURI = requestInfo.getAlternativeURI();
if (altURI != null) {
altURI = URIHelper.convertHostToAddress(altURI);
}
Iterator iterator = connections.iterator();
while (iterator.hasNext()) {
SocketManagedConnection connection =
(SocketManagedConnection) iterator.next();
if (connection.hasPrincipal(principal)) {
final URI remote = connection.getRemoteURI();
final URI local = connection.getLocalURI();
final URI remoteAlt = connection.getAlternativeURI();
if ((remote.equals(uri) || local.equals(uri)
|| remote.equals(altURI) || local.equals(altURI))
|| (remoteAlt != null && (remoteAlt.equals(uri)
|| remoteAlt.equals(altURI)))) {
result = connection;
break;
}
}
}