venice-dynamo-rewrite/venice-data-sso/idp/scripts/logout.js

53 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.util);
importPackage(Packages.com.silverwrist.venice.session);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
req = bsf.lookupBean("request"); // get request
rhelp = bsf.lookupBean("request_help"); // get request helper
target = rhelp.getParameterString("tgt"); // get the target for this operation
if (target==null)
target = "top.js.vs";
vlib.setOnError(req,target);
session = rhelp.getSession(); // get the session
user = vlib.getUser(session);
if (!(user.isAnonymous()))
{ // dump the login cookie, if we have it set
cctrl = cast.queryCookieControl(req);
if (cctrl.isCookiePresent(venice_session.loginCookieName))
{ // get rid of the cookie and its associated cookie authentication, lest it clutter the database
source = session.getObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_COOKIE_AUTH_SOURCE);
user.clearAuthenticationData(user,VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"cookie",source);
cctrl.deleteCookie(venice_session.loginCookieName);
} // end if
session.invalidate(); // this dumps the entire session
// Now tell SourceID to log us out as well.
rc = new ForwardToPath("/sso/logout");
rc.setParameter("Return.Success","/top.js.vs");
rc.setParameter("Return.Failure","/top.js.vs");
dynamo.scriptReturn(rc);
} // end if
dynamo.scriptOutput(new Redirect("SERVLET",target)); // bounce back to the target