use of org.jivesoftware.openfire.session.OutgoingServerSession in project Openfire by igniterealtime.
the class S2STestService method logSessionStatus.
/**
* Logs the status of the session.
*/
private void logSessionStatus() {
final DomainPair pair = new DomainPair(XMPPServer.getInstance().getServerInfo().getXMPPDomain(), domain);
OutgoingServerSession session = XMPPServer.getInstance().getSessionManager().getOutgoingServerSession(pair);
if (session != null) {
int connectionStatus = session.getStatus();
switch(connectionStatus) {
case Session.STATUS_CONNECTED:
Log.info("Session is connected.");
break;
case Session.STATUS_CLOSED:
Log.info("Session is closed.");
break;
case Session.STATUS_AUTHENTICATED:
Log.info("Session is authenticated.");
break;
}
} else {
Log.info("Failed to establish server to server session.");
}
}
use of org.jivesoftware.openfire.session.OutgoingServerSession in project Openfire by igniterealtime.
the class S2STestService method run.
/**
* Run a test against the domain.
* @return K-V pairs of debug information.
* @throws Exception On error.
*/
public Map<String, String> run() throws Exception {
waitUntil = new Semaphore(0);
Map<String, String> results = new HashMap<>();
final DomainPair pair = new DomainPair(XMPPServer.getInstance().getServerInfo().getXMPPDomain(), domain);
// Tear down existing routes.
final SessionManager sessionManager = SessionManager.getInstance();
for (final Session incomingServerSession : sessionManager.getIncomingServerSessions(domain)) {
incomingServerSession.close();
}
final Session outgoingServerSession = sessionManager.getOutgoingServerSession(pair);
if (outgoingServerSession != null) {
outgoingServerSession.close();
}
final IQ pingRequest = new IQ(Type.get);
pingRequest.setChildElement("ping", IQPingHandler.NAMESPACE);
pingRequest.setFrom(pair.getLocal());
pingRequest.setTo(domain);
// Intercept logging.
final Writer logs = new StringWriter();
final String appenderName = addAppender(logs);
// Intercept packets.
final PacketInterceptor interceptor = new S2SInterceptor(pingRequest);
InterceptorManager.getInstance().addInterceptor(interceptor);
// Send ping.
try {
Log.info("Sending server to server ping request to " + domain);
XMPPServer.getInstance().getIQRouter().route(pingRequest);
// Wait for success or exceed socket timeout.
waitUntil.tryAcquire(RemoteServerManager.getSocketTimeout(), TimeUnit.MILLISECONDS);
// Check on the connection status.
logSessionStatus();
// Prepare response.
results.put("certs", getCertificates());
results.put("stanzas", interceptor.toString());
results.put("logs", logs.toString());
return results;
} finally {
// Cleanup
InterceptorManager.getInstance().removeInterceptor(interceptor);
removeAppender(appenderName);
}
}
Aggregations