if (_saslServer.isComplete())
{
SaslOutcome outcome = new SaslOutcome();
outcome.setCode(SaslCode.OK);
_saslFrameOutput.send(new SASLFrame(outcome), null);
synchronized (getLock())
{
_saslComplete = true;
_authenticated = true;
_user = _saslServerProvider.getAuthenticatedPrincipal(_saslServer);
getLock().notifyAll();
}
if (_onSaslCompleteTask != null)
{
_onSaslCompleteTask.run();
}
}
else
{
SaslChallenge challengeBody = new SaslChallenge();
challengeBody.setChallenge(new Binary(challenge));
_saslFrameOutput.send(new SASLFrame(challengeBody), null);
}
}
catch (SaslException e)
{
SaslOutcome outcome = new SaslOutcome();
outcome.setCode(SaslCode.AUTH);
_saslFrameOutput.send(new SASLFrame(outcome), null);
synchronized (getLock())
{
_saslComplete = true;
_authenticated = false;
getLock().notifyAll();