_sender = sender;
Container container = new Container(_broker.getId().toString());
VirtualHost virtualHost = _broker.getVirtualHostRegistry().getVirtualHost((String)_broker.getAttribute(Broker.DEFAULT_VIRTUAL_HOST));
SubjectCreator subjectCreator = _broker.getSubjectCreator(getLocalAddress());
_conn = new ConnectionEndpoint(container, asSaslServerProvider(subjectCreator));
_conn.setRemoteAddress(getRemoteAddress());
_conn.setConnectionEventListener(new Connection_1_0(virtualHost, _conn, _connectionId));
_conn.setFrameOutputHandler(this);
_conn.setSaslFrameOutput(this);
_conn.setOnSaslComplete(new Runnable()
{
public void run()
{
if(_conn.isAuthenticated())
{
_sender.send(PROTOCOL_HEADER.duplicate());
_sender.flush();
}
else
{
_network.close();
}
}
});
_frameWriter = new FrameWriter(_conn.getDescribedTypeRegistry());
_frameHandler = new SASLFrameHandler(_conn);
_sender.send(HEADER.duplicate());
_sender.flush();
_conn.initiateSASL(subjectCreator.getMechanisms().split(" "));
}