public final class StreamFeaturesManager extends Object
Because the receiving entity for a stream acts as a gatekeeper to the domains it services, it imposes certain conditions for connecting as a client or as a peer server. At a minimum, the initiating entity needs to authenticate with the receiving entity before it is allowed to send stanzas to the receiving entity (for client-to-server streams this means using SASL as described under Section 6). However, the receiving entity can consider conditions other than authentication to be mandatory-to-negotiate, such as encryption using TLS as described under Section 5. The receiving entity informs the initiating entity about such conditions by communicating "stream features": the set of particular protocol interactions that the initiating entity needs to complete before the receiving entity will accept XML stanzas from the initiating entity, as well as any protocol interactions that are voluntary-to-negotiate but that might improve the handling of an XML stream (e.g., establishment of application-layer compression as described in [XEP-0138]).
Each feature is associated with a feature negotiator, which negotiates the particular feature.
This class manages these negotiators, receives XML elements and delegates them to the responsible feature negotiator for further processing.
It negotiates the stream by sequentially negotiating each stream feature.
| Constructor and Description |
|---|
StreamFeaturesManager(XmppSession xmppSession)
Creates a feature manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFeatureNegotiator(StreamFeatureNegotiator streamFeatureNegotiator)
Adds a new feature negotiator, which is responsible for negotiating an individual feature.
|
Map<Class<? extends StreamFeature>,StreamFeature> |
getFeatures()
Gets the available features, which the server has advertised.
|
void |
negotiateNextFeature()
Negotiates the next feature.
|
boolean |
processElement(Object element)
Tries to process an element, which is a feature or may belong to a feature protocol, e.g. the
<proceed/> element from TLS negotiation. |
void |
processFeatures(StreamFeatures featuresElement)
Processes the
<stream:features/> element and immediately starts negotiating the first feature. |
public StreamFeaturesManager(XmppSession xmppSession)
xmppSession - The connection, features will be negotiated for.public Map<Class<? extends StreamFeature>,StreamFeature> getFeatures()
public void addFeatureNegotiator(StreamFeatureNegotiator streamFeatureNegotiator)
streamFeatureNegotiator - The feature negotiator, which is responsible for the feature.public void processFeatures(StreamFeatures featuresElement) throws Exception
<stream:features/> element and immediately starts negotiating the first feature.featuresElement - The <stream:features/> element.Exception - If an exception occurred during feature negotiation.public boolean processElement(Object element) throws Exception
<proceed/> element from TLS negotiation.element - The element.Exception - If an exception occurred during feature negotiation.Copyright © 2014 XMPP.rocks. All rights reserved.