ADF Tips: How to login programmatically?

This is a quick post about how to log in programmaticallyagainst your WLS when working with ADF applications that are ADF Security enabled. The use case is simple; an ADF application with ADF Security Enabled with two pages. One of the pages is open to the world while other is only accessible to authenticated role. This is a 11.1.2.4 application but the same should work in other versions.