How to handle redirect sent by OpenSSO

Hi,

My application uses OpenSSO for authentication and session management. Every httprequest will be intercepted by OpenSSO’s agent, and if session expired, agent would sent redirect to the login page.

My question is, is there any feature in SmartClient to handle this in system-wide way, so I don’t need to code this in every smart client call ( whether it’s AJAX call or JSON or any remote call ).

What I have in mind in terms of code snippet is like this ( I don’t know how to do it in SmartClient, so I just use pseudocode ) :

// register window.document to listen to global event.
// this global event will be generated by javascript library after completion of AJAX call
// whenever session timeout, OpenSSO would set http header named ‘Set-Cookie’, with value contains ‘Path=/websso’ , so I just need to check this value after every AJAX call.

$(document).ajaxComplete(function(xmlHttpReq,options){
// check whether the header contains ‘Set-Cookie’
var set_cookie = xmlHttpReq.getResponseHeader(“Set-Cookie”);
if(set_cookie!=null){
if(set_cookie.indexOf(“Path=/websso”)!=-1){
// if yes, AJAX will redirect to logout URL

location.href=“http://logout_url.com”;
return false;
}
}
});

After I setup this, any AJAX call in any page will always call this code automatically, because the library will always generate ajaxComplete event globally. So I don’t need to code it in every AJAX call.

I tried with RPCManager.handleError, but it seems it doesn’t work like I expected.
Thank you in advance.

Support for this interaction is designed into SmartClient. See Relogin.

thanks for your reply.
I have read it, but unfortunately it seems this solution can’t be implemented because of this :

"To enable SmartClient to detect that session timeout has occurred, a snippet of HTML called the loginRequiredMarker must be added to the session timeout response sent by the authentication system. "

Authentication system is something that I can’t touch, so it should be as it is. Is there any other way to do this without I have to touch the authentication system ?

Including the loginRequiredMarker on the login page makes no perceptible difference in the appearance or behavior of the page. This is much simpler than trying to add a cookie or similar as you suggested before. Both involve configuration changes to the authentication system, but the marker is less invasive.

Ok, so it seems loginRequiredMarker is the most ideal solution. Is there any other alternative other than this, in case loginRequiredMarker not possible to be implemented ? Is this loginRequiredMarker only works for RPC ? Is it working for DataSource based call as well ? Thank you.

It works for all types of calls (see the docs).

We have implemented relogin in a lot of scenarios, and using markers has the broadest compatibility. If you actually run into a situation where another approach is needed, please let us know.

Hi, thanks for your suggestion. I’ve tried it in my environment, but since my websso use frameset for the login page, and I don’t have access to modify the frameset parent ( only 1 frameset child that I can change ), this solution doesn’t work. Any experience to embed this chunk of code to frame child ?

You can modify a frameset with the loginRequiredMarker without affecting it’s functionality.

If you have some kind of political situation preventing you from doing so, take a look at the actual contents of the loginRequiredMarker and it should be clear what to do. Best of luck.

Hi chr1sk,

Did u find urself clear on this thing.. ?? even i need to handle the same.

ISomorphic,

I can’t modify the login code as i am also using websso . Any alternate solution for this ??