There's an old adage that says if you ask two lawyers a question, you'll get three answers. What this means is that much of the law has gray areas that are open to argument. For example, the Bush adminstration argued that preemptive action in Iraq was legal because Iraq posed an imminent threat. Obviously, many have disagreed with this conclusion and continue to argue the illegality of the war. Those that adhere to that line of thinking would likely answer you question by saying that only an attack from a beligerent country would authorize a violation of that country's sovereignty (the theory being that they waived that sovereignty in the context of conflict by attacking another country).

I know of no legal basis for unilaterally entering a country in a military capacity to do things like administer humanitarian aid or to capture a terror suspect. I would think that even the Bush doctrine of preemptive action wouldn't cover this since the country itself would pose the threat. In other words, it is the terrorist that poses the threat not the country in which he is located. The humanitrian issue does not met this either unless someone can advance an argument that the humanitarian crisis poses a threat to a particular nation's sovereignty (i.e. its the equivalent of an attack).

With the terrorist example, I revert back to my comment I've shared before about treating the war on terror as a criminal rather than military fight. I think it would be easier to come to terms with various nations to allow an international unit (or international sponsored unit) to effectuate an arrest. However, I see many difficulties even with this.

Whatever the solution, I think we need to place it within a legal framework so that we do not weaken state sovereignty.