{
int uid = userEnv.getUid();
if (uid != UserEnvironment.ANONYMOUS_UID)
{
AuthenticationManager authMgr = (AuthenticationManager) req.getService(AuthenticationManager.ROLE,
"*");
authMgr.setUsername(userEnv.getLoginName());
authMgr.setPassword("");
authMgr.setDomain(userEnv.getDomain());
HashMap map = new HashMap();
map.put("request", req);
map.put("response", res);
map.put("remember", new Boolean("off"));
map.put("configuration", getConfiguration());
authMgr.setOtherConfig(map);
//Clear cookies if the clear-cookies config. attribute is true
boolean clearCookies = configuration.getAttributeAsBoolean("clear-cookies", true);
if (clearCookies)
{
HashMap cookies = new HashMap();
cookies.put(getLoginCookieName(configuration), "");
cookies.put(getPasswordCookieName(configuration), "");
cookies.put(getDomainCookieName(configuration), "");
res.setAttribute("cookies", cookies);
}
try
{
authMgr.logout(userEnv);
}
catch (Exception ee)
{
log.error("Logout Error", ee);
throw new ModelException(ee);