f031ea8417e472000031d5f85257bc100f134607.svn-base 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package com.system.filter;
  2. import java.io.IOException;
  3. import javax.servlet.Filter;
  4. import javax.servlet.FilterChain;
  5. import javax.servlet.FilterConfig;
  6. import javax.servlet.ServletException;
  7. import javax.servlet.ServletRequest;
  8. import javax.servlet.ServletResponse;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import com.sgcc.isc.ualogin.client.util.IscSSOResourceUtil;
  12. import com.sgcc.isc.ualogin.client.vo.IscSSOUser;
  13. import com.sinosoft.lz.system.auditLog.impl.AuditLogImpl;
  14. import com.sinosoft.lz.system.auditLog.vo.AuditLogVo;
  15. /**
  16. * 登录拦截器
  17. * @author zhuanghuiliang
  18. * @date 2015-11-06
  19. */
  20. public class LoginFilter implements Filter{
  21. public String forwardUrl = "/index.html";
  22. @Override
  23. public void destroy() {
  24. // TODO Auto-generated method stub
  25. }
  26. @Override
  27. public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
  28. throws IOException, ServletException {
  29. HttpServletRequest request = (HttpServletRequest) req;
  30. HttpServletResponse response = (HttpServletResponse) res;
  31. String servletPath = request.getRequestURI();
  32. /********
  33. * 审计日志
  34. *
  35. */
  36. /* if(servletPath.contains("ws/")&&!servletPath.contains("/LoginPw")){
  37. IscSSOUser userbean = IscSSOResourceUtil.getIscUser (request);
  38. System.out.println("用户ID号:"+ userbean.getUserId ());
  39. System.out.println("用户登录名:"+ userbean.getAccount());
  40. System.out.println("用户中文名:"+ userbean.getName());
  41. System.out.println("用户组织id:"+ userbean.getOrgId());
  42. System.out.println("用户登录时间:"+ userbean.getLoginTime());
  43. String userName = (String) (userbean==null?"":userbean.getAccount());
  44. String[] rss = servletPath.split("/");
  45. AuditLogVo auLog=new AuditLogVo();
  46. AuditLogImpl auLogImpl=new AuditLogImpl();
  47. auLog.setSip(request.getRemoteAddr());
  48. if(rss.length>3)
  49. auLog.setAppmodule(rss[3]);
  50. else
  51. auLog.setAppmodule("");
  52. if(rss.length>5)
  53. auLog.setOptype(rss[5]);
  54. else
  55. auLog.setOptype("");
  56. auLog.setMainaccount(userName);
  57. if(rss.length>4)
  58. auLog.setOpcontent(rss[4]);
  59. else
  60. auLog.setOpcontent("");
  61. auLog.setOpresult("成功");
  62. auLog.setLoglevel("一般");
  63. auLogImpl.insert(auLog);
  64. }*/
  65. chain.doFilter(req, res);
  66. // IscSSOUser userbean = IscSSOResourceUtil.getIscUser (request);
  67. // System.out.println("用户ID号:"+ userbean.getUserId ());
  68. // System.out.println("用户登录名:"+ userbean.getAccount());
  69. // System.out.println("用户中文名:"+ userbean.getName());
  70. // System.out.println("用户组织id:"+ userbean.getOrgId());
  71. // System.out.println("用户登录时间:"+ userbean.getLoginTime());
  72. // response.sendRedirect(request.getContextPath() + "/main.jsp?loginName="+userbean.getAccount());
  73. // request.getRequestDispatcher(request.getContextPath() + "/main.jsp").forward(request, response);
  74. // response.sendRedirect(request.getContextPath() + "/page/frameWork.html");
  75. //不过滤登录页
  76. /* if (servletPath.equals("/nwyj/index.html")||servletPath.equals("/nwyj/")||servletPath.equals("/nwyj/ws/sys/LoginService/Login")) {
  77. chain.doFilter(req, res);
  78. return;
  79. }
  80. Object sessionObj = request.getSession().getAttribute("User_Name");
  81. String referer = request.getHeader("Referer"); */
  82. // 如果Session为空,则跳转到指定页面
  83. /* if (sessionObj == null ||sessionObj != null && referer!=null&&!referer.contains("/nwyj") ) {
  84. response.sendRedirect(request.getContextPath() + "/index.html");
  85. } else {
  86. chain.doFilter(req, res);
  87. }*/
  88. }
  89. @Override
  90. public void init(FilterConfig cfg) throws ServletException {
  91. // TODO Auto-generated method stub
  92. }
  93. }