1 package org.apache.turbine.modules.actions; 2 3 56 57 import javax.servlet.http.HttpSession ; 58 59 import org.apache.turbine.Turbine; 60 import org.apache.turbine.RunData; 61 import org.apache.turbine.modules.Action; 62 import org.apache.fulcrum.security.entity.User; 63 import org.apache.fulcrum.security.TurbineSecurity; 64 import org.apache.fulcrum.security.util.AccessControlList; 65 66 73 public class LogoutUser 74 extends Action 75 { 76 93 public void doPerform( RunData data ) 94 throws Exception 95 { 96 User user = data.getUser(); 97 98 if ( user != null ) 99 { 100 if (!user.hasLoggedIn() ) 102 return; 103 104 user.setHasLoggedIn( new Boolean (false) ); 105 TurbineSecurity.saveUser( user ); 106 } 107 108 data.setMessage(Turbine.getConfiguration().getString( 109 Turbine.LOGOUT_MESSAGE)); 110 111 data.setACL(null); 114 115 data.setUser( TurbineSecurity.getAnonymousUser() ); 117 data.save(); 118 119 HttpSession session = data.getSession(); 123 if (session != null) 124 { 125 try 126 { 127 session.removeAttribute(AccessControlList.SESSION_KEY); 128 } 129 catch (IllegalStateException invalidatedSession) 130 { 131 } 132 } 133 134 if (!Turbine.getConfiguration().getString(Turbine.ACTION_LOGOUT, "") 142 .equals("LogoutUser")) 143 { 144 data.setTarget(Turbine.getConfiguration().getString( 145 Turbine.TEMPLATE_HOMEPAGE)); 146 } 147 } 148 } 149 | Popular Tags |