“More fundamentally, public confidence in the criminal justice system is shaken if terrorism occurs in prison or if people enter prison only to (become) more dangerous: and the ability of prisons to function is gravely degraded if prison officers fear imminent terrorist attack.”