package connection.peer.secure;
import handlers.AbstractContextualHandler;
import handlers.sets.ServerSideSecurityHandlerSet;
import java.io.IOException;
import main.settings.Settings;
import common.connection.AbstractConnection;
import common.handlers.AbstractHandlerSet;
import connection.peer.secure.reconnector.ServerSideReconnector;
public class ServerSideSecurableConnection extends AbstractSecurableConnection
{
private static final ServerSideSecurityHandlerSet HANDLER_SET = new ServerSideSecurityHandlerSet();
public ServerSideSecurableConnection(ConnectionSecurerInterface requestor)
throws IOException
{
super(requestor);
}
protected SecurityAbility determineSecurityAbility()
{
if (Settings.connection.security.from_peers)
{
return SecurityAbility.WANT;
}
else
{
return SecurityAbility.CAN;
}
}
protected AbstractHandlerSet getHandlerSet()
{
return HANDLER_SET;
}
public AbstractContextualHandler getContextualHandler(int protocolId, int opcode)
throws IOException, ClassNotFoundException
{
return ServerSideSecurityHandlerSet.HANDLERS[protocolId][opcode]
.createContext(this);
}
protected AbstractConnection reconnect(ConnectionSecurerInterface securer)
throws IOException
{
return new ServerSideReconnector(this, securer).reconnect();
}
}