throw body.getConnectionException(AMQConstant.RESOURCE_ERROR, "Unable to create SASL Server:" + body.getMechanism());
}
session.setSaslServer(ss);
final AuthenticationResult authResult = authMgr.authenticate(ss, body.getResponse());
//save clientProperties
if (session.getClientProperties() == null)
{
session.setClientProperties(body.getClientProperties());
}
MethodRegistry methodRegistry = session.getMethodRegistry();
switch (authResult.getStatus())
{
case ERROR:
Exception cause = authResult.getCause();
_logger.info("Authentication failed:" + (cause == null ? "" : cause.getMessage()));
stateManager.changeState(AMQState.CONNECTION_CLOSING);
ConnectionCloseBody closeBody =
methodRegistry.createConnectionCloseBody(AMQConstant.NOT_ALLOWED.getCode(), // replyCode
AMQConstant.NOT_ALLOWED.getName(),
body.getClazz(),
body.getMethod());
session.writeFrame(closeBody.generateFrame(0));
disposeSaslServer(session);
break;
case SUCCESS:
if (_logger.isInfoEnabled())
{
_logger.info("Connected as: " + UsernamePrincipal.getUsernamePrincipalFromSubject(authResult.getSubject()));
}
session.setAuthorizedSubject(authResult.getSubject());
stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);
ConnectionTuneBody tuneBody = methodRegistry.createConnectionTuneBody(ApplicationRegistry.getInstance().getConfiguration().getMaxChannelCount(),
getConfiguredFrameSize(),
ApplicationRegistry.getInstance().getConfiguration().getHeartBeatDelay());
session.writeFrame(tuneBody.generateFrame(0));
break;
case CONTINUE:
stateManager.changeState(AMQState.CONNECTION_NOT_AUTH);
ConnectionSecureBody secureBody = methodRegistry.createConnectionSecureBody(authResult.getChallenge());
session.writeFrame(secureBody.generateFrame(0));
}
}
catch (SaslException e)
{