Judge rules impeachment inquiry is legal