in server/core/src/main/java/org/apache/vysper/xmpp/server/s2s/DefaultXMPPServerConnector.java [219:282]
public void handleReceivedStanza(Stanza stanza) {
// check for basic stanza handlers
StanzaHandler s2sHandler = lookupS2SHandler(stanza);
if (s2sHandler != null) {
try {
stanzaHandlerExecutorFactory.build(s2sHandler).execute(stanza, serverRuntimeContext, false,
sessionContext, sessionStateHolder);
} catch (ProtocolException e) {
return;
}
if (sessionStateHolder.getState() == SessionState.AUTHENTICATED) {
LOG.info("XMPP server connector to {} authenticated", remoteServer);
authenticatedLatch.countDown();
// connection established, start pinging
startPinging();
}
// none of the handlers matched, stream start is handled separately
} else if (stanza.getName().equals("stream")) {
sessionContext.setSessionId(stanza.getAttributeValue("id"));
sessionContext.setInitiatingEntity(remoteServer);
String version = stanza.getAttributeValue("version");
if (version == null) {
// old protocol, assume dialback
String dailbackId = new DialbackIdGenerator().generate(remoteServer,
serverRuntimeContext.getServerEntity(), sessionContext.getSessionId());
Stanza dbResult = new StanzaBuilder("result", NamespaceURIs.JABBER_SERVER_DIALBACK, "db")
.addAttribute("from", serverRuntimeContext.getServerEntity().getDomain())
.addAttribute("to", remoteServer.getDomain()).addText(dailbackId).build();
write(dbResult);
}
if (dialbackSessionContext != null) {
// connector is being used for dialback verification, don't do further
// authentication
sessionContext.putAttribute("DIALBACK_SESSION_CONTEXT", dialbackSessionContext);
sessionContext.putAttribute("DIALBACK_SESSION_STATE_HOLDER", dialbackSessionStateHolder);
sessionContext.setInitiatingEntity(remoteServer);
sessionStateHolder.setState(SessionState.AUTHENTICATED);
authenticatedLatch.countDown();
}
} else {
if (sessionStateHolder.getState() != SessionState.AUTHENTICATED) {
LOG.warn("regular stanza sent before s2s session to {} was authenticated, closing", remoteServer);
sessionContext.close();
return;
}
// only deliver messages to directly server directly
if (!serverRuntimeContext.getServerEntity().equals(stanza.getTo())) {
LOG.info("not handling messages to clients here received from {} to {}", remoteServer, stanza.getTo());
sessionContext.close();
return;
}
stanzaProcessor.processStanza(serverRuntimeContext, sessionContext, stanza, sessionStateHolder);
}
}