Stanza responseStanza = null;
if (clientCall) {
// RFC3920: 'to' attribute SHOULD be used by the initiating entity
String toValue = stanza.getAttributeValue("to");
if (toValue != null) {
EntityImpl toEntity = null;
try {
toEntity = EntityImpl.parse(toValue);
} catch (EntityFormatException e) {
return new ResponseStanzaContainerImpl(ServerErrorResponses.getInstance().getStreamError(
StreamErrorCondition.IMPROPER_ADDRESSING, sessionContext.getXMLLang(),
"could not parse incoming stanza's TO attribute", null));
}
// TODO check if toEntity is served by this server
// if (!server.doesServe(toEntity)) throw WhateverException();
// TODO RFC3920: 'from' attribute SHOULD be silently ignored by the receiving entity
// TODO RFC3920bis: 'from' attribute SHOULD be not ignored by the receiving entity and used as 'to' in responses
}
responseStanza = new ServerResponses().getStreamOpener(clientCall, sessionContext.getServerJID(),
responseVersion, sessionContext);
} else if (serverCall) {
// RFC3920: 'from' attribute SHOULD be used by the receiving entity
String fromValue = stanza.getAttributeValue("from");
if (fromValue != null) {
EntityImpl entity = null;
try {
entity = EntityImpl.parse(fromValue);
} catch (EntityFormatException e) {
return new ResponseStanzaContainerImpl(ServerErrorResponses.getInstance().getStreamError(
StreamErrorCondition.INVALID_FROM, sessionContext.getXMLLang(),