For most people, the term "security" refers to cryptographic algorithms, biometric authentication techniques, passwords, etc. Beyond these intuitive notions, security is rather a very broad topic and may be viewed from a variety of other perspectives, including new access control models, software architectures for security systems, and security policies specifications. Pervasive environments are the prime field for applying security due to the high frequency of attacks and incompatibilities detected in these types of environments. This situation results from the distributed nature of pervasive environments, mobility of users and devices, services heterogeneity and the different capabilities of devices used to access the services. The main aim of this research is to point the research community to better consider context-based security as a new trend that may face future more subtle security attacks. We believe that the force of a good security system should not rely only on the force of security protocols but also on the way it copes with new and completely unpredictable situations or at least learn from new situations and updates its behavior accordingly. This goal can be reached by making future security solutions freely adaptive. The main contribution of this thesis is the design and implementation of a conceptual model and a software layer for integrating context-based security in pervasive environments. The thesis project relies on a multidisciplinary approach ; context-aware computing from which we bring the need for contextual information in order to provide adaptability and flexibility for security solutions ; software engineering from where we use the best design practices in order to provide an extensible software architecture for context-based security systems