I don't feel that what he did was legal. On the other hand, the way he has been incarcerated and treated while in military prison seems excessively cruel.
Cruel? He hasn't been excuted for exposing private government communications, including internal communications on national security issues and correspondence with foreign governments. That is potentially treason, and just a few decades ago he would have been summarily executed after a quick, brief trial.