Tuesday, October 30, 2012

ADF Mobile - Login Functionality

This post will be about new Oracle product - ADF Mobile. While ADF Mobile is deployed as native application, ADF Mobile Browser option is available as well - it allows to build lightweight ADF UI pages and host them on central server (check my previous post from 2011 about ADF Mobile Browser - iPhone Web Application Development With ADF Mobile Browser). New ADF Mobile approach with native deployment is cool when you want to access phone functionality (camera, email, sms and etc.), also when you want to build mobile applications with advanced UI. Same time ADF Mobile Browser remains very important for enterprise customers, because it simplifies development, deployment and maintenance procedure. If you want to expose simple worklist with approval/rejection to mobile interface, it would work just fine with ADF Mobile Browser approach (as per blog post above).

Today I will talk about new ADF Mobile and about Login functionality implementation (read more about it from ADF Mobile developer guide - 17.3 Introduction to Authentication). I will go step by step and describe how sample application is implemented - adfmobilelogin.zip. This archive contains two applications:

1. ADFBasicAuthApp - typical ADF application with basic ADF security authentication enabled. This application will be used as authentication server

2. ADFMobileSecuredApp - ADF Mobile application, with deployment profile for iOS simulator. Implemented secured home page and contains configuration for login page

Firstly I will describe ADFBasicAuthApp, this application contains single ADF page and is enabled with standard ADF Security - ADF Authentication option:


jazn-data.xml contains one registered user (we will test ADF Mobile login with this user) - redsam:


Page - index.jsf, is granted with authenticated access:


Application is deployed on the server and is accessible through URL:


You can see that URL is pointing to our index page. We will use the same URL for ADF Mobile Login functionality configuration. ADF Mobile is authenticating against remote authentication server (our ADF application with basic ADF Authentication) - username/password is passed from ADF Mobile Login page to access protected URL. If access is successful - user is allowed to access ADF Mobile application as well.

We move now to the second part - ADFMobileSecuredApp application. This one is quite basic ADF Mobile application, it contains single ADF Task Flow and page:


There is one feature defined, it is mapped with the ADF Task Flow (it renders home.amx page):


This feature is configured with remote credential authentication (authentication is done with remote secured application - ADFBasicAuthApp application enabled with basic ADF Authentication):


Login page behavior is configured in adfmf-application.xml file. ADF Mobile offers default login page, there is no need to build it (although you can build custom login page also, if you need it) - keep Default option:


We have only one feature, it is listed in Authentication and Access Control section - com.redsamurai.home. We should define Login Server Connection for this feature and point to our remote authentication application:


As you can see - Login URL points towards index.jsf, this is ADF Security protected page from ADFBasicAuthApp. If mobile user will be able to login into this application, user will be granted access to the mobile application also. You should specify JSESSIONID cookie, if authenticating against WebLogic server.

These are main steps in configuring Login for ADF Mobile application.

Here you can see how default Login page looks in iPhone simulator:


Try to login with un-existing user - sking:


It reports error about invalid username/password, as it was expected:


Provide now valid user - redsam/welcome1:


Authentication with remote ADF application is successful, home page is loaded:


59 comments:

Ravi Narayanaswamy said...

Andrejus,

Thanks for the post.

Can you please let us know how can we authenticate users present in weblogic realm in ADF browser/client based?

Regards,
Ravi

Andrej Baranovskij said...

Hi,

May be this blog will help you: http://andrejusb.blogspot.com/2011/10/iphone-web-application-development-with.html

Andrejus

Anonymous said...

Hi Andrejus,
We tried deploying the application on to Android simulator, apparently the Default Login Page fails to appear, instead a blank page shows up without any option for accepting user credentials. Are we missing out any steps or the default login page only comes up for iOS simulator ?

Regards
Naveen

Andrej Baranovskij said...

Did you tested on your environment with iOS simulator? I wasnt testing with Android simulator, but it should work - unless there is a bug.

May be Android simulator is not configured as per docs.

Andrejus

Ravi said...

Andrejus,

We had no luck to try this in Android device, its says login failed for no reason.

And can you please give some pointers how can we authenticate from ADF Mobile with users defined in weblogic?


Regards,
Ravi

Andrej Baranovskij said...

Hi Ravi,

This blogs describes how to authenticate with users defined in WebLogic.

Did you deployed - ADFBasicAuthApp and check URL's are correct in connection.xml file from ADFMobileSecuredApp. You will have different IP, change it to point to your WebLogic.

Andrejus

Ravi said...

Andrejus,

