public void connectionOpen(Connection conn, ConnectionOpen open)
{
final ServerConnection sconn = (ServerConnection) conn;
VirtualHostImpl vhost;
String vhostName;
if(open.hasVirtualHost())
{
vhostName = open.getVirtualHost();
}
else
{
vhostName = "";
}
vhost = ((AmqpPort)sconn.getPort()).getVirtualHost(vhostName);
if(vhost != null)
{
if (vhost.getState() != State.ACTIVE)
{
sconn.setState(Connection.State.CLOSING);
sconn.invoke(new ConnectionClose(ConnectionCloseCode.CONNECTION_FORCED, "Virtual host '"+vhostName+"' is not active"));
return;
}
sconn.setVirtualHost(vhost);
try
{
vhost.getSecurityManager().authoriseCreateConnection(sconn);
}
catch (AccessControlException e)
{
sconn.setState(Connection.State.CLOSING);
sconn.invoke(new ConnectionClose(ConnectionCloseCode.CONNECTION_FORCED, e.getMessage()));