123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- package com.system.filter;
- import java.io.IOException;
- import javax.servlet.Filter;
- import javax.servlet.FilterChain;
- import javax.servlet.FilterConfig;
- import javax.servlet.ServletException;
- import javax.servlet.ServletRequest;
- import javax.servlet.ServletResponse;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.sgcc.isc.ualogin.client.util.IscSSOResourceUtil;
- import com.sgcc.isc.ualogin.client.vo.IscSSOUser;
- import com.sinosoft.lz.system.auditLog.impl.AuditLogImpl;
- import com.sinosoft.lz.system.auditLog.vo.AuditLogVo;
- /**
- * 登录拦截器
- * @author zhuanghuiliang
- * @date 2015-11-06
- */
- public class LoginFilter implements Filter{
- public String forwardUrl = "/index.html";
- @Override
- public void destroy() {
- // TODO Auto-generated method stub
- }
- @Override
- public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
- throws IOException, ServletException {
- HttpServletRequest request = (HttpServletRequest) req;
- HttpServletResponse response = (HttpServletResponse) res;
- String servletPath = request.getRequestURI();
-
-
- /********
- * 审计日志
- *
- */
- /* if(servletPath.contains("ws/")&&!servletPath.contains("/LoginPw")){
-
- IscSSOUser userbean = IscSSOResourceUtil.getIscUser (request);
- System.out.println("用户ID号:"+ userbean.getUserId ());
- System.out.println("用户登录名:"+ userbean.getAccount());
- System.out.println("用户中文名:"+ userbean.getName());
- System.out.println("用户组织id:"+ userbean.getOrgId());
- System.out.println("用户登录时间:"+ userbean.getLoginTime());
-
- String userName = (String) (userbean==null?"":userbean.getAccount());
- String[] rss = servletPath.split("/");
-
- AuditLogVo auLog=new AuditLogVo();
- AuditLogImpl auLogImpl=new AuditLogImpl();
- auLog.setSip(request.getRemoteAddr());
- if(rss.length>3)
- auLog.setAppmodule(rss[3]);
- else
- auLog.setAppmodule("");
- if(rss.length>5)
- auLog.setOptype(rss[5]);
- else
- auLog.setOptype("");
- auLog.setMainaccount(userName);
- if(rss.length>4)
- auLog.setOpcontent(rss[4]);
- else
- auLog.setOpcontent("");
- auLog.setOpresult("成功");
- auLog.setLoglevel("一般");
- auLogImpl.insert(auLog);
- }*/
- chain.doFilter(req, res);
-
-
- // IscSSOUser userbean = IscSSOResourceUtil.getIscUser (request);
- // System.out.println("用户ID号:"+ userbean.getUserId ());
- // System.out.println("用户登录名:"+ userbean.getAccount());
- // System.out.println("用户中文名:"+ userbean.getName());
- // System.out.println("用户组织id:"+ userbean.getOrgId());
- // System.out.println("用户登录时间:"+ userbean.getLoginTime());
- // response.sendRedirect(request.getContextPath() + "/main.jsp?loginName="+userbean.getAccount());
- // request.getRequestDispatcher(request.getContextPath() + "/main.jsp").forward(request, response);
- // response.sendRedirect(request.getContextPath() + "/page/frameWork.html");
-
- //不过滤登录页
- /* if (servletPath.equals("/nwyj/index.html")||servletPath.equals("/nwyj/")||servletPath.equals("/nwyj/ws/sys/LoginService/Login")) {
- chain.doFilter(req, res);
- return;
- }
- Object sessionObj = request.getSession().getAttribute("User_Name");
- String referer = request.getHeader("Referer"); */
- // 如果Session为空,则跳转到指定页面
- /* if (sessionObj == null ||sessionObj != null && referer!=null&&!referer.contains("/nwyj") ) {
-
-
- response.sendRedirect(request.getContextPath() + "/index.html");
- } else {
- chain.doFilter(req, res);
- }*/
- }
- @Override
- public void init(FilterConfig cfg) throws ServletException {
- // TODO Auto-generated method stub
- }
- }
|