IazertyuiopI
IazertyuiopI

Reputation: 488

Automatically relogging in to a realm after connection loss in IBM Worklight

My problem is as follows :

I have an application protected by a mobile security test involving a LDAP server. The corresponding realm is called LDAPrealm. I use the form-based authenticator + custom LDAP login module.

When the connection to the worklight server is lost and then re-established, I see that the current user is not authenticated in the LDAP realm anymore.

What I want is be able to re authenticate the user without having him enter credentials again.

However, since the user is still authenticated for other realms included by default in the mobile security test, the worklight server does not challenge the client again for credentials, which is causing j_security_check error when trying to submit credentials.

As a side note those credentials are stored in the encrypted json store for offline authentication and use of the app.

So my question is : Is it possible to force the server to challenge the client again for this LDAPrealm and use submitLoginForm to re-log in?

More generally, is there a way to clear a user+device from all realms before trying to log in again?

Edit reasons : previous error was caused by a typo

Upvotes: 4

Views: 249

Answers (1)

IazertyuiopI
IazertyuiopI

Reputation: 488

In the case where the user first logs in online then loses connection then get connection again, calling

WL.Client.logout("LDAPRealm",{onSuccess:stealthed_relog});

and calling WL.Client.connect() later in stealthed_relog before sending credentials seems to wield the desired behaviour.

However, when the user logs in offline and then gets connection, when I try to use WL.Client.connect(), it says another instance of WL.Client.connect has already been called.

edit : for the log offline case, the application get challenged automatically shortly after that the connected event fires (cause of heartbeat? I do not really know), so you just have to use

login_clientside.submitLoginForm();

to successfully log in again.

If someone has a better way to implement auto-reconnecting in worklight with ldap server, feel free to post it and I'll unaccept my answer.

Upvotes: 4

Related Questions