Two former justice secretaries have criticised Prince Harry for attacking the judge who presided over his hacking case against the publisher of the Daily Mail.