mirror of
https://github.com/apache/struts.git
synced 2026-08-11 09:36:57 +00:00
b0413aa7d4
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_1@462588 13f79535-47bb-0310-9956-ffa450edef68
32 lines
831 B
Java
32 lines
831 B
Java
package mailreader2;
|
|
|
|
import com.opensymphony.xwork2.interceptor.Interceptor;
|
|
import com.opensymphony.xwork2.ActionInvocation;
|
|
import com.opensymphony.xwork2.Action;
|
|
import java.util.Map;
|
|
import org.apache.struts.apps.mailreader.dao.User;
|
|
|
|
public class AuthenticationInterceptor implements Interceptor {
|
|
|
|
public void destroy () {}
|
|
|
|
public void init() {}
|
|
|
|
public String intercept(ActionInvocation actionInvocation) throws Exception {
|
|
|
|
Map session = actionInvocation.getInvocationContext().getSession();
|
|
|
|
User user = (User) session.get(Constants.USER_KEY);
|
|
|
|
boolean isAuthenticated = (null!=user) && (null!=user.getDatabase());
|
|
|
|
if (!isAuthenticated) {
|
|
return Action.LOGIN;
|
|
}
|
|
else {
|
|
return actionInvocation.invoke();
|
|
}
|
|
|
|
}
|
|
}
|