Security experts generally believe that, "security cannot be added on, it must be designed from the beginning."This dissertation shows that retrofitting security does not need to be a massive reengineering effort, nor does it need to be ad hoc. Security solutions can be added through systematic, general purpose security-oriented program transformations. We describe a catalog of security-oriented program transformations; so far the catalog contains thirty seven transformations. These security-oriented program transformations improve the traditional approaches of security engineering and keep software secure in the face of new security threats. Security-oriented program transformations are not silver bullets; using them requires skill and knowledge of the program being transformed. They are instead power tools that make it easier to add security to existing systems replacing the point solution of a typical patch with a more systematic removal of a vulnerability. When appropriate tools are built and the program transformations are easy enough to apply, then they will allow a software developer to add 'security on demand'.