We have deployed basic auth on our weblogic server and we are able to access the same url from the device, which prompts for credentials.

And same url is provided in adfmf-application.xml by editing the security server connection.
When tested connection it says Successful. And aslo we have verified the connections.xml having same url.

But when deployed into Device, no luck.

I meant how can we authenticate against users present in web logic realm.

Regards,
Ravi

Andrej Baranovskij said...

It works for me on iPhone simulator and from iPhone device also.

Please test if it works on your environment from Android simulator.

Sample app from this blog authenticates against users present in WebLogic security realm. It is tested with iPhone simulator and real device.

Andrejus

Ravi said...

Andrejus,

No luck, same issue in emulator as well.
And even i tried with projects creation which resulted in same error.

My JDev Ver: 11.1.2.3.0

Andrej Baranovskij said...

This means something is not right on your environment.

There is no other version, only JDev 11.1.2.3.0 supports ADF Mobile.

Andrejus

Ravi said...

Andrejus,

Noticed that when the login url service is down, we get "Cannot Connect to login server. Check the network and try again" error message.

And when the service is UP, we get "Authentication error with unknown issue".

Can you please let us know if we can debug this issue?


Regards,
Ravi

Andrej Baranovskij said...

This means your basic ADF authentication is wrong.

Andrejus

Andrej Baranovskij said...

Or also possible that ADF Mobile application is not configured properly to get authentication info. What server you are using for authentication - WebLogic?

Andrejus

Ravi said...

Andrejus,

Yes, its weblogic 10.1.3.5 64 bit.

Regards,
Ravi

Andrej Baranovskij said...

Are you able to login to ADFBasicAuthApp from desktop browser?

Andrejus

Ravi said...

Andrejus,

We are able to login (any user deined in weblogic realm) into ADFBasicAuthApp from desktop browser and also mobile browser as well.

Regards,
Ravi

Andrej Baranovskij said...

Then I don't see any reason why it doesnt work :)

Andrejus

Ravi said...

Andrejus,

I was about to bang my head and throw my device, but last try saved me :)
phew!!!!

Since your ADFBasicAuthApp was in JSF 2.0, i had migrated to downgrade to JSF 1.2 and deployed in weblogic, during that process the below line got missed from jps-config.xml file. I believe this is MY MISTAKE , as migration does not delete it.



So now i am able to authenticate any user defined in weblogic realm.

I sincerely appreciate you for constantly replying to my queries.

Regards,
Ravi

Andrej Baranovskij said...

Perfect ! :-)

Ravi said...

Andrejus,

May be the last question in login usecase, how can we achieve LOGOUT functionality here.

I see in Dev guide, stating to call java class. Can you please let me know on this?

Regards,
Ravi

Ravi said...

Andrejus,

I tried adding a button in home.amx and registered a JavaBean to the action property, binding bean method logOut which has AdfmfJavaUtilities.logout();

public String logOut() {
AdfmfJavaUtilities.logout();
return null;
}

This seems to be doing the job :)

Can you please confirm?

Regards,
Ravi

Andrej Baranovskij said...

I will put this on my todo list.

Andrejus

Ravi said...

Andrejus,

And also it would be great if you can let us know how can be display different icons in Login Form and Home page.

Regards,
Ravi

Unknown said...

When I am trying to deploy the ADFBasicAuthApp in weblogic I am getting the error

Please help. Let me know what I am doing wrong.

Andrej Baranovskij said...

This means your server is not configured with ADF 11g R2 libs. Application is very basic, is just plain ADF app - it should work nicely.

What error you are getting?

Andrejus

Unknown said...

Thanks for the reply. I am getting the following error.

10:30:23 PM] Weblogic Server Exception: weblogic.application.ModuleException: Failed to load webapp: 'adfbasicauth'
[10:30:23 PM] Caused by: weblogic.management.DeploymentException: Error: Unresolved Webapp Library references for "ServletContext@1031007444[app:ADFBasicAuthApp_Project1_ADFBasicAuthApp module:adfbasicauth path:/adfbasicauth spec-version:2.5]", defined in weblogic.xml [Extension-Name: jsf, Specification-Version: 2, exact-match: false]
[10:30:23 PM] See server logs or server console for more details.
[10:30:23 PM] weblogic.application.ModuleException: Failed to load webapp: 'adfbasicauth'
[10:30:23 PM] Deployment cancelled.
[10:30:23 PM] ---- Deployment incomplete ----.
[10:30:23 PM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)

Andrej Baranovskij said...

Yes - this is WebLogic configuration error. You should open WebLogic console in the browser, navigate to Deployments section and open jsf 2.0 library. In the Targets sections make sure checkbox is set for your Managed Server.

