onSasl2Success method

  1. @override
Future<Result<bool, NegotiatorError>> onSasl2Success(
  1. XMLNode response
)
override

Called by the SASL2 negotiator when the SASL2 negotiations are done. response is the entire response nonza. This method is only called when the previous element contains an item with xmlns equal to negotiatingXmlns.

Implementation

@override
Future<Result<bool, NegotiatorError>> onSasl2Success(XMLNode response) async {
  final enabled = response
      .firstTag('bound', xmlns: bind2Xmlns)
      ?.firstTag('enabled', xmlns: smXmlns);
  final resumed = response.firstTag('resumed', xmlns: smXmlns);
  // We can only enable or resume->fail->enable. Thus, we check for enablement first
  // and then exit.
  if (_inlineStreamEnablementRequested) {
    if (enabled != null) {
      _log.finest('Inline stream enablement successful');
      await _onStreamEnablementSuccessful(enabled);
      return const Result(true);
    } else {
      _log.warning('Inline stream enablement failed');
      _onStreamEnablementFailed();
    }
  }

  if (resumed == null) {
    _log.warning('Inline stream resumption failed');
    await _onStreamResumptionFailed();
    state = NegotiatorState.done;
    return const Result(true);
  }

  _log.finest('Inline stream resumption successful');
  await _onStreamResumptionSuccessful(resumed);
  state = NegotiatorState.skipRest;

  attributes.removeNegotiatingFeature(smXmlns);
  attributes.removeNegotiatingFeature(bindXmlns);

  return const Result(true);
}