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. 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
  4. 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
  5. how to write a register form which enters data into database table in adf

    ReplyDelete
  6. 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
  7. hi login ok. I need logout also

    ReplyDelete
  8. last month he share is herbal medicine in some medical hospital and now he is well recognize as one of the best in West Africa, you don’t have to be sad any more or share your tears any more on this virus when the cure have already be find in 2013 if you want to get in touch with him in private contact him on his email dr.chalaherbalhome@mail.com Or you can visit his website on https://
    drchalaherbalhome.godaddysites.com or https://mywa.link/dr.chalaherbalhome

    ReplyDelete