Class Bind2StreamManagementHandler

java.lang.Object
org.jivesoftware.openfire.handler.Bind2StreamManagementHandler
All Implemented Interfaces:
Bind2InlineHandler

public class Bind2StreamManagementHandler extends Object implements Bind2InlineHandler
A Bind2InlineHandler that processes XEP-0198 Stream Management <enable/> elements sent inline within a SASL2 Bind2 request (XEP-0388 / XEP-0386).

When a client includes an <enable/> element in the urn:xmpp:sm:3 namespace inside its Bind2 <bind/> element, this handler delegates to the session's StreamManager to enable stream management (and optionally resumption) immediately after resource binding, without requiring a separate round-trip.

The <enabled/> response from the server is added as a child of the <bound/> element in the SASL2 <success/> stanza.

See Also:
  • Constructor Details

    • Bind2StreamManagementHandler

      public Bind2StreamManagementHandler()
  • Method Details

    • getNamespace

      public String getNamespace()
      Description copied from interface: Bind2InlineHandler
      Gets the namespace this handler processes.
      Specified by:
      getNamespace in interface Bind2InlineHandler
      Returns:
      The XML namespace URI this handler supports
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: Bind2InlineHandler
      Indicates whether this handler is currently available for advertisement and request processing. A handler whose feature is disabled by configuration is neither advertised in the Bind2 inline feature list nor invoked for a request that names its namespace, so that a peer is never offered something it cannot use.
      Specified by:
      isEnabled in interface Bind2InlineHandler
      Returns:
      true when the inline feature is available
    • handleElement

      public boolean handleElement(LocalClientSession session, org.dom4j.Element bound, org.dom4j.Element element)
      Handles an <enable/> element from a Bind2 inline feature request by enabling XEP-0198 stream management on the session. The <enabled/> response element produced by the stream manager is added as a child of the provided bound element.

      Only <enable/> elements are processed; any other element name is ignored.

      Specified by:
      handleElement in interface Bind2InlineHandler
      Parameters:
      session - the client session on which stream management should be enabled
      bound - the <bound/> element to which the <enabled/> response is added
      element - the inline element from the Bind2 request (expected to be <enable/>)
      Returns:
      true if the element was an <enable/> and was processed; false if the element was not an <enable/> or processing failed
    • handleFailure

      public void handleFailure(LocalClientSession session, org.dom4j.Element bound, org.dom4j.Element element, Exception cause)
      Adds the <failed/> element that XEP-0198 § 9.1.1 requires inside <bound/> when stream management could not be enabled. The condition is taken from the failure itself where one is available. A handler that declined the request without failing did so because the element was not an <enable/>, which is a malformed request.
      Specified by:
      handleFailure in interface Bind2InlineHandler
      Parameters:
      session - the client session
      bound - the Bind2 response element
      element - the request that could not be processed
      cause - the processing exception, or null when the handler returned false