Harmonic maps of infinite energy and rigidity results for representations of fundamental groups of quasiprojective varieties