Andrejus

Unknown said...

Hi,

We are trying to install weblogic server individually and would like to use it for Mobile ADF. Please suggest which version of weblogic and jdeveloper to use which is compatible to each other. Do we need to apply any new patches after installinh these two components.

Regards

Joseph Bazil

Unknown said...

Hi!

You have really supreme things here, but this ADF mobile sample simply does not work correctly or I misunderstood something.

I also read this URL: http://docs.oracle.com/cd/E35521_01/doc.111230/e24475/security.htm.

If I understand correctly ADF mobile should work like this: you login into server on some link and retrieve session cookie (JSESSIONID). Now on all other requests, when you call secured web service(s), you send JSESSIONID cookie to the server, the server recognizes you and sends you data back - so login is perfomed only once.

I deployed your sample to server and build my own (tried two servers) and behaviour is the same. ADF mobile does NOT send JSESIONID in web secured service calls - so authentication is performed again and again and again (i see different session ID each time I invoke web service). I checked the requests of web services calls and Cookie JSESSIONID=someNumber is not present in the header of HTTP request. But in header of SOAP request there is a username and password present and based on that data the login is executed at every call of web service.

Question for you is: is this correct behaviour when you call web service from ADF mobile? What's then the point of JSESSIONID cookie in ADF mobile if it is not used in web service calls? The webservice calls and ADF mobile client bahves the same even if I remove JESSIONID from project configuration. Can you comment please?

P.S: if I create normal ADF mobile application with username/password authentication and browse pages, JSESSIONID cookie is used and work correctly.

Andrej Baranovskij said...

Hi, i provide only working samples :) i will reply to your questions after holidays.

Andrejus

Andrej Baranovskij said...

Hi Leon,

This sample application demonstrates only ADF mobile app login. Web Service secured access is implemented here - http://andrejusb.blogspot.com/2012/11/adf-mobile-secured-web-service-access.html

Make sure adfCredentialStoreKey is set correctly to the same value for Login and Web Service connections.

Regards,
Andrejus

Anonymous said...

Hi,

How are you? I had gone thru your blogs written for ADF Mobile Application development. They are nice and helpful

Now I am trying to connect thru REST to access Fusion CRM WS : PersonService. When I am creating URL Service Data Control. Getting below error, I’m unable to proceed.

Last time I tried thru SOAP and using Web Service Data Control. Got attached error when I call createPerson() from ADF Service WSDL : PersonService (attached WSDL)

Fusion CRM – Person Service WSDL by using URL

https://crm-aufsn4x0iwf.oracleoutsourcing.com//foundationParties/PersonService?WSDL

PFA error screenshots and SOAP Request & Response XMLs. Can you please help me how to overcome these errors. Thanks a bunch in advance for all your help and time.
Is there any sample built for consuming Fusion CRM Web Services (NOT with On-Premise)? If you have any can you please share the sample. My CONTACTS : bhaskara.sannapureddy@crmit.com / +91-9008466722

Andrej Baranovskij said...

Hi,

I would suggest first to test with regular ADF application, to check if Web Service works. Only then try to access it from ADF Mobile.

Andrejus

Praveen S K said...

Hi Andrejus,

I followed exactly similar steps to add secured login functionality to my Mobile App. But Login doesn't seem to work. However, I am able to Login into the Authentication server URL through Mobile browser. Not sure what is missing. Login Screen from Auth Server is prompted but on giving right credentials, I am unable to Login.

Would you pls suggest any alternatives..?

Thanks,
Praveen S K

Anshul said...

Hi Andrejus,

I have successfully implemented the adf login functionality with weblogic server as described in your post, but further i need user authorization, can you please tell how?

Regards,
Anshul

Unknown said...

Hi Andre,

I was able to deploy both ADFMobilesecuredApp and ADFBasicAuthAPP to my server successfully. When I run the app from the simulator, after I put my user name and password, it comes up with the message saying

Thanks

Andrej Baranovskij said...

Check if there is any log printed on ADFBasicAuthAPP application side. Also check if redsam user was created in WLS.

Andrejus

Anonymous said...

Andrejus,

Thank you for the post.

I want to configure the ADF Mobile app being authenticated with our corporate active directory which is MS AD 2008. When using standard URL "ldap://abc.com/ou=users,ou=ppl,dc=dev,dc=uws,dc=edu,dc=au" (no quotes) and Testing Connection, I get "Login URL is invalid." message.

