Sunday, February 8, 2015

Custom Login Page using Login Bean in ADF

In most of the Oracle ADF Applications, applications have a customized login page which is specific to the application.

While configuring ADF Security, it generates a default Login and Error page which is good for testing the environment. But for actual applications , Customized Login page is required for the application. In this post we will be looking at it.

Use Case
Creating a customized login page and login the user programmatically using Managed Bean.

Lets get started.

Created a simple ADF Application CustomLoginApplication.

It consist of two JSPX pages. Custom Login and Landing page. Below is the code for custom login page.





And below is the code for LandingPage jspx.


As seen in CustomLogin page, reference to LoginBean is there. On Login Button, it calls doLogin() method of LoginBean.

Below is the code for LoginBean.



This is the heart of login and redirecting it to the landing page. Do make sure to add fctx.responseComplete(); at the end of the method else you will get Exception : Response already committed.

Now lets configure ADF Security. We need to provide our customized page as login page and error page which also we have created.



Do defaults in next screen and do a finish.

You need to provide anonymous role to CustomLogin.jspx and authenticated role to LandingPage.jspx.

Thats it. Lets Run the application (CustomLogin.jspx) and login with weblogic user.




Enter credentials for weblogic user (or any user in security realms ) .


It redirects to the LandingPage successfully. 



Application can be downloaded at: CustomLoginApplication

Thanks !!




10 comments:

  1. Thank you very much for sharing this post. It's very clear and easy to follow.
    Maybe some time you could also shed light in the setup of the LDAP repository in weblogic.
    Thanks a lot

    ReplyDelete
  2. Thanks Apostolos,

    I will be writing on LDAP Providers in weblogic and its API's very soon.

    Thanks
    Rohan

    ReplyDelete
  3. very nice post, thank you for posting this.
    for Latest Tech News check my blog Latest News Update 24x7.

    ReplyDelete
  4. what changes are to be acquired when my username and password are stored in a database table, how do I validate the presence of username and password combo and then take the desired navigation

    ReplyDelete
  5. Hi Rahul,
    I am a beginner in ADF, and I am doing a project on it.I want to perform login with the data stored in the database and also want to apply adf security on it.Will you please tell me how to do this?

    ReplyDelete
  6. how to write a register form which enters data into database table in adf

    ReplyDelete
  7. Hi Rahul,
    I am a beginner in ADF, and I am doing a project on it.I want to perform login with the data stored in the database and also want to apply adf security on it.Will you please tell me how to do this?

    ReplyDelete