public boolean isSessionRequired() {
return true;
}
public ResponseStanzaContainer execute(Stanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder) {
XMLElementVerifier xmlElementVerifier = stanza.getVerifier();
boolean jabberNamespace = xmlElementVerifier.namespacePresent(NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS);
boolean clientCall = xmlElementVerifier.namespacePresent(NamespaceURIs.JABBER_CLIENT);
boolean serverCall = xmlElementVerifier.namespacePresent(NamespaceURIs.JABBER_SERVER);
if (clientCall && serverCall) serverCall = false; // silently ignore ambiguous attributes
if (serverCall) sessionContext.setServerToServer(); else sessionContext.setClientToServer();
if (sessionStateHolder.getState() != SessionState.INITIATED &&
sessionStateHolder.getState() != SessionState.ENCRYPTED &&
sessionStateHolder.getState() != SessionState.AUTHENTICATED) {
return respondUnsupportedStanzaType("unexpected stream start");
}
// http://etherx.jabber.org/streams cannot be omitted
if (!jabberNamespace) {
return respondIllegalNamespaceError("namespace is mandatory: " + NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS);
}
// processing xml:lang
String xmlLang = stanza.getXMLLang();
sessionContext.setXMLLang(xmlLang);
// processing version
XMPPVersion responseVersion = null;
// if version is not present, version "0.0" is assumed, represented by NULL.
String versionAttributeValue = stanza.getAttributeValue("version");
if (versionAttributeValue != null) {
XMPPVersion clientVersion;
try {
clientVersion = new XMPPVersion(versionAttributeValue);
} catch (IllegalArgumentException e) {
// version string does not conform to spec
return respondUnsupportedVersionError(xmlLang, versionAttributeValue, "illegal version value: ");
}
// check if version is supported
if (!clientVersion.equals(XMPPVersion.VERSION_1_0)) {
if (clientVersion.getMajor() == XMPPVersion.VERSION_1_0.getMajor()) {
// we live with the higher minor version, but only support ours
responseVersion = XMPPVersion.VERSION_1_0;
} else {
// we do not support major changes, as of RFC3920
return respondUnsupportedVersionError(xmlLang, versionAttributeValue, "major version change not supported: ");
}
} else {
responseVersion = clientVersion;
}
}
if (xmlElementVerifier.attributePresent("id")) {
// ignore silently (see RFC3920 4.4)
}
Stanza responseStanza = null;
if (clientCall) {