1)
although the law may be unjust2) that doesn't mean that they weren't justly punished
Didn't you equivocate on "justice" there?
If "justly" only means "legally", the second quote is right. There's a reason why the Department of Law-interpretation-and-enforcement is called "Department of Justice" instead. Lawyers love to think that they're administering justice and not simply a piece of legislation. But we should not fall for this linguistic trick and equivocate justice with what is legal.
Political philosophers often use the word "justice" or "fairness" to refer to some moral ideal that is above existing laws, and which we can appeal to in evaluating existing and proposed laws. There are disagreements about the content of this ideal, of course, but none of that makes the concept of justice less authoritative than positive law. On this definition, the first quote would stand, but the second quote wouldn't make much sense.
There's also a sizable literature on civil disobedience, whereby citizens are morally permitted -- or even required -- to disregard laws that they believe are grossly unfair or unjust (provided that certain other conditions are met). IIRC Dworkin wrote an article or two on this topic, and so did Rawls.