1 package org.apache.turbine.pipeline; 2 3 56 57 import java.io.IOException ; 58 import java.util.Enumeration ; 59 import java.util.ArrayList ; 60 import java.util.List ; 61 import java.util.Iterator ; 62 import javax.servlet.http.HttpSession ; 63 64 import org.apache.turbine.Turbine; 65 import org.apache.turbine.TurbineConstants; 66 import org.apache.turbine.RunData; 67 import org.apache.turbine.TurbineException; 68 import org.apache.turbine.ValveContext; 69 import org.apache.turbine.modules.Action; 70 71 79 public class DefaultLoginValve 80 extends AbstractValve 81 implements TurbineConstants 82 { 83 88 public DefaultLoginValve() 89 throws Exception 90 { 91 } 92 93 96 public void invoke(RunData data, ValveContext context) 97 throws IOException , TurbineException 98 { 99 try 100 { 101 process(data); 102 } 103 catch (Exception e) 104 { 105 throw new TurbineException(e); 106 } 107 108 context.invokeNext(data); 110 } 111 112 118 protected void process(RunData data) 119 throws Exception 120 { 121 String actionName = data.getAction(); 127 if (data.hasAction() && 128 actionName.equalsIgnoreCase 129 (Turbine.getConfiguration().getString(ACTION_LOGIN)) || 130 actionName.equalsIgnoreCase 131 (Turbine.getConfiguration().getString(ACTION_LOGOUT))) 132 { 133 if (actionName.equalsIgnoreCase 145 (Turbine.getConfiguration().getString(ACTION_LOGIN))) 146 { 147 Enumeration names = data.getSession().getAttributeNames(); 148 if (names != null) 149 { 150 List nameList = new ArrayList (); 153 while (names.hasMoreElements()) 154 { 155 nameList.add(names.nextElement()); 156 } 157 158 HttpSession session = data.getSession(); 159 Iterator nameIter = nameList.iterator(); 160 while (nameIter.hasNext()) 161 { 162 try 163 { 164 session.removeAttribute((String )nameIter.next()); 165 } 166 catch (IllegalStateException invalidatedSession) 167 { 168 break; 169 } 170 } 171 } 172 } 173 174 Action action = (Action) Turbine.getResolver() 175 .getModule( ACTIONS, actionName ); 176 177 action.execute(data); 178 data.setAction(null); 179 } 180 } 181 } 182 | Popular Tags |