📄 tokeninterceptor.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: TokenInterceptor.java
package org.apache.struts2.interceptor;
import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import org.apache.commons.logging.Log;
import org.apache.struts2.util.TokenHelper;
public class TokenInterceptor extends MethodFilterInterceptor
{
private static final long serialVersionUID = 0xa348b21a6fbce95eL;
public static final String INVALID_TOKEN_CODE = "invalid.token";
public TokenInterceptor()
{
}
protected String doIntercept(ActionInvocation invocation)
throws Exception
{
if (log.isDebugEnabled())
log.debug("Intercepting invocation to check for valid transaction token.");
java.util.Map session = ActionContext.getContext().getSession();
java.util.Map map = session;
JVM INSTR monitorenter ;
if (!TokenHelper.validToken())
return handleInvalidToken(invocation);
handleValidToken(invocation);
map;
JVM INSTR monitorexit ;
return;
Exception exception;
exception;
throw exception;
}
protected String handleInvalidToken(ActionInvocation invocation)
throws Exception
{
Object action = invocation.getAction();
String errorMessage = LocalizedTextUtil.findText(getClass(), "struts.messages.invalid.token", invocation.getInvocationContext().getLocale(), "The form has already been processed or no token was supplied, please try again.", new Object[0]);
if (action instanceof ValidationAware)
((ValidationAware)action).addActionError(errorMessage);
else
log.warn(errorMessage);
return "invalid.token";
}
protected String handleValidToken(ActionInvocation invocation)
throws Exception
{
return invocation.invoke();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -