A Flexible Trust-Based Access Control Mechanism for Security and Privacy Enhancement in Ubiquitous Systems