0

I am developing a web application using Oracle ADF. In my web application user has to log in to access web application. Application is working fine. Now I need to enable a feature like once a user has logged In and due to some reasons he closed a tab not the browser. So whenever he try to access the same application he do not need to login again. Since browser has not closed the user has to be automatically logged in.

For this I googled a lot and got information that we can achieve this using browser cache and servlet filters. I got information from This Stackoverflow question. But I don't know how to implement Filters and all in Oracle ADF web application. Please help on this.

Thanks in advance.

Community
  • 1
  • 1
Abdul
  • 1,130
  • 4
  • 29
  • 65

1 Answers1

1

If the user is closing ONLY the tab containing the application, but not the browser, the user doesn't need to login again - this is how authentication works with Java Servlet API and ADF is built on this API. This happens because all browser tabs share the same http session and JSESSIONID cookie is stored at session level.

You can try logging on, close the tab, open another tab and type in the url directly to your home page (.../faces/main.jsf). This should get you in without login required.

Florin Marcus
  • 1,657
  • 1
  • 12
  • 11
  • Thanks for you time. In my application first page is index.jsf . I have created a bounded task-flow called login-flow.xml. In this task-flow default activity is login.jsf. I have dropped this bounded task flow as a region on to index.jsf. So when ever I type the url ../faces/index.jsf its showing me default activity, that is login.jsff. After logging in I closed the tab and retyped the url and getting the same login.jsff page. Please help. – Abdul Mar 12 '15 at 09:01
  • In such case, I think the quickest way to solve this problem is to refactor your task flow this way: Add a Router Activity as default activity in your task flow, having the condition: ADFContext.getCurrent().getSecurityContext().isAuthenticated() When above expression returns false, direct the router to login.jsf, otherwise go directly to your fragment after authentication. – Florin Marcus Mar 12 '15 at 14:11
  • Thanks a lot for your help. In my app I tried you Solution. But Always am getting default activity of the router activity(I think ADFContext... == 'false' is not working and I tried without quotes also). One thing I have to tell you am not using ADF Authentication. I have three activities in login-flow. 1.login.jsff, 2.router, and task-flow-call. When the user give his credentials I have a bean that validates and if credentials are valid I am routing to task-flow-call other wise am routing to login.jsff. Once again thank you very much for your time. Please suggest me on this what can be done. – Abdul Mar 13 '15 at 05:30
  • Thanks for your help. I achieved this feature using browser cookies. Am using your router logic and saving some cookies using bean. I got logic to store cookies from this post https://oralublog.wordpress.com/2014/08/19/adf-tips-cookies-in-adf/. Any how thanks a lot for your help... Thank you very much. – Abdul Mar 13 '15 at 09:47
  • Whatever type of security you are using, that security must have a way of saying user is authenticated or not. So, you need to replace ADFContext.getCurrent().getSecurityContext().isAuthenticated(), with your own logic. – Florin Marcus Mar 13 '15 at 09:49