String requestedMechanism = stanza.getAttributeValue("mechanism");
if (requestedMechanism == null) {
return respondSASLFailure();
}
SASLMechanism identifiedMechanism = null;
List<SASLMechanism> list = sessionContext.getServerRuntimeContext().getServerFeatures()
.getAuthenticationMethods();
for (SASLMechanism saslMechanism : list) {
if (saslMechanism.getName().equals(requestedMechanism)) {
identifiedMechanism = saslMechanism;
break;
}
}
if (identifiedMechanism == null)
throw new RuntimeException("return error");
Stanza responseStanza = identifiedMechanism.started(sessionContext, sessionStateHolder, stanza);
if (sessionStateHolder.getState() == SessionState.AUTHENTICATED) {
AuthorizationRetriesCounter.removeFromSession(sessionContext);
} else {
AuthorizationRetriesCounter.getFromSession(sessionContext).countFailedTry();
}