// The value of the 'action' attribute MUST be one of the following.
// If an entity receives a value not defined here, it MUST ignore the attribute and MUST return a <bad-request/> error to the sender.
// There is no default value for the 'action' attribute.
if (jingle.getAction() == null) {
xmppSession.send(iq.createError(new StanzaError(new BadRequest(), "No valid action attribute set.")));
} else if (jingle.getSessionId() == null) {
xmppSession.send(iq.createError(new StanzaError(new BadRequest(), "No session id set.")));
} else if (jingle.getAction() == Jingle.Action.SESSION_INITIATE) {
// Check if the Jingle request is not mal-formed, otherwise return a bad-request error.
// See 6.3.2 Errors
if (jingle.getContents().isEmpty()) {
xmppSession.send(iq.createError(new StanzaError(new BadRequest(), "No contents found.")));
} else {
boolean hasContentWithDispositionSession = false;
boolean hasSupportedApplications = false;
boolean hasSupportedTransports = false;
// Check if we support the application format and transport method and at least one content element has a disposition of "session".
for (Jingle.Content content : jingle.getContents()) {
// Check if the content disposition is "session" (default value is "session").
if (!hasContentWithDispositionSession && ("session".equals(content.getDisposition()) || content.getDisposition() == null)) {
hasContentWithDispositionSession = true;
}
if (!hasSupportedApplications && content.getApplicationFormat() != null) {
hasSupportedApplications = true;
}
if (!hasSupportedTransports && content.getTransportMethod() != null) {
hasSupportedTransports = true;
}
}
if (!hasContentWithDispositionSession) {
// When sending a session-initiate with one <content/> element,
// the value of the <content/> element's 'disposition' attribute MUST be "session"
// (if there are multiple <content/> elements then at least one MUST have a disposition of "session");
// if this rule is violated, the responder MUST return a <bad-request/> error to the initiator.
xmppSession.send(iq.createError(new StanzaError(new BadRequest(), "No content with disposition 'session' found.")));
} else {
// If the request was ok, immediately acknowledge the initiation request.
// See 6.3.1 Acknowledgement
xmppSession.send(iq.createResult());