1 5 package com.opensymphony.webwork.interceptor; 6 7 import com.opensymphony.webwork.ServletActionContext; 8 import com.opensymphony.webwork.util.InvocationSessionStore; 9 import com.opensymphony.webwork.util.TokenHelper; 10 import com.opensymphony.xwork.ActionInvocation; 11 import com.opensymphony.xwork.Result; 12 import com.opensymphony.xwork.util.OgnlValueStack; 13 14 import javax.servlet.http.HttpServletRequest ; 15 16 17 20 public class TokenSessionStoreInterceptor extends TokenInterceptor { 21 23 28 protected String handleInvalidToken(ActionInvocation invocation) throws Exception { 29 HttpServletRequest request = ServletActionContext.getRequest(); 30 String tokenName = TokenHelper.getTokenName(request); 31 String token = TokenHelper.getToken(tokenName, request); 32 33 if ((tokenName != null) && (token != null)) { 34 ActionInvocation savedInvocation = InvocationSessionStore.loadInvocation(tokenName, token); 35 36 if (savedInvocation != null) { 37 OgnlValueStack stack = savedInvocation.getStack(); 39 ServletActionContext.getRequest().setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, stack); 40 41 Result result = savedInvocation.getResult(); 42 43 if ((result != null) && (savedInvocation.getProxy().getExecuteResult())) { 44 result.execute(savedInvocation); 45 } 46 47 invocation.getProxy().setExecuteResult(false); 49 50 return savedInvocation.getResultCode(); 51 } 52 } 53 54 return INVALID_TOKEN_CODE; 55 } 56 57 62 protected String handleValidToken(ActionInvocation invocation) throws Exception { 63 HttpServletRequest request = ServletActionContext.getRequest(); 65 String key = TokenHelper.getTokenName(request); 66 String token = TokenHelper.getToken(key, request); 67 InvocationSessionStore.storeInvocation(key, token, invocation); 68 69 return invocation.invoke(); 70 } 71 } 72 | Popular Tags |