public WorldChannelInterface registerChannelServer(final String authKey, final ChannelWorldInterface cb) throws RemoteException {
	try {
	    Connection con = DatabaseConnection.getConnection();
	    PreparedStatement ps = con.prepareStatement("SELECT * FROM auth_server_channel WHERE `key` = SHA1(?) AND world = ?");
	    ps.setString(1, authKey);
	    ps.setInt(2, WorldServer.getInstance().getWorldId());
	    ResultSet rs = ps.executeQuery();
	    if (rs.next()) {
		int channelId = rs.getInt("number");
		if (channelId < 1) {
		    channelId = getFreeChannelId();
		    if (channelId == -1) {
			throw new RuntimeException("Maximum channels reached");
		    }
		} else {
		    if (channelServer.containsKey(channelId)) {
			ChannelWorldInterface oldch = channelServer.get(channelId);
			try {
			    oldch.shutdown(0);
			} catch (ConnectException ce) {
			    // silently ignore as we assume that the server is offline
			}
			// int switchChannel = getFreeChannelId();
			// if (switchChannel == -1) {
			// throw new RuntimeException("Maximum channels reached");
			// }
			// ChannelWorldInterface switchIf = channelServer.get(channelId);
			// deregisterChannelServer(switchChannel);
			// channelServer.put(switchChannel, switchIf);
			// switchIf.setChannelId(switchChannel);
			// for (LoginWorldInterface wli : loginServer) {
			// wli.channelOnline(switchChannel, switchIf.getIP());
			// }
		    }
		}
		channelServer.put(channelId, cb);
		cb.setChannelId(channelId);
		WorldChannelInterface ret = new WorldChannelInterfaceImpl(cb, rs.getInt("channelid"));
		rs.close();
		ps.close();
		return ret;
	    }
	    rs.close();
	    ps.close();
	} catch (SQLException ex) {
	    System.err.println("Encountered database error while authenticating channelserver" + ex);
	}
	throw new RuntimeException("Couldn't find a channel with the given key (" + authKey + ")");
    }