onSasl2FeaturesReceived method

  1. @override
Future<List<XMLNode>> onSasl2FeaturesReceived(
  1. XMLNode sasl2Features
)
override

Called by the SASL2 negotiator when we received the SASL2 stream features sasl2Features. The return value is a list of XML elements that should be added to the SASL2 nonza. This method is only called when the element contains an item with xmlns equal to negotiatingXmlns.

Implementation

@override
Future<List<XMLNode>> onSasl2FeaturesReceived(XMLNode sasl2Features) async {
  if (fastToken != null && pickedForSasl2) {
    // Specify that we are using a token
    return [
      // As we don't do TLS 0-RTT, we don't have to specify `count`.
      XMLNode.xmlns(
        tag: 'fast',
        xmlns: fastXmlns,
      ),
    ];
  }

  // Only request a new token when we don't already have one and we are not picked
  // for SASL
  if (!pickedForSasl2) {
    return [
      XMLNode.xmlns(
        tag: 'request-token',
        xmlns: fastXmlns,
        attributes: {
          'mechanism': 'HT-SHA-256-NONE',
        },
      ),
    ];
  } else {
    return [];
  }
}