How to force cAD session end with user logout

Hi all,

We need to add user permissions control depending on user profile to our application. After authentication, we add the user profile to the session context (ILookupContext) and each adapter uses this profile to build the page according the profile.

The problem appears when we need to end the session on user logout. When user clicks the logout button, we clean the user information from the session context and we redirect to the Login page:

public void logout()
{
	ILookupContext sessionCtx = findSessionContext();
	sessionCtx.releaseAllReferences();
    Login adLogin = (Login) findAdapter(Login.class);
    adLogin.clearFiels();
    this.switchToPage("Login.html");
 }

Within this method I want to finish the session and destroy all the adapters. Searching the documentation I’ve found these possibilities
this.markThisSubsessionForDestroy();
endProcess()
destroy()
But none of them works.

How can I finish the session? In other words, how can I destroy all the adapters so that the user could change the profile at the Login page and enter into the application with new adapters and not see previous results?

Thanks in advance.

Hi there,

this is a method I implemented for a logout and it works quite ok.

public void doLogout(){

	ArrayList activeGuis;
	String subSessionId;
	
	IMFWorkplace workplace = (IMFWorkplace)mContext.lookup(IMFWorkplace.IWORKPLACE_LOOKUP, false);
	
	activeGuis = this.getUserSession().getRegisteredGUISessions();
	
	Iterator iter = activeGuis.iterator();
	
	//checkIfPageIsCurrentContentPage(String subSessionId, String pageName, String modelId);

	
	this.openCISPageInTarget("/"+Ajax4BpmConstants.PAGE_APPLICATION_NAME+"/emptypage.html", 
								Ajax4BpmConstants.WORKPLACE_BOTTOM);
	
	//Causes a certain frame target to refresh its data content		
	//refreshTarget(Ajax4BpmConstants.WORKPLACE_BOTTOM);
	//refreshScreenOccuranceOfAdapter(WorkListAdapter.class.getName());
	
	//Remove all pages from workplace
	
	while(iter.hasNext()){
		
		subSessionId = (String)iter.next();
		workplace.removePageFromWorkplace(subSessionId);
		
	}
	
	workplace.updateWorkplace(this);		
	this.getUserSession().logout();
	
	//Refresh left function tree
	this.updateFunctionTree();
	
	//Refresh Browser - call redirect jsp 
	openPageInTarget("../"+Ajax4BpmConstants.PAGE_APPLICATION_NAME+"/start.jsp","_top"); 
	
	this.closePage();
	
}

Hi Konstantin,

I’m having problems using your piece of code.

  • I can not find the method:
    getUserSession().getRegisteredGUISessions(); (none of them)

  • After this call, the object workplace is null:
    IMFWorkplace workplace = (IMFWorkplace)mContext.lookup(IMFWorkplace.IWORKPLACE_LOOKUP, false);
    We do not use Multi Frame Workplace layouts, we use HTML pages.

Hi there,

actually I put some sample code of our framework as an example.
Let’s take this offline. I wrote you an email.
Bye,
Konstantin

HI,

a very simple way to force the server side session to be removed is to load a plain html document (ie a non framework page) into a frame with ONUNLOADBEHAVIOR==REMOVESESSION. Example: with the given frameset definition…


<mfpage separation="rows" sizing="*">
    <mfcisframe target="AAA" cisurl="/myproject/login.html" unloadbehaviour="REMOVESESSION">
    </mfcisframe>
</mfpage>

…just call…


openPageInTarget("goodbye.html", "AAA");

…in any page adapter to remove the server side session. Typically you want to provide for the possibility to re-logon. For that just place a button into “goodby.html” that starts the frameset again…



<input type="button" value="Re-logon" onclick="../servlet/StartCISPage?PAGEURL=/myproject/mystarterframesetpage.html">

…where “mystarterframesetpage.html” is the file name of the aboves frameset.

Martin