The real reason behind Hasan's success was that the Army and the FBI didn't do their jobs. The Army should have prosecuted Hasan for his anti-US statements under the UCMJ. The federal conviction would have gotten him out of the military and prevented him from purchasing firearms legally.
By the way - had the other military members in the Readiness Center been armed, Hasan would probably have not even tried to murder his fellow soldiers. If he had, he might have gotten one or two before being turned into swiss cheese.
§ 904. Art. 104. Aiding the enemy
Any person who (1) aids, or attempts to aid, the enemy with arms, ammunition, supplies, money, or other things; or (2) without proper authority, knowingly harbors or protects or gives intelligence to, or communicates or corresponds with or holds any intercourse with the enemy, either directly or indirectly; shall suffer death or such other punishment as a court-martial or military commission may direct.
You could also make a good case for a violation of Article 106, Espionage.