Nations have the right to just war and individuals have the right to self-defense. No, and most people understand that. The act itself must be good. The intention of the one doing it must be good. The circumstances must be appropriate.
Capital punishment is the right of the state.
This is the principle taught by the Church. The Pope does not deny it, but neither St. Thomas or any Magisterial text presumes this gives the state an unlimited right to make capital laws and carry them out. It is inherent in a just capital punishment law that there be proportion between the taking of the life of the criminal and the benefit expected to the common good. A law, for example, that takes no account of factors such as repentance, mental age and so on is unjust. States have executed the mentally retarded, who could be of no conceivable future threat to society, and in one case a woman whose evident conversion even the state admitted.