FROM THE BLOG

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. 

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

adf_programatically_login_01

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

adf_programatically_login_04

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.

adf_programatically_login_08

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

adf_programatically_login_07

And home page;

adf_programatically_login_09

Leave a comment

Your email address will not be published. Required fields are marked *

Social Media

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