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 application but the same should work in other versions. 

Now, the flow is simple, this is the adfc-config.xml;


In this case, home page is only available after authentication is done. Our Jazn-data looks like this:

adf_programatically_login_10 adf_programatically_login_11

Now, all magic happens on the login page and its managed bean;

adf_programatically_login_02 adf_programatically_login_03


Since this code was used in an old application, you can safely replace the deprecated method SimpleCallbackHandler for URLCallbackHandler.

Our login page only shows, using the securityContext if the user is authenticated and what is the user’s user name.


Running the application, with a username and password that exists in the WLS auth provider;


And home page;


Leave a comment

Your email address will not be published.

Social Media

Stay up-to-date with our latest ADF and related technical posts via your favourite social network services.