Finite rings in which commutativity is transitive