The military, by necessity must restrict or limit some of persons liberties - this you agree to when you join - but the military may not, ultimately deny a person their Constitutional Rights such as the right to deny self incrimination or the right to a speedy trial, or the right to be punished in a manner that is not cruel or unusual.
By the way, correct me if I'm wrong but in your enlistment papers there's a clause to the effect that "any assignment offered will be subject to the needs of the Navy/Marine Corps/Army/Air Force?"
Exactly.