AdminAuthInterceptor.java
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:2k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package com.opensource.blog.web.interceptor;
  2. import net.sf.struts.saif.ActionHaveForwardInterceptor;
  3. import org.apache.struts.action.*;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import javax.servlet.http.HttpSession;
  7. import java.io.IOException;
  8. import javax.servlet.ServletException;
  9. import com.opensource.blog.comm.*;
  10. import com.opensource.blog.web.action.*;
  11. public class AdminAuthInterceptor
  12.     implements ActionHaveForwardInterceptor {
  13.   public AdminAuthInterceptor() {
  14.   }
  15.   /**
  16.    * beforeAction
  17.    *
  18.    * @param action Action
  19.    * @param actionMapping ActionMapping
  20.    * @param actionForm ActionForm
  21.    * @param httpServletRequest HttpServletRequest
  22.    * @param httpServletResponse HttpServletResponse
  23.    * @return ActionForward
  24.    * @throws IOException
  25.    * @throws ServletException
  26.    * @todo Implement this net.sf.struts.saif.ActionHaveForwardInterceptor method
  27.    */
  28.   public ActionForward beforeAction(Action action, ActionMapping actionMapping,
  29.                                     ActionForm actionForm, HttpServletRequest httpServletRequest,
  30.                                     HttpServletResponse httpServletResponse) throws IOException,
  31.   ServletException {
  32.       HttpSession session = httpServletRequest.getSession();
  33.       if (session.getAttribute(Constant.USER_SESSION_KEY) == null) {
  34.     ActionErrors errors = new ActionErrors();
  35.     errors.add("error.timeout", new ActionMessage("error.timeout"));
  36.     ActionUtils.addErrors(httpServletRequest, errors);
  37.     return actionMapping.findForward("login");
  38.   }
  39.   return null;
  40.   }
  41.       /**
  42.        * afterAction
  43.        *
  44.        * @param action Action
  45.        * @param actionMapping ActionMapping
  46.        * @param actionForm ActionForm
  47.        * @param httpServletRequest HttpServletRequest
  48.        * @param httpServletResponse HttpServletResponse
  49.        * @return ActionForward
  50.        * @throws IOException
  51.        * @throws ServletException
  52.        * @todo Implement this net.sf.struts.saif.ActionHaveForwardInterceptor method
  53.        */
  54.       public ActionForward afterAction(Action action, ActionMapping actionMapping,
  55.                                        ActionForm actionForm, HttpServletRequest httpServletRequest,
  56.                                        HttpServletResponse httpServletResponse) throws IOException,
  57.   ServletException {
  58.       return null;
  59.   }
  60. }