All tutorials online and documentation refer strictly to WebLogic authentication. Please help on how to configure ADF Mobile authentication using MS AD.

Regards,
Ravi

Andrej Baranovskij said...

I doubt if this is supported.

Andrejus

Sureshbabu Rajendiran said...

Hi,

How to get the username and password to get the intial workFlow context...

Without getting logged-in user's context this doesn't looks like a working solution.

Kindly let me know your suggestions on this ...


Regards,
Suresh

Brunno said...

Hi Andrejus,
I was able to deploy succesfully to Android emulator.
First time i tried didn´t work. Login screen just wasn´t showing.
Then i realized that in adfmf-application.xml in the security tab, the Login Server Connection you created wasn´t selected on the Application Login Server list.
Just select and the app works fine.

Regards,
Brunno


Andrej Baranovskij said...

I think it was selected, may be JDev unselected it in your computer.

Andrejus

Anonymous said...

Hi,

Can you just guide how to integrate ADF Mobile Login functionality using REST webservice which accept username & password and validate those with database values and return the response accordingly.

Thanks in advance

Regards
Ashish

Anonymous said...

Hi Andrejus,

I have tried deploying your sample application to Android emulator, but the login page did not appear. Only a blank page shows up without any option for accepting user credentials.

Also checked that ADFBasicAuthApp has been deployed successfully to WebLogic server and the URL's are correct in connection.xml. Am able to login to ADFBasicAuthApp from desktop browser as well as from mobile browser.

Will there be any missing steps or libraries? Appreciate your advice and guidance on this.

Thanks,
PS

Andrej Baranovskij said...

Hard to say, as I was testing with iPhone only.

Andrejus

Anonymous said...

Hi PS,
I had the same problem. If I tried the sample on my Mac with iOS it worked fine. Then I tried the same on Windows with Anroid. No luck, black screen. After some investigations I found in adfmf-application.xml on tab security the field "Application LoginServer" was empty. I choose ADFBasicAuthAccess and tried again and it worked.

Good luck
Peter

Anonymous said...

How is the user credentials passed to the remote URL? also i'm getting null pointer exception when i deploy. Could you tell me where i'm going wrong

Xanthros said...

Thanks Andrejus for the great post. I'm not sure why other people keep posting that they aren't getting this to work on an Android device or the emulator. I had no issues.

Andrej Baranovskij said...

Great ! Thanks for update Xantros.

Andrejus

Unknown said...

Hi,Andrejus.Now,I am trying to complete a custom login page.But there are some problems.I copied the default login page file that generated when i deploy the app to iphone simulator to the finder(ApplicationController/public_html),and changed the security properties in adfmf-application.xml.Then redeploy the app.However,this file does not work correctly.All css files and javascript files are not loaded.So,I copy all file needed to the same finder. Finally the login file work correctly,but when i deploy the app to Android platform,it does not work.So what's the problem?Could you help to find it out?Thanks.

Andrej Baranovskij said...

Not sure. As per Xanthros reader comment above - it works for him on Android.

Andrejus

Anonymous said...

Hi Andrejus,

when deploying ADFBasicAuthApp in weblogic server i am etting exception like oracle.adf.view.faces.bi.webapp.MapProxyServlet.
I am using jdev 11.1.2.3 and trying to deploy into wls 11.1.1.6.0
Please help me.

Anonymous said...

Hi Andrejus,

Did you update ADF mobile extension with patch 5,
11.1.2.4.39.64.62.

If you did can you test your sample and try to login second time? It seems bug there, it would say the login server is not reachable. I have demo with same issue for second time login.

Andrej Baranovskij said...

Didn't had time to look into it yet.

Regards,
Andrejus

Unknown said...

Hi Andrejus,

I have an ADF application secured with FORM BASED authentication. I'm noticing that every documentation refers the use of basic auth.

Is it posible to use ADF Mobile authenticating through this method? If so...how?

Thanks in advance!

Unknown said...

Hi Andrejus,

I am trying to implement login functionality. But on deploying to android emulator, it says cannot connect to server. Could you please tell me how to fix it.I am using jdeveloper 11.1.2.4.0.

Thanks

Andrej Baranovskij said...

I was testing it with iOS only, not sure about Android.

Andrejus

Anonymous said...

Hello Andrejus,

I'm trying to save the session that the user will be in after successful login, so that the application will not abort/stop once the user hits the back button on an android device.

It seems that the "stop()" method in the lifeCycleListenerImp class is always fired on the back button press.

Can you provide us with pointers on this subject? much appreciated.

Anonymous said...

hello

How can we do this when application uses facebook or google credentials to login?